/// <summary> /// Deep Clone /// </summary> /// <returns></returns> public EQASubSystem Copy() { EQASubSystem subSystem = MemberwiseClone() as EQASubSystem; subSystem.Loops = this.Loops.Copy(); return(subSystem); }
/// <summary> /// 从SYS表的数据行和Cable表, Loop表, Eqp表生成子系统类的实例 /// </summary> /// <param name="rowEQASubSystem"></param> /// <param name="tableEQACable"></param> /// <param name="tableEQALoop"></param> /// <param name="tableEQAEquipment"></param> /// <returns></returns> public static EQASubSystem CreateEQASubSystem(DataRow rowEQASubSystem, DataTable tableEQACable, DataTable tableEQALoop, DataTable tableEQAEquipment) { if (rowEQASubSystem == null) { throw new System.ArgumentNullException("from function CreateEQASubSystem", "Parameter rowEQASubSystem equals to null"); } if (tableEQACable == null) { throw new System.ArgumentNullException("from function CreateEQASubSystem", "Parameter tableEQACable equals to null"); } if (tableEQALoop == null) { throw new System.ArgumentNullException("from function CreateEQASubSystem", "Parameter tableEQALoop equals to null"); } if (tableEQAEquipment == null) { throw new System.ArgumentNullException("from function CreateEQASubSystem", "Parameter tableEQAEquipment equals to null"); } EQASubSystem subSystem = new EQASubSystem(); lock (rowEQASubSystem) { try { subSystem.SubSystemID = (rowEQASubSystem[TblSys.ID] as string).Trim(); subSystem.Name = (rowEQASubSystem[TblSys.NAME] as string).Trim(); lock (tableEQALoop) { lock (tableEQAEquipment) { foreach (DataRow rowLoop in tableEQALoop.Rows) { if ((rowLoop[TblLoop.SYS_ID] as string).Trim() == subSystem.SubSystemID) { subSystem.Loops.Add(CreateEQALoop(rowLoop, tableEQAEquipment)); } } } } lock (tableEQACable) { foreach (DataRow rowCable in tableEQACable.Rows) { if ((rowCable[TblCbl.SYS] as string).Trim() == subSystem.SubSystemID) { subSystem.Cables.Add(CreateEQACable(rowCable)); } } } } catch (DataException ex) { MessageBoxWinForm.Info("数据访问错误", ex.Message, ""); } } return(subSystem); }