Esempio n. 1
0
        /// <summary>
        /// DeleteDirect including comments & history
        /// </summary>
        /// <param name="workId">workId</param>
        /// <param name="companyId">companyId</param>
        public void DeleteDirect(int workId, int companyId)
        {
            // Delete comments
            WorkComments workComments = new WorkComments(null);
            workComments.DeleteAllDirect(workId, companyId);

            // Delete History
            WorkHistory workHistory = new WorkHistory(null);
            workHistory.DeleteAllDirect(workId, companyId);

            // delete Work
            WorkGateway workGateway = new WorkGateway(Data);
            workGateway.Delete(workId, companyId);
        }
        /// <summary>
        /// Save all comments to database (direct)
        /// </summary>
        /// <param name="companyId">companyId</param>        
        public void Save(int companyId)
        {
            FlatSectionJlTDS flatSectionJlHistoryDetailsChanges = (FlatSectionJlTDS)Data.GetChanges();

            if (flatSectionJlHistoryDetailsChanges.FlatSectionJlHistoryDetails.Rows.Count > 0)
            {
                FlatSectionJlHistoryDetailsGateway flatSectionJlHistoryDetailsGateway = new FlatSectionJlHistoryDetailsGateway(flatSectionJlHistoryDetailsChanges);

                foreach (FlatSectionJlTDS.FlatSectionJlHistoryDetailsRow row in (FlatSectionJlTDS.FlatSectionJlHistoryDetailsDataTable)flatSectionJlHistoryDetailsChanges.FlatSectionJlHistoryDetails)
                {
                    // Insert new comments
                    if ((!row.Deleted) && (!row.InDatabase))
                    {
                        WorkHistory workHistory = new WorkHistory(null);
                        int? libraryFilesId = null; if (!row.IsLIBRARY_FILES_IDNull()) libraryFilesId = row.LIBRARY_FILES_ID;
                        string workType = ""; if (!row.IsWorkTypeNull()) workType = row.WorkType;

                        workHistory.InsertDirect(row.WorkID, row.RefID, row.Type, row.Subject, row.UserID, row.DateTime_, row.History, libraryFilesId, row.Deleted, row.COMPANY_ID, workType);
                    }

                    // Update comments
                    if ((!row.Deleted) && (row.InDatabase))
                    {
                        int workId = row.WorkID;
                        int refId = row.RefID;
                        bool originalDeleted = false;
                        int originalCompanyId = companyId;

                        // original values
                        string originalType = flatSectionJlHistoryDetailsGateway.GetTypeOriginal(workId, refId);
                        string originalSubject = flatSectionJlHistoryDetailsGateway.GetSubjectOriginal(workId, refId);
                        int originalUserId = flatSectionJlHistoryDetailsGateway.GetUserIdOriginal(workId, refId);
                        DateTime? originalDateTime = null; if (flatSectionJlHistoryDetailsGateway.GetDateTime_Original(workId, refId) != null) originalDateTime = flatSectionJlHistoryDetailsGateway.GetDateTime_Original(workId, refId);
                        string originalComment = flatSectionJlHistoryDetailsGateway.GetCommentOriginal(workId, refId);
                        int? originalLibraryFilesId = null; if (flatSectionJlHistoryDetailsGateway.GetLIBRARY_FILES_IDOriginal(workId, refId) != null) originalLibraryFilesId = flatSectionJlHistoryDetailsGateway.GetLIBRARY_FILES_IDOriginal(workId, refId);
                        string originalWorkType = flatSectionJlHistoryDetailsGateway.GetWorkTypeOriginal(workId, refId);

                        // new values
                        string newSubject = flatSectionJlHistoryDetailsGateway.GetSubject(workId, refId);
                        string newComment = flatSectionJlHistoryDetailsGateway.GetComment(workId, refId);
                        int? newLibraryFilesId = null; if (flatSectionJlHistoryDetailsGateway.GetLIBRARY_FILES_IDOriginal(workId, refId) != null) originalLibraryFilesId = flatSectionJlHistoryDetailsGateway.GetLIBRARY_FILES_ID(workId, refId);

                        WorkHistory workHistory = new WorkHistory(null);
                        workHistory.UpdateDirect(workId, refId, originalType, originalSubject, originalUserId, originalDateTime, originalComment, originalLibraryFilesId, originalDeleted, originalCompanyId, originalWorkType, workId, refId, originalType, newSubject, originalUserId, originalDateTime, newComment, newLibraryFilesId, originalDeleted, originalCompanyId, originalWorkType);
                    }

                    // Deleted comments
                    if ((row.Deleted) && (row.InDatabase))
                    {
                        WorkHistory workHistory = new WorkHistory(null);
                        workHistory.DeleteDirect(row.WorkID, row.RefID, row.COMPANY_ID);
                    }
                }
            }
        }
        /// <summary>
        /// Save Previous History
        /// </summary>
        /// <param name="workId">workId</param>
        /// <param name="workType">workType</param>
        /// <param name="companyId">companyId</param>
        /// <param name="newSectionWorkId">newSectionWorkId</param>
        private void SavePreviousHistory(int workId, string workType, int companyId, int newSectionWorkId)
        {
            WorkHistoryGateway workHistoryGateway = new WorkHistoryGateway();
            workHistoryGateway.LoadAllByWorkIdWorkType(workId, companyId, workType);

            foreach (WorkTDS.LFS_WORK_HISTORYRow historyRow in (WorkTDS.LFS_WORK_HISTORYDataTable)workHistoryGateway.Table)
            {
                int refId = historyRow.RefID;
                string type = ""; if (!historyRow.IsTypeNull()) type = historyRow.Type;
                string subject = historyRow.Subject;
                int userId = historyRow.UserID;
                DateTime? dateTime_ = null; if (!historyRow.IsDateTime_Null()) dateTime_ = historyRow.DateTime_;
                string history = ""; if (!historyRow.IsHistoryNull()) history = historyRow.History;
                int? libraryFilesId = null; if (!historyRow.IsLIBRARY_FILES_IDNull()) libraryFilesId = historyRow.LIBRARY_FILES_ID;

                WorkHistory workHistory = new WorkHistory();
                workHistory.InsertDirect(newSectionWorkId, refId, type, subject, userId, dateTime_, history, libraryFilesId, false, companyId, workType);
            }
        }
        /// <summary>
        /// Save a JL Work
        /// </summary>
        /// <param name="originalId">originalId</param>
        /// <param name="projectId">projectId</param>
        /// <param name="section_assetId">section_assetId</param>
        /// <param name="numLats">numLats</param>
        /// <param name="notLinedYet">notLinedYet</param>
        /// <param name="allMeasured">allMeasured</param>
        /// <param name="issueWithLaterals">issueWithLaterals</param>
        /// <param name="notMeasuredYet">notMeasuredYet</param>
        /// <param name="notDeliveredYet">notDeliveredYet</param>
        /// <param name="countryId">countryId</param>
        /// <param name="provinceId">provinceId</param>
        /// <param name="countyId">countyId</param>
        /// <param name="cityId">cityId</param>
        /// <param name="companyId">companyId</param>
        private void SaveJLWork(Guid originalId, int section_assetId, int numLats, int notLinedYet, bool allMeasured, string issueWithLaterals, int notMeasuredYet, int notDeliveredYet, int projectId, Int64? countryId, Int64? provinceId, Int64? countyId, Int64? cityId, int companyId)
        {
            // Insert Junction Lining Section
            WorkJunctionLiningSection workJunctionLiningSection = new WorkJunctionLiningSection(null);
            int sectionWorkId = workJunctionLiningSection.InsertDirect(projectId, section_assetId, null, numLats, notLinedYet, allMeasured, issueWithLaterals, notMeasuredYet, notDeliveredYet, false, companyId, "", "", "", "", false, "", 0);

            // Insert Junction Lining Laterals
            SectionTDS sectionTDS = new SectionTDS();

            SectionGateway sectionGateway = new SectionGateway(sectionTDS);
            sectionGateway.LoadById(originalId, companyId);

            JlinerGateway jlinerGateway = new JlinerGateway(sectionTDS);
            jlinerGateway.LoadByIdCompanyId(originalId, companyId);

            foreach (SectionTDS.LFS_JUNCTION_LINER2Row row in (SectionTDS.LFS_JUNCTION_LINER2DataTable)jlinerGateway.Table)
            {
                string lateralID = ""; if (!row.IsDetailIDNull()) lateralID = row.DetailID;
                string address = ""; if (!row.IsAddressNull()) address = row.Address;
                string distanceFromUSMH = ""; if (!row.IsDistanceFromUSMHNull()) distanceFromUSMH = row.DistanceFromUSMH.ToString();
                string distanceFromDSMH = ""; if (!row.IsDistanceFromDSMHNull()) distanceFromDSMH = row.DistanceFromDSMH.ToString();
                DateTime? pipeLocated = null; if (!row.IsPipeLocatedNull()) pipeLocated = row.PipeLocated;
                DateTime? servicesLocated = null; if (!row.IsServicesLocatedNull()) servicesLocated = row.ServicesLocated;
                DateTime? coInstalled = null; if (!row.IsCoInstalledNull()) coInstalled = row.CoInstalled;
                DateTime? backfilledConcrete = null; if (!row.IsBackfilledConcreteNull()) backfilledConcrete = row.BackfilledConcrete;
                DateTime? backfilledSoil = null; if (!row.IsBackfilledSoilNull()) backfilledSoil = row.BackfilledSoil;
                DateTime? grouted = null; if (!row.IsGroutedNull()) grouted = row.Grouted;
                DateTime? cored = null; if (!row.IsCoredNull()) cored = row.Cored;
                DateTime? prepped = null; if (!row.IsPreppedNull()) prepped = row.Prepped;
                DateTime? measured = null; if (!row.IsMeasuredNull()) measured = row.Measured;
                string linerSize = ""; if (!row.IsLinerSizeNull()) linerSize = row.LinerSize;
                DateTime? inProcess = null; if (!row.IsInProcessNull()) inProcess = row.InProcess;
                DateTime? inStock = null; if (!row.IsInStockNull()) inStock = row.InStock;
                DateTime? delivered = null; if (!row.IsDeliveredNull()) delivered = row.Delivered;
                int? buildRebuid = null; if (!row.IsBuildRebuildNull()) buildRebuid = row.BuildRebuild;
                DateTime? preVideo = null; if (!row.IsPreVideoNull()) preVideo = row.PreVideo;
                DateTime? linerInstalled = null; if (!row.IsLinerInstalledNull()) linerInstalled = row.LinerInstalled;
                DateTime? finalVideo = null; if (!row.IsFinalVideoNull()) finalVideo = row.FinalVideo;
                string map = ""; if (!row.IsMapNull()) map = row.Map;
                decimal? cost = null; if (!row.IsCostNull()) cost = row.Cost;
                DateTime? videoInspection = null; if (!row.IsVideoInspectionNull()) videoInspection = row.VideoInspection;
                bool coRequired = row.CoRequired;
                bool pitRequired = row.PitRequired;
                string coPitLocation = ""; if (!row.IsCoPitLocationNull()) coPitLocation = row.CoPitLocation;
                bool postContractDigRequired = row.PostContractDigRequired;
                string comments = ""; if (!row.IsCommentsNull()) comments = row.Comments;
                string history = ""; if (!row.IsHistoryNull()) history = row.History;
                DateTime? coCutDown = null; if (!row.IsCoCutDownNull()) coCutDown = row.CoCutDown;
                DateTime? finalRestoration = null; if (!row.IsFinalRestorationNull()) finalRestoration = row.FinalRestoration;
                string clientLateralId = ""; if (!row.IsClientLateralIDNull()) clientLateralId = row.ClientLateralID;
                string videoLengthToPropertyLine = ""; if (!row.IsVideoLengthToPropertyLineNull()) videoLengthToPropertyLine = row.VideoLengthToPropertyLine;
                bool liningThruCo = row.LiningThruCo;
                DateTime? noticeDelivered = null; if (!row.IsNoticeDeliveredNull()) noticeDelivered = row.NoticeDelivered;
                string hamiltonInspectionNumber = ""; if (!row.IsHamiltonInspectionNumberNull()) hamiltonInspectionNumber = row.HamiltonInspectionNumber;
                bool dyeTestReq = row.DyeTestReq;
                DateTime? dyeTestComplete = null; if (!row.IsDyeTestCompleteNull()) dyeTestComplete = row.DyeTestComplete;

                // Fields only presents in new Junction lining
                string flange = "";
                string gasket = "";
                string connectionType = "";
                string depthOfLocated = "";
                bool digRequiredPriorToLining = false;
                DateTime? digRequiredPriorToLiningCompleted = null;
                bool digRequiredAfterLining = false;
                DateTime? digRequiredAfterLiningCompleted = null;
                bool outOfScope = false;
                bool holdClientIssue = false;
                DateTime? holdClientIssueResolved  = null;
                bool holdLFSIssue = false;
                DateTime? holdLFSIssueResolved = null;
                bool requiresRoboticPrep = false;
                DateTime? requiresRoboticPrepCompleted = null;

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

                // Insert into LFS Asset Lateral
                LfsAssetSewerLateral lfsAssetSewerLateral = new LfsAssetSewerLateral(null);
                int lateralAssetId = lfsAssetSewerLateral.InsertDirect(countryId, provinceId, countyId, cityId, section_assetId, address, lateralID, "", "", "", "", "Live", "", distanceFromUSMH, distanceFromDSMH, "", false, companyId, connectionType);

                // Insert into LFS Asset Lateral Client
                LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null);
                lfsAssetSewerLateralClient.InsertDirect(lateralAssetId, clientId, clientLateralId, false, companyId);

                // Insert into Work Junction Lining Lateral
                WorkJunctionLiningLateral workJunctionLiningLateral = new WorkJunctionLiningLateral(null);
                int workLateral = workJunctionLiningLateral.InsertDirect(projectId, lateralAssetId, sectionWorkId, pipeLocated, servicesLocated, coInstalled, backfilledConcrete, backfilledSoil, grouted, cored, prepped, measured, linerSize, inProcess, inStock, delivered, buildRebuid, 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, "", "", dyeTestReq, dyeTestComplete, "");

                // Insert into Work Comments
                JlinerCommentGateway jlinerCommentGateway = new JlinerCommentGateway(sectionTDS);
                jlinerCommentGateway.LoadByIdRefId(originalId, row.RefID, companyId);

                foreach (SectionTDS.LFS_JUNCTION_LINER2_COMMENTRow rowComment in (SectionTDS.LFS_JUNCTION_LINER2_COMMENTDataTable)jlinerCommentGateway.Table)
                {
                    int loginId = rowComment.LoginID;
                    DateTime dateTime_ = rowComment.DateTime_;
                    string comment = rowComment.Comment;

                    WorkCommentsGateway workCommentsGateway = new WorkCommentsGateway();
                    workCommentsGateway.LoadByWorkIdWorkType(workLateral, companyId, "Junction Lining Lateral");
                    WorkComments workComments = new WorkComments(workCommentsGateway.Data);
                    workComments.Insert(workLateral, 0, "Junction Lining Lateral", "Bulk Upload Comments", loginId, dateTime_, comment, null, false, companyId, false, "Junction Lining");

                    // Update Comments
                    workCommentsGateway.Update();
                }

                // Insert into Work History
                JlinerHistoryGateway jlinerHistoryGateway = new JlinerHistoryGateway(sectionTDS);
                jlinerHistoryGateway.LoadByIdRefId(originalId, row.RefID, companyId);

                foreach (SectionTDS.LFS_JUNCTION_LINER2_HISTORYRow rowHistory in (SectionTDS.LFS_JUNCTION_LINER2_HISTORYDataTable)jlinerHistoryGateway.Table)
                {
                    int loginId = rowHistory.LoginID;
                    DateTime dateTime_H = rowHistory.DateTime_;
                    string history_ = rowHistory.History;

                    WorkHistoryGateway workHistoryGateway = new WorkHistoryGateway();
                    workHistoryGateway.LoadByWorkIdWorkType(workLateral, companyId, "Junction Lining Lateral");
                    WorkHistory workHistory = new WorkHistory(workHistoryGateway.Data);
                    workHistory.Insert(workLateral, 0, "Junction Lining Lateral", "Bulk Upload History", loginId, dateTime_H, history_, null, false, companyId, false, "Junction Lining");

                    // Update History
                    workHistoryGateway.Update();
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Transfer to History
        /// </summary>
        /// <param name="loginId">loginId</param>
        /// <param name="adminPermission">admin Permission</param>
        /// <param name="workHistory">workHistory</param>
        public void TransferToHistory(int loginId, bool adminPermission, WorkHistory workHistory)
        {
            int? libraryFilesId = null;

            foreach (WorkTDS.LFS_WORK_COMMENTRow commentRow in (WorkTDS.LFS_WORK_COMMENTDataTable)Table)
            {
                if (adminPermission)
                {
                    if (!commentRow.IsToHistoryNull())
                    {
                        if ((commentRow.ToHistory) && (!commentRow.Deleted))
                        {
                            if (!commentRow.IsLIBRARY_FILES_IDNull())
                            {
                                libraryFilesId = commentRow.LIBRARY_FILES_ID;
                            }
                            else
                            {
                                libraryFilesId = null;
                            }

                            // Insert to history
                            workHistory.Insert(commentRow.WorkID, commentRow.RefID, commentRow.Type, commentRow.Subject, commentRow.UserID, commentRow.DateTime_, commentRow.Comment, libraryFilesId, commentRow.Deleted, commentRow.COMPANY_ID, false, commentRow.WorkType);

                            // Delete from comments
                            commentRow.Deleted = true;
                        }
                    }
                }
                else
                {
                    if (commentRow.UserID == loginId)
                    {
                        if (!commentRow.IsToHistoryNull())
                        {
                            if ((commentRow.ToHistory) && (!commentRow.Deleted))
                            {
                                if (!commentRow.IsLIBRARY_FILES_IDNull())
                                {
                                    libraryFilesId = commentRow.LIBRARY_FILES_ID;
                                }
                                else
                                {
                                    libraryFilesId = null;
                                }

                                // Insert to history
                                workHistory.Insert(commentRow.WorkID, commentRow.RefID, commentRow.Type, commentRow.Subject, commentRow.UserID, commentRow.DateTime_, commentRow.Comment, libraryFilesId, commentRow.Deleted, commentRow.COMPANY_ID, false, commentRow.WorkType);

                                // Delete from comments
                                commentRow.Deleted = true;
                            }
                        }
                    }
                }

            }
        }
        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);
            }
        }
        /// <summary>
        /// Save Previous History
        /// </summary>
        /// <param name="workId">workId</param>
        /// <param name="workType">workType</param>
        /// <param name="companyId">companyId</param>
        /// <param name="newSectionWorkId">newSectionWorkId</param>
        private void SavePreviousHistory(int parentWorkId, string workType, int companyId, int childWorkId)
        {
            WorkHistoryGateway parentWorkHistoryGateway = new WorkHistoryGateway();
            parentWorkHistoryGateway.LoadAllByWorkIdWorkType(parentWorkId, companyId, workType);

            WorkHistoryGateway childWorkHistoryGateway = new WorkHistoryGateway();
            childWorkHistoryGateway.LoadAllByWorkIdWorkType(childWorkId, companyId, workType);
            WorkHistory childWorkHistory = new WorkHistory(childWorkHistoryGateway.Data);

            int lastRefId = childWorkHistory.GetNewRefId();

            foreach (WorkTDS.LFS_WORK_HISTORYRow commentRow in (WorkTDS.LFS_WORK_HISTORYDataTable)parentWorkHistoryGateway.Table)
            {
                WorkHistory workHistory = new WorkHistory();

                int refId = lastRefId;
                string type = ""; if (!commentRow.IsTypeNull()) type = commentRow.Type;
                string subject = commentRow.Subject;
                int userId = commentRow.UserID;
                DateTime? dateTime_ = null; if (!commentRow.IsDateTime_Null()) dateTime_ = commentRow.DateTime_;
                string comment = ""; if (!commentRow.IsHistoryNull()) comment = commentRow.History;
                int? libraryFilesId = null; if (!commentRow.IsLIBRARY_FILES_IDNull()) libraryFilesId = commentRow.LIBRARY_FILES_ID;

                workHistory.InsertDirect(childWorkId, refId, type, subject, userId, dateTime_, comment, libraryFilesId, false, companyId, workType);

                lastRefId++;
            }
        }