EDMIService: First completed version of UpdateFileMethod
This commit is contained in:
@@ -34,37 +34,17 @@ Namespace Methods.IDB.NewFile
|
||||
|
||||
' Find ObjectStore by Title
|
||||
Logger.Debug("Checking for DataStore [{0}].", pData.StoreName)
|
||||
Dim oStore = GlobalState.ObjectStores.Where(Function(store) store.Title.Equals(pData.StoreName, StringComparison.OrdinalIgnoreCase)).SingleOrDefault()
|
||||
Dim oStore = GlobalState.ObjectStores.
|
||||
Where(Function(store) store.Title = pData.StoreName).
|
||||
SingleOrDefault()
|
||||
|
||||
If oStore Is Nothing Then
|
||||
LogAndThrow($"DataStore [{pData.StoreName}] does not exist. Exiting.")
|
||||
End If
|
||||
|
||||
' Get Store base path
|
||||
Dim oBasePath As String = oStore.Path
|
||||
Logger.Debug("Store BasePath is [{0}]", oBasePath)
|
||||
|
||||
' Get directory by DateImported or, if not supplied, by current date
|
||||
Dim oSubDirectory As String
|
||||
If IsNothing(pData.File.FileImportedAt) Then
|
||||
oSubDirectory = GetDateSubDirectory(Now)
|
||||
Else
|
||||
oSubDirectory = GetDateSubDirectory(pData.File.FileImportedAt)
|
||||
End If
|
||||
Logger.Debug("Subdirectory is [{0}]", oSubDirectory)
|
||||
|
||||
' Check and create final path, if necessary
|
||||
Dim oFinalPath = IO.Path.Combine(oBasePath, oSubDirectory)
|
||||
If Not IO.Directory.Exists(oFinalPath) Then
|
||||
Try
|
||||
Logger.Debug("Path does not exist, creating: [{0}]", oFinalPath)
|
||||
IO.Directory.CreateDirectory(oFinalPath)
|
||||
Logger.Debug("Created folder [{0}]", oFinalPath)
|
||||
Catch ex As Exception
|
||||
LogAndThrow(ex, $"Store Directory [{oFinalPath}] could not be created!")
|
||||
End Try
|
||||
End If
|
||||
Logger.Debug("Final Directory is [{0}]", oFinalPath)
|
||||
' Get Store base and final path
|
||||
Logger.Debug("Store BasePath is [{0}]", oStore.Path)
|
||||
Dim oFinalPath = Helpers.GetFileObjectPath(oStore, pData.File.FileImportedAt)
|
||||
|
||||
' Get filename
|
||||
Dim oKeepFileName As Boolean = False
|
||||
@@ -182,10 +162,6 @@ Namespace Methods.IDB.NewFile
|
||||
Return $"{IDB_OBJ_ID}.ddfo"
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Function GetDateSubDirectory(pDate As Date) As String
|
||||
Return IO.Path.Combine(pDate.ToString("yyyy"), pDate.ToString("MM"), pDate.ToString("dd"))
|
||||
End Function
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
Reference in New Issue
Block a user