Esempio n. 1
0
 public static bool DelCable(CableInfo cable)
 {
     TmpCables.Remove(cable);
     TmpCircuits.RemoveAll(circuit => circuit.ParentCableId == cable.CableId);
     TmpDots.RemoveAll(dot => dot.ParentCableId == cable.CableId);
     return(true);
 }
Esempio n. 2
0
        public static bool CopyCable(CableInfo cable, string username)
        {
            var newCbale = new CableInfo(cable)
            {
                CableName  = cable.CableName + " 副本",
                CreateUser = username,
                ModifyDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
            };

            TmpCables.Add(newCbale);

            var circuits = TmpCircuits.Where(circuit => circuit.ParentCableId == cable.CableId).ToList();

            foreach (var srcCircuit in circuits)
            {
                var circuit = new CircuitInfo(srcCircuit)
                {
                    ParentCableId = newCbale.CableId,
                };
                TmpCircuits.Add(circuit);
            }

            var dots = TmpDots.Where(dot => dot.ParentCableId == cable.CableId).ToList();

            foreach (var srcDot in dots)
            {
                var dot = new DotInfo(srcDot)
                {
                    ParentCableId = newCbale.CableId
                };
                TmpDots.Add(dot);
            }
            return(true);
        }
Esempio n. 3
0
 public static int GetMaxDotId(CableInfo cable)
 {
     if (TmpDots == null || TmpDots.Count <= 0)
     {
         return(0);
     }
     return(TmpDots.Where(dot => dot.ParentCableId == cable.CableId).Max(x => x.DotId));
 }
Esempio n. 4
0
 public static int GetMaxCircuitId(CableInfo cable)
 {
     if (TmpCircuits == null || TmpCircuits.Count <= 0)
     {
         return(0);
     }
     return(TmpCircuits.Where(circuit => circuit.ParentCableId == cable.CableId).Max(x => x.CircuitId));
 }
Esempio n. 5
0
 public static bool IsCableNameExist(CableInfo cmpCable, string cableName, out bool isCableNameExist)
 {
     if (TmpCables.Any(cable => cable.CableName == cableName.Trim() && cable != cmpCable))
     {
         isCableNameExist = true;
         return(true);
     }
     isCableNameExist = false;
     return(true);
 }
Esempio n. 6
0
        public static bool AddCable(CableInfo cable)
        {
            TmpCables.Add(cable);
            var circuitInfo = new CircuitInfo
            {
                ParentCableId = cable.CableId,
                CircuitId     = 0,
                Name          = "空点"
            };

            AddCircuit(circuitInfo);
            return(true);
        }
Esempio n. 7
0
 public CableInfo(CableInfo cable)
 {
     CableId    = CacheGraph.GetMaxCableId() + 1;
     CableName  = cable.CableName;
     Remark     = cable.Remark;
     ModifyDate = cable.ModifyDate;
     CreateUser = cable.CreateUser;
     BgImgPath  = cable.BgImgPath;
     Settings   = new CheckSetting
     {
         AutoStart     = cable.Settings.AutoStart,
         OkAutoRelease = cable.Settings.OkAutoRelease,
         NgAutoRelease = cable.Settings.NgAutoRelease,
         OkTime        = cable.Settings.OkTime,
         NgTime        = cable.Settings.NgTime
     };
 }
Esempio n. 8
0
        public static bool SelectCables(out List <CableInfo> cablesInfos)
        {
            const string querySql = "SELECT id,product_name,remark,create_date,create_user,graph_path,auto_start,ok_auto_release,ng_auto_release,ng_time,ok_time FROM sample_info";
            DataTable    dt;

            cablesInfos = new List <CableInfo>();

            if (!QueryData(querySql, out dt))
            {
                return(false);
            }

            for (var i = 0; i < dt.Rows.Count; i++)
            {
                var tmpCableInfo = new CableInfo
                {
                    CableId    = Convert.ToInt32(dt.Rows[i][0].ToString()),
                    CableName  = dt.Rows[i][1].ToString(),
                    Remark     = dt.Rows[i][2].ToString(),
                    ModifyDate = dt.Rows[i][3].ToString(),
                    CreateUser = dt.Rows[i][4].ToString(),
                    BgImgPath  = dt.Rows[i][5].ToString(),
                    Settings   = new CheckSetting
                    {
                        AutoStart     = Convert.ToBoolean(dt.Rows[i][6]),
                        OkAutoRelease = Convert.ToBoolean(dt.Rows[i][7]),
                        NgAutoRelease = Convert.ToBoolean(dt.Rows[i][8]),

                        NgTime = Convert.ToInt32(dt.Rows[i][9].ToString()),
                        OkTime = Convert.ToInt32(dt.Rows[i][10].ToString())
                    }
                };

                cablesInfos.Add(tmpCableInfo);
            }
            return(true);
        }