// ////////////////////////////////////////////////////////////////////////
        // PUBLIC METHODS
        //
        /// <summary>
        /// Delete
        /// </summary>
        /// <param name="workId">workId</param>
        /// <param name="companyId">companyId</param>
        public void Delete(int workId, int companyId)
        {
            WorkFullLengthLiningM1LateralGateway workFullLengthLiningM1LateralGateway = new WorkFullLengthLiningM1LateralGateway();
            workFullLengthLiningM1LateralGateway.LoadByWorkId(workId, companyId);

            foreach (WorkTDS.LFS_WORK_FULLLENGTHLINING_M1_LATERALRow row in (WorkTDS.LFS_WORK_FULLLENGTHLINING_M1_LATERALDataTable)workFullLengthLiningM1LateralGateway.Table)
            {
                // delete lfs lateral client
                WorkGateway workGateway = new WorkGateway();
                workGateway.LoadByWorkId(workId, companyId);
                int currentProjectId = workGateway.GetProjectId(workId);

                ProjectGateway projectGateway = new ProjectGateway();
                projectGateway.LoadByProjectId(currentProjectId);
                int clientId = projectGateway.GetClientID(currentProjectId);

                LfsAssetSewerLateralClientGateway lfsAssetSewerLateralClientGateway = new LfsAssetSewerLateralClientGateway();
                lfsAssetSewerLateralClientGateway.LoadByAssetIdClientId(row.Lateral, clientId, companyId);

                if (lfsAssetSewerLateralClientGateway.Table.Rows.Count > 0)
                {
                    LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null);
                    lfsAssetSewerLateralClient.DeleteDirect(row.Lateral, clientId, companyId);
                }

                // Delete work lateral
                workFullLengthLiningM1LateralGateway.Delete(workId, row.Lateral, companyId);

                // Delete section
                LfsAssetSewerLateral lfsAssetSewerLateral = new LfsAssetSewerLateral(null);
                lfsAssetSewerLateral.DeleteDirect(row.Lateral, companyId);
            }
        }
        /// <summary>
        /// Save a Previous PR work
        /// </summary>
        /// <param name="projectId">projectId</param>
        /// <param name="section_assetId">section_assetId</param>
        /// <param name="companyId">companyId</param>
        private void SavePreviousPRWork(int projectId, int section_assetId, int companyId)
        {
            // Load Previous work - Point Repairs data (last sections work)
            string workType = "Point Repairs";
            WorkPointRepairsGateway workPointRepairsGateway = new WorkPointRepairsGateway();
            workPointRepairsGateway.LoadTop1ByProjectIdAssetIdWorkType(projectId, section_assetId, workType, companyId);

            int workId = workPointRepairsGateway.GetWorkIdTop1();
            string clientId = ""; if (workPointRepairsGateway.GetClientId(workId) != "") clientId = workPointRepairsGateway.GetClientId(workId);
            string measurementTakenBy = ""; if (workPointRepairsGateway.GetMeasurementTakenBy(workId) != "") measurementTakenBy = workPointRepairsGateway.GetMeasurementTakenBy(workId);
            DateTime? repairConfirmationDate = null; if (workPointRepairsGateway.GetRepairConfirmationDate(workId).HasValue) repairConfirmationDate = workPointRepairsGateway.GetRepairConfirmationDate(workId);
            bool bypassRequired = workPointRepairsGateway.GetBypassRequired(workId);
            string roboticDistances = ""; if (workPointRepairsGateway.GetRoboticDistances(workId) != "") roboticDistances = workPointRepairsGateway.GetRoboticDistances(workId);
            DateTime? proposedLiningDate = null; if (workPointRepairsGateway.GetProposedLiningDate(workId).HasValue) proposedLiningDate = workPointRepairsGateway.GetProposedLiningDate(workId);
            DateTime? deadlineLiningDate = null; if (workPointRepairsGateway.GetDeadlineLiningDate(workId).HasValue) deadlineLiningDate = workPointRepairsGateway.GetDeadlineLiningDate(workId);
            DateTime? finalVideoDate = null; if (workPointRepairsGateway.GetFinalVideoDate(workId).HasValue) finalVideoDate = workPointRepairsGateway.GetFinalVideoDate(workId);
            int? estimatedJoints = null; if (workPointRepairsGateway.GetEstimatedJoints(workId).HasValue) estimatedJoints = workPointRepairsGateway.GetEstimatedJoints(workId);
            int? jointsTestSealed = null; if (workPointRepairsGateway.GetJointsTestSealed(workId).HasValue) jointsTestSealed = workPointRepairsGateway.GetJointsTestSealed(workId);
            bool issueIdentified = workPointRepairsGateway.GetIssueIdentified(workId);
            bool issueLfs = workPointRepairsGateway.GetIssueLFS(workId);
            bool issueClient = workPointRepairsGateway.GetIssueClient(workId);
            bool issueSales = workPointRepairsGateway.GetIssueSales(workId);
            bool issueGivenToClient = workPointRepairsGateway.GetIssueGivenToClient(workId);
            bool issueResolved = workPointRepairsGateway.GetIssueResolved(workId);
            bool issueInvestigation = workPointRepairsGateway.GetIssueInvestigation(workId);
            string repairId = ""; if (workPointRepairsGateway.GetRepairID(workId) != "") repairId = workPointRepairsGateway.GetRepairID(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
            WorkPointRepairs workPointRepairs = new WorkPointRepairs(null);
            int newSectionWorkId = workPointRepairs.InsertDirect(projectId, section_assetId, libraryCategoriesId, clientId, measurementTakenBy, repairConfirmationDate, bypassRequired, roboticDistances, proposedLiningDate, deadlineLiningDate, finalVideoDate, estimatedJoints, jointsTestSealed, issueIdentified, issueLfs, issueClient, issueSales, issueGivenToClient, issueResolved, issueInvestigation, repairId, false, companyId, comments, history);

            // Load Previous work  -  Save pr repair
            WorkPointRepairsRepairGateway workPointRepairsRepairGateway = new WorkPointRepairsRepairGateway();
            workPointRepairsRepairGateway.LoadByWorkId(workId, companyId);

            foreach (WorkTDS.LFS_WORK_POINT_REPAIRS_REPAIRRow row in (WorkTDS.LFS_WORK_POINT_REPAIRS_REPAIRDataTable)workPointRepairsRepairGateway.Table)
            {
                string repairPointId = row.RepairPointID;
                string type = ""; if (!row.IsTypeNull()) type = row.Type;
                string reamDistance = ""; if (!row.IsReamDistanceNull()) reamDistance = row.ReamDistance;
                DateTime? reamDate = null; if (!row.IsReamDateNull()) reamDate = row.ReamDate;
                string linerDistance = ""; if (!row.IsLinerDistanceNull()) linerDistance = row.LinerDistance;
                string direction = ""; if (!row.IsDirectionNull()) direction = row.Direction;
                int? reinstates = null; if (!row.IsReinstatesNull()) reinstates = row.Reinstates;
                string ltmh = ""; if (!row.IsLTMHNull()) ltmh = row.LTMH;
                string vtmh = ""; if (!row.IsVTMHNull()) vtmh = row.VTMH;
                string distance = ""; if (!row.IsDistanceNull()) distance = row.Distance;
                string size_ = ""; if (!row.IsSize_Null()) size_ = row.Size_;
                DateTime? installDate = null; if (!row.IsInstallDateNull()) installDate = row.InstallDate;
                string mhShot = ""; if (!row.IsMHShotNull()) mhShot = row.MHShot;
                string groutDistance = ""; if (!row.IsGroutDistanceNull()) groutDistance = row.GroutDistance;
                DateTime? groutDate = null; if (!row.IsGroutDateNull()) groutDate = row.GroutDate;
                string approval = ""; if (!row.IsApprovalNull()) approval = row.Approval;
                bool extraRepair = row.ExtraRepair;
                bool cancelled = row.Cancelled;
                string commentsRepair = ""; if (!row.IsCommentsNull()) commentsRepair = row.Comments;
                string defectQualifier = ""; if (!row.IsDefectQualifierNull()) defectQualifier = row.DefectQualifier;
                string defecDetails = ""; if (!row.IsDefectDetailsNull()) defecDetails = row.DefectDetails;
                string length = ""; if (!row.IsLengthNull()) length = row.Length;
                DateTime? reinstateDate = null; if (!row.IsReinstateDateNull()) reinstateDate = row.ReinstateDate;

                WorkPointRepairsRepair workPointRepairsRepair = new WorkPointRepairsRepair();
                workPointRepairsRepair.InsertDirect(newSectionWorkId, repairPointId, type, reamDistance, reamDate, linerDistance, direction, reinstates, ltmh, vtmh, distance, size_, installDate, mhShot, groutDistance, groutDate, approval, extraRepair, cancelled, commentsRepair, false, companyId, defectQualifier, defectQualifier, length, reinstateDate);
            }

            // Load Previous work  - Comments and History
            SavePreviousComments(workId, workType, companyId, newSectionWorkId);
            SavePreviousHistory(workId, workType, companyId, newSectionWorkId);
        }
        /// <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 FL work
        /// </summary>
        /// <param name="projectId">projectId</param>
        /// <param name="section_assetId">section_assetId</param>
        /// <param name="companyId">companyId</param>
        private void SavePreviousFLWork(int projectId, int section_assetId, int companyId)
        {
            // Load Previous work  -  Full Length Lining data (last sections work)
            string workType = "Full Length Lining";
            WorkFullLengthLiningGateway workFullLengthLiningGateway = new WorkFullLengthLiningGateway();
            workFullLengthLiningGateway.LoadTop1ByProjectIdAssetIdWorkType(projectId, section_assetId, workType, companyId);

            int workId = workFullLengthLiningGateway.GetWorkIdTop1();
            string clientId = ""; if (workFullLengthLiningGateway.GetClientId(workId) != "") clientId = workFullLengthLiningGateway.GetClientId(workId);
            DateTime? proposedLiningDate = null; if (workFullLengthLiningGateway.GetProposedLiningDate(workId).HasValue) proposedLiningDate = workFullLengthLiningGateway.GetProposedLiningDate(workId);
            DateTime? deadlineLiningDate = null; if (workFullLengthLiningGateway.GetDeadlineLiningDate(workId).HasValue) deadlineLiningDate = workFullLengthLiningGateway.GetDeadlineLiningDate(workId);
            DateTime? p1Date = null; if (workFullLengthLiningGateway.GetP1Date(workId).HasValue) p1Date = workFullLengthLiningGateway.GetP1Date(workId);
            DateTime? m1Date = null; if (workFullLengthLiningGateway.GetM1Date(workId).HasValue) m1Date = workFullLengthLiningGateway.GetM1Date(workId);
            DateTime? m2Date = null; if (workFullLengthLiningGateway.GetM2Date(workId).HasValue) m2Date = workFullLengthLiningGateway.GetM2Date(workId);
            DateTime? installDate = null; if (workFullLengthLiningGateway.GetInstallDate(workId).HasValue) installDate = workFullLengthLiningGateway.GetInstallDate(workId);
            DateTime? finalVideoDate = null; if (workFullLengthLiningGateway.GetFinalVideoDate(workId).HasValue) finalVideoDate = workFullLengthLiningGateway.GetFinalVideoDate(workId);
            bool issueIdentified = workFullLengthLiningGateway.GetIssueIdentified(workId);
            bool issueLfs = workFullLengthLiningGateway.GetIssueLFS(workId);
            bool issueClient = workFullLengthLiningGateway.GetIssueClient(workId);
            bool issueSales = workFullLengthLiningGateway.GetIssueSales(workId);
            bool issueGivenToClient = workFullLengthLiningGateway.GetIssueGivenToClient(workId);
            bool issueResolved = workFullLengthLiningGateway.GetIssueResolved(workId);
            bool issueInvestigation = workFullLengthLiningGateway.GetIssueInvestigation(workId);

            // Load Previous work  -  Full Length Lining M1 data (last sections work)
            FullLengthLiningWorkDetailsGateway fullLengthLiningWorkDetailsGateway = new FullLengthLiningWorkDetailsGateway();
            fullLengthLiningWorkDetailsGateway.LoadByWorkIdAssetId(workId, section_assetId, companyId);

            string measurementTakenBy = ""; if (fullLengthLiningWorkDetailsGateway.GetMeasurementTakenBy(workId) != "") measurementTakenBy = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenBy(workId);
            string trafficControl = ""; if (fullLengthLiningWorkDetailsGateway.GetTrafficControl(workId) != "") trafficControl = fullLengthLiningWorkDetailsGateway.GetTrafficControl(workId);
            string siteDetails = ""; if (fullLengthLiningWorkDetailsGateway.GetSiteDetails(workId) != "") siteDetails = fullLengthLiningWorkDetailsGateway.GetSiteDetails(workId);
            string accessType = ""; if (fullLengthLiningWorkDetailsGateway.GetAccessType(workId) != "") accessType = fullLengthLiningWorkDetailsGateway.GetAccessType(workId);
            bool pipeSizeChange = fullLengthLiningWorkDetailsGateway.GetPipeSizeChange(workId);
            bool standardByPass = fullLengthLiningWorkDetailsGateway.GetStandardBypass(workId);
            string standardByPassComments = ""; if (fullLengthLiningWorkDetailsGateway.GetStandardBypassComments(workId) != "") standardByPassComments = fullLengthLiningWorkDetailsGateway.GetStandardBypassComments(workId);
            string trafficControlDetails = ""; if (fullLengthLiningWorkDetailsGateway.GetTrafficControlDetails(workId) != "") trafficControlDetails = fullLengthLiningWorkDetailsGateway.GetTrafficControlDetails(workId);
            string measurementType = ""; if (fullLengthLiningWorkDetailsGateway.GetMeasurementType(workId) != "") measurementType = fullLengthLiningWorkDetailsGateway.GetMeasurementType(workId);
            string measurementFromMH = ""; if (fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workId) != "") measurementFromMH = fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workId);
            string videoDoneFromMH = ""; if (fullLengthLiningWorkDetailsGateway.GetVideoDoneFromMh(workId) != "") videoDoneFromMH = fullLengthLiningWorkDetailsGateway.GetVideoDoneFromMh(workId);
            string videoDoneToMH = ""; if (fullLengthLiningWorkDetailsGateway.GetVideoDoneToMh(workId) != "") videoDoneToMH = fullLengthLiningWorkDetailsGateway.GetVideoDoneToMh(workId);

            // Load Previous work  -  Full Length Lining M2 data (last sections work)
            string videoLength = ""; if (fullLengthLiningWorkDetailsGateway.GetVideoLength(workId) != "") videoLength = fullLengthLiningWorkDetailsGateway.GetVideoLength(workId);
            string measurementTakenBy2 = ""; if (fullLengthLiningWorkDetailsGateway.GetMeasurementTakenByM2(workId) != "") measurementTakenBy2 = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenByM2(workId);
            bool dropPipe = fullLengthLiningWorkDetailsGateway.GetDropPipe(workId);
            string dropPipeInvertDepth = ""; if (fullLengthLiningWorkDetailsGateway.GetDropPipeInvertDepth(workId) != "") dropPipeInvertDepth = fullLengthLiningWorkDetailsGateway.GetDropPipeInvertDepth(workId);
            int? cappedLaterals = null; if (fullLengthLiningWorkDetailsGateway.GetCappedLaterals(workId).HasValue) cappedLaterals = fullLengthLiningWorkDetailsGateway.GetCappedLaterals(workId);
            string lineWithID = ""; if (fullLengthLiningWorkDetailsGateway.GetLineWithId(workId) != "") lineWithID = fullLengthLiningWorkDetailsGateway.GetLineWithId(workId);
            string hydrantAddress = ""; if (fullLengthLiningWorkDetailsGateway.GetHydrantAddress(workId) != "") hydrantAddress = fullLengthLiningWorkDetailsGateway.GetHydrantAddress(workId);
            string hydroWireWithin10FtOfInversionMH = ""; if (fullLengthLiningWorkDetailsGateway.GetHydroWiredWithin10FtOfInversionMH(workId) != "") hydroWireWithin10FtOfInversionMH = fullLengthLiningWorkDetailsGateway.GetHydroWiredWithin10FtOfInversionMH(workId);
            string distanceToInversionMH = ""; if (fullLengthLiningWorkDetailsGateway.GetDistanceToInversionMh(workId) != "") distanceToInversionMH = fullLengthLiningWorkDetailsGateway.GetDistanceToInversionMh(workId);
            string surfaceGrade = ""; if (fullLengthLiningWorkDetailsGateway.GetSurfaceGrade(workId) != "") surfaceGrade = fullLengthLiningWorkDetailsGateway.GetSurfaceGrade(workId);
            bool hydroPulley = fullLengthLiningWorkDetailsGateway.GetHydroPulley(workId);
            bool fridgeCart = fullLengthLiningWorkDetailsGateway.GetFridgeCart(workId);
            bool twoPump = fullLengthLiningWorkDetailsGateway.GetTwoPump(workId);
            bool sixBypass = fullLengthLiningWorkDetailsGateway.GetSixBypass(workId);
            bool scaffolding = fullLengthLiningWorkDetailsGateway.GetScaffolding(workId);
            bool winchExtention = fullLengthLiningWorkDetailsGateway.GetWinchExtension(workId);
            bool extraGenerator = fullLengthLiningWorkDetailsGateway.GetExtraGenerator(workId);
            bool greyCableExtension = fullLengthLiningWorkDetailsGateway.GetGreyCableExtension(workId);
            bool easementMats = fullLengthLiningWorkDetailsGateway.GetEasementMats(workId);
            bool rampRequired = fullLengthLiningWorkDetailsGateway.GetRampRequired(workId);
            bool cameraSkid = fullLengthLiningWorkDetailsGateway.GetCameraSkid(workId);

            // Load Previous work  -  Full Length Lining P1 data (last sections work)
            int? cxisRemoved = null; if (fullLengthLiningWorkDetailsGateway.GetCxisRemoved(workId).HasValue) fullLengthLiningWorkDetailsGateway.GetCxisRemoved(workId);
            bool roboticPrepCompleted = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompleted(workId);
            DateTime? roboticPrepCompletedDate = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedDate(workId);
            bool p1Completed = fullLengthLiningWorkDetailsGateway.GetP1Completed(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
            WorkFullLengthLining workFullLengthLining = new WorkFullLengthLining(null);
            int newSectionWorkId = workFullLengthLining.InsertDirectFullWork(projectId, section_assetId, libraryCategoriesId, clientId, proposedLiningDate, deadlineLiningDate, p1Date, m1Date, m2Date, installDate, finalVideoDate, issueIdentified, issueLfs, issueClient, issueSales, issueGivenToClient, issueResolved, false, companyId, issueInvestigation, comments, history, cxisRemoved, roboticPrepCompleted, roboticPrepCompletedDate, measurementTakenBy, trafficControl, siteDetails, pipeSizeChange, standardByPass, standardByPassComments, trafficControlDetails, measurementType, measurementFromMH, videoDoneFromMH, videoDoneToMH, videoLength, measurementTakenBy2, dropPipe, dropPipeInvertDepth, cappedLaterals, lineWithID, hydrantAddress, hydroWireWithin10FtOfInversionMH, distanceToInversionMH, surfaceGrade, hydroPulley, fridgeCart, twoPump, sixBypass, scaffolding, winchExtention, extraGenerator, greyCableExtension, easementMats, rampRequired, cameraSkid, accessType, p1Completed);

            // Load Previous work  -  Save fl laterals
            WorkFullLengthLiningM1LateralGateway workFullLengthLiningM1LateralGateway = new WorkFullLengthLiningM1LateralGateway();
            workFullLengthLiningM1LateralGateway.LoadByWorkId(workId, companyId);

            foreach (WorkTDS.LFS_WORK_FULLLENGTHLINING_M1_LATERALRow lateralRow in (WorkTDS.LFS_WORK_FULLLENGTHLINING_M1_LATERALDataTable)workFullLengthLiningM1LateralGateway.Table)
            {
                int lateral = lateralRow.Lateral;
                string videoDistance = ""; if (!lateralRow.IsVideoDistanceNull()) videoDistance = lateralRow.VideoDistance;
                string clockPosition = ""; if (!lateralRow.IsClockPositionNull()) clockPosition = lateralRow.ClockPosition;
                string distanceToCentre = ""; if (!lateralRow.IsDistanceToCentreNull()) distanceToCentre = lateralRow.DistanceToCentre;
                string timeOpened = ""; if (!lateralRow.IsTimeOpenedNull()) timeOpened = lateralRow.TimeOpened;
                string reverseSetup = ""; if (!lateralRow.IsReverseSetupNull()) reverseSetup = lateralRow.ReverseSetup;
                DateTime? reinstate = null; if (!lateralRow.IsReinstateNull()) reinstate = lateralRow.Reinstate;
                string lateralComments = ""; if (!lateralRow.IsCommentsNull()) lateralComments = lateralRow.Comments;
                string clientInspectionNo = ""; if (!lateralRow.IsClientInspectionNoNull()) clientInspectionNo = lateralRow.ClientInspectionNo;
                DateTime? v1Inspection = null; if (!lateralRow.IsV1InspectionNull()) v1Inspection = lateralRow.V1Inspection;
                bool requiresRoboticPrep = lateralRow.RequiresRoboticPrep;
                DateTime? requiresRoboticPrepDate = null; if (!lateralRow.IsRequiresRoboticPrepDateNull()) requiresRoboticPrepDate = lateralRow.RequiresRoboticPrepDate;
                bool holdClientIssue = lateralRow.HoldClientIssue;
                bool holdLFSIssue = lateralRow.HoldLFSIssue;
                bool lineLateral = lateralRow.LineLateral;
                bool dyeTestReq = lateralRow.DyeTestReq;
                DateTime? dyeTestComplete = null; if (!lateralRow.IsDyeTestCompleteNull()) dyeTestComplete = lateralRow.DyeTestComplete;
                string contractYear = lateralRow.ContractYear;

                WorkFullLengthLiningM1Lateral workFullLengthLiningM1Lateral = new WorkFullLengthLiningM1Lateral();
                workFullLengthLiningM1Lateral.InsertDirect(newSectionWorkId, lateral, videoDistance, clockPosition, distanceToCentre, timeOpened, reverseSetup, reinstate, lateralComments, false, companyId, clientInspectionNo, v1Inspection, requiresRoboticPrep, requiresRoboticPrepDate, holdClientIssue, holdLFSIssue, lineLateral, dyeTestReq, dyeTestComplete, contractYear);
            }

            // Load Previous work  - Comments and History
            SavePreviousComments(workId, workType, companyId, newSectionWorkId);
            SavePreviousHistory(workId, workType, companyId, newSectionWorkId);
        }
Exemplo n.º 5
0
        // ////////////////////////////////////////////////////////////////////////
        // PRIVATE METHODS
        //
        /// <summary>
        /// UpdateForReport
        /// </summary>
        /// <param name="unitType">unitType</param>
        private void UpdateForReport(string unitType)
        {
            // Load comments
            foreach (FlM1ReportTDS.M1ReportByClientRow row in (FlM1ReportTDS.M1ReportByClientDataTable)Table)
            {
                WorkGateway workGateway = new WorkGateway();
                workGateway.LoadByWorkId(row.WorkID, row.COMPANY_ID);
                row.M1Comments = workGateway.GetComments(row.WorkID);
            }

            // Update for unit type
            FlM1LateralReportGateway flM1LateralReportGateway = new FlM1LateralReportGateway(Data);
            flM1LateralReportGateway.ClearBeforeFill = false;
            FlM1LateralReport flM1LateralReport = new FlM1LateralReport(Data);

            foreach (FlM1ReportTDS.M1ReportByClientRow row in (FlM1ReportTDS.M1ReportByClientDataTable)Table)
            {
                if (!row.IsM1CommentsNull())
                {
                    row.M1Comments = row.M1Comments.Replace("<br>", "\n");
                }

                Distance d;

                if (unitType == "Metric")
                {
                    if (!row.IsSize_Null())
                    {
                        if (Distance.IsValidDistance(row.Size_))
                        {
                            d = new Distance(row.Size_);
                            row.Size_ = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsLengthNull())
                    {
                        if (Distance.IsValidDistance(row.Length))
                        {
                            d = new Distance(row.Length);
                            row.Length = d.ToStringInMet2();
                        }
                    }

                    if (!row.IsUSMHDepthNull())
                    {
                        if (Distance.IsValidDistance(row.USMHDepth))
                        {
                            d = new Distance(row.USMHDepth);
                            row.USMHDepth = d.ToStringInMet2();
                        }
                    }

                    if (!row.IsDSMHDepthNull())
                    {
                        if (Distance.IsValidDistance(row.DSMHDepth))
                        {
                            d = new Distance(row.DSMHDepth);
                            row.DSMHDepth = d.ToStringInMet2();
                        }
                    }

                    if (!row.IsUSMHMouth12Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth12))
                        {
                            d = new Distance(row.USMHMouth12);
                            row.USMHMouth12 = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsUSMHMouth1Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth1))
                        {
                            d = new Distance(row.USMHMouth1);
                            row.USMHMouth1 = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsUSMHMouth2Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth2))
                        {
                            d = new Distance(row.USMHMouth2);
                            row.USMHMouth2 = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsUSMHMouth3Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth3))
                        {
                            d = new Distance(row.USMHMouth3);
                            row.USMHMouth3 = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsUSMHMouth4Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth4))
                        {
                            d = new Distance(row.USMHMouth4);
                            row.USMHMouth4 = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsUSMHMouth5Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth5))
                        {
                            d = new Distance(row.USMHMouth5);
                            row.USMHMouth5 = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsDSMHMouth12Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth12))
                        {
                            d = new Distance(row.DSMHMouth12);
                            row.DSMHMouth12 = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsDSMHMouth1Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth1))
                        {
                            d = new Distance(row.DSMHMouth1);
                            row.DSMHMouth1 = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsDSMHMouth2Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth2))
                        {
                            d = new Distance(row.DSMHMouth2);
                            row.DSMHMouth2 = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsDSMHMouth3Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth3))
                        {
                            d = new Distance(row.DSMHMouth3);
                            row.DSMHMouth3 = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsDSMHMouth4Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth4))
                        {
                            d = new Distance(row.DSMHMouth4);
                            row.DSMHMouth4 = d.ToStringInMil2();
                        }
                    }

                    if (!row.IsDSMHMouth5Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth5))
                        {
                            d = new Distance(row.DSMHMouth5);
                            row.DSMHMouth5 = d.ToStringInMil2();
                        }
                    }
                }

                if (unitType == "Imperial")
                {
                    if (!row.IsSize_Null())
                    {
                        if (Distance.IsValidDistance(row.Size_))
                        {
                            Distance distance = new Distance(row.Size_);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.Size_ = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.Size_) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.Size_) * 0.03937;
                                            row.Size_ = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.Size_ = row.Size_ + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.Size_ = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.Size_ = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsLengthNull())
                    {
                        d = new Distance(row.Length);
                        row.Length = d.ToStringInEng1();
                    }

                    if (!row.IsUSMHDepthNull())
                    {
                        if (Distance.IsValidDistance(row.USMHDepth))
                        {
                            Distance distance = new Distance(row.USMHDepth);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.USMHDepth = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.Size_) > 99)
                                        {
                                            double newUSMHDepth = 0;
                                            newUSMHDepth = Convert.ToDouble(row.Size_) * 0.03937;
                                            row.USMHDepth = Convert.ToString(Math.Ceiling(newUSMHDepth)) + "\"";
                                        }
                                        else
                                        {
                                            row.USMHDepth = row.USMHDepth + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.USMHDepth = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.USMHDepth = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsDSMHDepthNull())
                    {
                        if (Distance.IsValidDistance(row.DSMHDepth))
                        {
                            Distance distance = new Distance(row.DSMHDepth);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.DSMHDepth = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.Size_) > 99)
                                        {
                                            double newDSMHDepth = 0;
                                            newDSMHDepth = Convert.ToDouble(row.Size_) * 0.03937;
                                            row.DSMHDepth = Convert.ToString(Math.Ceiling(newDSMHDepth)) + "\"";
                                        }
                                        else
                                        {
                                            row.DSMHDepth = row.USMHDepth + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.DSMHDepth = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.DSMHDepth = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsUSMHMouth12Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth12))
                        {
                            Distance distance = new Distance(row.USMHMouth12);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.USMHMouth12 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.USMHMouth12) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.USMHMouth12) * 0.03937;
                                            row.USMHMouth12 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.USMHMouth12 = row.USMHMouth12 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.USMHMouth12 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.USMHMouth12 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsUSMHMouth1Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth1))
                        {
                            Distance distance = new Distance(row.USMHMouth1);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.USMHMouth1 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.USMHMouth1) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.USMHMouth1) * 0.03937;
                                            row.USMHMouth1 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.USMHMouth1 = row.USMHMouth1 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.USMHMouth1 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.USMHMouth1 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsUSMHMouth2Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth2))
                        {
                            Distance distance = new Distance(row.USMHMouth2);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.USMHMouth2 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.USMHMouth2) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.USMHMouth2) * 0.03937;
                                            row.USMHMouth2 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.USMHMouth2 = row.USMHMouth2 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.USMHMouth2 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.USMHMouth2 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsUSMHMouth3Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth3))
                        {
                            Distance distance = new Distance(row.USMHMouth3);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.USMHMouth3 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.USMHMouth3) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.USMHMouth3) * 0.03937;
                                            row.USMHMouth3 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.USMHMouth3 = row.USMHMouth3 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.USMHMouth3 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.USMHMouth3 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsUSMHMouth4Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth4))
                        {
                            Distance distance = new Distance(row.USMHMouth4);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.USMHMouth4 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.USMHMouth4) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.USMHMouth4) * 0.03937;
                                            row.USMHMouth4 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.USMHMouth4 = row.USMHMouth4 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.USMHMouth4 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.USMHMouth4 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsUSMHMouth5Null())
                    {
                        if (Distance.IsValidDistance(row.USMHMouth5))
                        {
                            Distance distance = new Distance(row.USMHMouth5);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.USMHMouth5 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.USMHMouth5) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.USMHMouth5) * 0.03937;
                                            row.USMHMouth5 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.USMHMouth5 = row.USMHMouth5 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.USMHMouth5 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.USMHMouth5 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsDSMHMouth12Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth12))
                        {
                            Distance distance = new Distance(row.DSMHMouth12);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.DSMHMouth12 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.DSMHMouth12) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.DSMHMouth12) * 0.03937;
                                            row.DSMHMouth12 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.DSMHMouth12 = row.DSMHMouth12 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.DSMHMouth12 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.DSMHMouth12 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsDSMHMouth1Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth1))
                        {
                            Distance distance = new Distance(row.DSMHMouth1);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.DSMHMouth1 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.DSMHMouth1) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.DSMHMouth1) * 0.03937;
                                            row.DSMHMouth1 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.DSMHMouth1 = row.DSMHMouth1 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.DSMHMouth1 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.DSMHMouth1 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsDSMHMouth2Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth2))
                        {
                            Distance distance = new Distance(row.DSMHMouth2);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.DSMHMouth2 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.DSMHMouth2) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.DSMHMouth2) * 0.03937;
                                            row.DSMHMouth2 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.DSMHMouth2 = row.DSMHMouth2 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.DSMHMouth2 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.DSMHMouth2 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsDSMHMouth3Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth3))
                        {
                            Distance distance = new Distance(row.DSMHMouth3);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.DSMHMouth3 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.DSMHMouth3) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.DSMHMouth3) * 0.03937;
                                            row.DSMHMouth3 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.DSMHMouth3 = row.DSMHMouth3 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.DSMHMouth3 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.DSMHMouth3 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsDSMHMouth4Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth4))
                        {
                            Distance distance = new Distance(row.DSMHMouth4);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.DSMHMouth4 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.DSMHMouth4) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.DSMHMouth4) * 0.03937;
                                            row.DSMHMouth4 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.DSMHMouth4 = row.DSMHMouth4 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.DSMHMouth4 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.DSMHMouth4 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsDSMHMouth5Null())
                    {
                        if (Distance.IsValidDistance(row.DSMHMouth5))
                        {
                            Distance distance = new Distance(row.DSMHMouth5);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.DSMHMouth5 = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    try
                                    {
                                        if (Convert.ToDouble(row.DSMHMouth5) > 99)
                                        {
                                            double newSize_ = 0;
                                            newSize_ = Convert.ToDouble(row.DSMHMouth5) * 0.03937;
                                            row.DSMHMouth5 = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                        }
                                        else
                                        {
                                            row.DSMHMouth5 = row.DSMHMouth5 + "\"";
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    break;
                                case 4:
                                    row.DSMHMouth5 = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.DSMHMouth5 = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }
                }

                flM1LateralReportGateway.LoadByAssetId(row.AssetID, row.COMPANY_ID);
                flM1LateralReport.UpdateForReport(row.FlowOrderID, unitType);
            }
        }
Exemplo n.º 6
0
        // ////////////////////////////////////////////////////////////////////////
        // PRIVATE METHODS
        //
        /// <summary>
        /// UpdateForReport
        /// </summary>
        /// <param name="unitType">unitType</param>
        public void UpdateForReport(string unitType)
        {
            // Load comments
            foreach (FlM1ReportTDS.M2_SECTIONRow row in (FlM1ReportTDS.M2_SECTIONDataTable)Table)
            {
                WorkGateway workGateway = new WorkGateway();
                workGateway.LoadByWorkId(row.WorkID, row.COMPANY_ID);

                row.Comments = workGateway.GetComments(row.WorkID);

                Distance d;

                if (unitType == "Metric")
                {
                    if (!row.IsSize_Null())
                    {
                        d = new Distance(row.Size_);
                        row.Size_ = d.ToStringInMet2();
                    }

                    if (!row.IsVideoLengthNull())
                    {
                        d = new Distance(row.VideoLength);
                        row.VideoLength = d.ToStringInMet2();
                    }

                    if (!row.IsSurfaceGradeNull())
                    {
                        if (row.SurfaceGrade == "0-3 ft")
                        {
                            row.SurfaceGrade = "0-0.91 m";
                        }

                        if (row.SurfaceGrade == "3-6 ft")
                        {
                            row.SurfaceGrade = "0.91-1.83 m";
                        }

                        if (row.SurfaceGrade == "6 ft +")
                        {
                            row.SurfaceGrade = "1.83 m +";
                        }
                    }
                }

                if (unitType == "Imperial")
                {
                    if (!row.IsSize_Null())
                    {
                        if (Distance.IsValidDistance(row.Size_))
                        {
                            Distance distance = new Distance(row.Size_);

                            switch (distance.DistanceType)
                            {
                                case 2:
                                    row.Size_ = distance.ToStringInEng1();
                                    break;
                                case 3:
                                    if (Convert.ToDouble(row.Size_) > 99)
                                    {
                                        double newSize_ = 0;
                                        newSize_ = Convert.ToDouble(row.Size_) * 0.03937;
                                        row.Size_ = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                                    }
                                    else
                                    {
                                        row.Size_ = row.Size_ + "\"";
                                    }
                                    break;
                                case 4:
                                    row.Size_ = distance.ToStringInEng1();
                                    break;
                                case 5:
                                    row.Size_ = distance.ToStringInEng1();
                                    break;
                            }
                        }
                    }

                    if (!row.IsVideoLengthNull())
                    {
                        d = new Distance(row.VideoLength);
                        row.VideoLength = d.ToStringInEng1();
                    }
                }
            }

            // Update for unit type
            //foreach (FlM1ReportTDS.M2_SECTIONRow row in (FlM1ReportTDS.M2_SECTIONDataTable)Table)
            //{
                //Distance d;

                //if (unitType == "Metric")
                //{
                //    if (!row.IsSize_Null())
                //    {
                //        d = new Distance(row.Size_);
                //        row.Size_ = d.ToStringInMet2();
                //    }

                //    if (!row.IsVideoLengthNull())
                //    {
                //        d = new Distance(row.VideoLength);
                //        row.VideoLength = d.ToStringInMet2();
                //    }

                //    if (!row.IsSurfaceGradeNull())
                //    {
                //        if (row.SurfaceGrade == "0-3 ft")
                //        {
                //            row.SurfaceGrade = "0-0.91 m";
                //        }

                //        if (row.SurfaceGrade == "3-6 ft")
                //        {
                //            row.SurfaceGrade = "0.91-1.83 m";
                //        }

                //        if (row.SurfaceGrade == "6 ft +")
                //        {
                //            row.SurfaceGrade = "1.83 m +";
                //        }
                //    }
                //}

                //if (unitType == "Imperial")
                //{
                //    if (!row.IsSize_Null())
                //    {
                //        if (Distance.IsValidDistance(row.Size_))
                //        {
                //            Distance distance = new Distance(row.Size_);

                //            switch (distance.DistanceType)
                //            {
                //                case 2:
                //                    row.Size_ = distance.ToStringInEng1();
                //                    break;
                //                case 3:
                //                    if (Convert.ToDouble(row.Size_) > 99)
                //                    {
                //                        double newSize_ = 0;
                //                        newSize_ = Convert.ToDouble(row.Size_) * 0.03937;
                //                        row.Size_ = Convert.ToString(Math.Ceiling(newSize_)) + "\"";
                //                    }
                //                    else
                //                    {
                //                        row.Size_ = row.Size_ + "\"";
                //                    }
                //                    break;
                //                case 4:
                //                    row.Size_ = distance.ToStringInEng1();
                //                    break;
                //                case 5:
                //                    row.Size_ = distance.ToStringInEng1();
                //                    break;
                //            }
                //        }
                //    }

                //    if (!row.IsVideoLengthNull())
                //    {
                //        d = new Distance(row.VideoLength);
                //        row.VideoLength = d.ToStringInEng1();
                //    }
                //}
            //}
        }
Exemplo n.º 7
0
        /// <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);
                }
            }
        }
        /// <summary>
        /// UpdateCommentsWetOutForSummaryEdit
        /// </summary>
        /// <param name="workId">workId</param>
        /// <param name="companyId">companyId</param>
        public void UpdateCommentsWetOutForSummaryEdit(int workId, int companyId)
        {
            WorkFullLengthLiningWetOutCommentsGateway workFullLengthLiningWetOutCommentsGateway = new WorkFullLengthLiningWetOutCommentsGateway();
            WorkFullLengthLiningWetOutComments workFullLengthLiningWetOutComments = new WorkFullLengthLiningWetOutComments(workFullLengthLiningWetOutCommentsGateway.Data);
            WorkGateway workGateway = new WorkGateway();

            FullLengthLiningTDS.WorkDetailsRow row = GetRow(workId);

            workGateway.LoadByWorkId(workId, companyId);
            workFullLengthLiningWetOutCommentsGateway.LoadAllByWorkIdWorkType(workId, companyId, "Full Length Lining Wet Out");
            row.CommentsCipp = workFullLengthLiningWetOutComments.GetAllComments(workId, companyId, workFullLengthLiningWetOutCommentsGateway.Table.Rows.Count, "\n");
        }
        private void WorkUpdate()
        {
            // Get general variables
            int projectId = Int32.Parse(hdfCurrentProject.Value.Trim());
            int companyId = Convert.ToInt32(Session["companyID"]);
            FlatSectionJl flatSectionJl = new FlatSectionJl(flatSectionJlTDS);
            DataView dataViewFlatSectionJl = new DataView(flatSectionJlTDS.FlatSectionJl);
            dataViewFlatSectionJl.RowFilter = "(Selected = 1) AND (Deleted = 0)";

            foreach (DataRowView row in dataViewFlatSectionJl)
            {
                int workId = Int32.Parse(row["WorkID"].ToString());
                int assetId = Int32.Parse(row["AssetID"].ToString());
                string workType = "Junction Lining Lateral";

                // Get original variables
                WorkGateway workGateway = new WorkGateway();
                workGateway.LoadByWorkId(workId, companyId);

                string originalWorkType = workGateway.GetWorkTypeOriginal(workId);
                int? originalLibraryCategoriesId = workGateway.GetLibraryCategoriesIdOriginal(workId);
                string originalComment = workGateway.GetCommentsOriginal(workId);
                string originalHistory = workGateway.GetHistoryOriginal(workId);

                // Get new comment
                WorkCommentsGateway workCommentsGateway = new WorkCommentsGateway();
                workCommentsGateway.LoadByWorkIdWorkType(workId, companyId, "Junction Lining Lateral");
                WorkComments workComments = new WorkComments(workCommentsGateway.Data);
                string newComments = workComments.GetAllComments(workId, companyId, workCommentsGateway.Table.Rows.Count, "\n");

                // Get new history
                WorkHistoryGateway workHistoryGateway = new WorkHistoryGateway();
                workHistoryGateway.LoadByWorkIdWorkType(workId, companyId, "Junction Lining Lateral");
                WorkHistory workHistory = new WorkHistory(workHistoryGateway.Data);
                string newHistory = workHistory.GetAllHistory(workId, companyId, workHistoryGateway.Table.Rows.Count, "\n");

                Work work = new Work(null);
                work.UpdateDirect(workId, projectId, assetId, originalWorkType, originalLibraryCategoriesId, false, companyId, originalComment, originalHistory, workId, projectId, assetId, originalWorkType, originalLibraryCategoriesId, false, companyId, newComments, newHistory);

                flatSectionJl.UpdateCommentsHistoryForSummaryEdit(workId, workType, companyId);
            }
        }
Exemplo n.º 10
0
        private void workUpdate(int workId, int projectId, int assetId, int companyId, string workType)
        {
            // Get original variables
            WorkGateway workGateway = new WorkGateway();
            workGateway.LoadByWorkId(workId, companyId);

            string originalWorkType = workGateway.GetWorkTypeOriginal(workId);
            int? originalLibraryCategoriesId = workGateway.GetLibraryCategoriesIdOriginal(workId);
            string originalComment = workGateway.GetCommentsOriginal(workId);
            string originalHistory = workGateway.GetHistoryOriginal(workId);

            //Get new comment
            WorkCommentsGateway workCommentsGateway = new WorkCommentsGateway();
            workCommentsGateway.LoadByAssetIdWorkTypeProjectId(assetId, companyId, workType, projectId);

            WorkComments workComments = new WorkComments(workCommentsGateway.Data);
            string newComment = workComments.GetCommentsSummary(companyId, workCommentsGateway.Table.Rows.Count, "\n");

            Work work = new Work(null);
            work.UpdateDirect(workId, projectId, assetId, originalWorkType, originalLibraryCategoriesId, false, companyId, originalComment, originalHistory, workId, projectId, assetId, originalWorkType, originalLibraryCategoriesId, false, companyId, newComment, originalHistory);
        }
Exemplo n.º 11
0
        /// <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);
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Delete
        /// </summary>
        /// <param name="workId">workId</param>
        /// <param name="assetIdLateral">assetIdLateral</param>
        /// <param name="sectionWorkId">sectionWorkId</param>
        /// <param name="companyId">companyId</param>
        private void Delete(int workId, int assetIdLateral, int sectionWorkId, int companyId)
        {
            WorkGateway workGateway = new WorkGateway();
            workGateway.LoadByWorkId(workId, companyId);
            int currentProjectId = workGateway.GetProjectId(workId);

            ProjectGateway projectGateway = new ProjectGateway();
            projectGateway.LoadByProjectId(currentProjectId);
            int clientId = projectGateway.GetClientID(currentProjectId);

            // delete lateral work
            WorkJunctionLiningLateral workJunctionLiningLateral = new WorkJunctionLiningLateral(null);
            workJunctionLiningLateral.DeleteDirect(workId, sectionWorkId, companyId);

            // delete lfs lateral
            LfsAssetSewerLateral lfsAssetSewerLateral = new LfsAssetSewerLateral(null);
            bool isDeleted = lfsAssetSewerLateral.DeleteDirect(assetIdLateral, companyId);

            if (isDeleted)
            {
                // delete lfs lateral client
                LfsAssetSewerLateralClientGateway lfsAssetSewerLateralClientGateway = new LfsAssetSewerLateralClientGateway();
                lfsAssetSewerLateralClientGateway.LoadByAssetIdClientId(assetIdLateral, clientId, companyId);

                if (lfsAssetSewerLateralClientGateway.Table.Rows.Count > 0)
                {
                    LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null);
                    lfsAssetSewerLateralClient.DeleteDirect(assetIdLateral, clientId, companyId);
                }
            }
        }
Exemplo n.º 13
0
        /// <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");
                    }
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // PRIVATE METHODS
        //
        /// <summary>
        /// UpdateForReport
        /// </summary>
        /// <param name="unitType">unitType</param>
        private void UpdateForReport(string unitType)
        {
            // Load comments
            foreach (FlM1LateralReportTDS.M1ReportByClientRow row in (FlM1LateralReportTDS.M1ReportByClientDataTable)Table)
            {
                WorkGateway workGateway = new WorkGateway();
                workGateway.LoadByWorkId(row.WorkID, row.COMPANY_ID);
                row.M1Comments = workGateway.GetComments(row.WorkID);
            }

            // Update for unit type
            FlM1LateralLateralReportGateway flM1LateralReportGateway = new FlM1LateralLateralReportGateway(Data);
            flM1LateralReportGateway.ClearBeforeFill = false;
            FlM1LateralLateralReport flM1LateralReport = new FlM1LateralLateralReport(Data);

            foreach (FlM1LateralReportTDS.M1ReportByClientRow row in (FlM1LateralReportTDS.M1ReportByClientDataTable)Table)
            {
                flM1LateralReportGateway.LoadByAssetId(row.AssetID, row.COMPANY_ID);
                flM1LateralReport.UpdateForReport(row.FlowOrderID, unitType);
            }
        }
Exemplo n.º 15
0
        /// <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>
        /// 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 SavePreviousRAWork(int projectId, int section_assetId, int companyId)
        {
            // Load Previous work  - Rehab assessment data (last sections work)
            string workType = "Rehab Assessment";
            WorkRehabAssessmentGateway workRehabAssessmentGateway = new WorkRehabAssessmentGateway();
            workRehabAssessmentGateway.LoadTop1ByProjectIdAssetIdWorkType(projectId, section_assetId, workType, companyId);

            int workId = workRehabAssessmentGateway.GetWorkIdTop1();
            DateTime? preFlushDate = null; if (workRehabAssessmentGateway.GetPreFlushDateTop1().HasValue) preFlushDate = workRehabAssessmentGateway.GetPreFlushDateTop1();
            DateTime? preVideoDate = null; if (workRehabAssessmentGateway.GetPreVideoDateTop1().HasValue) preVideoDate = workRehabAssessmentGateway.GetPreVideoDateTop1();

            // 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
            WorkRehabAssessment workRehabAssessment = new WorkRehabAssessment(null);
            int newSectionWorkId = workRehabAssessment.InsertDirect(projectId, section_assetId, libraryCategoriesId, preFlushDate, preVideoDate, false, companyId, comments, history);

            // Load Previous work  - Comments and History
            SavePreviousComments(workId, workType, companyId, newSectionWorkId);
            SavePreviousHistory(workId, workType, companyId, newSectionWorkId);
        }
        /// <summary>
        /// UpdateCommentsForSummaryEdit
        /// </summary>
        /// <param name="workId">workId</param>
        /// <param name="companyId">companyId</param>
        public void UpdateCommentsForSummaryEdit(int workId, int companyId)
        {
            WorkCommentsGateway workComentsGateway = new WorkCommentsGateway();
            WorkComments workComments = new WorkComments(workComentsGateway.Data);
            WorkGateway workGateway = new WorkGateway();

            ManholeRehabilitationTDS.WorkDetailsRow row = GetRow(workId);

            workGateway.LoadByWorkId(workId, companyId);
            workComentsGateway.LoadByWorkIdWorkType(workId, companyId, "Manhole Rehabilitation");
            row.Comments = workComments.GetAllComments(workId, companyId, workComentsGateway.Table.Rows.Count, "\n");
        }
        /// <summary>
        /// UpdateDirect
        /// </summary>
        /// <param name="countryId">countryId</param>
        /// <param name="provinceId">provinceId</param>
        /// <param name="countyId">countyId</param>
        /// <param name="cityId">cityId</param>
        /// <param name="projectId">projectId</param>
        /// <param name="sectionAssetId">sectionAssetId</param>
        /// <param name="companyId">companyId</param>
        public void Save(Int64? countryId, Int64? provinceId, Int64? countyId, Int64? cityId, int projectId, int sectionAssetId, int companyId)
        {
            PointRepairsTDS pointRepairsChanges = (PointRepairsTDS)Data.GetChanges();

            if (pointRepairsChanges.WorkDetails.Rows.Count > 0)
            {
                PointRepairsWorkDetailsGateway pointRepairsWorkDetailsGateway = new PointRepairsWorkDetailsGateway(pointRepairsChanges);

                // Update sections
                foreach (PointRepairsTDS.WorkDetailsRow workDetailsRow in (PointRepairsTDS.WorkDetailsDataTable)pointRepairsChanges.WorkDetails)
                {
                    // Unchanged values
                    int workId = workDetailsRow.WorkID;

                    // Original values
                    string originalClientId = pointRepairsWorkDetailsGateway.GetClientIdOriginal(workId);
                    string originalMeasurementTakenBy = pointRepairsWorkDetailsGateway.GetMeasurementTakenByOriginal(workId);
                    DateTime? originalRepairConfirmationDate = pointRepairsWorkDetailsGateway.GetRepairConfirmationDateOriginal(workId);
                    bool originalBypassRequired = pointRepairsWorkDetailsGateway.GetBypassRequiredOriginal(workId);
                    string originalRoboticDistances = pointRepairsWorkDetailsGateway.GetRoboticDistancesOriginal(workId);
                    DateTime? originalProposedLiningDate = pointRepairsWorkDetailsGateway.GetProposedLiningDateOriginal(workId);
                    DateTime? originalDeadlineLiningDate = pointRepairsWorkDetailsGateway.GetDeadlineLiningDateOriginal(workId);
                    DateTime? originalFinalVideoDate = pointRepairsWorkDetailsGateway.GetFinalVideoDateOriginal(workId);
                    int? originalEstimatedJoints = pointRepairsWorkDetailsGateway.GetEstimatedJointsOriginal(workId);
                    int? originalJointsTestSealed = pointRepairsWorkDetailsGateway.GetJointsTestSealedOriginal(workId);
                    bool originalIssueIdentified = pointRepairsWorkDetailsGateway.GetIssueIdentifiedOriginal(workId);
                    bool originalIssueLFS = pointRepairsWorkDetailsGateway.GetIssueLFSOriginal(workId);
                    bool originalIssueClient = pointRepairsWorkDetailsGateway.GetIssueClientOriginal(workId);
                    bool originalIssueSales = pointRepairsWorkDetailsGateway.GetIssueSalesOriginal(workId);
                    bool originalIssueGivenToClient = pointRepairsWorkDetailsGateway.GetIssueGivenToClientOriginal(workId);
                    bool originalIssueResolved = pointRepairsWorkDetailsGateway.GetIssueResolvedOriginal(workId);
                    bool originalIssueInvestigation = pointRepairsWorkDetailsGateway.GetIssueInvestigationOriginal(workId);

                    // New variables
                    string newClientId = pointRepairsWorkDetailsGateway.GetClientId(workId);
                    string newMeasurementTakenBy = pointRepairsWorkDetailsGateway.GetMeasurementTakenBy(workId);
                    DateTime? newRepairConfirmationDate = pointRepairsWorkDetailsGateway.GetRepairConfirmationDate(workId);
                    bool newBypassRequired = pointRepairsWorkDetailsGateway.GetBypassRequired(workId);
                    string newRoboticDistances = pointRepairsWorkDetailsGateway.GetRoboticDistances(workId);
                    DateTime? newProposedLiningDate = pointRepairsWorkDetailsGateway.GetProposedLiningDate(workId);
                    DateTime? newDeadlineLiningDate = pointRepairsWorkDetailsGateway.GetDeadlineLiningDate(workId);
                    DateTime? newFinalVideoDate = pointRepairsWorkDetailsGateway.GetFinalVideoDate(workId);
                    int? newEstimatedJoints = pointRepairsWorkDetailsGateway.GetEstimatedJoints(workId);
                    int? newJointsTestSealed = pointRepairsWorkDetailsGateway.GetJointsTestSealed(workId);
                    bool newIssueIdentified = pointRepairsWorkDetailsGateway.GetIssueIdentified(workId);
                    bool newIssueLFS = pointRepairsWorkDetailsGateway.GetIssueLFS(workId);
                    bool newIssueClient = pointRepairsWorkDetailsGateway.GetIssueClient(workId);
                    bool newIssueSales = pointRepairsWorkDetailsGateway.GetIssueSales(workId);
                    bool newIssueGivenToClient = pointRepairsWorkDetailsGateway.GetIssueGivenToClient(workId);
                    bool newIssueResolved = pointRepairsWorkDetailsGateway.GetIssueResolved(workId);
                    bool newIssueInvestigation = pointRepairsWorkDetailsGateway.GetIssueInvestigation(workId);

                    // ... RA
                    DateTime? originalPreFlushDate = pointRepairsWorkDetailsGateway.GetPreFlushDateOriginal(workId);
                    DateTime? originalPreVideoDate = pointRepairsWorkDetailsGateway.GetPreVideoDateOriginal(workId);

                    // ... FLL P1
                    DateTime? originalP1Date = pointRepairsWorkDetailsGateway.GetP1DateOriginal(workId);
                    int? originalCxisRemoved = pointRepairsWorkDetailsGateway.GetCxisRemovedOriginal(workId);

                    // ... FLL M1
                    string originalTrafficControl = pointRepairsWorkDetailsGateway.GetTrafficControlOriginal(workId);
                    string originalMaterial = pointRepairsWorkDetailsGateway.GetMaterialOriginal(workId);

                    // ... FLL M2
                    string originalVideoLength = pointRepairsWorkDetailsGateway.GetVideoLengthOriginal(workId);

                    // ... P1
                    DateTime? newP1Date = pointRepairsWorkDetailsGateway.GetP1Date(workId);
                    int? newCxisRemoved = pointRepairsWorkDetailsGateway.GetCxisRemoved(workId);
                    string newTrafficControl = pointRepairsWorkDetailsGateway.GetTrafficControl(workId);
                    string newMaterial = pointRepairsWorkDetailsGateway.GetMaterial(workId);

                    // ... M2
                    string newVideoLength = pointRepairsWorkDetailsGateway.GetVideoLength(workId);

                    // ... RA
                    DateTime? newPreFlushDate = pointRepairsWorkDetailsGateway.GetPreFlushDate(workId);
                    DateTime? newPreVideoDate = pointRepairsWorkDetailsGateway.GetPreVideoDate(workId);

                    // ... FLL WorkID
                    int workIdFll = 0; if (!workDetailsRow.IsWorkIDFLLNull()) workIdFll = workDetailsRow.WorkIDFLL;
                    int workIdRa = 0; if (!workDetailsRow.IsWorkIDRANull()) workIdRa = workDetailsRow.WorkIDRA;

                    if (workIdFll != 0) // ... Has Fll work
                    {
                        FullLengthLiningWorkDetailsGateway fullLengthLiningWorkDetailsGateway = new FullLengthLiningWorkDetailsGateway();
                        fullLengthLiningWorkDetailsGateway.LoadByWorkIdAssetId(workIdFll, sectionAssetId, companyId);

                        // Original values
                        string originalClientIdFLL = fullLengthLiningWorkDetailsGateway.GetClientIdOriginal(workIdFll);
                        DateTime? originalProposedLiningDateFLL = fullLengthLiningWorkDetailsGateway.GetProposedLiningDateOriginal(workIdFll);
                        DateTime? originalDeadlineLiningDateFLL = fullLengthLiningWorkDetailsGateway.GetDeadlineLiningDateOriginal(workIdFll);
                        DateTime? originalM1Date = fullLengthLiningWorkDetailsGateway.GetM1DateOriginal(workIdFll);
                        DateTime? originalM2Date = fullLengthLiningWorkDetailsGateway.GetM2DateOriginal(workIdFll);
                        DateTime? originalInstallDate = fullLengthLiningWorkDetailsGateway.GetInstallDateOriginal(workIdFll);
                        DateTime? originalFinalVideoDateFLL = fullLengthLiningWorkDetailsGateway.GetFinalVideoDateOriginal(workIdFll);
                        bool originalIssueIdentifiedFLL = fullLengthLiningWorkDetailsGateway.GetIssueIdentifiedOriginal(workIdFll);
                        bool originalIssueLFSFLL = fullLengthLiningWorkDetailsGateway.GetIssueLFSOriginal(workIdFll);
                        bool originalIssueClientFLL = fullLengthLiningWorkDetailsGateway.GetIssueClientOriginal(workIdFll);
                        bool originalIssueSalesFLL = fullLengthLiningWorkDetailsGateway.GetIssueSalesOriginal(workIdFll);
                        bool originalIssueGivenToClientFLL = fullLengthLiningWorkDetailsGateway.GetIssueGivenToClientOriginal(workIdFll);
                        bool originalIssueResolvedFLL = fullLengthLiningWorkDetailsGateway.GetIssueResolvedOriginal(workIdFll);
                        bool originalIssueInvestigationFLL = fullLengthLiningWorkDetailsGateway.GetIssueInvestigationOriginal(workIdFll);
                        bool originalRoboticPrepCompleted = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedOriginal(workIdFll);
                        DateTime? originalRoboticPrepCompletedDate = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedDateOriginal(workIdFll);
                        bool originalP1Completed = fullLengthLiningWorkDetailsGateway.GetP1CompletedOriginal(workIdFll);

                        // M1 data
                        string originalMeasurementTakenByFLL = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenByOriginal(workIdFll);
                        string originalSiteDetails = fullLengthLiningWorkDetailsGateway.GetSiteDetailsOriginal(workIdFll);
                        bool originalPipeSizeChange = fullLengthLiningWorkDetailsGateway.GetPipeSizeChangeOriginal(workIdFll);
                        bool originalStandardBypass = fullLengthLiningWorkDetailsGateway.GetStandardBypassOriginal(workIdFll);
                        string originalStandardBypassComments = fullLengthLiningWorkDetailsGateway.GetStandardBypassCommentsOriginal(workIdFll);
                        string originalTrafficControlDetails = fullLengthLiningWorkDetailsGateway.GetTrafficControlDetailsOriginal(workIdFll);
                        string originalMeasurementType = fullLengthLiningWorkDetailsGateway.GetMeasurementTypeOriginal(workIdFll);
                        string originalMeasurementFromMh = fullLengthLiningWorkDetailsGateway.GetMeasurementFromMhOriginal(workIdFll);
                        string originalVideoDoneFromMh = fullLengthLiningWorkDetailsGateway.GetVideoDoneFromMhOriginal(workIdFll);
                        string originalVideoDoneToMh = fullLengthLiningWorkDetailsGateway.GetVideoDoneToMhOriginal(workIdFll);
                        string originalAccessType = fullLengthLiningWorkDetailsGateway.GetAccessTypeOriginal(workIdFll);

                        // M2 data
                        string originalMeasurementTakenByM2 = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenByM2Original(workIdFll);
                        bool originalDropPipe = fullLengthLiningWorkDetailsGateway.GetDropPipeOriginal(workIdFll);
                        string originalDropPipeInvertDepth = fullLengthLiningWorkDetailsGateway.GetDropPipeInvertDepthOriginal(workIdFll);
                        int? originalCappedLaterals = fullLengthLiningWorkDetailsGateway.GetCappedLateralsOriginal(workIdFll);
                        string originalLineWithId = fullLengthLiningWorkDetailsGateway.GetLineWithIdOriginal(workIdFll);
                        string originalHydrantAddress = fullLengthLiningWorkDetailsGateway.GetHydrantAddressOriginal(workIdFll);
                        string originalHydroWireWithin10FtOfInversionMH = fullLengthLiningWorkDetailsGateway.GetHydroWiredWithin10FtOfInversionMHOriginal(workIdFll);
                        string originalDistanceToInversionMh = fullLengthLiningWorkDetailsGateway.GetDistanceToInversionMhOriginal(workIdFll);
                        string originalSurfaceGrade = fullLengthLiningWorkDetailsGateway.GetSurfaceGradeOriginal(workIdFll);
                        bool originalHydroPulley = fullLengthLiningWorkDetailsGateway.GetHydroPulleyOriginal(workIdFll);
                        bool originalFridgeCart = fullLengthLiningWorkDetailsGateway.GetFridgeCartOriginal(workIdFll);
                        bool originalTwoPump = fullLengthLiningWorkDetailsGateway.GetTwoPumpOriginal(workIdFll);
                        bool originalSixBypass = fullLengthLiningWorkDetailsGateway.GetSixBypassOriginal(workIdFll);
                        bool originalScaffolding = fullLengthLiningWorkDetailsGateway.GetScaffoldingOriginal(workIdFll);
                        bool originalWinchExtension = fullLengthLiningWorkDetailsGateway.GetWinchExtensionOriginal(workIdFll);
                        bool originalExtraGenerator = fullLengthLiningWorkDetailsGateway.GetExtraGeneratorOriginal(workIdFll);
                        bool originalGreyCableExtension = fullLengthLiningWorkDetailsGateway.GetGreyCableExtensionOriginal(workIdFll);
                        bool originalEasementMats = fullLengthLiningWorkDetailsGateway.GetEasementMatsOriginal(workIdFll);
                        bool originalRampRequired = fullLengthLiningWorkDetailsGateway.GetRampRequiredOriginal(workIdFll);
                        bool originalCameraSkid = fullLengthLiningWorkDetailsGateway.GetCameraSkidOriginal(workIdFll);

                        // Comments
                        string originalComments = fullLengthLiningWorkDetailsGateway.GetCommentsOriginal(workIdFll);

                        // New variables
                        string newClientIdFLL = fullLengthLiningWorkDetailsGateway.GetClientId(workIdFll);
                        DateTime? newProposedLiningDateFLL = fullLengthLiningWorkDetailsGateway.GetProposedLiningDate(workIdFll);
                        DateTime? newDeadlineLiningDateFLL = fullLengthLiningWorkDetailsGateway.GetDeadlineLiningDate(workIdFll);
                        DateTime? newM1Date = fullLengthLiningWorkDetailsGateway.GetM1Date(workIdFll);
                        DateTime? newM2Date = fullLengthLiningWorkDetailsGateway.GetM2Date(workIdFll);
                        DateTime? newInstallDate = fullLengthLiningWorkDetailsGateway.GetInstallDate(workIdFll);
                        DateTime? newFinalVideoDateFLL = fullLengthLiningWorkDetailsGateway.GetFinalVideoDate(workIdFll);
                        bool newIssueIdentifiedFLL = fullLengthLiningWorkDetailsGateway.GetIssueIdentified(workIdFll);
                        bool newIssueLFSFLL = fullLengthLiningWorkDetailsGateway.GetIssueLFS(workIdFll);
                        bool newIssueClientFLL = fullLengthLiningWorkDetailsGateway.GetIssueClient(workIdFll);
                        bool newIssueSalesFLL = fullLengthLiningWorkDetailsGateway.GetIssueSales(workIdFll);
                        bool newIssueGivenToClientFLL = fullLengthLiningWorkDetailsGateway.GetIssueGivenToClient(workIdFll);
                        bool newIssueResolvedFLL = fullLengthLiningWorkDetailsGateway.GetIssueResolved(workIdFll);
                        bool newIssueInvestigationFLL = fullLengthLiningWorkDetailsGateway.GetIssueInvestigation(workIdFll);
                        bool newRoboticPrepCompleted = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompleted(workIdFll);
                        DateTime? newRoboticPrepCompletedDate = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedDate(workIdFll);
                        bool newP1Completed = fullLengthLiningWorkDetailsGateway.GetP1Completed(workIdFll);

                        // M1
                        string newMeasurementTakenByFLL = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenBy(workIdFll);
                        string newSiteDetails = fullLengthLiningWorkDetailsGateway.GetSiteDetails(workIdFll);
                        bool newPipeSizeChange = fullLengthLiningWorkDetailsGateway.GetPipeSizeChange(workIdFll);
                        bool newStandardBypass = fullLengthLiningWorkDetailsGateway.GetStandardBypass(workIdFll);
                        string newStandardBypassComments = fullLengthLiningWorkDetailsGateway.GetStandardBypassComments(workIdFll);
                        string newTrafficControlDetails = fullLengthLiningWorkDetailsGateway.GetTrafficControlDetails(workIdFll);
                        string newMeasurementType = fullLengthLiningWorkDetailsGateway.GetMeasurementType(workIdFll);
                        string newMeasurementFromMh = fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workIdFll);
                        string newVideoDoneFromMh = fullLengthLiningWorkDetailsGateway.GetVideoDoneFromMh(workIdFll);
                        string newVideoDoneToMh = fullLengthLiningWorkDetailsGateway.GetVideoDoneToMh(workIdFll);
                        string newAccessType = fullLengthLiningWorkDetailsGateway.GetAccessType(workIdFll);

                        // M2
                        string newMeasurementTakenByM2 = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenByM2(workIdFll);
                        bool newDropPipe = fullLengthLiningWorkDetailsGateway.GetDropPipe(workIdFll);
                        string newDropPipeInvertDepth = fullLengthLiningWorkDetailsGateway.GetDropPipeInvertDepth(workIdFll);
                        int? newCappedLaterals = fullLengthLiningWorkDetailsGateway.GetCappedLaterals(workIdFll);
                        string newLineWithId = fullLengthLiningWorkDetailsGateway.GetLineWithId(workIdFll);
                        string newHydrantAddress = fullLengthLiningWorkDetailsGateway.GetHydrantAddress(workIdFll);
                        string newHydroWireWithin10FtOfInversionMH = fullLengthLiningWorkDetailsGateway.GetHydroWiredWithin10FtOfInversionMH(workIdFll);
                        string newDistanceToInversionMh = fullLengthLiningWorkDetailsGateway.GetDistanceToInversionMh(workIdFll);
                        string newSurfaceGrade = fullLengthLiningWorkDetailsGateway.GetSurfaceGrade(workIdFll);
                        bool newHydroPulley = fullLengthLiningWorkDetailsGateway.GetHydroPulley(workIdFll);
                        bool newFridgeCart = fullLengthLiningWorkDetailsGateway.GetFridgeCart(workIdFll);
                        bool newTwoPump = fullLengthLiningWorkDetailsGateway.GetTwoPump(workIdFll);
                        bool newSixBypass = fullLengthLiningWorkDetailsGateway.GetSixBypass(workIdFll);
                        bool newScaffolding = fullLengthLiningWorkDetailsGateway.GetScaffolding(workIdFll);
                        bool newWinchExtension = fullLengthLiningWorkDetailsGateway.GetWinchExtension(workIdFll);
                        bool newExtraGenerator = fullLengthLiningWorkDetailsGateway.GetExtraGenerator(workIdFll);
                        bool newGreyCableExtension = fullLengthLiningWorkDetailsGateway.GetGreyCableExtension(workIdFll);
                        bool newEasementMats = fullLengthLiningWorkDetailsGateway.GetEasementMats(workIdFll);
                        bool newRampRequired = fullLengthLiningWorkDetailsGateway.GetRampRequired(workIdFll);
                        bool newCameraSkid = fullLengthLiningWorkDetailsGateway.GetCameraSkid(workIdFll);

                        // comments
                        string newComments = fullLengthLiningWorkDetailsGateway.GetComments(workIdFll);

                        // ... Update work
                        UpdateFllWork(sectionAssetId, countryId, provinceId, countyId, cityId, workIdFll, originalClientIdFLL, originalProposedLiningDateFLL, originalDeadlineLiningDateFLL, originalP1Date, originalM1Date, originalM2Date, originalInstallDate, originalFinalVideoDateFLL, originalIssueIdentifiedFLL, originalIssueLFSFLL, originalIssueClientFLL, originalIssueSalesFLL, originalIssueGivenToClientFLL, originalIssueResolvedFLL, originalIssueInvestigationFLL, originalCxisRemoved, originalRoboticPrepCompleted, originalRoboticPrepCompletedDate, originalMeasurementTakenByFLL, originalTrafficControl, originalSiteDetails, originalPipeSizeChange, originalStandardBypass, originalStandardBypassComments, originalTrafficControlDetails, originalMeasurementType, originalMeasurementFromMh, originalVideoDoneFromMh, originalVideoDoneToMh, originalVideoLength, originalComments, false, companyId, originalMaterial, originalAccessType, originalP1Completed, newClientIdFLL, originalProposedLiningDateFLL, originalDeadlineLiningDateFLL, newP1Date, newM1Date, originalM2Date, originalInstallDate, originalFinalVideoDateFLL, originalIssueIdentifiedFLL, originalIssueLFSFLL, originalIssueClientFLL, originalIssueSalesFLL, originalIssueGivenToClientFLL, originalIssueResolvedFLL, originalIssueInvestigationFLL, newCxisRemoved, newRoboticPrepCompleted, newRoboticPrepCompletedDate, newMeasurementTakenByFLL, newMaterial, newTrafficControl, newSiteDetails, newPipeSizeChange, newStandardBypass, newStandardBypassComments, newTrafficControlDetails, newMeasurementType, newMeasurementFromMh, newVideoDoneFromMh, newVideoDoneToMh, newVideoLength, newComments, false, companyId, newAccessType, newP1Completed);
                    }
                    else
                    {
                        if (newP1Date.HasValue || newCxisRemoved.HasValue || newMaterial != "" || newTrafficControl != "" || newVideoLength != "") // Insert Fll work
                        {
                            WorkFullLengthLining workFullLengthLining = new WorkFullLengthLining(null);
                            workIdFll = workFullLengthLining.InsertDirectEmptyWorks(projectId, sectionAssetId, null, "", null, null, null, null, null, null, null, false, false, false, false, false, false, false, companyId, false, "", "");

                            FullLengthLiningWorkDetailsGateway fullLengthLiningWorkDetailsGateway = new FullLengthLiningWorkDetailsGateway();
                            fullLengthLiningWorkDetailsGateway.LoadByWorkIdAssetId(workIdFll, sectionAssetId, companyId);

                            // Original values
                            string originalClientIdFLL = fullLengthLiningWorkDetailsGateway.GetClientIdOriginal(workIdFll);
                            DateTime? originalProposedLiningDateFLL = fullLengthLiningWorkDetailsGateway.GetProposedLiningDateOriginal(workIdFll);
                            DateTime? originalDeadlineLiningDateFLL = fullLengthLiningWorkDetailsGateway.GetDeadlineLiningDateOriginal(workIdFll);
                            DateTime? originalM1Date = fullLengthLiningWorkDetailsGateway.GetM1DateOriginal(workIdFll);
                            DateTime? originalM2Date = fullLengthLiningWorkDetailsGateway.GetM2DateOriginal(workIdFll);
                            DateTime? originalInstallDate = fullLengthLiningWorkDetailsGateway.GetInstallDateOriginal(workIdFll);
                            DateTime? originalFinalVideoDateFLL = fullLengthLiningWorkDetailsGateway.GetFinalVideoDateOriginal(workIdFll);
                            bool originalIssueIdentifiedFLL = fullLengthLiningWorkDetailsGateway.GetIssueIdentifiedOriginal(workIdFll);
                            bool originalIssueLFSFLL = fullLengthLiningWorkDetailsGateway.GetIssueLFSOriginal(workIdFll);
                            bool originalIssueClientFLL = fullLengthLiningWorkDetailsGateway.GetIssueClientOriginal(workIdFll);
                            bool originalIssueSalesFLL = fullLengthLiningWorkDetailsGateway.GetIssueSalesOriginal(workIdFll);
                            bool originalIssueGivenToClientFLL = fullLengthLiningWorkDetailsGateway.GetIssueGivenToClientOriginal(workIdFll);
                            bool originalIssueResolvedFLL = fullLengthLiningWorkDetailsGateway.GetIssueResolvedOriginal(workIdFll);
                            bool originalIssueInvestigationFLL = fullLengthLiningWorkDetailsGateway.GetIssueInvestigationOriginal(workIdFll);
                            bool originalRoboticPrepCompleted = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedOriginal(workIdFll);
                            DateTime? originalRoboticPrepCompletedDate = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedDateOriginal(workIdFll);
                            bool originalP1Completed = fullLengthLiningWorkDetailsGateway.GetP1CompletedOriginal(workIdFll);

                            // M1 data
                            string originalMeasurementTakenByFLL = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenByOriginal(workIdFll);
                            string originalSiteDetails = fullLengthLiningWorkDetailsGateway.GetSiteDetailsOriginal(workIdFll);
                            bool originalPipeSizeChange = fullLengthLiningWorkDetailsGateway.GetPipeSizeChangeOriginal(workIdFll);
                            bool originalStandardBypass = fullLengthLiningWorkDetailsGateway.GetStandardBypassOriginal(workIdFll);
                            string originalStandardBypassComments = fullLengthLiningWorkDetailsGateway.GetStandardBypassCommentsOriginal(workIdFll);
                            string originalTrafficControlDetails = fullLengthLiningWorkDetailsGateway.GetTrafficControlDetailsOriginal(workIdFll);
                            string originalMeasurementType = fullLengthLiningWorkDetailsGateway.GetMeasurementTypeOriginal(workIdFll);
                            string originalMeasurementFromMh = fullLengthLiningWorkDetailsGateway.GetMeasurementFromMhOriginal(workIdFll);
                            string originalVideoDoneFromMh = fullLengthLiningWorkDetailsGateway.GetVideoDoneFromMhOriginal(workIdFll);
                            string originalVideoDoneToMh = fullLengthLiningWorkDetailsGateway.GetVideoDoneToMhOriginal(workIdFll);
                            string originalAccessType = fullLengthLiningWorkDetailsGateway.GetAccessTypeOriginal(workIdFll);

                            // M2 data
                            string originalMeasurementTakenByM2 = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenByM2Original(workIdFll);
                            bool originalDropPipe = fullLengthLiningWorkDetailsGateway.GetDropPipeOriginal(workIdFll);
                            string originalDropPipeInvertDepth = fullLengthLiningWorkDetailsGateway.GetDropPipeInvertDepthOriginal(workIdFll);
                            int? originalCappedLaterals = fullLengthLiningWorkDetailsGateway.GetCappedLateralsOriginal(workIdFll);
                            string originalLineWithId = fullLengthLiningWorkDetailsGateway.GetLineWithIdOriginal(workIdFll);
                            string originalHydrantAddress = fullLengthLiningWorkDetailsGateway.GetHydrantAddressOriginal(workIdFll);
                            string originalHydroWireWithin10FtOfInversionMH = fullLengthLiningWorkDetailsGateway.GetHydroWiredWithin10FtOfInversionMHOriginal(workIdFll);
                            string originalDistanceToInversionMh = fullLengthLiningWorkDetailsGateway.GetDistanceToInversionMhOriginal(workIdFll);
                            string originalSurfaceGrade = fullLengthLiningWorkDetailsGateway.GetSurfaceGradeOriginal(workIdFll);
                            bool originalHydroPulley = fullLengthLiningWorkDetailsGateway.GetHydroPulleyOriginal(workIdFll);
                            bool originalFridgeCart = fullLengthLiningWorkDetailsGateway.GetFridgeCartOriginal(workIdFll);
                            bool originalTwoPump = fullLengthLiningWorkDetailsGateway.GetTwoPumpOriginal(workIdFll);
                            bool originalSixBypass = fullLengthLiningWorkDetailsGateway.GetSixBypassOriginal(workIdFll);
                            bool originalScaffolding = fullLengthLiningWorkDetailsGateway.GetScaffoldingOriginal(workIdFll);
                            bool originalWinchExtension = fullLengthLiningWorkDetailsGateway.GetWinchExtensionOriginal(workIdFll);
                            bool originalExtraGenerator = fullLengthLiningWorkDetailsGateway.GetExtraGeneratorOriginal(workIdFll);
                            bool originalGreyCableExtension = fullLengthLiningWorkDetailsGateway.GetGreyCableExtensionOriginal(workIdFll);
                            bool originalEasementMats = fullLengthLiningWorkDetailsGateway.GetEasementMatsOriginal(workIdFll);
                            bool originalRampRequired = fullLengthLiningWorkDetailsGateway.GetRampRequiredOriginal(workIdFll);
                            bool originalCameraSkid = fullLengthLiningWorkDetailsGateway.GetCameraSkidOriginal(workIdFll);

                            // Comments
                            string originalComments = fullLengthLiningWorkDetailsGateway.GetCommentsOriginal(workIdFll);

                            // New variables
                            string newClientIdFLL = fullLengthLiningWorkDetailsGateway.GetClientId(workIdFll);
                            DateTime? newProposedLiningDateFLL = fullLengthLiningWorkDetailsGateway.GetProposedLiningDate(workIdFll);
                            DateTime? newDeadlineLiningDateFLL = fullLengthLiningWorkDetailsGateway.GetDeadlineLiningDate(workIdFll);
                            DateTime? newM1Date = fullLengthLiningWorkDetailsGateway.GetM1Date(workIdFll);
                            DateTime? newM2Date = fullLengthLiningWorkDetailsGateway.GetM2Date(workIdFll);
                            DateTime? newInstallDate = fullLengthLiningWorkDetailsGateway.GetInstallDate(workIdFll);
                            DateTime? newFinalVideoDateFLL = fullLengthLiningWorkDetailsGateway.GetFinalVideoDate(workIdFll);
                            bool newIssueIdentifiedFLL = fullLengthLiningWorkDetailsGateway.GetIssueIdentified(workIdFll);
                            bool newIssueLFSFLL = fullLengthLiningWorkDetailsGateway.GetIssueLFS(workIdFll);
                            bool newIssueClientFLL = fullLengthLiningWorkDetailsGateway.GetIssueClient(workIdFll);
                            bool newIssueSalesFLL = fullLengthLiningWorkDetailsGateway.GetIssueSales(workIdFll);
                            bool newIssueGivenToClientFLL = fullLengthLiningWorkDetailsGateway.GetIssueGivenToClient(workIdFll);
                            bool newIssueResolvedFLL = fullLengthLiningWorkDetailsGateway.GetIssueResolved(workIdFll);
                            bool newIssueInvestigationFLL = fullLengthLiningWorkDetailsGateway.GetIssueInvestigation(workIdFll);
                            bool newRoboticPrepCompleted = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompleted(workIdFll);
                            DateTime? newRoboticPrepCompletedDate = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedDate(workIdFll);
                            bool newP1Completed = fullLengthLiningWorkDetailsGateway.GetP1Completed(workIdFll);

                            // M1
                            string newMeasurementTakenByFLL = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenBy(workIdFll);
                            string newSiteDetails = fullLengthLiningWorkDetailsGateway.GetSiteDetails(workIdFll);
                            bool newPipeSizeChange = fullLengthLiningWorkDetailsGateway.GetPipeSizeChange(workIdFll);
                            bool newStandardBypass = fullLengthLiningWorkDetailsGateway.GetStandardBypass(workIdFll);
                            string newStandardBypassComments = fullLengthLiningWorkDetailsGateway.GetStandardBypassComments(workIdFll);
                            string newTrafficControlDetails = fullLengthLiningWorkDetailsGateway.GetTrafficControlDetails(workIdFll);
                            string newMeasurementType = fullLengthLiningWorkDetailsGateway.GetMeasurementType(workIdFll);
                            string newMeasurementFromMh = fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workIdFll);
                            string newVideoDoneFromMh = fullLengthLiningWorkDetailsGateway.GetVideoDoneFromMh(workIdFll);
                            string newVideoDoneToMh = fullLengthLiningWorkDetailsGateway.GetVideoDoneToMh(workIdFll);
                            string newAccessType = fullLengthLiningWorkDetailsGateway.GetAccessType(workIdFll);

                            // M2
                            string newMeasurementTakenByM2 = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenByM2(workIdFll);
                            bool newDropPipe = fullLengthLiningWorkDetailsGateway.GetDropPipe(workIdFll);
                            string newDropPipeInvertDepth = fullLengthLiningWorkDetailsGateway.GetDropPipeInvertDepth(workIdFll);
                            int? newCappedLaterals = fullLengthLiningWorkDetailsGateway.GetCappedLaterals(workIdFll);
                            string newLineWithId = fullLengthLiningWorkDetailsGateway.GetLineWithId(workIdFll);
                            string newHydrantAddress = fullLengthLiningWorkDetailsGateway.GetHydrantAddress(workIdFll);
                            string newHydroWireWithin10FtOfInversionMH = fullLengthLiningWorkDetailsGateway.GetHydroWiredWithin10FtOfInversionMH(workIdFll);
                            string newDistanceToInversionMh = fullLengthLiningWorkDetailsGateway.GetDistanceToInversionMh(workIdFll);
                            string newSurfaceGrade = fullLengthLiningWorkDetailsGateway.GetSurfaceGrade(workIdFll);
                            bool newHydroPulley = fullLengthLiningWorkDetailsGateway.GetHydroPulley(workIdFll);
                            bool newFridgeCart = fullLengthLiningWorkDetailsGateway.GetFridgeCart(workIdFll);
                            bool newTwoPump = fullLengthLiningWorkDetailsGateway.GetTwoPump(workIdFll);
                            bool newSixBypass = fullLengthLiningWorkDetailsGateway.GetSixBypass(workIdFll);
                            bool newScaffolding = fullLengthLiningWorkDetailsGateway.GetScaffolding(workIdFll);
                            bool newWinchExtension = fullLengthLiningWorkDetailsGateway.GetWinchExtension(workIdFll);
                            bool newExtraGenerator = fullLengthLiningWorkDetailsGateway.GetExtraGenerator(workIdFll);
                            bool newGreyCableExtension = fullLengthLiningWorkDetailsGateway.GetGreyCableExtension(workIdFll);
                            bool newEasementMats = fullLengthLiningWorkDetailsGateway.GetEasementMats(workIdFll);
                            bool newRampRequired = fullLengthLiningWorkDetailsGateway.GetRampRequired(workIdFll);
                            bool newCameraSkid = fullLengthLiningWorkDetailsGateway.GetCameraSkid(workIdFll);

                            // comments
                            string newComments = fullLengthLiningWorkDetailsGateway.GetComments(workIdFll);

                            // ... Update work
                            UpdateFllWork(sectionAssetId, countryId, provinceId, countyId, cityId, workIdFll, originalClientIdFLL, originalProposedLiningDateFLL, originalDeadlineLiningDateFLL, originalP1Date, originalM1Date, originalM2Date, originalInstallDate, originalFinalVideoDateFLL, originalIssueIdentifiedFLL, originalIssueLFSFLL, originalIssueClientFLL, originalIssueSalesFLL, originalIssueGivenToClientFLL, originalIssueResolvedFLL, originalIssueInvestigationFLL, originalCxisRemoved, originalRoboticPrepCompleted, originalRoboticPrepCompletedDate, originalMeasurementTakenByFLL, originalTrafficControl, originalSiteDetails, originalPipeSizeChange, originalStandardBypass, originalStandardBypassComments, originalTrafficControlDetails, originalMeasurementType, originalMeasurementFromMh, originalVideoDoneFromMh, originalVideoDoneToMh, originalVideoLength, originalComments, false, companyId, originalMaterial, originalAccessType, originalP1Completed, newClientIdFLL, originalProposedLiningDateFLL, originalDeadlineLiningDateFLL, newP1Date, newM1Date, originalM2Date, originalInstallDate, originalFinalVideoDateFLL, originalIssueIdentifiedFLL, originalIssueLFSFLL, originalIssueClientFLL, originalIssueSalesFLL, originalIssueGivenToClientFLL, originalIssueResolvedFLL, originalIssueInvestigationFLL, newCxisRemoved, newRoboticPrepCompleted, newRoboticPrepCompletedDate, newMeasurementTakenByFLL, newMaterial, newTrafficControl, newSiteDetails, newPipeSizeChange, newStandardBypass, newStandardBypassComments, newTrafficControlDetails, newMeasurementType, newMeasurementFromMh, newVideoDoneFromMh, newVideoDoneToMh, newVideoLength, newComments, false, companyId, newAccessType, newP1Completed);
                        }
                    }

                    if (workIdRa != 0) // ... Has Fll work
                    {
                        UpdateRaWork(workIdRa, originalPreFlushDate, originalPreVideoDate, newPreFlushDate, newPreVideoDate, companyId);
                    }
                    else
                    {
                        if (newPreFlushDate.HasValue || newPreVideoDate.HasValue) // Insert RA work
                        {
                            WorkRehabAssessment workRehabAssessment = new WorkRehabAssessment(null);
                            workIdRa = workRehabAssessment.InsertDirect(projectId, sectionAssetId, null, newPreFlushDate, newPreVideoDate, false, companyId, "", "");

                            UpdateRaWork(workIdRa, originalPreFlushDate, originalPreVideoDate, newPreFlushDate, newPreVideoDate, companyId);
                        }
                    }

                    // Update work
                    WorkPointRepairs workPointRepairs = new WorkPointRepairs(null);
                    workPointRepairs.UpdateDirect(sectionAssetId, workId, originalClientId, originalMeasurementTakenBy, originalRepairConfirmationDate, originalBypassRequired, originalRoboticDistances, originalProposedLiningDate, originalDeadlineLiningDate, originalFinalVideoDate, originalEstimatedJoints, originalJointsTestSealed, originalIssueIdentified, originalIssueLFS, originalIssueClient, originalIssueSales, originalIssueGivenToClient, originalIssueResolved, originalIssueInvestigation, "", false, companyId, workId, newClientId, newMeasurementTakenBy, newRepairConfirmationDate, newBypassRequired, newRoboticDistances, newProposedLiningDate, newDeadlineLiningDate, newFinalVideoDate, newEstimatedJoints, newJointsTestSealed, newIssueIdentified, newIssueLFS, newIssueClient, newIssueSales, newIssueGivenToClient, newIssueResolved, newIssueInvestigation, "", false, companyId);

                    // Get original variables
                    WorkGateway workGateway = new WorkGateway();
                    workGateway.LoadByWorkId(workId, companyId);

                    string originalWorkType = workGateway.GetWorkTypeOriginal(workId);
                    int? originalLibraryCategoriesId = workGateway.GetLibraryCategoriesIdOriginal(workId);
                    string originalComment = workGateway.GetCommentsOriginal(workId);
                    string originalHistory = workGateway.GetHistoryOriginal(workId);

                    //Get new comment
                    WorkCommentsGateway workCommentsGateway = new WorkCommentsGateway();
                    workCommentsGateway.LoadByAssetIdWorkTypeProjectId(sectionAssetId, companyId, "Point Repairs", projectId);
                    WorkComments workComments = new WorkComments(workCommentsGateway.Data);
                    string newComment = workComments.GetCommentsSummary(companyId, workCommentsGateway.Table.Rows.Count, "\n");

                    Work work = new Work(null);
                    work.UpdateDirect(workId, projectId, sectionAssetId, originalWorkType, originalLibraryCategoriesId, false, companyId, originalComment, originalHistory, workId, projectId, sectionAssetId, originalWorkType, originalLibraryCategoriesId, false, companyId, newComment, originalHistory);
                }
            }
        }
Exemplo n.º 19
0
        private void workUpdate()
        {
            // Get general variables
            int workId = Int32.Parse(hdfWorkId.Value.Trim());
            int projectId = Int32.Parse(hdfCurrentProjectId.Value.Trim());
            int assetId = Int32.Parse(hdfAssetId.Value.Trim());
            int companyId = Int32.Parse(hdfCompanyId.Value.Trim());
            string workType = hdfWorkType.Value.Trim();

            // Update comments for rehab assessment
            // Get original variables
            WorkGateway workGateway = new WorkGateway();
            workGateway.LoadByWorkId(workId, companyId);

            string originalWorkType = workGateway.GetWorkTypeOriginal(workId);
            int? originalLibraryCategoriesId = workGateway.GetLibraryCategoriesIdOriginal(workId);
            string originalComment = workGateway.GetCommentsOriginal(workId);
            string originalHistory = workGateway.GetHistoryOriginal(workId);

            //Get all new rehab assessment comments
            RehabAssessmentCommentDetailsGateway rehabAssessmentCommentDetailsGateway = new RehabAssessmentCommentDetailsGateway(rehabAssessmentTDS);
            rehabAssessmentCommentDetailsGateway.LoadAllByWorkIdWorkType(workId, companyId, workType);
            RehabAssessmentCommentDetails rehabAssessmentCommentDetails = new RehabAssessmentCommentDetails(rehabAssessmentCommentDetailsGateway.Data);
            string newComment = rehabAssessmentCommentDetails.GetAllRehabAssessmentComments(workId, companyId, rehabAssessmentCommentDetailsGateway.Table.Rows.Count, "\n");

            Work work = new Work(null);
            work.UpdateDirect(workId, projectId, assetId, originalWorkType, originalLibraryCategoriesId, false, companyId, originalComment, originalHistory, workId, projectId, assetId, originalWorkType, originalLibraryCategoriesId, false, companyId, newComment, originalHistory);

            // Update comments for full length lining
            int workIdFll = Int32.Parse(hdfWorkIdFll.Value.Trim());

            if (workIdFll != 0)
            {
                WorkGateway workGatewayForFll = new WorkGateway();
                workGatewayForFll.LoadByWorkId(workIdFll, companyId);

                string originalWorkTypeForFll = workGatewayForFll.GetWorkTypeOriginal(workIdFll);
                int? originalLibraryCategoriesIdForFll = workGatewayForFll.GetLibraryCategoriesIdOriginal(workIdFll);
                string originalCommentForFll = workGatewayForFll.GetCommentsOriginal(workIdFll);
                string originalHistoryForFll = workGatewayForFll.GetHistoryOriginal(workIdFll);

                //Get all new fulllengthlining comments
                FullLengthLiningCommentDetailsGateway fullLengthLiningCommentDetailsGateway = new FullLengthLiningCommentDetailsGateway();
                fullLengthLiningCommentDetailsGateway.LoadAllByWorkIdWorkType(workIdFll, companyId, "Full Length Lining");
                FullLengthLiningCommentDetails fullLengthLiningCommentDetails = new FullLengthLiningCommentDetails(fullLengthLiningCommentDetailsGateway.Data);
                string newCommentForFll = fullLengthLiningCommentDetails.GetAllFullLengthLiningComments(workIdFll, companyId, fullLengthLiningCommentDetailsGateway.Table.Rows.Count, "\n");

                // Save comments
                Work workForFll = new Work(null);
                workForFll.UpdateDirect(workIdFll, projectId, assetId, originalWorkTypeForFll, originalLibraryCategoriesIdForFll, false, companyId, originalCommentForFll, originalHistoryForFll, workIdFll, projectId, assetId, originalWorkTypeForFll, originalLibraryCategoriesIdForFll, false, companyId, newCommentForFll, originalHistoryForFll);
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// UpdateCommentsHistory
        /// </summary>
        /// <param name="workId">workId</param>
        /// <param name="assetId">assetId</param>
        /// <param name="projectId">projectId</param>
        /// <param name="newComments">newComments</param>
        /// <param name="newHistory">newHistory</param>
        /// <param name="companyId">companyId</param>
        public void UpdateCommentsHistory(int workId, int assetId, int projectId, string newComments, string newHistory, int companyId)
        {
            JlNavigatorTDS.JlNavigatorRow jlNavigatorRow = GetRow(assetId);
            jlNavigatorRow.Comments = newComments;
            jlNavigatorRow.History = newHistory;

            // Save work
            // ... Get original variables
            WorkGateway workGateway = new WorkGateway();
            workGateway.LoadByWorkId(workId, companyId);

            string originalWorkType = workGateway.GetWorkTypeOriginal(workId);
            int? originalLibraryCategoriesId = workGateway.GetLibraryCategoriesIdOriginal(workId);
            string originalComment = workGateway.GetCommentsOriginal(workId);
            string originalHistory = workGateway.GetHistoryOriginal(workId);

            Work work = new Work(null);
            work.UpdateDirect(workId, projectId, assetId, originalWorkType, originalLibraryCategoriesId, false, companyId, originalComment, originalHistory, workId, projectId, assetId, originalWorkType, originalLibraryCategoriesId, false, companyId, newComments, newHistory);
        }