[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

need to convert change the Dim m match from vb.net to Fore each string() in line

Posted on 2009-02-09
5
Medium Priority
?
299 Views
Last Modified: 2012-05-06
 Dim Conn As New SqlConnection(ConfigurationManager.AppSettings("SqlString"))
            Dim Cmd As New SqlCommand("select distinct Filename from cdr_zip_file", Conn)
            Conn.Open()
            Dim Ds As New DataSet()
            Dim Da As New SqlDataAdapter(Cmd)
            Da.Fill(Ds, "ZipTable")
            Conn.Close()

            Dim strReplyFromCheckFile As String 'TP
            Dim Dt As DataTable = Ds.Tables("ZipTable")
            Dt.PrimaryKey = New DataColumn() {Dt.Columns("Filename")}
          Dim m As Match

            For Each m In mch

                If Dt.Rows.Find(m.Groups(2).Value) Is Nothing Then

                    strReplyFromCheckFile = Utilities.CheckFileTobeDownloaded(m.Groups(2).Value) 'TP

                   


                        Try
                            Utilities.WriteToDB(MessageTypes.MessageTypeLog, Categories.CategoryCDRScrape, "System", "Downloading CDR file '" & m.Groups(2).Value & "'")

                            cli.DownloadFile(ConfigurationManager.AppSettings("CDRFilesPath") & m.Groups(1).Value, ConfigurationManager.AppSettings("TempFileLocation") & m.Groups(2).Value)

                            Try
                                Utilities.WriteToDB(MessageTypes.MessageTypeLog, Categories.CategoryCDRScrape, "System", "Writing CDR file '" & m.Groups(2).Value & "' zip components to production.")
                                ZipOperations.WriteZipComponentsToFTP(ConfigurationManager.AppSettings("TempFileLocation") & m.Groups(2).Value, _
                                              ConfigurationManager.AppSettings("FTPSite"), _
                                              ConfigurationManager.AppSettings("FTPUsername"), _
                                               ConfigurationManager.AppSettings("FTPPassword"))

                                Utilities.WriteToDB(MessageTypes.MessageTypeLog, Categories.CategoryCDRScrape, "System", "Finished processing CDR file '" & m.Groups(2).Value & "'")

                                Cmd = New SqlCommand("insert into cdr_zip_file (Filename) values (@ZipFileName)", Conn)
                                Cmd.Parameters.Add(New SqlParameter("@ZipFileName", SqlDbType.VarChar)).Value = m.Groups(2).Value
                                Conn.Open()
                                Cmd.ExecuteNonQuery()
                                Conn.Close()
                            Catch ex As Exception
                                Conn.Close()
                                Utilities.ReportException("System", _
                                                          ex, _
                                                          Categories.CategoryCDRScrape)
                            Finally
                                Dim Di As New System.IO.DirectoryInfo(ConfigurationManager.AppSettings("TempFileLocation"))
                                Dim Fi As System.IO.FileInfo
                                For Each Fi In Di.GetFiles()
                                    If Fi.CreationTime.CompareTo(DateTime.Now().AddDays(-10)) < 0 Then
                                        Fi.Delete()
                                    End If
                                Next
                            End Try
                        Catch ex As Exception
                            Conn.Close()
                            Utilities.ReportException("System", _
                                                      ex, _
                                                      Categories.CategoryCDRScrape)
                        End Try

                    End If 'TP

                End If
            Next
Dim Conn As New SqlConnection(ConfigurationManager.AppSettings("SqlString"))
            Dim Cmd As New SqlCommand("select distinct Filename from cdr_zip_file", Conn)
            Conn.Open()
            Dim Ds As New DataSet()
            Dim Da As New SqlDataAdapter(Cmd)
            Da.Fill(Ds, "ZipTable")
            Conn.Close()
 
            Dim strReplyFromCheckFile As String 'TP
            Dim Dt As DataTable = Ds.Tables("ZipTable")
            Dt.PrimaryKey = New DataColumn() {Dt.Columns("Filename")}
 
            ' Read each file and put in to string parse
            Dim ListofFiles() As String = GetFileList(reqFTPIn.Credentials, ConfigurationManager.AppSettings("FTPSite"))
For Each Str() In line
                If Dt.Rows.Find(m.Groups(2).Value) Is Nothing Then ''' this needs to be replave
 
-------------------------------------------------------------------
what do i do here i am not sure i am

Open in new window

0
Comment
Question by:mathieu_cupryk
  • 2
  • 2
5 Comments
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 23597308
Hi mathieu_cupryk,
You can always use this vb.net convertor for any c# conversion(from vb.net or vice versa)
http://www.developerfusion.com/tools/convert/vb-to-csharp/

Hope it helps. Please let us know if you need any further assistance.
0
 
LVL 16

Expert Comment

by:sunithnair
ID: 23598614
What is the value for m.Groups(2).Value? This could should work properly since you have already defined file name as primary key. Does your m.Groups(2).Value contain the filename?
0
 

Author Comment

by:mathieu_cupryk
ID: 23600794
I think I need to loop through the files

 Dim ListofFiles() As String = GetFileList(reqFTPIn.Credentials, ConfigurationManager.AppSettings("FTPSite"))

and check if the file name exist in the datatable.
How should I do ths?
0
 

Author Comment

by:mathieu_cupryk
ID: 23600910
it would be something like this?
For Each filename As String In filenames

check for file in dt
            Next
0
 
LVL 16

Accepted Solution

by:
sunithnair earned 2000 total points
ID: 23604538
Yes it would be like that and make sure your function GetFileList is returning string array
        Dim ListofFiles() As String = New String() {"file1.txt", "file2.txt", "file3"}
        For Each filename As String In ListofFiles
            'Write code to write the code to check the database if the file exists
        Next

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Loops Section Overview
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month18 days, 17 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question