/// <summary>
        /// DeleteDirect
        /// </summary>
        /// <param name="assetId">assetId</param>
        /// <param name="companyId">companyId</param>
        /// <returns></returns>
        public bool DeleteDirect(int assetId, int companyId)
        {
            // Verify in use
            if (!InUse(assetId, companyId))
            {
                // Delete laterals
                // ... Define initial models
                LfsAssetSewerLateral lfsAssetSewerLateral = new LfsAssetSewerLateral(null);

                // ... Load laterals
                AssetSewerLateralGateway assetSewerLateralGateway = new AssetSewerLateralGateway();
                assetSewerLateralGateway.LoadBySectionId(assetId, companyId);

                // ... Delete laterals
                foreach (AssetsTDS.AM_ASSET_SEWER_LATERALRow rowLateral in (AssetsTDS.AM_ASSET_SEWER_LATERALDataTable)assetSewerLateralGateway.Table)
                {
                    lfsAssetSewerLateral.DeleteDirect(rowLateral.AssetID, companyId);
                }

                // Get MHs for deleted
                AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway();
                assetSewerSectionGateway.LoadByAssetId(assetId, companyId);
                int? usmh_assetId = assetSewerSectionGateway.GetUSMH(assetId);
                int? dsmh_assetId = assetSewerSectionGateway.GetDSMH(assetId);

                // Delete section
                LfsAssetSewerSectionGateway lfsAssetSewerSectionGateway = new LfsAssetSewerSectionGateway(null);
                lfsAssetSewerSectionGateway.Delete(assetId, companyId);

                LfsAssetSewer lfsAssetSewer = new LfsAssetSewer(null);
                lfsAssetSewer.DeleteDirect(assetId, companyId);

                LfsAsset lfsAsset = new LfsAsset(null);
                lfsAsset.DeleteDirect(assetId, companyId);

                // delete section in AM tables
                AssetSewerSection assetSewerSection = new AssetSewerSection(null);
                assetSewerSection.DeleteDirect(assetId, companyId);

                // Delete USMH (if not in use)
                if (usmh_assetId.HasValue)
                {
                    LfsAssetSewerMH lfsAssetSewerUsmh = new LfsAssetSewerMH(null);
                    lfsAssetSewerUsmh.DeleteDirect((int)usmh_assetId, companyId);
                }

                // Delete DSMH (if not in use)
                if (dsmh_assetId.HasValue)
                {
                    LfsAssetSewerMH lfsAssetSewerDsmh = new LfsAssetSewerMH(null);
                    lfsAssetSewerDsmh.DeleteDirect((int)dsmh_assetId, companyId);
                }

                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// DeleteDirect
        /// </summary>
        /// <param name="assetId">assetId</param>
        /// <param name="companyId">companyId</param>
        public bool DeleteDirect(int assetId, int companyId)
        {
            // Get initial data
            AssetSewerLateralGateway assetSewerLateralGateway = new AssetSewerLateralGateway();
            assetSewerLateralGateway.LoadByAssetId(assetId, companyId);
            int section_ = assetSewerLateralGateway.GetSection(assetId);
            string state = assetSewerLateralGateway.GetState(assetId);

            // Delete lateral
            assetSewerLateralGateway.Delete(assetId, companyId);
            AssetSewer assetSewer = new AssetSewer(null);
            assetSewer.DeleteDirect(assetId, companyId);
            Asset asset = new Asset(null);
            asset.DeleteDirect(assetId, companyId);

            // Update Section
            // ... Load section
            AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway();
            assetSewerSectionGateway.LoadByAssetId(section_, companyId);

            // ... Get old values of section
            string sectionIdS = assetSewerSectionGateway.GetSectionId(section_);
            string streetS = assetSewerSectionGateway.GetStreet(section_);
            int? usmhIdS = assetSewerSectionGateway.GetUSMH(section_);
            int? dsmhIdS = assetSewerSectionGateway.GetDSMH(section_);
            string mapSizeS = assetSewerSectionGateway.GetMapSize(section_);
            string size_S = assetSewerSectionGateway.GetSize_(section_);
            string mapLengthS = assetSewerSectionGateway.GetMapSize(section_);
            string lengthS = assetSewerSectionGateway.GetLength(section_);
            int? lateralsS = assetSewerSectionGateway.GetLaterals(section_);
            int? liveLateralsS = assetSewerSectionGateway.GetLiveLaterals(section_);
            string flowDirectionS = assetSewerSectionGateway.GetFlowDirection(section_);
            string usmhDepthS = assetSewerSectionGateway.GetUSMHDepth(section_);
            string dsmhDepthS = assetSewerSectionGateway.GetDSMHDepth(section_);
            bool deletedS = assetSewerSectionGateway.GetDeleted(section_);
            string flowOrderIdS = assetSewerSectionGateway.GetFlowOrderID(section_);

            // ... Calculate new values of section
            int? newLaterals = lateralsS - 1;

            int? newLiveLaterals = liveLateralsS;
            if ((newLiveLaterals.HasValue) && (state == "Live"))
            {
                newLiveLaterals = newLiveLaterals - 1;
            }

            // ... Update section
            AssetSewerSection assetSewerSection = new AssetSewerSection(assetSewerSectionGateway.Data);
            assetSewerSection.UpdateDirect(section_, sectionIdS, streetS, usmhIdS, dsmhIdS, mapSizeS, size_S, mapLengthS, lengthS, lateralsS, liveLateralsS, flowDirectionS, usmhDepthS, dsmhDepthS, deletedS, companyId, flowOrderIdS, section_, sectionIdS, streetS, usmhIdS, dsmhIdS, mapSizeS, size_S, mapLengthS, lengthS, newLaterals, newLiveLaterals, flowDirectionS, usmhDepthS, dsmhDepthS, deletedS, companyId, flowOrderIdS);

            return true;
        }
        /// <summary>
        /// UpdateSection
        /// </summary>
        /// <param name="originalWorkId">originalWorkId</param>
        /// <param name="assetId">assetId</param>
        /// <param name="originalSectionId">originalSectionId</param>
        /// <param name="originalStreet">originalStreet</param>
        /// <param name="originalUsmh">originalUsmh</param>
        /// <param name="originalDsmh">originalDsmh</param>
        /// <param name="originalMapSize">originalMapSize</param>
        /// <param name="originalSize">originalSize</param>
        /// <param name="originalMapLength">originalMapLength</param>
        /// <param name="originalLength">originalLength</param>
        /// <param name="originalLaterals">laterals</param>
        /// <param name="originalLiveLaterals">liveLaterals</param>
        /// <param name="originalUsmhDepth">originalUsmhDepth</param>
        /// <param name="originalDsmhDepth">originalDsmhDepth</param>
        /// <param name="originalSteelTapeThroughSewer">originalSteelTapeThroughSewer</param>
        /// <param name="originalSubArea">originalSubArea</param>
        /// <param name="originalUsmhMouth12">originalUsmhMouth12</param>
        /// <param name="originalUsmhMouth1">originalUsmhMouth1</param>
        /// <param name="originalUsmhMouth2">originalUsmhMouth2</param>
        /// <param name="originalUsmhMouth3">originalUsmhMouth3</param>
        /// <param name="originalUsmhMouth4">originalUsmhMouth4</param>
        /// <param name="originalUsmhMouth5">originalUsmhMouth5</param>
        /// <param name="originalDsmhMouth12">originalDsmhMouth12</param>
        /// <param name="originalDsmhMouth1">originalDsmhMouth1</param>
        /// <param name="originalDsmhMouth2">originalDsmhMouth2</param>
        /// <param name="originalDsmhMouth3">originalDsmhMouth3</param>
        /// <param name="originalDsmhMouth4">originalDsmhMouth4</param>
        /// <param name="originalDsmhMouth5">originalDsmhMouth5</param>
        /// <param name="originalDelete">originalDelete</param>
        /// <param name="originalCompanyId">originalCompanyId</param>
        /// <param name="originalUsmhAddress">originalUsmhAddress</param>
        /// <param name="originalDsmhAddress">originalDsmhAddress</param>
        /// <param name="originalThickness">originalThickness</param>
        /// 
        /// <param name="newWorkId">newWorkId</param>
        /// <param name="newAssetId">newAssetId</param>
        /// <param name="newSectionId">newSectionId</param>
        /// <param name="newStreet">newStreet</param>
        /// <param name="newUsmh">newUsmh</param>
        /// <param name="newDsmh">newDsmh</param>
        /// <param name="newMapSize">newMapSize</param>
        /// <param name="newSize">newSize</param>
        /// <param name="newMapLength">newMapLength</param>
        /// <param name="newLength">newLength</param>
        /// <param name="newMapLength">newMapLength</param>
        /// <param name="newLaterals">newLaterals</param>
        /// <param name="newLiveLaterals">newLiveLaterals</param>
        /// <param name="newUsmhDepth">newUsmhDepth</param>
        /// <param name="newDsmhDepth">newDsmhDepth</param>
        /// <param name="newSteelTapeThroughSewer">newSteelTapeThroughSewer</param>
        /// <param name="newSubArea">newSubArea</param>
        /// <param name="newUsmhMouth12">newUsmhMouth12</param>
        /// <param name="newUsmhMouth1">newUsmhMouth1</param>
        /// <param name="newUsmhMouth2">newUsmhMouth2</param>
        /// <param name="newUsmhMouth3">newUsmhMouth3</param>
        /// <param name="newUsmhMouth4">newUsmhMouth4</param>
        /// <param name="newUsmhMouth5">newUsmhMouth5</param>
        /// <param name="newDsmhMouth12">newDsmhMouth12</param>
        /// <param name="newDsmhMouth1">newDsmhMouth1</param>
        /// <param name="newDsmhMouth2">newDsmhMouth2</param>
        /// <param name="newDsmhMouth3">newDsmhMouth3</param>
        /// <param name="newDsmhMouth4">newDsmhMouth4</param>
        /// <param name="newDsmhMouth5">newDsmhMouth5</param>
        /// <param name="newDelete">newDelete</param>
        /// <param name="newCompanyId">newCompanyId</param>
        /// <param name="newUsmhAddress">newUsmhAddress</param>
        /// <param name="newDsmhAddress">newDsmhAddress</param>
        /// <param name="newThickness">newThickness</param>
        /// <param name="projectId">projectId</param>        
        private void UpdateSection(int originalWorkId, int assetId, string originalSectionId, string originalStreet, int? originalUsmh, int? originalDsmh, string originalMapSize, string originalSize, string originalMapLength, string originalLength, int? originalLaterals, int? originalLiveLaterals, string originalUsmhDepth, string originalDsmhDepth, string originalSteelTapeThroughSewer, string originalSubArea, string originalUsmhMouth12, string originalUsmhMouth1, string originalUsmhMouth2, string originalUsmhMouth3, string originalUsmhMouth4, string originalUsmhMouth5, string originalDsmhMouth12, string originalDsmhMouth1, string originalDsmhMouth2, string originalDsmhMouth3, string originalDsmhMouth4, string originalDsmhMouth5, bool originalDelete, int originalCompanyId, string originalUsmhAddress, string originalDsmhAddress, string originalThickness, int newWorkId, int newAssetId, string newSectionId, string newStreet, int? newUsmh, int? newDsmh, string newMapSize, string newSize, string newMapLength, string newLength, int? newLaterals, int? newLiveLaterals, string newUsmhDepth, string newDsmhDepth, string newSteelTapeThroughSewer, string newSubArea, string newUsmhMouth12, string newUsmhMouth1, string newUsmhMouth2, string newUsmhMouth3, string newUsmhMouth4, string newUsmhMouth5, string newDsmhMouth12, string newDsmhMouth1, string newDsmhMouth2, string newDsmhMouth3, string newDsmhMouth4, string newDsmhMouth5, bool newDelete, int newCompanyId, string newUsmhAddress, string newDsmhAddress, string newThickness, int projectId)
        {
            // Get unchanged data
            // ... section
            AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway();
            assetSewerSectionGateway.LoadByAssetId(assetId, originalCompanyId);

            int? laterals = assetSewerSectionGateway.GetLaterals(assetId);
            string flowDirection = assetSewerSectionGateway.GetFlowDirection(assetId);

            // Update section
            LfsAssetSewerSection lfsAssetSewerSection = new LfsAssetSewerSection(null);
            lfsAssetSewerSection.UpdateDirect(assetId, originalSectionId, originalStreet, originalUsmh, originalDsmh, originalMapSize, originalSize, originalMapLength, originalLength, originalLaterals, originalLiveLaterals, flowDirection, originalUsmhDepth, originalDsmhDepth, originalSteelTapeThroughSewer, originalUsmhMouth12, originalUsmhMouth1, originalUsmhMouth2, originalUsmhMouth3, originalUsmhMouth4, originalUsmhMouth5, originalDsmhMouth12, originalDsmhMouth1, originalDsmhMouth2, originalDsmhMouth3, originalDsmhMouth4, originalDsmhMouth5, originalDelete, originalCompanyId, originalSubArea, originalThickness, assetId, newSectionId, newStreet, newUsmh, newDsmh, newMapSize, newSize, newMapLength, newLength, newLaterals, newLiveLaterals, flowDirection, newUsmhDepth, newDsmhDepth, newSteelTapeThroughSewer, newUsmhMouth12, newUsmhMouth1, newUsmhMouth2, newUsmhMouth3, newUsmhMouth4, newUsmhMouth5, newDsmhMouth12, newDsmhMouth1, newDsmhMouth2, newDsmhMouth3, newDsmhMouth4, newDsmhMouth5, newDelete, newCompanyId, newSubArea, newThickness);
        }
        /// <summary>
        /// UpdateFieldsForSections
        /// </summary>
        /// <param name="companyId">companyId</param>
        /// <param name="currentProjectId">currentProjectId</param>
        private void UpdateFieldsForSections(int companyId, int currentProjectId)
        {
            AssetSewerSectionGateway assetSewerFindSectionGateway = new AssetSewerSectionGateway();

            AssetSewerMHGateway assetSewerFindMHGateway = new AssetSewerMHGateway();
            WorkGateway workGateway = new WorkGateway();
            foreach (ProjectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATORRow row in (ProjectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATORDataTable)Table)
            {
                //General data for asset
                assetSewerFindSectionGateway.LoadByAssetId(row.AssetID, companyId); //COMPANY_ID

                // ... For usmh
                row.USMHDescription = "";
                if (!row.IsUSMHNull())
                {
                    assetSewerFindMHGateway.LoadByAssetId(row.USMH, companyId);
                    row.USMHDescription = assetSewerFindMHGateway.GetMHID(row.USMH);
                }

                // ... For dsmh
                row.DSMHDescription = "";
                if (!row.IsDSMHNull())
                {
                    assetSewerFindMHGateway.LoadByAssetId(row.DSMH, companyId);
                    row.DSMHDescription = assetSewerFindMHGateway.GetMHID(row.DSMH);
                }

                // ... For Works
                row.RehabAssessment = workGateway.ExistsProjectIdAssetIdWorkTypeCompanyId(row.AssetID, currentProjectId, "Rehab Assessment", companyId);
                row.FullLengthLining = workGateway.ExistsProjectIdAssetIdWorkTypeCompanyId(row.AssetID, currentProjectId, "Full Length Lining", companyId);
                row.JunctionLining = workGateway.ExistsProjectIdAssetIdWorkTypeCompanyId(row.AssetID, currentProjectId, "Junction Lining Section", companyId);

                row.WorksDescription = "";
                if (row.RehabAssessment) row.WorksDescription = row.WorksDescription + "Rehab Assessment";

                if (row.FullLengthLining)
                {
                    if (row.WorksDescription.Trim().Length > 0)
                    {
                        row.WorksDescription = row.WorksDescription + ", Full Length Lining";
                    }
                    else
                    {
                        row.WorksDescription = row.WorksDescription + "Full Length Lining";
                    }
                }
                if (row.JunctionLining)
                {
                    if (row.WorksDescription.Trim().Length > 0)
                    {
                        row.WorksDescription = row.WorksDescription + ", Junction Lining";
                    }
                    else
                    {
                        row.WorksDescription = row.WorksDescription + "Junction Lining";
                    }
                }

                // ... For Laterals
                AssetSewerLateralGateway assetSewerLateralGateway = new AssetSewerLateralGateway();

                assetSewerLateralGateway.LoadBySectionId(row.AssetID, companyId);

                AssetSewerLateral assetSewerLateral = new AssetSewerLateral(assetSewerLateralGateway.Data);
                row.LateralsDescription = assetSewerLateral.GetAllLaterals(row.AssetID, companyId);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Save
        /// </summary>
        /// <param name="projectId">projectId</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>
        /// <param name="loginId">loginId</param>
        public void Save(int companyId, int loginId)
        {
            foreach (DataMigrationTDS.JlDataMigrationRow row in (DataMigrationTDS.JlDataMigrationDataTable)Table)
            {
                // Get ids & location
                ProjectGateway projectGateway = new ProjectGateway();
                DataMigrationProjectGateway dataMigrationProjectGateway = new DataMigrationProjectGateway(null);
                string name = string.Format("{0} Data Migration Project", row.Client);

                int projectId = dataMigrationProjectGateway.GetProjectIdByName(name);

                if (projectId != 0)
                {
                    projectGateway.LoadByProjectId(projectId);

                    // get parameters
                    Int64 countryId = projectGateway.GetCountryID(projectId);
                    Int64? provinceId = null; if (projectGateway.GetProvinceID(projectId).HasValue) provinceId = projectGateway.GetProvinceID(projectId);
                    Int64? countyId = null; if (projectGateway.GetCountyID(projectId).HasValue) countyId = projectGateway.GetCountyID(projectId);
                    Int64? cityId = null; if (projectGateway.GetCityID(projectId).HasValue) cityId = projectGateway.GetCityID(projectId);

                    //Save section
                    int section_assetId = SaveSection(row, projectId, countryId, provinceId, countyId, cityId, companyId);
                    Guid originalId = row.OriginalID;

                    if (row.JLiner)
                    {
                        SaveJLWork(originalId, section_assetId, row.NumLats, row.NotLinedYet, row.AllMeasured, row.IssueWithLaterals, row.NotMeasuredYet, row.NotDeliveredYet, projectId, countryId, provinceId, countyId, cityId, companyId);
                    }

                    // Insert in DataMigration Table
                    string originalSectionId = row.OriginalSectionID;
                    AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway();
                    assetSewerSectionGateway.LoadByAssetId(section_assetId, companyId);
                    string newSectionId = assetSewerSectionGateway.GetSectionId(section_assetId);

                    DataMigrationGateway dataMigrationGateway = new DataMigrationGateway(null);
                    dataMigrationGateway.InsertDataMigration(originalId, originalSectionId, section_assetId, newSectionId);
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!Convert.ToBoolean(Session["sgLFS_PROJECTS_VIEW"]))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }

                // Validate query string
                if (Request.QueryString["source_page"] == null)
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in projects2.aspx");
                }

                // Tag page
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfProjectId.Value = Request.QueryString["project_id"];
                hdfAssetID.Value = Request.QueryString["asset_id"];
                Session.Remove("projectSectionsNavigatorLateralsNewDummy");
                Session.Remove("projectSectionsNavigatorLaterals");

                // Initialize data
                projectTDS = (ProjectTDS)Session["lfsProjectTDS"];
                assetsTDS = new AssetsTDS();
                lfsAssetsTDS = new LfsAssetsTDS();
                workTDS = new WorkTDS();
                projectSectionsNavigatorTDS = new ProjectSectionsNavigatorTDS();

                // Load data
                int companyId = Int32.Parse(hdfCompanyId.Value);
                int assetId = Int32.Parse(hdfAssetID.Value);
                int projectId = Int32.Parse(hdfProjectId.Value);

                AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway();
                assetSewerSectionGateway.LoadByAssetId(assetId, companyId);

                if (assetSewerSectionGateway.Table.Rows.Count > 0)
                {
                    tbxSectionId.Text = assetSewerSectionGateway.GetFlowOrderID(assetId);
                    tbxStreet.Text = assetSewerSectionGateway.GetStreet(assetId);

                    // ... For usmh
                    if (assetSewerSectionGateway.GetUSMH(assetId).HasValue)
                    {
                        AssetSewerMHGateway assetSewerFindMHGateway = new AssetSewerMHGateway();
                        int USMH = (int)assetSewerSectionGateway.GetUSMH(assetId);

                        assetSewerFindMHGateway.LoadByAssetId(USMH, companyId);
                        tbxUSMH.Text = assetSewerFindMHGateway.GetMHID(USMH);
                    }

                    // ... For usmh
                    if (assetSewerSectionGateway.GetDSMH(assetId).HasValue)
                    {
                        AssetSewerMHGateway assetSewerFindMHGateway = new AssetSewerMHGateway();
                        int DSMH = (int)assetSewerSectionGateway.GetDSMH(assetId);

                        assetSewerFindMHGateway.LoadByAssetId(DSMH, companyId);
                        tbxDSMH.Text = assetSewerFindMHGateway.GetMHID(DSMH);
                    }

                    // ... For Works
                    WorkGateway workGateway = new WorkGateway();
                    if (workGateway.ExistsProjectIdAssetIdWorkTypeCompanyId(assetId, projectId, "Rehab Assessment", companyId))
                        ckbxRehabAssessment.Checked = true;
                    if (workGateway.ExistsProjectIdAssetIdWorkTypeCompanyId(assetId, projectId, "Full Length Lining", companyId))
                        ckbxFullLengthLining.Checked = true;
                    if (workGateway.ExistsProjectIdAssetIdWorkTypeCompanyId(assetId, projectId, "Junction Lining Section", companyId))
                        ckbxJunctionLining.Checked = true;

                    // ... For Laterals
                    if (assetSewerSectionGateway.GetLaterals(int.Parse(hdfAssetID.Value)).HasValue)
                    {
                        tbxTotalLaterals.Text = ((int)assetSewerSectionGateway.GetLaterals(assetId)).ToString();
                    }
                    else
                    {
                        tbxTotalLaterals.Text = "0";
                    }

                    ProjectSectionsNavigatorLateralsGateway projectSectionsNavigatorLateralsGateway = new ProjectSectionsNavigatorLateralsGateway(projectSectionsNavigatorTDS);
                    projectSectionsNavigatorLateralsGateway.LoadBySection_ProjectId(assetId, projectId, companyId);

                    AssetSewerLateralGateway assetSewerLateralGateway = new AssetSewerLateralGateway(assetsTDS);
                    assetSewerLateralGateway.LoadBySectionProjectId(assetId, projectId, companyId);

                    // ... store datasets
                    Session["projectSectionsNavigatorTDS"] = projectSectionsNavigatorTDS;
                    projectSectionsNavigatorLaterals = projectSectionsNavigatorTDS.ProjectSectionNavigatorLaterals;
                    Session["projectSectionsNavigatorLaterals"] = projectSectionsNavigatorLaterals;
                }
            }
            else
            {
                // Restore dataset
                projectTDS = (ProjectTDS)Session["lfsProjectTDS"];
                projectSectionsNavigatorTDS = (ProjectSectionsNavigatorTDS)Session["lfsProjectSectionsNavigatorTDS"];
                projectSectionsNavigatorLaterals = (ProjectSectionsNavigatorTDS.ProjectSectionNavigatorLateralsDataTable)Session["projectSectionsNavigatorLaterals"];
                assetsTDS = (AssetsTDS)Session["assetsTDS"];
                lfsAssetsTDS = (LfsAssetsTDS)Session["lfsAssetsTDS"];
                workTDS = (WorkTDS)Session["workTDS"];
            }
        }
        /// <summary>
        /// UpdateDirect
        /// </summary>
        /// <param name="originalAssetId">originalAssetId</param>
        /// <param name="originalSection_">originalSection_</param>
        /// <param name="originalAddress">originalAddress</param>
        /// <param name="originalLateralId">originalLateralId</param>
        /// <param name="originalLatitudeAtSection">originalLatitudeAtSection</param>
        /// <param name="originalLongitudeAtSection">originalLongitudeAtSection</param>
        /// <param name="originalLatitudeAtPropertyLine">originalLatitudeAtPropertyLine</param>
        /// <param name="originalLongitudeAtPropertyLine">originalLongitudeAtPropertyLine</param>
        /// <param name="originalState">originalState</param>
        /// <param name="orignalSize">orignalSize</param>
        /// <param name="originalDistanceFromUsmh">originalDistanceFromUsmh</param>
        /// <param name="originalDistanceFromDsmh">originalDistanceFromDsmh</param>
        /// <param name="originalMapSize">originalMapSize</param>
        /// <param name="originalDeleted">originalDeleted</param>
        /// <param name="originalCompanyId">originalCompanyId</param>
        /// <param name="originalConnectionType">originalConnectionType</param>
        /// 
        /// <param name="newAssetId">newAssetId</param>
        /// <param name="newSection_">newSection_</param>
        /// <param name="newAddress">newAddress</param>
        /// <param name="newLateralId">newLateralId</param>
        /// <param name="newLatitudeAtSection">newLatitudeAtSection</param>
        /// <param name="newLongitudeAtSection">newLongitudeAtSection</param>
        /// <param name="newLatitudeAtPropertyLine">newLatitudeAtPropertyLine</param>
        /// <param name="newLongitudeAtPropertyLine">newLongitudeAtPropertyLine</param>
        /// <param name="newState">newState</param>
        /// <param name="newSize">newSize</param>
        /// <param name="newDistanceFromUsmh">newDistanceFromUsmh</param>
        /// <param name="newDistanceFromDsmh">newDistanceFromDsmh</param>
        /// <param name="newMapSize">newMapSize</param>
        /// <param name="newDeleted">newDeleted</param>
        /// <param name="newCompanyId">newCompanyId</param>
        /// <param name="newConnectionType">newConnectionType</param>
        public void UpdateDirect(int originalAssetId, int originalSection_, string originalAddress, string originalLateralId, string originalLatitudeAtSection, string originalLongitudeAtSection, string originalLatitudeAtPropertyLine, string originalLongitudeAtPropertyLine, string originalState, string orignalSize, string originalDistanceFromUsmh, string originalDistanceFromDsmh, string originalMapSize, bool originalDeleted, int originalCompanyId, string originalConnectionType, int newAssetId, int newSection_, string newAddress, string newLateralId, string newLatitudeAtSection, string newLongitudeAtSection, string newLatitudeAtPropertyLine, string newLongitudeAtPropertyLine, string newState, string newSize, string newDistanceFromUsmh, string newDistanceFromDsmh, string newMapSize, bool newDeleted, int newCompanyId, string newConnectionType)
        {
            AssetSewerLateralGateway assetSewerLateralGateway = new AssetSewerLateralGateway();
            assetSewerLateralGateway.Update(originalAssetId, originalSection_, originalAddress, originalLateralId, originalLatitudeAtSection, originalLongitudeAtSection, originalLatitudeAtPropertyLine, originalLongitudeAtPropertyLine, originalState, orignalSize, originalDistanceFromUsmh, originalDistanceFromDsmh, originalMapSize, originalDeleted, originalCompanyId, originalConnectionType, newAssetId, newSection_, newAddress, newLateralId, newLatitudeAtSection, newLongitudeAtSection, newLatitudeAtPropertyLine, newLongitudeAtPropertyLine, newState, newSize, newDistanceFromUsmh, newDistanceFromDsmh, newMapSize, newDeleted, newCompanyId, newConnectionType);

            // Update section
            if ((originalState != newState) && ((newState == "Live") || (originalState == "Live")))
            {
                // ... Load section
                AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway();
                assetSewerSectionGateway.LoadByAssetId(originalSection_, originalCompanyId);

                // ... Get old values of section
                string sectionIdS = assetSewerSectionGateway.GetSectionId(originalSection_);
                string streetS = assetSewerSectionGateway.GetStreet(originalSection_);
                int? usmhIdS = assetSewerSectionGateway.GetUSMH(originalSection_);
                int? dsmhIdS = assetSewerSectionGateway.GetDSMH(originalSection_);
                string mapSizeS = assetSewerSectionGateway.GetMapSize(originalSection_);
                string size_S = assetSewerSectionGateway.GetSize_(originalSection_);
                string mapLengthS = assetSewerSectionGateway.GetMapSize(originalSection_);
                string lengthS = assetSewerSectionGateway.GetLength(originalSection_);
                int? lateralsS = assetSewerSectionGateway.GetLaterals(originalSection_);
                int? liveLateralsS = assetSewerSectionGateway.GetLiveLaterals(originalSection_);
                string flowDirectionS = assetSewerSectionGateway.GetFlowDirection(originalSection_);
                string usmhDepthS = assetSewerSectionGateway.GetUSMHDepth(originalSection_);
                string dsmhDepthS = assetSewerSectionGateway.GetDSMHDepth(originalSection_);
                bool deletedS = assetSewerSectionGateway.GetDeleted(originalSection_);
                string flowOrderIdS = assetSewerSectionGateway.GetFlowOrderID(originalSection_);

                // ... Calculate new values of section
                int? newLiveLaterals = liveLateralsS;
                if (originalState == "Live")
                {
                    newLiveLaterals = newLiveLaterals - 1;
                }
                if (newState == "Live")
                {
                    newLiveLaterals = newLiveLaterals + 1;
                }

                // ... Update section
                AssetSewerSection assetSewerSection = new AssetSewerSection(assetSewerSectionGateway.Data);
                assetSewerSection.UpdateDirect(originalSection_, sectionIdS, streetS, usmhIdS, dsmhIdS, mapSizeS, size_S, mapLengthS, lengthS, lateralsS, liveLateralsS, flowDirectionS, usmhDepthS, dsmhDepthS, deletedS, originalCompanyId, flowOrderIdS, originalSection_, sectionIdS, streetS, usmhIdS, dsmhIdS, mapSizeS, size_S, mapLengthS, lengthS, lateralsS, newLiveLaterals, flowDirectionS, usmhDepthS, dsmhDepthS, deletedS, originalCompanyId, flowOrderIdS);
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // PUBLIC METHODS
        //
        /// <summary>
        /// InsertDirect
        /// </summary>
        /// <param name="countryId">countryId</param>
        /// <param name="provinceId">provinceId</param>
        /// <param name="countyId">countyId</param>
        /// <param name="cityId">cityId</param>
        /// <param name="section_">section_</param>
        /// <param name="address">address</param>
        /// <param name="lateralID">lateralID</param>
        /// <param name="latitudeAtSection">latitudeAtSection</param>
        /// <param name="longitudeAtSection">longitudeAtSection</param>
        /// <param name="latitudeAtPropertyLine">latitudeAtPropertyLine</param>
        /// <param name="longitudeAtPropertyLine">longitudeAtPropertyLine</param>
        /// <param name="state">state</param>
        /// <param name="size_">size_</param>
        /// <param name="distanceFromUSMH">distanceFromUSMH</param>
        /// <param name="distanceFromDSMH">distanceFromDSMH</param>
        /// <param name="mapSize">mapSize</param>
        /// <param name="deleted">deleted</param>
        /// <param name="companyId">companyId</param>
        /// <param name="connectionType">connectionType</param>
        /// <returns></returns>
        public int InsertDirect(Int64? countryId, Int64? provinceId, Int64? countyId, Int64? cityId, int section_, string address, string lateralID, string latitudeAtSection, string longitudeAtSection, string latitudeAtPropertyLine, string longitudeAtPropertyLine, string state, string size_, string distanceFromUSMH, string distanceFromDSMH, string mapSize, bool deleted, int companyId, string connectionType)
        {
            AssetSewerLateralGateway assetSewerLateralGateway = new AssetSewerLateralGateway();
            assetSewerLateralGateway.LoadBySectionLateralId(section_, lateralID, companyId);

            int lateral_assetId = 0;
            if (assetSewerLateralGateway.Table.Rows.Count == 0)
            {
                // Insert Asset
                lateral_assetId = new Asset(new DataSet()).InsertDirect("Sewer", countryId, provinceId, countyId, cityId, deleted, companyId);
                new AssetSewer(new DataSet()).InsertDirect(lateral_assetId, "Lateral", deleted, companyId);
                assetSewerLateralGateway.Insert(lateral_assetId, section_, address, lateralID, latitudeAtSection, longitudeAtSection, latitudeAtPropertyLine, longitudeAtPropertyLine, state, size_, distanceFromUSMH, distanceFromDSMH, mapSize, deleted, companyId, connectionType);

                // Update Section
                // ... load section
                AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway();
                assetSewerSectionGateway.LoadByAssetId(section_, companyId);

                // ... get old values of section
                string sectionIdS = assetSewerSectionGateway.GetSectionId(section_);
                string streetS = assetSewerSectionGateway.GetStreet(section_);
                int? usmhIdS = assetSewerSectionGateway.GetUSMH(section_);
                int? dsmhIdS = assetSewerSectionGateway.GetDSMH(section_);
                string mapSizeS = assetSewerSectionGateway.GetMapSize(section_);
                string size_S = assetSewerSectionGateway.GetSize_(section_);
                string mapLengthS = assetSewerSectionGateway.GetMapSize(section_);
                string lengthS = assetSewerSectionGateway.GetLength(section_);
                int? lateralsS = assetSewerSectionGateway.GetLaterals(section_);
                int? liveLateralsS = assetSewerSectionGateway.GetLiveLaterals(section_);
                string flowDirectionS = assetSewerSectionGateway.GetFlowDirection(section_);
                string usmhDepthS = assetSewerSectionGateway.GetUSMHDepth(section_);
                string dsmhDepthS = assetSewerSectionGateway.GetDSMHDepth(section_);
                string flowOrderIdS = assetSewerSectionGateway.GetFlowOrderID(section_);

                // ... calculate new values of section
                int? newLaterals  = lateralsS;
                if (newLaterals.HasValue)
                {
                    newLaterals = newLaterals + 1;
                }
                else
                {
                    newLaterals = 1;
                }

                int? newLiveLaterals = liveLateralsS;
                if (state == "Live")
                {
                    if (newLiveLaterals.HasValue)
                    {
                        newLiveLaterals = newLiveLaterals + 1;
                    }
                    else
                    {
                        newLiveLaterals = 1;
                    }
                }
                else
                {
                    newLiveLaterals = 0;
                }

                // ... update section
                AssetSewerSection assetSewerSection = new AssetSewerSection(assetSewerSectionGateway.Data);
                assetSewerSection.UpdateDirect(section_, sectionIdS, streetS, usmhIdS, dsmhIdS, mapSizeS, size_S, mapLengthS, lengthS, lateralsS, liveLateralsS, flowDirectionS, usmhDepthS, dsmhDepthS, deleted, companyId, flowOrderIdS, section_, sectionIdS, streetS, usmhIdS, dsmhIdS, mapSizeS, size_S, mapLengthS, lengthS, newLaterals, newLiveLaterals, flowDirectionS, usmhDepthS, dsmhDepthS, deleted, companyId, flowOrderIdS);
            }
            else
            {
                lateral_assetId = assetSewerLateralGateway.GetAssetID(section_, lateralID);
            }

            return lateral_assetId;
        }
Exemplo n.º 9
0
        /// <summary>
        /// UpdateSection
        /// </summary>
        /// <param name="countryId">countryId</param>
        /// <param name="provinceId">provinceId</param>
        /// <param name="countyId">countyId</param>
        /// <param name="cityId">cityId</param>
        /// <param name="assetId">assetId</param>
        /// <param name="sectionId">sectionId</param>
        /// <param name="originalStreet">originalStreet</param>
        /// <param name="originalUsmh">originalUsmh</param>
        /// <param name="originalDsmh">originalDsmh</param>
        /// <param name="originalSize_">originalSize_</param>
        /// <param name="originalLength">originalLength</param>
        /// <param name="originalSubArea">originalSubArea</param>
        /// <param name="newStreet">newStreet</param>
        /// <param name="newUsmh">newUsmh</param>
        /// <param name="newDsmh">newDsmh</param>
        /// <param name="newSize_">newSize_</param>
        /// <param name="newLength">newLength</param>
        /// <param name="newSubArea">newSubArea</param>
        /// <param name="companyId">companyId</param>
        /// <param name="projectId">projectId</param>
        /// <param name="workId">workId</param>
        private void UpdateSection(Int64? countryId, Int64? provinceId, Int64? countyId, Int64? cityId, int assetId, string sectionId, string originalStreet, int? originalUsmh, int? originalDsmh, string originalSize_, string originalLength, string originalSubArea, string newStreet, int? newUsmh, int? newDsmh, string newSize_, string newLength, string newSubArea, int companyId, int projectId, int workId)
        {
            // Load data
            AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway();
            assetSewerSectionGateway.LoadByAssetId(assetId, companyId);

            LfsAssetSewerSectionGateway lfsAssetSewerSectionGateway = new LfsAssetSewerSectionGateway(assetSewerSectionGateway.Data);
            lfsAssetSewerSectionGateway.LoadByAssetId(assetId, companyId);

            // Get unchanged data
            // ... section
            string mapSize_ = assetSewerSectionGateway.GetMapSize(assetId);
            string mapLength = assetSewerSectionGateway.GetMapLength(assetId);
            int? laterals = assetSewerSectionGateway.GetLaterals(assetId);
            int? liveLaterals = assetSewerSectionGateway.GetLiveLaterals(assetId);
            string flowDirection = assetSewerSectionGateway.GetFlowDirection(assetId);
            string usmhDepth = assetSewerSectionGateway.GetUSMHDepth(assetId);
            string dsmhDepth = assetSewerSectionGateway.GetDSMHDepth(assetId);

            // ... lfs section
            string steelTapeTroughSewer = lfsAssetSewerSectionGateway.GetSteelTapeThroughSewer(assetId);
            string usmhMouth12 = lfsAssetSewerSectionGateway.GetUSMHMouth12(assetId);
            string usmhMouth1 = lfsAssetSewerSectionGateway.GetUSMHMouth1(assetId);
            string usmhMouth2 = lfsAssetSewerSectionGateway.GetUSMHMouth2(assetId);
            string usmhMouth3 = lfsAssetSewerSectionGateway.GetUSMHMouth3(assetId);
            string usmhMouth4 = lfsAssetSewerSectionGateway.GetUSMHMouth4(assetId);
            string usmhMouth5 = lfsAssetSewerSectionGateway.GetUSMHMouth5(assetId);
            string dsmhMouth12 = lfsAssetSewerSectionGateway.GetDSMHMouth12(assetId);
            string dsmhMouth1 = lfsAssetSewerSectionGateway.GetDSMHMouth1(assetId);
            string dsmhMouth2 = lfsAssetSewerSectionGateway.GetDSMHMouth2(assetId);
            string dsmhMouth3 = lfsAssetSewerSectionGateway.GetDSMHMouth3(assetId);
            string dsmhMouth4 = lfsAssetSewerSectionGateway.GetDSMHMouth4(assetId);
            string dsmhMouth5 = lfsAssetSewerSectionGateway.GetDSMHMouth5(assetId);
            string thickness = lfsAssetSewerSectionGateway.GetThickness(assetId);

            //Update Full Length Lining work
            if (originalLength != newLength)
            {
                steelTapeTroughSewer = newLength;
            }
            // Update
            LfsAssetSewerSection lfsAssetSewerSection = new LfsAssetSewerSection(null);
            lfsAssetSewerSection.UpdateDirect(assetId, sectionId, originalStreet, originalUsmh, originalDsmh, mapSize_, originalSize_, mapLength, originalLength, laterals, liveLaterals, flowDirection, usmhDepth, dsmhDepth, steelTapeTroughSewer, usmhMouth12, usmhMouth1, usmhMouth2, usmhMouth3, usmhMouth4, usmhMouth5, dsmhMouth12, dsmhMouth1, dsmhMouth2, dsmhMouth3, dsmhMouth4, dsmhMouth5, false, companyId, originalSubArea, thickness, assetId, sectionId, newStreet, newUsmh, newDsmh, mapSize_, newSize_, mapLength, newLength, laterals, liveLaterals, flowDirection, usmhDepth, dsmhDepth, steelTapeTroughSewer, usmhMouth12, usmhMouth1, usmhMouth2, usmhMouth3, usmhMouth4, usmhMouth5, dsmhMouth12, dsmhMouth1, dsmhMouth2, dsmhMouth3, dsmhMouth4, dsmhMouth5, false, companyId, newSubArea, thickness);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Save
        /// </summary>
        /// <param name="projectId">projectId</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>
        /// <param name="loginId">loginId</param>
        public void Save(int companyId, int loginId)
        {
            foreach (DataMigrationTDS.DataMigrationRow row in (DataMigrationTDS.DataMigrationDataTable)Table)
            {
                // Get ids & location
                ProjectGateway projectGateway = new ProjectGateway();
                DataMigrationProjectGateway dataMigrationProjectGateway = new DataMigrationProjectGateway(null);
                string name = string.Format("{0} Data Migration Project", row.Client);

                int projectId = dataMigrationProjectGateway.GetProjectIdByName(name);

                if (projectId != 0)
                {
                    projectGateway.LoadByProjectId(projectId);

                    // get parameters
                    Int64 countryId = projectGateway.GetCountryID(projectId);
                    Int64? provinceId = null; if (projectGateway.GetProvinceID(projectId).HasValue) provinceId = projectGateway.GetProvinceID(projectId);
                    Int64? countyId = null; if (projectGateway.GetCountyID(projectId).HasValue) countyId = projectGateway.GetCountyID(projectId);
                    Int64? cityId = null; if (projectGateway.GetCityID(projectId).HasValue) cityId = projectGateway.GetCityID(projectId);

                    //Save section
                    int section_assetId = SaveSection(row, projectId, countryId, provinceId, countyId, cityId, companyId);

                    if (row.RehabAssessment)
                    {
                        string raComments = "";
                        SaveRAWork(row, projectId, section_assetId, companyId, raComments, loginId);
                    }

                    if (row.FullLengthLining)
                    {
                        string fllComments = "";
                        SaveFLLWork(row, projectId, section_assetId, companyId, fllComments, loginId);
                    }

                    if (row.JLiner)
                    {
                        SaveJLWork(projectId, section_assetId, companyId);
                    }

                    // Insert in DataMigration Table
                    Guid originalId = row.OriginalID;
                    string originalSectionId = row.OriginalSectionID;
                    AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway();
                    assetSewerSectionGateway.LoadByAssetId(section_assetId, companyId);
                    string newSectionId = assetSewerSectionGateway.GetSectionId(section_assetId);

                    DataMigrationGateway dataMigrationGateway = new DataMigrationGateway(null);
                    dataMigrationGateway.InsertDataMigration(originalId, originalSectionId, section_assetId, newSectionId);
                }
            }
        }