Exemplo n.º 1
0
        /// <summary>
        /// Deep Clone
        /// </summary>
        /// <returns></returns>
        public IDSSubEquipment Copy()
        {
            IDSSubEquipment idsSubEquipment = MemberwiseClone() as IDSSubEquipment;

            // idsSubEquipment.MountingRepository = this.MountingRepository.Copy();
            idsSubEquipment.Cables         = this.Cables.Copy();
            idsSubEquipment.MountingScheme = this.MountingScheme.Copy();

            return(idsSubEquipment);
        }
Exemplo n.º 2
0
        public static IDSSubEquipment CreateIDSSubEquipment(DataRow rowIDSSubEquipment,
                                                            string equipmentTag,
                                                            string location,
                                                            DataTable tableIDSCable,
                                                            DataTable tableIDSMountingScheme)
        {
            if (rowIDSSubEquipment == null)
            {
                throw new System.ArgumentNullException("frome function CreateIDSSubEquipment", "Parameter rowIDSSubEquipment equals to null");
            }

            IDSSubEquipment subEquipment = new IDSSubEquipment();

            lock (rowIDSSubEquipment) {
                try {
                    subEquipment.ID       = Convert.ToString(rowIDSSubEquipment[TblIDSSubEquipment.ID]);
                    subEquipment.ParentID = Convert.ToString(rowIDSSubEquipment[TblIDSSubEquipment.ParentID]);

                    subEquipment.Tag = (rowIDSSubEquipment[TblIDSSubEquipment.Tag] as string);
                    if (IDSEnumWayToGenerateSymbol.AutoGenerate == subEquipment.Tag)
                    {
                        subEquipment.Tag = equipmentTag;
                    }

                    subEquipment.FunctionCode = (rowIDSSubEquipment[TblIDSSubEquipment.FunctionCode] as string).Trim();
                    subEquipment.Suffix       = (rowIDSSubEquipment[TblIDSSubEquipment.Suffix] as string).Trim();
                    subEquipment.NameSuffix   = (rowIDSSubEquipment[TblIDSSubEquipment.NameSuffix] as string).Trim();
                    subEquipment.MountingType = (rowIDSSubEquipment[TblIDSSubEquipment.MountingType] as string).Trim();

                    subEquipment.MountingLocation = (rowIDSSubEquipment[TblIDSSubEquipment.MountingLocation] as string).Trim();
                    if (IDSEnumLocationSymbol.On == subEquipment.MountingLocation)
                    {
                        subEquipment.MountingLocation = location;
                    }
                    else if (IDSEnumLocationSymbol.OnTheSide == subEquipment.MountingLocation)
                    {
                        subEquipment.MountingLocation = location + "旁";
                    }

                    subEquipment.DataPlate     = (rowIDSSubEquipment[TblIDSSubEquipment.DataPlate] as string).Trim();
                    subEquipment.PowerSupply   = (rowIDSSubEquipment[TblIDSSubEquipment.PowerSupply] as string).Trim();
                    subEquipment.SwitchTag     = (rowIDSSubEquipment[TblIDSSubEquipment.MountingLocation] as string).Trim();
                    subEquipment.ActingCurrent = (rowIDSSubEquipment[TblIDSSubEquipment.ActingCurrent] as string).Trim();

                    string mountingSchemeID = (rowIDSSubEquipment[TblIDSSubEquipment.MountingSchemeID] as string).Trim();

                    subEquipment.Cables.Clear();
                    lock (tableIDSCable) {
                        foreach (DataRow rowCable in tableIDSCable.Rows)
                        {
                            if (Convert.ToString(rowCable[TblIDSCable.ParentID]).Trim() == subEquipment.ID)
                            {
                                subEquipment.Cables.Add(CreateIDSCable(rowCable));
                            }
                        }
                    }

                    if (mountingSchemeID != null)
                    {
                        lock (tableIDSMountingScheme) {
                            foreach (DataRow rowMountingScheme in tableIDSMountingScheme.Rows)
                            {
                                if (Convert.ToString(rowMountingScheme[TblIDSMountingScheme.ParentID]).Trim() == subEquipment.ID)
                                {
                                    subEquipment.MountingScheme = CreateIDSMountingScheme(rowMountingScheme);
                                    break;
                                }
                            }
                        }
                    }
                }
                catch (System.Data.DataException ex) {
                    MessageBoxWinForm.Info("数据访问错误", ex.Message, "");
                }
            }

            return(subEquipment);
        }