mathieu_cupryk
asked on
need to convert change the Dim m match from vb.net to Fore each string() in line
Dim Conn As New SqlConnection(Configuratio nManager.A ppSettings ("SqlStrin g"))
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).V alue) Is Nothing Then
strReplyFromCheckFile = Utilities.CheckFileTobeDow nloaded(m. Groups(2). Value) 'TP
Try
Utilities.WriteToDB(Messag eTypes.Mes sageTypeLo g, Categories.CategoryCDRScra pe, "System", "Downloading CDR file '" & m.Groups(2).Value & "'")
cli.DownloadFile(Configura tionManage r.AppSetti ngs("CDRFi lesPath") & m.Groups(1).Value, ConfigurationManager.AppSe ttings("Te mpFileLoca tion") & m.Groups(2).Value)
Try
Utilities.WriteToDB(Messag eTypes.Mes sageTypeLo g, Categories.CategoryCDRScra pe, "System", "Writing CDR file '" & m.Groups(2).Value & "' zip components to production.")
ZipOperations.WriteZipComp onentsToFT P(Configur ationManag er.AppSett ings("Temp FileLocati on") & m.Groups(2).Value, _
ConfigurationManager.AppSe ttings("FT PSite"), _
ConfigurationManager.AppSe ttings("FT PUsername" ), _
ConfigurationManager.AppSe ttings("FT PPassword" ))
Utilities.WriteToDB(Messag eTypes.Mes sageTypeLo g, Categories.CategoryCDRScra pe, "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.CategoryCDRScra pe)
Finally
Dim Di As New System.IO.DirectoryInfo(Co nfiguratio nManager.A ppSettings ("TempFile Location") )
Dim Fi As System.IO.FileInfo
For Each Fi In Di.GetFiles()
If Fi.CreationTime.CompareTo( DateTime.N ow().AddDa ys(-10)) < 0 Then
Fi.Delete()
End If
Next
End Try
Catch ex As Exception
Conn.Close()
Utilities.ReportException( "System", _
ex, _
Categories.CategoryCDRScra pe)
End Try
End If 'TP
End If
Next
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).V
strReplyFromCheckFile = Utilities.CheckFileTobeDow
Try
Utilities.WriteToDB(Messag
cli.DownloadFile(Configura
Try
Utilities.WriteToDB(Messag
ZipOperations.WriteZipComp
ConfigurationManager.AppSe
ConfigurationManager.AppSe
ConfigurationManager.AppSe
Utilities.WriteToDB(Messag
Cmd = New SqlCommand("insert into cdr_zip_file (Filename) values (@ZipFileName)", Conn)
Cmd.Parameters.Add(New SqlParameter("@ZipFileName
Conn.Open()
Cmd.ExecuteNonQuery()
Conn.Close()
Catch ex As Exception
Conn.Close()
Utilities.ReportException(
ex, _
Categories.CategoryCDRScra
Finally
Dim Di As New System.IO.DirectoryInfo(Co
Dim Fi As System.IO.FileInfo
For Each Fi In Di.GetFiles()
If Fi.CreationTime.CompareTo(
Fi.Delete()
End If
Next
End Try
Catch ex As Exception
Conn.Close()
Utilities.ReportException(
ex, _
Categories.CategoryCDRScra
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
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?
ASKER
I think I need to loop through the files
Dim ListofFiles() As String = GetFileList(reqFTPIn.Crede ntials, ConfigurationManager.AppSe ttings("FT PSite"))
and check if the file name exist in the datatable.
How should I do ths?
Dim ListofFiles() As String = GetFileList(reqFTPIn.Crede
and check if the file name exist in the datatable.
How should I do ths?
ASKER
it would be something like this?
For Each filename As String In filenames
check for file in dt
Next
For Each filename As String In filenames
check for file in dt
Next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.