/// /// <b>Method GetFDEList()</b> /// \brief <i>GetFDEList()</i> This method Read the log message from the Database /// \details <b>Details</b> /// The purpose of this function is read the message with the current date from the Database /// /// \param FileDataEntity - <b>List</b> - representation of the message which is want to read into the Database /// \return N/A - no return value /// public List <FileDataEntity> GetFDEList() { string sqlCmd = "SELECT Action,PathName,OldPathName,TimeAffected FROM Data ORDER BY TimeAffected DESC;"; List <FileDataEntity> fdeList = new List <FileDataEntity>(); try { cmd.CommandText = sqlCmd; conn.Open(); rdr = cmd.ExecuteReader(); while (rdr.Read()) { FileDataEntity fde = new FileDataEntity(); fde.Action = rdr["Action"].ToString(); fde.PathName = rdr["PathName"].ToString(); fde.OldPathName = rdr["OldPathName"].ToString(); fde.TimeAffected = (DateTime)rdr["TimeAffected"]; fdeList.Add(fde); } } catch (Exception ex) { Logger.Log("Exception: " + ex.Message); } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } } return(fdeList); }
/// /// <b>Method AddFileData()</b> /// \brief <i>AddFileData()</i> This method writes the log message into the Database /// \details <b>Details</b> /// The purpose of this function is writing the message with the current date into the Database /// /// \param fde - <b>FileDataEntity</b> - representation of the message which is want to write into the Database /// \return N/A - no return value /// public void AddFileData(FileDataEntity fde) { string sqlCmd = "INSERT INTO Data(Action,PathName,OldPathName,TimeAffected)" + "VALUES('" + fde.Action + "','" + fde.PathName + "','" + fde.OldPathName + "','" + fde.TimeAffected.ToString("yyyy-MM-dd HH:mm:ss") + "');"; try { cmd.CommandText = sqlCmd; conn.Open(); int result = cmd.ExecuteNonQuery(); } catch (Exception ex) { Logger.Log("Exception: " + ex.Message); } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } } }
/// <summary> /// Обновить модель файла данных на основе окончательного ответа /// </summary> public static FileDataEntity UpdateFileDataFromResponse(FileDataEntity fileDataEntity, FileDataResponseServer fileDataResponse) { var fileDataSourceEntity = fileDataResponse.FilesDataSource. Select(fileData => ToFileDataSource(fileData, fileDataEntity)). ToList(); fileDataEntity.StatusProcessing = fileDataResponse.StatusProcessing; fileDataEntity.FileErrors = fileDataResponse.FileErrors.Select(ToErrorComponent).ToList(); fileDataEntity.FileDataSourceServerEntities = fileDataSourceEntity; return(fileDataEntity); }
static void Main(string[] args) { Logger.Log("Test Method"); DAL dal = new DAL(); FileDataEntity fde = new FileDataEntity(); fde.PathName = "some path name"; fde.OldPathName = "some old path name"; fde.Action = "Create"; fde.TimeAffected = DateTime.UtcNow; dal.AddFileData(fde); List <FileDataEntity> flist = dal.GetFDEList(); foreach (FileDataEntity fdeItem in flist) { Console.WriteLine(fdeItem.Action + ", " + fdeItem.PathName + ", " + fdeItem.TimeAffected.ToString()); } Console.WriteLine("Enter to Continue..."); Console.ReadLine(); }
/// <summary> /// Обновить модель файла данных на основе промежуточного ответа /// </summary> public static FileDataEntity UpdateFileDataFromShortResponse(FileDataEntity fileDataEntity, FileDataShortResponseServer fileDataResponse) { fileDataEntity.StatusProcessing = fileDataResponse.StatusProcessing; fileDataEntity.FileErrors = fileDataResponse.FileErrors.Select(ToErrorComponent).ToList(); return(fileDataEntity); }
/// <summary> /// Обновить модель файла данных на основе окончательного ответа /// </summary> public static FileDataSourceEntity ToFileDataSource(FileDataSourceResponseServer fileDataSource, FileDataEntity fileDataEntity) => new FileDataSourceEntity(fileDataSource.FileName, fileDataSource.FileExtensionType, fileDataSource.PaperSize, fileDataSource.PrinterName, fileDataSource.FileDataSource). Void(source => source.FileDataEntity = fileDataEntity);
/// <summary> /// Конвертировать файл модели базы данных в основной ответ /// </summary> public static FileDataResponseClient FileDataAccessToResponse(FileDataEntity fileDataEntity) => new FileDataResponseClient(fileDataEntity.FilePath, fileDataEntity.StatusProcessing, fileDataEntity.FileErrors.Select(ToErrorCommon).ToList(), fileDataEntity.FileDataSourceServerEntities. Where(fileData => fileData.FileDataSource != null). Select(FileDataSourceToResponse).ToList());
/// <summary> /// Конвертировать файл модели базы данных в промежуточную /// </summary> private static FileDataShortResponseClient FileDataAccessToIntermediateResponse(FileDataEntity fileDataEntity) => new FileDataShortResponseClient(fileDataEntity.FilePath, fileDataEntity.StatusProcessing, fileDataEntity.FileErrors.Select(ToErrorCommon).ToList());
/// <summary> /// Конвертировать файл модели базы данных в запрос /// </summary> private static FileDataRequestServer FileDataToRequest(FileDataEntity fileDataEntity) => new FileDataRequestServer(fileDataEntity.FilePath, fileDataEntity.ColorPrintType, fileDataEntity.StatusProcessing, fileDataEntity.FileDataSource.ToArray(), fileDataEntity.FileExtensionAdditional, fileDataEntity.FileDataSourceAdditional?.ToArray());