コード例 #1
0
        /// <summary>
        /// Deep Clone
        /// </summary>
        /// <returns></returns>
        public IDSEquipment Copy()
        {
            IDSEquipment equipment = MemberwiseClone() as IDSEquipment;

            equipment.EquipmentRepository = this.EquipmentRepository.Copy();
            equipment.SubEquipments       = this.SubEquipments.Copy();

            return(equipment);
        }
コード例 #2
0
        /// <summary>
        /// 构造函数, 初始化成员属性为默认值
        /// </summary>
        public IDSSubEquipment(IDSEquipment equipment)
        {
            ID                       = "";
            ParentID                 = "";
            _equipment               = equipment;
            OriginalTag              = "";
            FunctionCode             = "";
            Suffix                   = "";
            NameSuffix               = "";
            OriginalMountingType     = "";
            OriginalMountingLocation = "";
            DataPlate                = "";
            PowerSupply              = "";
            SwitchTag                = "";
            ActingCurrent            = "";

            _cables         = new IDSCableCollection();
            _mountingScheme = new IDSMountingScheme();
        }
コード例 #3
0
        public static IDSEquipment CreateIDSEquipment(DataRow rowIDSEquipment,
                                                      string subLoopCode,
                                                      string loopType,
                                                      string loopSerialNumber,
                                                      string loopSuffix,
                                                      string subSystemCode,
                                                      string systemCode,
                                                      string location,
                                                      DataTable tableSubEquipment,
                                                      DataTable tableRepositories,
                                                      DataTable tableCable,
                                                      DataTable tableMountingScheme)
        {
            if (rowIDSEquipment == null)
            {
                throw new System.ArgumentNullException("frome function CreateIDSEquipment", "Parameter rowIDSEquipment equals to null");
            }

            IDSEquipment equipment = new IDSEquipment();

            lock (rowIDSEquipment) {
                try {
                    equipment.ID       = Convert.ToString(rowIDSEquipment[TblIDSEquipment.ID]).Trim();
                    equipment.ParentID = Convert.ToString(rowIDSEquipment[TblIDSEquipment.ParentID]).Trim();

                    equipment.FunctionCode = (rowIDSEquipment[TblIDSEquipment.Function] as string).Trim();

                    equipment.Tag    = (rowIDSEquipment[TblIDSEquipment.Tag] as string).Trim();
                    equipment.Suffix = (rowIDSEquipment[TblIDSEquipment.Suffix] as string).Trim();
                    if (IDSEnumWayToGenerateSymbol.AutoGenerate == equipment.Tag)
                    {
                        equipment.Tag = systemCode + "." + loopType + equipment.FunctionCode + "-" + subSystemCode + loopSerialNumber + loopSuffix + subLoopCode + equipment.Suffix;
                    }

                    equipment.EquipmentCatagory = (rowIDSEquipment[TblIDSEquipment.EquipmentCatagory] as string).Trim();
                    equipment.SpecificInfo1     = (rowIDSEquipment[TblIDSEquipment.SpecificeInfo1] as string).Trim();
                    equipment.SpecificInfo2     = (rowIDSEquipment[TblIDSEquipment.SpecificeInfo2] as string).Trim();
                    equipment.Quantity          = Convert.ToInt32(rowIDSEquipment[TblIDSEquipment.Quantity]);
                    equipment.Remark            = (rowIDSEquipment[TblIDSEquipment.Remark] as string).Trim();

                    string repositoryName = Convert.ToString(rowIDSEquipment[TblIDSEquipment.EquipmentRepositoryID]).Trim();

                    if (repositoryName != null && repositoryName != "")
                    {
                        lock (tableRepositories) {
                            foreach (DataRow rowRepository in tableRepositories.Rows)
                            {
                                if (Convert.ToString(rowRepository[TblIDSRepository.RepositoryID]) == repositoryName)
                                {
                                    equipment.EquipmentRepository = CreateIDSRepository(rowRepository);
                                    break;
                                }
                            }
                        }
                    }

                    equipment.SubEquipments.Clear();
                    lock (tableSubEquipment) {
                        foreach (DataRow rowSubEquipment in tableSubEquipment.Rows)
                        {
                            if (Convert.ToString(rowSubEquipment[TblIDSSubEquipment.ParentID]).Trim() == equipment.ID)
                            {
                                equipment.SubEquipments.Add(CreateIDSSubEquipment(rowSubEquipment,
                                                                                  equipment.Tag,
                                                                                  location,
                                                                                  tableCable,
                                                                                  tableMountingScheme));
                            }
                        }
                    }
                }
                catch (System.Data.DataException ex) {
                    MessageBoxWinForm.Info("数据访问错误", ex.Message, "");
                }
            }

            return(equipment);
        }