Exemple #1
0
        //WS: attached an instance of a class to element. If already exists, delete it and re-attach.
        private void AttachInstanceAndValues(BCOM.Element oEle, string strClassName, GeoTagDataBase oGeoTagData)
        {
            //WS: create an empty class instance.
            ECOI.IECInstance pInstance = oECAdaptor.CreateClassInstance(oECAdaptor.Schema, strClassName);

            //WS: populate instance values
            oECAdaptor.SetInstancePropertyValue(ref pInstance, "Tag_Number", oGeoTagData.Tag_Number);
            oECAdaptor.SetInstancePropertyValue(ref pInstance, "Tag_Status", oGeoTagData.Tag_Status);
            oECAdaptor.SetInstancePropertyValue(ref pInstance, "Location", oGeoTagData.Location);
            oECAdaptor.SetInstancePropertyValue(ref pInstance, "Service_Description", oGeoTagData.Service_Description);
            oECAdaptor.SetInstancePropertyValue(ref pInstance, "Type", oGeoTagData.Type);
            oECAdaptor.SetInstancePropertyValue(ref pInstance, "Plot_Plan_Document_Number", oGeoTagData.Plot_Plan_Document_Number);
            oECAdaptor.SetInstancePropertyValue(ref pInstance, "Detail_Drawing_Document_Number", oGeoTagData.Detail_Drawing_Document_Number);
            oECAdaptor.SetInstancePropertyValue(ref pInstance, "Construction_Month", oGeoTagData.Construction_Month);
            oECAdaptor.SetInstancePropertyValue(ref pInstance, "Construction_Year", oGeoTagData.Construction_Year);
            oECAdaptor.SetInstancePropertyValue(ref pInstance, "Originating_Contractor", oGeoTagData.Originating_Contractor);
            oECAdaptor.SetInstancePropertyValue(ref pInstance, "Document_Number", oGeoTagData.Document_Number);
            oECAdaptor.SetInstancePropertyValue(ref pInstance, "Material_Main", oGeoTagData.Material_Main);
            oECAdaptor.SetInstancePropertyValue(ref pInstance, "Procument_Package_Number", oGeoTagData.Procument_Package_Number);
            oECAdaptor.SetInstancePropertyValue(ref pInstance, "Contract_Package_Number", oGeoTagData.Contract_Package_Number);
            oECAdaptor.SetInstancePropertyValue(ref pInstance, "Construction_Contractor_Name", oGeoTagData.Construction_Contractor_Name);
            oECAdaptor.SetInstancePropertyValue(ref pInstance, "Construction_Specification_Document_Number", oGeoTagData.Construction_Specification_Document_Number);

            if (strClassName == "Pond")
            {
                oECAdaptor.SetInstancePropertyValue(ref pInstance, "Supplier_Name", (oGeoTagData as Pond).Supplier_Name);
                oECAdaptor.SetInstancePropertyValue(ref pInstance, "Supplier_Reference_Drawing_Doc_Number", (oGeoTagData as Pond).Supplier_Reference_Drawing_Doc_Number);
                oECAdaptor.SetInstancePropertyValue(ref pInstance, "Design_Capacity", (oGeoTagData as Pond).Design_Capacity);
                oECAdaptor.SetInstancePropertyValue(ref pInstance, "Fluid_Description", (oGeoTagData as Pond).Fluid_Description);
                oECAdaptor.SetInstancePropertyValue(ref pInstance, "Max_Fluid_Level", (oGeoTagData as Pond).Max_Fluid_Level);
            }

            if (strClassName == "Road")
            {
                oECAdaptor.SetInstancePropertyValue(ref pInstance, "Number_of_Lanes", (oGeoTagData as Road).Number_of_Lanes);
            }

            if (strClassName == "OpenChannel")
            {
                oECAdaptor.SetInstancePropertyValue(ref pInstance, "Fluid_Description", (oGeoTagData as OpenChannel).Fluid_Description);
            }

            //WS: check if an instance of the class already exists in the element.
            if (!oECAdaptor.HasECInstanceAttached(oEle, strClassName))
            {
                //WS: attach to element
                oECAdaptor.CreateInstance(oEle, ref pInstance);
            }
            else //WS: if already has instance attached, delete it first, and then create a new one.
            {
                //WS: update instance, need to modify..
                //oECAdaptor.UpdateInstance(oEle, ref pInstance);

                oECAdaptor.DeleteInstancesOnElement(oEle, strClassName);

                oECAdaptor.CreateInstance(oEle, ref pInstance);
            }
        }
Exemple #2
0
        private bool ApplyTagFromUI2Selection(string strFunctionCode)
        {
            bool retVal = false;

            try
            {
                GeoTagDataBase oGeoTagDataBase = null;

                string strClassName = Commons.MapFunctionCode2ClassName(strFunctionCode);

                if (strFunctionCode == "PND")
                {
                    oGeoTagDataBase = new Pond();
                }
                else if (strFunctionCode == "ROAD")
                {
                    oGeoTagDataBase = new Road();
                }
                else if (strFunctionCode == "CHN")
                {
                    oGeoTagDataBase = new OpenChannel();
                }
                else if (strFunctionCode == "EMB")
                {
                    oGeoTagDataBase = new Embankment();
                }
                else if (strFunctionCode == "DIKE")
                {
                    oGeoTagDataBase = new Dike();
                }
                else if (strFunctionCode == "RW")
                {
                    oGeoTagDataBase = new RetainWall();
                }

                oGeoTagDataBase.Tag_Number = this.lblTagValue.Text;

                oGeoTagDataBase.Tag_Status          = this.cmbTagStatus.Text;
                oGeoTagDataBase.Location            = this.txtLocation.Text;
                oGeoTagDataBase.Service_Description = this.txtSerDesc.Text;
                oGeoTagDataBase.Type = this.cmbType.Text;
                oGeoTagDataBase.Plot_Plan_Document_Number      = this.txtPlotPlan.Text;
                oGeoTagDataBase.Detail_Drawing_Document_Number = this.txtDetailDwg.Text;
                oGeoTagDataBase.Construction_Month             = this.dateTimePickerMon.Text;
                oGeoTagDataBase.Construction_Year            = this.dateTimePickerYear.Text;
                oGeoTagDataBase.Originating_Contractor       = this.txtOriContractor.Text;
                oGeoTagDataBase.Document_Number              = this.txtDocNo.Text;
                oGeoTagDataBase.Material_Main                = this.cmbMaterial.Text;
                oGeoTagDataBase.Procument_Package_Number     = this.txtProcumentPkg.Text;
                oGeoTagDataBase.Contract_Package_Number      = this.txtContractPkgNo.Text;
                oGeoTagDataBase.Construction_Contractor_Name = this.txtConstrContractor.Text;
                oGeoTagDataBase.Construction_Specification_Document_Number = this.txtConstrSpec.Text;

                if (oGeoTagDataBase is Pond)
                {
                    (oGeoTagDataBase as Pond).Supplier_Name     = this.txt17.Text;
                    (oGeoTagDataBase as Pond).Design_Capacity   = this.txt19.Text;
                    (oGeoTagDataBase as Pond).Fluid_Description = this.txt16.Text;
                    (oGeoTagDataBase as Pond).Max_Fluid_Level   = this.txt20.Text;
                    (oGeoTagDataBase as Pond).Supplier_Reference_Drawing_Doc_Number = this.txt18.Text;
                }

                if (oGeoTagDataBase is Road)
                {
                    (oGeoTagDataBase as Road).Number_of_Lanes = this.txt16.Text;
                }

                if (oGeoTagDataBase is OpenChannel)
                {
                    (oGeoTagDataBase as OpenChannel).Fluid_Description = this.txt16.Text;
                }

                BCOM.CellElement oCel = null;

                BCOM.ElementEnumerator oEnum = AddInMain.ComApp.ActiveModelReference.GetSelectedElements();

                BCOM.Element[] oEleSet = oEnum.BuildArrayFromContents();

                if (oEleSet.Length < 1)
                {
                    return(false);
                }

                //WS: if a tagged celll is selected.
                if (oEleSet.Length == 1)
                {
                    if (oEleSet[0].IsCellElement())
                    {
                        if (oEleSet[0].AsCellElement().Name == "Embankment" || oEleSet[0].AsCellElement().Name == "RetainWall" ||
                            oEleSet[0].AsCellElement().Name == "Pond" || oEleSet[0].AsCellElement().Name == "Road" ||
                            oEleSet[0].AsCellElement().Name == "OpenChannel" || oEleSet[0].AsCellElement().Name == "Dike")
                        {
                            oCel = oEleSet[0].AsCellElement();
                        }
                    }
                }
                else //WS: when more than 1 elements selected.
                {
                    oCel = GroupGeoTagCell(strClassName);
                }

                if (oCel == null)
                {
                    return(false);
                }

                AttachInstanceAndValues(oCel, strClassName, oGeoTagDataBase);

                retVal = true;
            }
            catch (Exception)
            {
                throw new Exception("Unexpected error:  GeoTag.ApplyTagFromUI2Selection");
            }

            return(retVal);
        }