/// <summary> /// Save Previous History /// </summary> /// <param name="workId">workId</param> /// <param name="workType">workType</param> /// <param name="companyId">companyId</param> /// <param name="newSectionWorkId">newSectionWorkId</param> private void SavePreviousHistory(int workId, string workType, int companyId, int newSectionWorkId) { WorkHistoryGateway workHistoryGateway = new WorkHistoryGateway(); workHistoryGateway.LoadAllByWorkIdWorkType(workId, companyId, workType); foreach (WorkTDS.LFS_WORK_HISTORYRow historyRow in (WorkTDS.LFS_WORK_HISTORYDataTable)workHistoryGateway.Table) { int refId = historyRow.RefID; string type = ""; if (!historyRow.IsTypeNull()) type = historyRow.Type; string subject = historyRow.Subject; int userId = historyRow.UserID; DateTime? dateTime_ = null; if (!historyRow.IsDateTime_Null()) dateTime_ = historyRow.DateTime_; string history = ""; if (!historyRow.IsHistoryNull()) history = historyRow.History; int? libraryFilesId = null; if (!historyRow.IsLIBRARY_FILES_IDNull()) libraryFilesId = historyRow.LIBRARY_FILES_ID; WorkHistory workHistory = new WorkHistory(); workHistory.InsertDirect(newSectionWorkId, refId, type, subject, userId, dateTime_, history, libraryFilesId, false, companyId, workType); } }
/// <summary> /// Save all comments to database (direct) /// </summary> /// <param name="companyId">companyId</param> public void Save(int companyId) { FlatSectionJlTDS flatSectionJlHistoryDetailsChanges = (FlatSectionJlTDS)Data.GetChanges(); if (flatSectionJlHistoryDetailsChanges.FlatSectionJlHistoryDetails.Rows.Count > 0) { FlatSectionJlHistoryDetailsGateway flatSectionJlHistoryDetailsGateway = new FlatSectionJlHistoryDetailsGateway(flatSectionJlHistoryDetailsChanges); foreach (FlatSectionJlTDS.FlatSectionJlHistoryDetailsRow row in (FlatSectionJlTDS.FlatSectionJlHistoryDetailsDataTable)flatSectionJlHistoryDetailsChanges.FlatSectionJlHistoryDetails) { // Insert new comments if ((!row.Deleted) && (!row.InDatabase)) { WorkHistory workHistory = new WorkHistory(null); int? libraryFilesId = null; if (!row.IsLIBRARY_FILES_IDNull()) libraryFilesId = row.LIBRARY_FILES_ID; string workType = ""; if (!row.IsWorkTypeNull()) workType = row.WorkType; workHistory.InsertDirect(row.WorkID, row.RefID, row.Type, row.Subject, row.UserID, row.DateTime_, row.History, libraryFilesId, row.Deleted, row.COMPANY_ID, workType); } // Update comments if ((!row.Deleted) && (row.InDatabase)) { int workId = row.WorkID; int refId = row.RefID; bool originalDeleted = false; int originalCompanyId = companyId; // original values string originalType = flatSectionJlHistoryDetailsGateway.GetTypeOriginal(workId, refId); string originalSubject = flatSectionJlHistoryDetailsGateway.GetSubjectOriginal(workId, refId); int originalUserId = flatSectionJlHistoryDetailsGateway.GetUserIdOriginal(workId, refId); DateTime? originalDateTime = null; if (flatSectionJlHistoryDetailsGateway.GetDateTime_Original(workId, refId) != null) originalDateTime = flatSectionJlHistoryDetailsGateway.GetDateTime_Original(workId, refId); string originalComment = flatSectionJlHistoryDetailsGateway.GetCommentOriginal(workId, refId); int? originalLibraryFilesId = null; if (flatSectionJlHistoryDetailsGateway.GetLIBRARY_FILES_IDOriginal(workId, refId) != null) originalLibraryFilesId = flatSectionJlHistoryDetailsGateway.GetLIBRARY_FILES_IDOriginal(workId, refId); string originalWorkType = flatSectionJlHistoryDetailsGateway.GetWorkTypeOriginal(workId, refId); // new values string newSubject = flatSectionJlHistoryDetailsGateway.GetSubject(workId, refId); string newComment = flatSectionJlHistoryDetailsGateway.GetComment(workId, refId); int? newLibraryFilesId = null; if (flatSectionJlHistoryDetailsGateway.GetLIBRARY_FILES_IDOriginal(workId, refId) != null) originalLibraryFilesId = flatSectionJlHistoryDetailsGateway.GetLIBRARY_FILES_ID(workId, refId); WorkHistory workHistory = new WorkHistory(null); workHistory.UpdateDirect(workId, refId, originalType, originalSubject, originalUserId, originalDateTime, originalComment, originalLibraryFilesId, originalDeleted, originalCompanyId, originalWorkType, workId, refId, originalType, newSubject, originalUserId, originalDateTime, newComment, newLibraryFilesId, originalDeleted, originalCompanyId, originalWorkType); } // Deleted comments if ((row.Deleted) && (row.InDatabase)) { WorkHistory workHistory = new WorkHistory(null); workHistory.DeleteDirect(row.WorkID, row.RefID, row.COMPANY_ID); } } } }
/// <summary> /// Save Previous History /// </summary> /// <param name="workId">workId</param> /// <param name="workType">workType</param> /// <param name="companyId">companyId</param> /// <param name="newSectionWorkId">newSectionWorkId</param> private void SavePreviousHistory(int parentWorkId, string workType, int companyId, int childWorkId) { WorkHistoryGateway parentWorkHistoryGateway = new WorkHistoryGateway(); parentWorkHistoryGateway.LoadAllByWorkIdWorkType(parentWorkId, companyId, workType); WorkHistoryGateway childWorkHistoryGateway = new WorkHistoryGateway(); childWorkHistoryGateway.LoadAllByWorkIdWorkType(childWorkId, companyId, workType); WorkHistory childWorkHistory = new WorkHistory(childWorkHistoryGateway.Data); int lastRefId = childWorkHistory.GetNewRefId(); foreach (WorkTDS.LFS_WORK_HISTORYRow commentRow in (WorkTDS.LFS_WORK_HISTORYDataTable)parentWorkHistoryGateway.Table) { WorkHistory workHistory = new WorkHistory(); int refId = lastRefId; string type = ""; if (!commentRow.IsTypeNull()) type = commentRow.Type; string subject = commentRow.Subject; int userId = commentRow.UserID; DateTime? dateTime_ = null; if (!commentRow.IsDateTime_Null()) dateTime_ = commentRow.DateTime_; string comment = ""; if (!commentRow.IsHistoryNull()) comment = commentRow.History; int? libraryFilesId = null; if (!commentRow.IsLIBRARY_FILES_IDNull()) libraryFilesId = commentRow.LIBRARY_FILES_ID; workHistory.InsertDirect(childWorkId, refId, type, subject, userId, dateTime_, comment, libraryFilesId, false, companyId, workType); lastRefId++; } }