/// <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>
        /// Update Lateral
        /// </summary>
        /// <param name="row">row</param>
        /// <param name="projectId">projectId</param>
        /// <param name="sectionAssetId">sectionAssetId</param>
        /// <param name="countryId">countryId</param>
        /// <param name="provinceId">provinceId</param>
        /// <param name="countyId">countyId</param>
        /// <param name="cityId">cityId</param>
        /// <param name="videoLength">videoLength</param>
        /// <param name="companyId">companyId</param>
        private void UpdateLateral(FullLengthLiningTDS.LateralDetailsRow row, int projectId, int sectionAssetId, Int64 countryId, Int64? provinceId, Int64? countyId, Int64? cityId, string videoLength, int companyId)
        {
            // not modified variables
            FullLengthLiningTDS fullLengthLining = (FullLengthLiningTDS)Data;
            FullLengthLiningLateralDetailsGateway fullLengthLiningLateralDetailsGateway = new FullLengthLiningLateralDetailsGateway(fullLengthLining);
            int lateral = row.Lateral;

            AssetSewerLateralGateway assetSewerLateralGateway = new AssetSewerLateralGateway();
            assetSewerLateralGateway.LoadByAssetId(lateral, companyId);

            int section_ = assetSewerLateralGateway.GetSection(lateral);
            string address = assetSewerLateralGateway.GetAddress(lateral);
            string lateralId = assetSewerLateralGateway.GetLateralId(lateral);
            string latitudeAtSection = assetSewerLateralGateway.GetLatitudeAtSection(lateral);
            string longitudeAtSection = assetSewerLateralGateway.GetLongitudeAtSection(lateral);
            string latitudeAtPropertyLine = assetSewerLateralGateway.GetLatitudeAtPropertyLine(lateral);
            string longitudeAtPropertyLine = assetSewerLateralGateway.GetLongitudeAtPropertyLine(lateral);
            string mapSize = assetSewerLateralGateway.GetMapSize(lateral);

            // original values
            string originalState = fullLengthLiningLateralDetailsGateway.GetLiveOriginal(lateral);
            string originalSize = fullLengthLiningLateralDetailsGateway.GetSizeOriginal(lateral);
            string originalDistanceFromUsmh = fullLengthLiningLateralDetailsGateway.GetDistanceFromUSMHOriginal(lateral);
            string originalDistanceFromDsmh = fullLengthLiningLateralDetailsGateway.GetDistanceFromDSMHOriginal(lateral);
            string originalConnectionType = fullLengthLiningLateralDetailsGateway.GetConnectionTypeOriginal(lateral);
            string originalAddress = fullLengthLiningLateralDetailsGateway.GetMnOriginal(lateral);

            // new values
            string newState = fullLengthLiningLateralDetailsGateway.GetLive(lateral);
            string newSize = fullLengthLiningLateralDetailsGateway.GetSize(lateral);
            string newDistanceFromUsmh = fullLengthLiningLateralDetailsGateway.GetDistanceFromUSMH(lateral);
            string newDistanceFromDsmh = fullLengthLiningLateralDetailsGateway.GetDistanceFromDSMH(lateral);
            string newConnectionType = fullLengthLiningLateralDetailsGateway.GetConnectionType(lateral);
            string newAddress = fullLengthLiningLateralDetailsGateway.GetMn(lateral);

            // update asset laterals
            AssetSewerLateral assetSewerLateral = new AssetSewerLateral(null);
            assetSewerLateral.UpdateDirect(lateral, section_, originalAddress, lateralId, latitudeAtSection, longitudeAtSection, latitudeAtPropertyLine, longitudeAtPropertyLine, originalState, originalSize, originalDistanceFromUsmh, originalDistanceFromDsmh, mapSize, false, companyId, originalConnectionType, lateral, section_, newAddress, lateralId, latitudeAtSection, longitudeAtSection, latitudeAtPropertyLine, longitudeAtPropertyLine, newState, newSize, newDistanceFromUsmh, newDistanceFromDsmh, mapSize, false, companyId, newConnectionType);
        }
Пример #3
0
        /// <summary>
        /// LateralUpdate
        /// </summary>
        /// <param name="currentProjectId">currentProjectId</param>
        /// <param name="assetId">assetId</param>
        /// <param name="distanceFromDsmh">distanceFromDsmh</param>
        /// <param name="distanceFromUsmh">distanceFromUsmh</param>
        /// <param name="mapSize">mapSize</param>
        /// <param name="companyId">companyId</param>
        /// <param name="clientLateralId">clientLateralId</param>
        /// <param name="address">address</param>
        /// <param name="connectionType">connectionType</param>
        private void LateralUpdate(int currentProjectId, int assetId, string distanceFromDsmh, string distanceFromUsmh, string mapSize, int companyId, string clientLateralId, string address, string connectionType)
        {
            AssetSewerLateralGateway assetSewerLateralGateway = new AssetSewerLateralGateway();
            assetSewerLateralGateway.LoadByAssetId(assetId, companyId);

            // original values
            int originalSection_ = assetSewerLateralGateway.GetSection(assetId);
            string originalAddress = assetSewerLateralGateway.GetAddress(assetId);
            string originalLateralId = assetSewerLateralGateway.GetLateralId(assetId);
            string originalLatitudeAtSection = assetSewerLateralGateway.GetLatitudeAtSection(assetId);
            string originalLongitudeAtSection = assetSewerLateralGateway.GetLongitudeAtSection(assetId);
            string originalLatitudeAtPropertyLine = assetSewerLateralGateway.GetLatitudeAtPropertyLine(assetId);
            string originalLongitudeAtPropertyLine = assetSewerLateralGateway.GetLongitudeAtPropertyLine(assetId);
            string originalState = assetSewerLateralGateway.GetState(assetId);
            string originalSize_ = assetSewerLateralGateway.GetSize(assetId);
            string originalDistanceFromUsmh = assetSewerLateralGateway.GetDistanceFromUSMH(assetId);
            string originalDistanceFromDsmh = assetSewerLateralGateway.GetDistanceFromDSMH(assetId);
            string originalMapSize = assetSewerLateralGateway.GetMapSize(assetId);
            bool originalDelete = assetSewerLateralGateway.GetDeleted(assetId);
            int originalCompanyId = assetSewerLateralGateway.GetCompanyId(assetId);
            string originalConnectionType = assetSewerLateralGateway.GetConnectionType(assetId);

            // new values
            string newAddress = address;
            string newDistanceFromUsmh = originalDistanceFromUsmh;
            string newDistanceFromDsmh = originalDistanceFromDsmh;
            string newMapSize = mapSize;
            string newConnectionType = connectionType;

            // Update Sewer lateral
            AssetSewerLateral assetSewerLateral = new AssetSewerLateral(null);
            assetSewerLateral.UpdateDirect(assetId, originalSection_, originalAddress, originalLateralId, originalLatitudeAtSection, originalLongitudeAtSection, originalLatitudeAtPropertyLine, originalLongitudeAtPropertyLine, originalState, originalSize_, originalDistanceFromUsmh, originalDistanceFromDsmh, originalMapSize, originalDelete, originalCompanyId, originalConnectionType, assetId, originalSection_, newAddress, originalLateralId, originalLatitudeAtSection, originalLongitudeAtSection, originalLatitudeAtPropertyLine, originalLongitudeAtPropertyLine, originalState, originalSize_, newDistanceFromUsmh, newDistanceFromDsmh, newMapSize, originalDelete, originalCompanyId, newConnectionType);

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

            LfsAssetSewerLateralClientGateway lfsAssetSewerLateralClientGateway = new LfsAssetSewerLateralClientGateway();
            lfsAssetSewerLateralClientGateway.LoadAllByAssetIdClientId(assetId, clientId, companyId);

            if (lfsAssetSewerLateralClientGateway.Table.Rows.Count == 0)
            {
                LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null);
                lfsAssetSewerLateralClient.InsertDirect(assetId, clientId, clientLateralId, false, companyId);
            }
            else
            {
                LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null);
                string originalClientLateralId = lfsAssetSewerLateralClientGateway.GetClientLateralId(assetId, clientId);
                string newClientLateralId = clientLateralId;

                lfsAssetSewerLateralClient.UpdateDirect(assetId, clientId, originalClientLateralId, false, companyId, assetId, clientId, newClientLateralId, false, companyId);
            }
        }