Private Sub btnUpdateSiteFiles_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateSiteFiles.Click
Dim Err As Integer = 0
Dim Err2 As Integer = 0
Try
txtStatus.Text = ""
lblUpdateSiteFiles.Text = ""
lblProgress.Text = ""
lblUpdateSiteFiles.Visible = True
lblProgress.Visible = True
'lblMsg.Visible = False
Me.Cursor = Cursors.WaitCursor 'Changing the Cursor to Waititng State
Dim selectedCount As Integer = SelectedDataBaseCount()
If selectedCount = 0 Then
ErrorLog.XmlError("btnUpdateSiteFiles", New ApplicationException("Please choose atleast one database to update site files."))
txtStatus.Text &= "Please choose atleast one database to update site files. " & Environment.NewLine
txtStatus.Refresh()
MsgBox("Please choose atleast one database to update site files.")
Err = 1
Return
End If
Try
'Dim SourcePath As String = ConfigurationManager.AppSettings("FilesSourcepath")
'Dim DestinationPath As String = DBUtil.GetSettings("EasyShopFolder")
'Dim FilePath As String = SourcePath & "\app_offline.htm"
'NewDestinationPath = DestinationPath & "\app_offline.htm"
'File.Copy(FilePath, NewDestinationPath, True)
'Copy Easyshop Files
CopySiteFiles(Err)
'File.Delete(NewDestinationPath)
Catch ex As Exception
'If File.Exists(NewDestinationPath) Then
' File.Delete(NewDestinationPath)
'End If
ErrorLog.XmlError("btnUpdateSiteFiles", ex)
txtStatus.Text &= ex.Message & vbCrLf
txtStatus.Refresh()
MessageBox.Show(ex.Message.ToString(), "Errors")
Err = Err + 1
End Try
Try
'Copy AimsShopLinkFiles
CopyAimsShopLinkFiles(Err2)
Catch ex As Exception
ErrorLog.XmlError("btnUpdateSiteFiles", ex)
txtStatus.Text &= ex.Message & vbCrLf
txtStatus.Refresh()
MessageBox.Show(ex.Message.ToString(), "Errors")
Err2 = Err2 + 1
End Try
Catch ex As Exception
ErrorLog.XmlError("btnUpdateSiteFiles", ex)
txtStatus.Text &= ex.Message & vbCrLf
txtStatus.Refresh()
MessageBox.Show(ex.Message.ToString(), "Errors")
Finally
lblUpdateSiteFiles.Text = ""
lblProgress.Text = ""
lblUpdateSiteFiles.Visible = False
lblProgress.Visible = True
lblProgress.Text = "Completed successfully"
' lblMsg.Visible = True
Me.Cursor = Cursors.Default 'Changing the Cursor to Waititng State
If Err = 0 AndAlso Err2 = 0 Then
MessageBox.Show("Update Site Files Process Completed successfully.", "Update SiteFiles")
ElseIf Err = 1 Or Err2 = 1 Then
ErrorLog.XmlError("btnUpdateSiteFiles", New ApplicationException("There is Problem in Updating Files."))
txtStatus.Text &= "There is Problem in Updating Files." & Environment.NewLine
txtStatus.Refresh()
MessageBox.Show("There is Problem in Updating Files.", "Update SiteFiles")
End If
End Try
End Sub
--------------
Private Function SelectedDataBaseCount() As Integer
Dim count As Integer = 0
For Each dr As Infragistics.Win.UltraWinGrid.UltraGridRow In dgvDatabases.Rows
If dr.Cells("select").Value = True Then
count = count + 1
End If
Next
gCount = count
Return count
End Function
---------
Public Sub CopySiteFiles(ByRef Err As Integer)
Try
For Each dr As Infragistics.Win.UltraWinGrid.UltraGridRow In dgvDatabases.Rows
If dr.Cells("select").Value = True Then
DBUtil.DatabaseName = dr.Cells("DataBaseName_Text").Value.ToString()
DatabaseName = dr.Cells("DataBaseName_Text").Value.ToString()
Dim SourcePath As String = ConfigurationManager.AppSettings("FilesSourcepath")
Dim DestinationPath As String = DBUtil.GetSettings("EasyShopFolder")
If DestinationPath = "" Then
ErrorLog.XmlError("CopySiteFiles Function", New ApplicationException("Please provide Easy Shop Folder for" & DBUtil.DatabaseName))
txtStatus.Text &= "Please provide Easy Shop Folder for " & DBUtil.DatabaseName & Environment.NewLine
txtStatus.Refresh()
MessageBox.Show("Please provide Easy Shop Folder for " & DBUtil.DatabaseName, "Errors")
GoTo nextrecord
End If
ThemeName = DBUtil.GetSettings("ThemeName")
Dim dSourceInfo As New DirectoryInfo(SourcePath)
Dim dTargetInfo As New DirectoryInfo(DestinationPath)
Dim FilePath As String = SourcePath & "\app_offline.htm"
NewDestinationPath = DestinationPath & "\app_offline.htm"
File.Copy(FilePath, NewDestinationPath, True)
CopyFilesAndDirectories(dSourceInfo, dTargetInfo, ThemeName, "")
txtStatus.Text &= "Updated EasyShop files for " & DatabaseName & Environment.NewLine
txtStatus.Refresh()
'Aded by Team7e for Issue#1426.
Dim TZone As String = TimeZoneName(DateTime.Now)
Dim ObjSettings As New SystemSettings()
ObjSettings.LastMaintenanceDate = System.DateTime.Now.ToString() & "@" & TZone & "."
DBUtil.UpdateLastMaintenanceDate(ObjSettings, DBUtil.DatabaseName)
File.Delete(NewDestinationPath)
End If
nextrecord:
Next
Catch ex As Exception
If File.Exists(NewDestinationPath) Then
File.Delete(NewDestinationPath)
End If
txtStatus.Text &= ex.Message & vbCrLf
txtStatus.Refresh()
txtStatus.Text &= "Updated EasyShop files for " & DatabaseName & " with errors." & Environment.NewLine
txtStatus.Refresh()
lblProgress.Text = "Updated EasyShop files for " & DatabaseName & " with errors."
lblProgress.Refresh()
ErrorLog.XmlError("btnUpdateSiteFiles", ex)
MessageBox.Show(ex.Message.ToString(), "Errors")
Err = Err + 1
End Try
End Sub
-------------------------
Public Shared Function TimeZoneName(ByVal dt As DateTime) As [String]
Dim sName As [String] = If(TimeZone.CurrentTimeZone.IsDaylightSavingTime(dt), TimeZone.CurrentTimeZone.DaylightName, TimeZone.CurrentTimeZone.StandardName)
Dim sNewName As [String] = ""
Dim sSplit As [String]() = sName.Split(New Char() {" "c})
For Each s As [String] In sSplit
If s.Length >= 1 Then
sNewName += s.Substring(0, 1)
End If
Next
Return sNewName
End Function
---------------------------------
Public Shared Sub UpdateLastMaintenanceDate(ByVal objSettings As SystemSettings, ByVal DatabaseName As String)
Dim conn As String
If (UseTrustedConnection) Then
conn = "server=" & ServerName & ";Integrated Security=SSPI;Database=" & DatabaseName & ";pooling='true'; Max Pool Size=800"
Else
conn = "server=" & ServerName & ";user id=" & ServerUserName & ";password=" & ServerPassword & ";Database=" & DatabaseName & ";pooling='true'; Max Pool Size=800"
End If
Dim connection As New SqlConnection(conn)
Try
If connection.State <> ConnectionState.Open Then
connection.Open()
End If
Dim sqlCmd As New SqlCommand()
sqlCmd.CommandText = "SP_UpdateLastMaintenanceDate"
sqlCmd.CommandType = CommandType.StoredProcedure
sqlCmd.Connection = connection
sqlCmd.Parameters.AddWithValue("@LastMaintenanceDate", objSettings.LastMaintenanceDate)
sqlCmd.ExecuteNonQuery()
Catch ex As Exception
ErrorLog.XmlError("btnUpdateSettings_Click", ex)
MessageBox.Show(ex.Message.ToString())
Finally
If connection.State <> ConnectionState.Closed Then
connection.Close()
End If
End Try
End Sub
---------------------------
Public Sub CopyFilesAndDirectories(ByVal source As DirectoryInfo, ByVal target As DirectoryInfo, ByVal Theme As String, ByVal CurrentDir As String)
Try
' Check if the target directory exists, if not, create it.
If Directory.Exists(target.FullName) = False Then
Directory.CreateDirectory(target.FullName)
End If
' Copy each file into it’s new directory.
For Each fi As FileInfo In source.GetFiles()
If CurrentDir <> "ErrorLogs" Then
fi.Attributes = FileAttributes.Archive
fi.CopyTo(Path.Combine(target.ToString(), fi.Name), True)
lblUpdateSiteFiles.Text = "Copying files: " & fi.Name
lblProgress.Text = "Copying files: " & target.ToString() & "\" & fi.Name
lblProgress.Refresh()
lblUpdateSiteFiles.Refresh()
End If
Next
'Copy each subdirectory using recursion.
For Each diSourceSubDir As DirectoryInfo In source.GetDirectories()
If CurrentDir = "App_Themes" Then
If diSourceSubDir.Name = Theme OrElse diSourceSubDir.Name.ToLower() = "notheme" OrElse diSourceSubDir.Name = "StoreLocator" OrElse diSourceSubDir.Name = "Admin" OrElse diSourceSubDir.Name = "Preview" Then 'exclude other theme files
GoTo Cnt
Else
GoTo Nextdir
End If
End If
If CurrentDir = "CustomPages" Then 'Added by Team7e for Issue#1446.
If diSourceSubDir.Name.ToLower() = Theme.ToLower() OrElse diSourceSubDir.Name.ToLower() = "images" Then
GoTo Cnt
Else
GoTo Nextdir
End If
End If
Cnt:
Dim nextTargetSubDir As DirectoryInfo = Nothing
If diSourceSubDir.Name.ToLower() <> "productimages" Then
nextTargetSubDir = target.CreateSubdirectory(diSourceSubDir.Name)
End If
If diSourceSubDir.Name.ToLower() <> "productimages" Then
Dim strParentDirectory As String = diSourceSubDir.Name
CopyFilesAndDirectories(diSourceSubDir, nextTargetSubDir, Theme, strParentDirectory)
End If
Nextdir:
Next
Catch ex As Exception
ErrorLog.XmlError("CopyFilesAndDirectories Function", ex)
txtStatus.Text &= ex.Message & vbCrLf
txtStatus.Refresh()
MessageBox.Show(ex.Message.ToString(), "Errors")
End Try
End Sub
--------------------------
Public Sub CopyAimsShopLinkFiles(ByRef Err As Integer)
Try
For Each dr As Infragistics.Win.UltraWinGrid.UltraGridRow In dgvDatabases.Rows
If dr.Cells("select").Value = True Then
DBUtil.DatabaseName = dr.Cells("DataBaseName_Text").Value.ToString()
DatabaseName = dr.Cells("DataBaseName_Text").Value.ToString()
Dim SourcePath As String = ConfigurationManager.AppSettings("AimsShopLinkSource")
Dim DestinationPath As String = DBUtil.GetSettings("AimsShopLinkFolder")
If DestinationPath = "" Then
ErrorLog.XmlError("CopyAimsShopLinkFiles Function", New ApplicationException("Please provide AimsShopLink Folder for" & DBUtil.DatabaseName))
txtStatus.Text &= "Please provide AimsShopLink Folder for " & DBUtil.DatabaseName & Environment.NewLine
txtStatus.Refresh()
MessageBox.Show("Please provide AimsShopLink Folder for " & DBUtil.DatabaseName, "Errors")
GoTo nextrecord
End If
ThemeName = DBUtil.GetSettings("ThemeName")
Dim dSourceInfo As New DirectoryInfo(SourcePath)
Dim dTargetInfo As New DirectoryInfo(DestinationPath)
CopyFilesAndDirectories(dSourceInfo, dTargetInfo, "")
txtStatus.Text &= "Updated AIMSShopLink files for " & DatabaseName & Environment.NewLine
txtStatus.Refresh()
End If
nextrecord:
Next
Catch ex As Exception
txtStatus.Text &= ex.Message & vbCrLf
txtStatus.Refresh()
txtStatus.Text &= "Updated AIMSShopLink files for " & DatabaseName & " with errors." & Environment.NewLine
txtStatus.Refresh()
lblProgress.Text = "Updated AIMSShopLink files for " & DatabaseName & " with errors."
lblProgress.Refresh()
ErrorLog.XmlError("CopyAimsShopLinkFiles", ex)
MessageBox.Show(ex.Message.ToString(), "CopyAimsShopLinkFiles")
Err = Err + 1
End Try
End Sub
------------------------------------
'Copy Aims Shoplink Source files
Public Sub CopyFilesAndDirectories(ByVal source As DirectoryInfo, ByVal target As DirectoryInfo, ByVal CurrentDir As String)
Try
' Check if the target directory exists, if not, create it.
If Directory.Exists(target.FullName) = False Then
Directory.CreateDirectory(target.FullName)
End If
' Copy each file into it’s new directory.
For Each fi As FileInfo In source.GetFiles()
If CurrentDir <> "ErrorLogs" Then
If fi.Extension <> ".vspscc" Then
fi.Attributes = FileAttributes.Archive
fi.CopyTo(Path.Combine(target.ToString(), fi.Name), True)
lblUpdateSiteFiles.Text = "Copying files: " & fi.Name
lblProgress.Text = "Copying files: " & target.ToString() & "\" & fi.Name
lblProgress.Refresh()
lblUpdateSiteFiles.Refresh()
End If
End If
Next
'Copy each subdirectory using recursion.
For Each diSourceSubDir As DirectoryInfo In source.GetDirectories()
Dim nextTargetSubDir As DirectoryInfo = Nothing
nextTargetSubDir = target.CreateSubdirectory(diSourceSubDir.Name)
Dim strParentDirectory As String = diSourceSubDir.Name
CopyFilesAndDirectories(diSourceSubDir, nextTargetSubDir, strParentDirectory)
Next
Catch ex As Exception
ErrorLog.XmlError("CopyFilesAndDirectories Function", ex)
txtStatus.Text &= ex.Message & vbCrLf
txtStatus.Refresh()
MessageBox.Show(ex.Message.ToString(), "CopyFilesAndDirectories")
End Try
End Sub
Dim Err As Integer = 0
Dim Err2 As Integer = 0
Try
txtStatus.Text = ""
lblUpdateSiteFiles.Text = ""
lblProgress.Text = ""
lblUpdateSiteFiles.Visible = True
lblProgress.Visible = True
'lblMsg.Visible = False
Me.Cursor = Cursors.WaitCursor 'Changing the Cursor to Waititng State
Dim selectedCount As Integer = SelectedDataBaseCount()
If selectedCount = 0 Then
ErrorLog.XmlError("btnUpdateSiteFiles", New ApplicationException("Please choose atleast one database to update site files."))
txtStatus.Text &= "Please choose atleast one database to update site files. " & Environment.NewLine
txtStatus.Refresh()
MsgBox("Please choose atleast one database to update site files.")
Err = 1
Return
End If
Try
'Dim SourcePath As String = ConfigurationManager.AppSettings("FilesSourcepath")
'Dim DestinationPath As String = DBUtil.GetSettings("EasyShopFolder")
'Dim FilePath As String = SourcePath & "\app_offline.htm"
'NewDestinationPath = DestinationPath & "\app_offline.htm"
'File.Copy(FilePath, NewDestinationPath, True)
'Copy Easyshop Files
CopySiteFiles(Err)
'File.Delete(NewDestinationPath)
Catch ex As Exception
'If File.Exists(NewDestinationPath) Then
' File.Delete(NewDestinationPath)
'End If
ErrorLog.XmlError("btnUpdateSiteFiles", ex)
txtStatus.Text &= ex.Message & vbCrLf
txtStatus.Refresh()
MessageBox.Show(ex.Message.ToString(), "Errors")
Err = Err + 1
End Try
Try
'Copy AimsShopLinkFiles
CopyAimsShopLinkFiles(Err2)
Catch ex As Exception
ErrorLog.XmlError("btnUpdateSiteFiles", ex)
txtStatus.Text &= ex.Message & vbCrLf
txtStatus.Refresh()
MessageBox.Show(ex.Message.ToString(), "Errors")
Err2 = Err2 + 1
End Try
Catch ex As Exception
ErrorLog.XmlError("btnUpdateSiteFiles", ex)
txtStatus.Text &= ex.Message & vbCrLf
txtStatus.Refresh()
MessageBox.Show(ex.Message.ToString(), "Errors")
Finally
lblUpdateSiteFiles.Text = ""
lblProgress.Text = ""
lblUpdateSiteFiles.Visible = False
lblProgress.Visible = True
lblProgress.Text = "Completed successfully"
' lblMsg.Visible = True
Me.Cursor = Cursors.Default 'Changing the Cursor to Waititng State
If Err = 0 AndAlso Err2 = 0 Then
MessageBox.Show("Update Site Files Process Completed successfully.", "Update SiteFiles")
ElseIf Err = 1 Or Err2 = 1 Then
ErrorLog.XmlError("btnUpdateSiteFiles", New ApplicationException("There is Problem in Updating Files."))
txtStatus.Text &= "There is Problem in Updating Files." & Environment.NewLine
txtStatus.Refresh()
MessageBox.Show("There is Problem in Updating Files.", "Update SiteFiles")
End If
End Try
End Sub
--------------
Private Function SelectedDataBaseCount() As Integer
Dim count As Integer = 0
For Each dr As Infragistics.Win.UltraWinGrid.UltraGridRow In dgvDatabases.Rows
If dr.Cells("select").Value = True Then
count = count + 1
End If
Next
gCount = count
Return count
End Function
---------
Public Sub CopySiteFiles(ByRef Err As Integer)
Try
For Each dr As Infragistics.Win.UltraWinGrid.UltraGridRow In dgvDatabases.Rows
If dr.Cells("select").Value = True Then
DBUtil.DatabaseName = dr.Cells("DataBaseName_Text").Value.ToString()
DatabaseName = dr.Cells("DataBaseName_Text").Value.ToString()
Dim SourcePath As String = ConfigurationManager.AppSettings("FilesSourcepath")
Dim DestinationPath As String = DBUtil.GetSettings("EasyShopFolder")
If DestinationPath = "" Then
ErrorLog.XmlError("CopySiteFiles Function", New ApplicationException("Please provide Easy Shop Folder for" & DBUtil.DatabaseName))
txtStatus.Text &= "Please provide Easy Shop Folder for " & DBUtil.DatabaseName & Environment.NewLine
txtStatus.Refresh()
MessageBox.Show("Please provide Easy Shop Folder for " & DBUtil.DatabaseName, "Errors")
GoTo nextrecord
End If
ThemeName = DBUtil.GetSettings("ThemeName")
Dim dSourceInfo As New DirectoryInfo(SourcePath)
Dim dTargetInfo As New DirectoryInfo(DestinationPath)
Dim FilePath As String = SourcePath & "\app_offline.htm"
NewDestinationPath = DestinationPath & "\app_offline.htm"
File.Copy(FilePath, NewDestinationPath, True)
CopyFilesAndDirectories(dSourceInfo, dTargetInfo, ThemeName, "")
txtStatus.Text &= "Updated EasyShop files for " & DatabaseName & Environment.NewLine
txtStatus.Refresh()
'Aded by Team7e for Issue#1426.
Dim TZone As String = TimeZoneName(DateTime.Now)
Dim ObjSettings As New SystemSettings()
ObjSettings.LastMaintenanceDate = System.DateTime.Now.ToString() & "@" & TZone & "."
DBUtil.UpdateLastMaintenanceDate(ObjSettings, DBUtil.DatabaseName)
File.Delete(NewDestinationPath)
End If
nextrecord:
Next
Catch ex As Exception
If File.Exists(NewDestinationPath) Then
File.Delete(NewDestinationPath)
End If
txtStatus.Text &= ex.Message & vbCrLf
txtStatus.Refresh()
txtStatus.Text &= "Updated EasyShop files for " & DatabaseName & " with errors." & Environment.NewLine
txtStatus.Refresh()
lblProgress.Text = "Updated EasyShop files for " & DatabaseName & " with errors."
lblProgress.Refresh()
ErrorLog.XmlError("btnUpdateSiteFiles", ex)
MessageBox.Show(ex.Message.ToString(), "Errors")
Err = Err + 1
End Try
End Sub
-------------------------
Public Shared Function TimeZoneName(ByVal dt As DateTime) As [String]
Dim sName As [String] = If(TimeZone.CurrentTimeZone.IsDaylightSavingTime(dt), TimeZone.CurrentTimeZone.DaylightName, TimeZone.CurrentTimeZone.StandardName)
Dim sNewName As [String] = ""
Dim sSplit As [String]() = sName.Split(New Char() {" "c})
For Each s As [String] In sSplit
If s.Length >= 1 Then
sNewName += s.Substring(0, 1)
End If
Next
Return sNewName
End Function
---------------------------------
Public Shared Sub UpdateLastMaintenanceDate(ByVal objSettings As SystemSettings, ByVal DatabaseName As String)
Dim conn As String
If (UseTrustedConnection) Then
conn = "server=" & ServerName & ";Integrated Security=SSPI;Database=" & DatabaseName & ";pooling='true'; Max Pool Size=800"
Else
conn = "server=" & ServerName & ";user id=" & ServerUserName & ";password=" & ServerPassword & ";Database=" & DatabaseName & ";pooling='true'; Max Pool Size=800"
End If
Dim connection As New SqlConnection(conn)
Try
If connection.State <> ConnectionState.Open Then
connection.Open()
End If
Dim sqlCmd As New SqlCommand()
sqlCmd.CommandText = "SP_UpdateLastMaintenanceDate"
sqlCmd.CommandType = CommandType.StoredProcedure
sqlCmd.Connection = connection
sqlCmd.Parameters.AddWithValue("@LastMaintenanceDate", objSettings.LastMaintenanceDate)
sqlCmd.ExecuteNonQuery()
Catch ex As Exception
ErrorLog.XmlError("btnUpdateSettings_Click", ex)
MessageBox.Show(ex.Message.ToString())
Finally
If connection.State <> ConnectionState.Closed Then
connection.Close()
End If
End Try
End Sub
---------------------------
Public Sub CopyFilesAndDirectories(ByVal source As DirectoryInfo, ByVal target As DirectoryInfo, ByVal Theme As String, ByVal CurrentDir As String)
Try
' Check if the target directory exists, if not, create it.
If Directory.Exists(target.FullName) = False Then
Directory.CreateDirectory(target.FullName)
End If
' Copy each file into it’s new directory.
For Each fi As FileInfo In source.GetFiles()
If CurrentDir <> "ErrorLogs" Then
fi.Attributes = FileAttributes.Archive
fi.CopyTo(Path.Combine(target.ToString(), fi.Name), True)
lblUpdateSiteFiles.Text = "Copying files: " & fi.Name
lblProgress.Text = "Copying files: " & target.ToString() & "\" & fi.Name
lblProgress.Refresh()
lblUpdateSiteFiles.Refresh()
End If
Next
'Copy each subdirectory using recursion.
For Each diSourceSubDir As DirectoryInfo In source.GetDirectories()
If CurrentDir = "App_Themes" Then
If diSourceSubDir.Name = Theme OrElse diSourceSubDir.Name.ToLower() = "notheme" OrElse diSourceSubDir.Name = "StoreLocator" OrElse diSourceSubDir.Name = "Admin" OrElse diSourceSubDir.Name = "Preview" Then 'exclude other theme files
GoTo Cnt
Else
GoTo Nextdir
End If
End If
If CurrentDir = "CustomPages" Then 'Added by Team7e for Issue#1446.
If diSourceSubDir.Name.ToLower() = Theme.ToLower() OrElse diSourceSubDir.Name.ToLower() = "images" Then
GoTo Cnt
Else
GoTo Nextdir
End If
End If
Cnt:
Dim nextTargetSubDir As DirectoryInfo = Nothing
If diSourceSubDir.Name.ToLower() <> "productimages" Then
nextTargetSubDir = target.CreateSubdirectory(diSourceSubDir.Name)
End If
If diSourceSubDir.Name.ToLower() <> "productimages" Then
Dim strParentDirectory As String = diSourceSubDir.Name
CopyFilesAndDirectories(diSourceSubDir, nextTargetSubDir, Theme, strParentDirectory)
End If
Nextdir:
Next
Catch ex As Exception
ErrorLog.XmlError("CopyFilesAndDirectories Function", ex)
txtStatus.Text &= ex.Message & vbCrLf
txtStatus.Refresh()
MessageBox.Show(ex.Message.ToString(), "Errors")
End Try
End Sub
--------------------------
Public Sub CopyAimsShopLinkFiles(ByRef Err As Integer)
Try
For Each dr As Infragistics.Win.UltraWinGrid.UltraGridRow In dgvDatabases.Rows
If dr.Cells("select").Value = True Then
DBUtil.DatabaseName = dr.Cells("DataBaseName_Text").Value.ToString()
DatabaseName = dr.Cells("DataBaseName_Text").Value.ToString()
Dim SourcePath As String = ConfigurationManager.AppSettings("AimsShopLinkSource")
Dim DestinationPath As String = DBUtil.GetSettings("AimsShopLinkFolder")
If DestinationPath = "" Then
ErrorLog.XmlError("CopyAimsShopLinkFiles Function", New ApplicationException("Please provide AimsShopLink Folder for" & DBUtil.DatabaseName))
txtStatus.Text &= "Please provide AimsShopLink Folder for " & DBUtil.DatabaseName & Environment.NewLine
txtStatus.Refresh()
MessageBox.Show("Please provide AimsShopLink Folder for " & DBUtil.DatabaseName, "Errors")
GoTo nextrecord
End If
ThemeName = DBUtil.GetSettings("ThemeName")
Dim dSourceInfo As New DirectoryInfo(SourcePath)
Dim dTargetInfo As New DirectoryInfo(DestinationPath)
CopyFilesAndDirectories(dSourceInfo, dTargetInfo, "")
txtStatus.Text &= "Updated AIMSShopLink files for " & DatabaseName & Environment.NewLine
txtStatus.Refresh()
End If
nextrecord:
Next
Catch ex As Exception
txtStatus.Text &= ex.Message & vbCrLf
txtStatus.Refresh()
txtStatus.Text &= "Updated AIMSShopLink files for " & DatabaseName & " with errors." & Environment.NewLine
txtStatus.Refresh()
lblProgress.Text = "Updated AIMSShopLink files for " & DatabaseName & " with errors."
lblProgress.Refresh()
ErrorLog.XmlError("CopyAimsShopLinkFiles", ex)
MessageBox.Show(ex.Message.ToString(), "CopyAimsShopLinkFiles")
Err = Err + 1
End Try
End Sub
------------------------------------
'Copy Aims Shoplink Source files
Public Sub CopyFilesAndDirectories(ByVal source As DirectoryInfo, ByVal target As DirectoryInfo, ByVal CurrentDir As String)
Try
' Check if the target directory exists, if not, create it.
If Directory.Exists(target.FullName) = False Then
Directory.CreateDirectory(target.FullName)
End If
' Copy each file into it’s new directory.
For Each fi As FileInfo In source.GetFiles()
If CurrentDir <> "ErrorLogs" Then
If fi.Extension <> ".vspscc" Then
fi.Attributes = FileAttributes.Archive
fi.CopyTo(Path.Combine(target.ToString(), fi.Name), True)
lblUpdateSiteFiles.Text = "Copying files: " & fi.Name
lblProgress.Text = "Copying files: " & target.ToString() & "\" & fi.Name
lblProgress.Refresh()
lblUpdateSiteFiles.Refresh()
End If
End If
Next
'Copy each subdirectory using recursion.
For Each diSourceSubDir As DirectoryInfo In source.GetDirectories()
Dim nextTargetSubDir As DirectoryInfo = Nothing
nextTargetSubDir = target.CreateSubdirectory(diSourceSubDir.Name)
Dim strParentDirectory As String = diSourceSubDir.Name
CopyFilesAndDirectories(diSourceSubDir, nextTargetSubDir, strParentDirectory)
Next
Catch ex As Exception
ErrorLog.XmlError("CopyFilesAndDirectories Function", ex)
txtStatus.Text &= ex.Message & vbCrLf
txtStatus.Refresh()
MessageBox.Show(ex.Message.ToString(), "CopyFilesAndDirectories")
End Try
End Sub
No comments:
Post a Comment