We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

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

mathieu_cupryk
on
Medium Priority
339 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

Comment
Watch Question

David H.H.LeeDigital Marketing (Hospitality)
CERTIFIED EXPERT

Commented:
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.
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?

Author

Commented:
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?

Author

Commented:
it would be something like this?
For Each filename As String In filenames

check for file in dt
            Next
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.