/// <summary> /// Save a Previous JL work /// </summary> /// <param name="projectId">projectId</param> /// <param name="section_assetId">section_assetId</param> /// <param name="companyId">companyId</param> private void SavePreviousJLWork(int projectId, int section_assetId, int companyId) { // Load Previous work - Junction Lining section data (last sections work) string workType = "Junction Lining Section"; WorkJunctionLiningSectionGateway workJunctionLiningSectionGateway = new WorkJunctionLiningSectionGateway(); workJunctionLiningSectionGateway.LoadTop1ByProjectIdAssetIdWorkType(projectId, section_assetId, workType, companyId); int workId = workJunctionLiningSectionGateway.GetWorkIdTop1(); int numLats = workJunctionLiningSectionGateway.GetNumLats(workId); int notLinedYet = workJunctionLiningSectionGateway.GetNotLinedYet(workId); Boolean allMeasured = workJunctionLiningSectionGateway.GetAllMeasured(workId); string issueWithLaterals = workJunctionLiningSectionGateway.GetIssueWithLaterals(workId); int notMeasuredYet = workJunctionLiningSectionGateway.GetNotMeasuredYet(workId); int notDeliveredYet = workJunctionLiningSectionGateway.GetNotDeliveredYet(workId); string trafficControl = ""; if (workJunctionLiningSectionGateway.GetTrafficControl(workId) != "") trafficControl = workJunctionLiningSectionGateway.GetTrafficControl(workId); string trafficControlDetails = ""; if (workJunctionLiningSectionGateway.GetTrafficControlDetails(workId) != "") trafficControlDetails = workJunctionLiningSectionGateway.GetTrafficControlDetails(workId); Boolean standardBypass = workJunctionLiningSectionGateway.GetStandardBypass(workId); string standardBypassComments = ""; if (workJunctionLiningSectionGateway.GetStandardBypassComments(workId) != "") standardBypassComments = workJunctionLiningSectionGateway.GetStandardBypassComments(workId); int availableToLine = workJunctionLiningSectionGateway.GetAvailableToLine(workId); // Load Previous work - General work data WorkGateway workGateway = new WorkGateway(); workGateway.LoadByWorkId(workId, companyId); int? libraryCategoriesId = null; if (workGateway.GetLibraryCategoriesId(workId).HasValue) libraryCategoriesId = workGateway.GetLibraryCategoriesId(workId); string comments = workGateway.GetComments(workId); string history = workGateway.GetHistory(workId); // Save new work WorkJunctionLiningSection workJunctionLiningSection = new WorkJunctionLiningSection(null); int newSectionWorkId = workJunctionLiningSection.InsertDirect(projectId, section_assetId, libraryCategoriesId, numLats, notLinedYet, allMeasured, issueWithLaterals, notMeasuredYet, notDeliveredYet, false, companyId, comments, history, trafficControl, trafficControlDetails, standardBypass, standardBypassComments, availableToLine); // Load Previous work - Junction Lining Lateral data WorkJunctionLiningLateralGateway workJunctionLiningLateralGateway = new WorkJunctionLiningLateralGateway(); workJunctionLiningLateralGateway.LoadBySectionWorkId(workId, companyId); foreach (WorkTDS.LFS_WORK_JUNCTIONLINING_LATERALRow lateralRow in (WorkTDS.LFS_WORK_JUNCTIONLINING_LATERALDataTable)workJunctionLiningLateralGateway.Table) { WorkGateway workGatewayForLateral = new WorkGateway(); workGatewayForLateral.LoadByWorkId(lateralRow.WorkID, companyId); int lateral_assetId = workGatewayForLateral.GetAssetId(lateralRow.WorkID); DateTime? pipeLocated = null; if (!lateralRow.IsPipeLocatedNull()) pipeLocated = lateralRow.PipeLocated; DateTime? sevicesLocated = null; if (!lateralRow.IsServicesLocatedNull()) sevicesLocated = lateralRow.ServicesLocated; DateTime? coInstalled = null; if (!lateralRow.IsCoInstalledNull()) coInstalled = lateralRow.CoInstalled; DateTime? backfilledConcrete = null; if (!lateralRow.IsBackfilledConcreteNull()) backfilledConcrete = lateralRow.BackfilledConcrete; DateTime? backfilledSoil = null; if (!lateralRow.IsBackfilledSoilNull()) backfilledSoil = lateralRow.BackfilledSoil; DateTime? grouted = null; if (!lateralRow.IsGroutedNull()) grouted = lateralRow.Grouted; DateTime? cored = null; if (!lateralRow.IsCoredNull()) cored = lateralRow.Cored; DateTime? prepped = null; if (!lateralRow.IsPreppedNull()) prepped = lateralRow.Prepped; DateTime? measured = null; if (!lateralRow.IsMeasuredNull()) measured = lateralRow.Measured; string linerSize = ""; if (!lateralRow.IsLinerSizeNull()) linerSize = lateralRow.LinerSize; DateTime? inProcess = null; if (!lateralRow.IsInProcessNull()) inProcess = lateralRow.InProcess; DateTime? inStock = null; if (!lateralRow.IsInStockNull()) inStock = lateralRow.InStock; DateTime? delivered = null; if (!lateralRow.IsDeliveredNull()) delivered = lateralRow.Delivered; int? buildRebuild = null; if (!lateralRow.IsBuildRebuildNull()) buildRebuild = lateralRow.BuildRebuild; DateTime? preVideo = null; if (!lateralRow.IsPreVideoNull()) preVideo = lateralRow.PreVideo; DateTime? linerInstalled = null; if (!lateralRow.IsLinerInstalledNull()) linerInstalled = lateralRow.LinerInstalled; DateTime? finalVideo = null; if (!lateralRow.IsFinalVideoNull()) finalVideo = lateralRow.FinalVideo; decimal? cost = null; if (!lateralRow.IsCostNull()) cost = lateralRow.Cost; DateTime? videoInspection = null; if (!lateralRow.IsVideoInspectionNull()) videoInspection = lateralRow.VideoInspection; bool coRequired = lateralRow.CoRequired; bool pitRequired = lateralRow.PitRequired; string coPitLocation = ""; if (!lateralRow.IsCoPitLocationNull()) coPitLocation = lateralRow.CoPitLocation; bool postContractDigRequired = lateralRow.PostContractDigRequired; DateTime? coCutDown = null; if (!lateralRow.IsCoCutDownNull()) coCutDown = lateralRow.CoCutDown; DateTime? finalRestoration = null; if (!lateralRow.IsFinalRestorationNull()) finalRestoration = lateralRow.FinalRestoration; string videoLengthToPropertyLine = ""; if (!lateralRow.IsVideoLengthToPropertyLineNull()) videoLengthToPropertyLine = lateralRow.VideoLengthToPropertyLine; bool liningThruCo = lateralRow.LiningThruCo; DateTime? noticeDelivered = null; if (!lateralRow.IsNoticeDeliveredNull()) noticeDelivered = lateralRow.NoticeDelivered; string hamiltonInspectionNumber = ""; if (!lateralRow.IsHamiltonInspectionNumberNull()) hamiltonInspectionNumber = lateralRow.HamiltonInspectionNumber; string flange = ""; if (!lateralRow.IsFlangeNull()) flange = lateralRow.Flange; string gasket = ""; if (!lateralRow.IsGasketNull()) gasket = lateralRow.Gasket; string depthOfLocated = ""; if (!lateralRow.IsDepthOfLocatedNull()) depthOfLocated = lateralRow.DepthOfLocated; bool digRequiredPriorToLining = lateralRow.DigRequiredPriorToLining; DateTime? digRequiredPriorToLiningCompleted = null; if (!lateralRow.IsDigRequiredPriorToLiningCompletedNull()) digRequiredPriorToLiningCompleted = lateralRow.DigRequiredPriorToLiningCompleted; bool digRequiredAfterLining = lateralRow.DigRequiredAfterLining; DateTime? digRequiredAfterLiningCompleted = null; if (!lateralRow.IsDigRequiredAfterLiningCompletedNull()) digRequiredAfterLiningCompleted = lateralRow.DigRequiredAfterLiningCompleted; bool outOfScope = lateralRow.OutOfScope; bool holdClientIssue = lateralRow.HoldClientIssue; DateTime? holdClientIssueResolved = null; if (!lateralRow.IsHoldClientIssueResolvedNull()) holdClientIssueResolved = lateralRow.HoldClientIssueResolved; bool holdLFSIssue = lateralRow.HoldLFSIssue; DateTime? holdLFSIssueResolved = null; if (!lateralRow.IsHoldLFSIssueResolvedNull()) holdLFSIssueResolved = lateralRow.HoldLFSIssueResolved; bool requiresRoboticPrep = lateralRow.LateralRequiresRoboticPrep; DateTime? requiresRoboticPrepCompleted = null; if (!lateralRow.IsLateralRequiresRoboticPrepCompletedNull()) requiresRoboticPrepCompleted = lateralRow.LateralRequiresRoboticPrepCompleted; string linerType = ""; if (!lateralRow.IsLinerTypeNull()) linerType = lateralRow.LinerType; string prepType = ""; if (!lateralRow.IsPrepTypeNull()) prepType = lateralRow.PrepType; bool dyeTestReq = lateralRow.DyeTestReq; DateTime? dyeTestComplete = null; if (!lateralRow.IsDyeTestCompleteNull()) dyeTestComplete = lateralRow.DyeTestComplete; string contractYear = ""; if (!lateralRow.IsContractYearNull()) contractYear = lateralRow.ContractYear; WorkJunctionLiningLateral workJunctionLiningLateral = new WorkJunctionLiningLateral(null); workJunctionLiningLateral.InsertDirect(projectId, lateral_assetId, newSectionWorkId, pipeLocated, sevicesLocated, coInstalled, backfilledConcrete, backfilledSoil, grouted, cored, prepped, measured, linerSize, inProcess, inStock, delivered, buildRebuild, preVideo, linerInstalled, finalVideo, cost, videoInspection, coRequired, pitRequired, coPitLocation, postContractDigRequired, coCutDown, finalRestoration, false, companyId, comments, history, videoLengthToPropertyLine, liningThruCo, noticeDelivered, hamiltonInspectionNumber, flange, gasket, depthOfLocated, digRequiredPriorToLining, digRequiredPriorToLiningCompleted, digRequiredAfterLining, digRequiredAfterLiningCompleted, outOfScope, holdClientIssue, holdClientIssueResolved, holdLFSIssue, holdLFSIssueResolved, requiresRoboticPrep, requiresRoboticPrepCompleted, linerType, prepType, dyeTestReq, dyeTestComplete, contractYear); } // Load Previous work - Comments and History SavePreviousComments(workId, workType, companyId, newSectionWorkId); SavePreviousHistory(workId, workType, companyId, newSectionWorkId); }
/// <summary> /// Save a Previous RA work /// </summary> /// <param name="projectId">projectId</param> /// <param name="section_assetId">section_assetId</param> /// <param name="companyId">companyId</param> private void SavePreviousWork(int parentProjectId, int childProjectId, int assetId, string workType, int companyId) { int parentWorkId = 0; int childWorkId = 0; int childJLLWorkId = 0; int parentJLLWorkID = 0; // Load Previous work - Rehab assessment data (last sections work) WorkGateway parentWorkGateway = new WorkGateway(); WorkGateway childWorkGateway = new WorkGateway(); WorkGateway childJLLWorkGateway = new WorkGateway(); parentWorkGateway.LoadByProjectIdAssetIdWorkType(parentProjectId, assetId, workType, companyId); if (parentWorkGateway.Table.Rows.Count > 0) { parentWorkId = parentWorkGateway.GetWorkId(assetId, workType, parentProjectId); childWorkGateway.LoadByProjectIdAssetIdWorkType(childProjectId, assetId, workType, companyId); childWorkId = childWorkGateway.GetWorkId(assetId, workType, childProjectId); // Load Previous work - Comments and History SavePreviousComments(parentWorkId, workType, companyId, childWorkId); SavePreviousHistory(parentWorkId, workType, companyId, childWorkId); if (workType == "Junction Lining Section") { // Load Previous work - Junction Lining Lateral data WorkJunctionLiningLateralGateway workJunctionLiningLateralGateway = new WorkJunctionLiningLateralGateway(); workJunctionLiningLateralGateway.LoadBySectionWorkId(parentWorkId, companyId); foreach (WorkTDS.LFS_WORK_JUNCTIONLINING_LATERALRow lateralRow in (WorkTDS.LFS_WORK_JUNCTIONLINING_LATERALDataTable)workJunctionLiningLateralGateway.Table) { try { WorkGateway workGatewayForLateral = new WorkGateway(); workGatewayForLateral.LoadByWorkId(lateralRow.WorkID, companyId); int lateral_assetId = workGatewayForLateral.GetAssetId(lateralRow.WorkID); parentJLLWorkID = lateralRow.WorkID; childJLLWorkGateway.LoadByProjectIdAssetIdWorkType(childProjectId, lateral_assetId, "Junction Lining Lateral", companyId); childJLLWorkId = childJLLWorkGateway.GetWorkId(lateral_assetId, "Junction Lining Lateral", childProjectId); // Load Previous work - Comments and History SavePreviousComments(parentJLLWorkID, "Junction Lining Lateral", companyId, childJLLWorkId); SavePreviousHistory(parentJLLWorkID, "Junction Lining Lateral", companyId, childJLLWorkId); workUpdate(childJLLWorkId, childProjectId, lateral_assetId, companyId, "Junction Lining Lateral"); } catch { } } } else { workUpdate(childWorkId, childProjectId, assetId, companyId, workType); } } }
/// <summary> /// UpdateForReport /// </summary> /// <param name="companyId">companyId</param> public void UpdateForReport(int companyId) { foreach (JlLiningPlanTDS.JlLiningPlanJlinerRow row in (JlLiningPlanTDS.JlLiningPlanJlinerDataTable)Table) { // Update comments int jlWorkId = row.SectionWorkID; WorkGateway workGateway = new WorkGateway(); workGateway.LoadByWorkId(jlWorkId, companyId); int assetId = workGateway.GetAssetId(jlWorkId); int projectId = workGateway.GetProjectId(jlWorkId); // ... Get raWorkId int raWorkId = 0; WorkGateway raWorkGateway = new WorkGateway(); raWorkGateway.LoadByProjectIdAssetIdWorkType(projectId, row.Section_, "Rehab Assessment", companyId); if (raWorkGateway.Table.Rows.Count > 0) { raWorkId = raWorkGateway.GetWorkId(row.Section_, "Rehab Assessment", projectId); } // ... Get raWorkId int flWorkId = 0; WorkGateway flWorkGateway = new WorkGateway(); flWorkGateway.LoadByProjectIdAssetIdWorkType(projectId, row.Section_, "Full Length Lining", companyId); if (flWorkGateway.Table.Rows.Count > 0) { flWorkId = flWorkGateway.GetWorkId(row.Section_, "Full Length Lining", projectId); } // ... Load All Comments FlatSectionJLAllComments flatSectionJLAllComments = new FlatSectionJLAllComments(); flatSectionJLAllComments.LoadAllByJlWorkIdFlWorkIdRaWorkId(jlWorkId, flWorkId, raWorkId, companyId); row.Comments = flatSectionJLAllComments.GetJLOrFLOrRAComments(companyId, flatSectionJLAllComments.Table.Rows.Count, "\n"); // Add M1 comments WorkFullLengthLiningM1LateralGateway workFullLengthLiningM1LateralGateway = new WorkFullLengthLiningM1LateralGateway(); workFullLengthLiningM1LateralGateway.LoadByWorkIdLateral(flWorkId, row.AssetID, companyId); if (workFullLengthLiningM1LateralGateway.Table.Rows.Count > 0) { string m1LateralComment = workFullLengthLiningM1LateralGateway.GetComments(flWorkId, row.AssetID); if (m1LateralComment != "") { row.Comments = row.Comments + "\n\nType: M1 Lateral Comments\nComment: " + m1LateralComment; } } if (!row.IsCommentsNull()) { row.Comments = row.Comments.Replace("<br>", "\n"); } // Round PullInDistance if (Validator.IsValidDecimal(row.PullInDistance)) { row.PullInDistance = decimal.Round(decimal.Parse(row.PullInDistance), 1).ToString(); } else { row.PullInDistance = "0"; } // Update Main size if (!row.IsMainSizeNull()) { if (Distance.IsValidDistance(row.MainSize)) { Distance distance = new Distance(row.MainSize); switch (distance.DistanceType) { case 2: row.MainSize = distance.ToStringInEng1(); break; case 3: if (Convert.ToDouble(row.MainSize) > 99) { double newMainSize = 0; newMainSize = Convert.ToDouble(row.MainSize) * 0.03937; row.MainSize = Convert.ToString(Math.Ceiling(newMainSize)) + "\""; } else { row.MainSize = row.MainSize + "\""; } break; case 4: row.MainSize = distance.ToStringInEng1(); break; case 5: row.MainSize = distance.ToStringInEng1(); break; } } } } }
/// <summary> /// UpdateCommentsHistoryForSummaryEdit /// </summary> /// <param name="jlWorkId">jlWorkId</param> /// <param name="workType">workType</param> /// <param name="companyId">companyId</param> /// <returns>comments</returns> public void UpdateCommentsHistoryForSummaryEdit(int jlWorkId, string workType, int companyId) { foreach (FlatSectionJlTDS.FlatSectionJlRow row in (FlatSectionJlTDS.FlatSectionJlDataTable)Table) { WorkGateway workGateway = new WorkGateway(); workGateway.LoadByWorkId(jlWorkId, companyId); int assetId = workGateway.GetAssetId(jlWorkId); int projectId = workGateway.GetProjectId(jlWorkId); if (row.AssetID == assetId) { // Update Comments // ... Get raWorkId int raWorkId = 0; WorkGateway raWorkGateway = new WorkGateway(); raWorkGateway.LoadByProjectIdAssetIdWorkType(projectId, row.Section_, "Rehab Assessment", companyId); if (raWorkGateway.Table.Rows.Count > 0) { raWorkId = raWorkGateway.GetWorkId(row.Section_, "Rehab Assessment", projectId); } // ... Get flWorkId int flWorkId = 0; WorkGateway flWorkGateway = new WorkGateway(); flWorkGateway.LoadByProjectIdAssetIdWorkType(projectId, row.Section_, "Full Length Lining", companyId); if (flWorkGateway.Table.Rows.Count > 0) { flWorkId = flWorkGateway.GetWorkId(row.Section_, "Full Length Lining", projectId); } // ... Load All Comments FlatSectionJLAllComments flatSectionJLAllComments = new FlatSectionJLAllComments(); flatSectionJLAllComments.LoadAllByJlWorkIdFlWorkIdRaWorkId(jlWorkId, flWorkId, raWorkId, companyId); row.Comments = flatSectionJLAllComments.GetJLOrFLOrRAComments(companyId, flatSectionJLAllComments.Table.Rows.Count, "\n"); // Add M1 comments WorkFullLengthLiningM1LateralGateway workFullLengthLiningM1LateralGateway = new WorkFullLengthLiningM1LateralGateway(); workFullLengthLiningM1LateralGateway.LoadByWorkIdLateral(flWorkId, row.AssetID, companyId); if (workFullLengthLiningM1LateralGateway.Table.Rows.Count > 0) { string m1LateralComments = workFullLengthLiningM1LateralGateway.GetComments(flWorkId, row.AssetID); if (m1LateralComments != "") { row.Comments = row.Comments + "\n\nType: M1 Lateral Comments\nComment: " + m1LateralComments; } } WorkFullLengthLiningM1Gateway workFullLengthLiningM1Gateway = new WorkFullLengthLiningM1Gateway(); workFullLengthLiningM1Gateway.LoadByWorkId(flWorkId, companyId); if (workFullLengthLiningM1Gateway.Table.Rows.Count > 0) { string trafficControlDetails = workFullLengthLiningM1Gateway.GetTrafficControlDetails(flWorkId); if (trafficControlDetails != "") { row.Comments = row.Comments + "\n\nType: Traffic Control Details\nComment: " + trafficControlDetails ; } string standardByPassComments = workFullLengthLiningM1Gateway.GetStandardBypassComments(flWorkId); if (standardByPassComments != "") { row.Comments = row.Comments + "\n\nType: Standard Bypass Comments\nComment: " + standardByPassComments ; } } if (!row.IsCommentsNull()) { row.Comments = row.Comments.Replace("<br>", "\n"); } // Update History FlatSectionJLAllHistory flatSectionJLAllHistory = new FlatSectionJLAllHistory(); flatSectionJLAllHistory.LoadAllByJlWorkIdFlWorkIdRaWorkId(jlWorkId, flWorkId, raWorkId, companyId); row.History = flatSectionJLAllHistory.GetJLOrFLOrRAHistory(companyId, flatSectionJLAllHistory.Table.Rows.Count, "\n"); if (!row.IsHistoryNull()) { row.History = row.History.Replace("<br>", "\n"); } } } }
/// <summary> /// UpdateComments /// </summary> /// <param name="jlWorkId">workIdjlWorkIdparam> /// <param name="workType">workType</param> /// <param name="companyId">companyId</param> public void UpdateComments(int jlWorkId, string workType, int companyId) { foreach (JlNavigatorTDS.JlNavigatorRow row in (JlNavigatorTDS.JlNavigatorDataTable)Table) { WorkGateway workGateway = new WorkGateway(); workGateway.LoadByWorkId(jlWorkId, companyId); int assetId = workGateway.GetAssetId(jlWorkId); int projectId = workGateway.GetProjectId(jlWorkId); if (row.AssetID_ == assetId) { // Update Comments // ... Get raWorkId int raWorkId = 0; // ... Get raWorkId int flWorkId = 0; // ... Load All Comments FlatSectionJLAllComments flatSectionJLAllComments = new FlatSectionJLAllComments(); flatSectionJLAllComments.LoadAllByJlWorkIdFlWorkIdRaWorkId(jlWorkId, flWorkId, raWorkId, companyId); row.Comments = flatSectionJLAllComments.GetJLOrFLOrRAComments(companyId, flatSectionJLAllComments.Table.Rows.Count, "\n"); if (!row.IsHistoryNull()) { row.Comments = row.Comments.Replace("<br>", "\n"); } // Update History FlatSectionJLAllHistory flatSectionJLAllHistory = new FlatSectionJLAllHistory(); flatSectionJLAllHistory.LoadAllByJlWorkIdFlWorkIdRaWorkId(jlWorkId, flWorkId, raWorkId, companyId); row.History = flatSectionJLAllHistory.GetJLOrFLOrRAHistory(companyId, flatSectionJLAllHistory.Table.Rows.Count, "\n"); if (!row.IsHistoryNull()) { row.History = row.History.Replace("<br>", "\n"); } // Save work // ... Get original variables workGateway.LoadByWorkId(jlWorkId, companyId); string originalWorkType = workGateway.GetWorkTypeOriginal(jlWorkId); int? originalLibraryCategoriesId = workGateway.GetLibraryCategoriesIdOriginal(jlWorkId); string originalComment = workGateway.GetCommentsOriginal(jlWorkId); string originalHistory = workGateway.GetHistoryOriginal(jlWorkId); Work work = new Work(null); work.UpdateDirect(jlWorkId, projectId, assetId, originalWorkType, originalLibraryCategoriesId, false, companyId, originalComment, originalHistory, jlWorkId, projectId, assetId, originalWorkType, originalLibraryCategoriesId, false, companyId, row.Comments, row.History); } } }