Exemplo n.º 1
0
        public void GetWatchHouseState(int GangTingID, ref bool GangTingState,
                                       ref bool DianYuanState, ref bool LedState)
        {
            WatchHouseInfo          vResult = new WatchHouseInfo();
            WatchHouseConfigEFModel vWatchHouseConfigEFModel = new WatchHouseConfigEFModel()
            {
                GangTingID = GangTingID
            };

            WatchHouseConfigEFModel[] vSelectResult = m_BasicDBClassSelect.SelectRecordsEx(vWatchHouseConfigEFModel);
            if (vSelectResult != null && vSelectResult.Length > 0)
            {
                if (vSelectResult[0].GangTingTXSJ != null &&
                    (DateTime.Now - vSelectResult[0].GangTingTXSJ.Value).TotalSeconds < m_OfflineTime)
                {
                    GangTingState = true;
                }
                if (vSelectResult[0].DianYuanTXSJ != null &&
                    (DateTime.Now - vSelectResult[0].DianYuanTXSJ.Value).TotalSeconds < m_OfflineTime)
                {
                    DianYuanState = true;
                }
                if ((vSelectResult[0].GuanGao1TXSJ != null &&
                     (DateTime.Now - vSelectResult[0].GuanGao1TXSJ.Value).TotalSeconds < m_OfflineTime) ||
                    (vSelectResult[0].GuanGao2TXSJ != null &&
                     (DateTime.Now - vSelectResult[0].GuanGao2TXSJ.Value).TotalSeconds < m_OfflineTime))
                {
                    LedState = true;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取当前工作的工号信息
        /// </summary>
        /// <param name="GangTingID"></param>
        /// <returns></returns>
        public GongHaoPaiInfo GetGongHaoPaiInfo(int GangTingID)
        {
            GongHaoPaiInfo          vResult = new GongHaoPaiInfo();
            WatchHouseConfigEFModel vWatchHouseConfigEFModel = new WatchHouseConfigEFModel()
            {
                GangTingID = GangTingID
            };
            WatchHouseConfigEFModel vSelectResult = m_BasicDBClassSelect.SelectRecordsEx(vWatchHouseConfigEFModel).FirstOrDefault();

            if (vSelectResult.GongHao != null)
            {
                EmployeeEFModel vEmployeeEFModel = new EmployeeEFModel()
                {
                    GongHao = vSelectResult.GongHao
                };
                EmployeeEFModel vSelectResult1 = m_BasicDBClassSelect.SelectRecordsEx(vEmployeeEFModel).FirstOrDefault();
                if (vSelectResult1.XingMing != null)
                {
                    vResult = new GongHaoPaiInfo()
                    {
                        XinMing = vSelectResult1.XingMing,
                        GeYan   = vSelectResult1.GeYan,
                        XingJi  = vSelectResult1.XingJi,
                        GonHao  = vSelectResult1.GongHao.Value
                    };
                }
            }
            return(vResult);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 更新电源最后通讯时间
 /// </summary>
 /// <param name="dianYuanID"></param>
 void updateTongXunSJ(int dianYuanID)
 {
     WatchHouseConfigEFModel vWatchHouseConfigEFModel = new WatchHouseConfigEFModel()
     {
         DianYuanTXSJ = DateTime.Now,
         DianYuan1ID  = "11" //测试数据
     };
 }
Exemplo n.º 4
0
        void getLEDInfo(int watchHouseID, ref string ipAddress, ref int width, ref int height)
        {
            WatchHouseConfigEFModel vWatchHouseConfigEFModel = new WatchHouseConfigEFModel()
            {
                GangTingID = watchHouseID
            };

            WatchHouseConfigEFModel[] vSelectResult = m_BasicDBClass.SelectRecordsEx(vWatchHouseConfigEFModel);
            if (vSelectResult != null && vSelectResult.Length > 0)
            {
                ipAddress = vSelectResult[0].GuanGaoPing1IP;
                width     = vSelectResult[0].GuanGao1Kuang ?? 0;
                height    = vSelectResult[0].GuanGao1Gao ?? 0;
            }
        }
Exemplo n.º 5
0
        Task pingLed()
        {
            return(Task.Run(() =>
            {
                while (m_IsRun)
                {
                    foreach (WatchHouseConfigEFModel vTempHouse in m_LedInfoList)
                    {
                        if (vTempHouse.GuanGaoPing1IP != null && vTempHouse.GuanGaoPing1IP != "")
                        {
                            if (ping(vTempHouse.GuanGaoPing1IP))
                            {
                                WatchHouseConfigEFModel vEFModel = new WatchHouseConfigEFModel()
                                {
                                    ID = vTempHouse.ID,
                                    GuanGao1TXSJ = DateTime.Now
                                };
                                m_BasicDBClass_Send.UpdateRecord(vEFModel);
                            }
                        }

                        if (vTempHouse.GuanGaoPing2IP != null && vTempHouse.GuanGaoPing2IP != "")
                        {
                            if (ping(vTempHouse.GuanGaoPing2IP))
                            {
                                WatchHouseConfigEFModel vEFModel = new WatchHouseConfigEFModel()
                                {
                                    ID = vTempHouse.ID,
                                    GuanGao2TXSJ = DateTime.Now
                                };
                                m_BasicDBClass_Send.UpdateRecord(vEFModel);
                            }
                        }
                    }
                    Thread.Sleep(60000);//间隔时间1分钟
                }
            }));
        }
Exemplo n.º 6
0
        void processorData_RunningStatus(PowerDataPack_Receive_RunningStatus vData, string IPAddress)
        {
            try
            {
                PowerDataEFModel vModel = new PowerDataEFModel()
                {
                    DianLiu      = BitConverter.ToInt16(new byte[] { vData.DianLiu2, vData.DianLiu1 }, 0),
                    DianYa       = BitConverter.ToInt16(new byte[] { vData.DianYa2, vData.DianYa1 }, 0),
                    DianNeng     = BitConverter.ToInt32(new byte[] { vData.DianNeng4, vData.DianNeng3, vData.DianNeng2, vData.DianNeng1 }, 0),
                    GongLuYinShu = BitConverter.ToInt16(new byte[] { vData.GongLuYS2, vData.GongLuYS1 }, 0),
                    LouDianLiu   = BitConverter.ToInt16(new byte[] { vData.LouDianLiu2, vData.LouDianLiu1 }, 0),
                    LuHao        = vData.LuHao,
                    PinLu        = BitConverter.ToInt16(new byte[] { vData.PinLu2, vData.PinLu1 }, 0),
                    WenDu        = BitConverter.ToInt16(new byte[] { vData.WenDu2, vData.WenDu1 }, 0),
                    WuGongGL     = BitConverter.ToInt16(new byte[] { vData.WuGongGL2, vData.WuGongGL1 }, 0),
                    YouGongGL    = BitConverter.ToInt16(new byte[] { vData.YouGongGL2, vData.YouGongGL1 }, 0),
                    LeiXing      = convertSwitchLeiXing(vData.LeiXing),
                    DianYuanID   = BitConverter.ToString(new byte[] { vData.MAC1, vData.MAC2, vData.MAC3, vData.MAC4, vData.MAC5, vData.MAC6 }),
                    ZhuanTai     = convertSwitchState(vData.SwitchState),
                    Time         = DateTime.Now
                };
                switch (vData.SwitchState)
                {
                //开
                case 129:    //正常
                case 131:    //应急
                    vModel.ZhuanTai = "开";
                    break;

                //关
                case 128:    //正常
                case 130:    //应急
                    vModel.ZhuanTai = "关";
                    break;
                }

                WatchHouseConfigEFModel vWatchHouseConfigEFModel = new WatchHouseConfigEFModel()
                {
                    DianYuanTXSJ = DateTime.Now,
                    DianYuan1IP  = IPAddress
                };
                m_BasicDBClass_Receive.TransactionBegin();
                int  vID     = m_BasicDBClass_Receive.InsertRecord(vModel);
                bool vResult = m_BasicDBClass_Receive.UpdateRecord(vWatchHouseConfigEFModel, string.Format("DianYuan1ID='{0}' ", vModel.DianYuanID));
                if (!vResult)
                {
                    vWatchHouseConfigEFModel = new WatchHouseConfigEFModel()
                    {
                        DianYuanTXSJ = DateTime.Now,
                        DianYuan2IP  = IPAddress
                    };
                    m_BasicDBClass_Receive.UpdateRecord(vWatchHouseConfigEFModel, string.Format("DianYuan2ID='{0}' ", vModel.DianYuanID));
                }
                m_BasicDBClass_Receive.TransactionCommit();
                //更新客户端字典表
                if (m_ClientDict.ContainsKey(vModel.DianYuanID))
                {
                    m_ClientDict[vModel.DianYuanID] = IPAddress;
                }
                //更新客户端最大ID字段
                if (m_ClientMaxID.ContainsKey(vModel.DianYuanID))
                {
                    m_ClientMaxID[vModel.DianYuanID] = vID;
                }
            }
            catch (Exception ex)
            {
                string vOutInfo = string.Format("插入数据至[电源数据表]中发生异常,异常信息为:{0}", ex.Message);
                Console.WriteLine(vOutInfo);
                LogHelper.WriteLog_Error(typeof(PowerControl), vOutInfo);
            }
        }
Exemplo n.º 7
0
        public bool Update(int ID, int GanTingID, string GanTingMC, string GanTingLX,
                           string Led1IP, int LED1Gao, int LED1Kuan, string Led2IP, int Led2Gao, int Led2Kuan,
                           string DianYuanID1, string DianYuanID2,
                           DataTable SwitchInfoTable1, DataTable SwitchInfoTable2,
                           ref string OutInfo)
        {
            bool vResult = false;
            WatchHouseConfigEFModel vSelectRecord = m_BasicDBClass.SelectRecordByPrimaryKeyEx <WatchHouseConfigEFModel>(ID);
            string vOldDianYuanID1 = vSelectRecord.DianYuan1ID;
            string vOldDianYuanID2 = vSelectRecord.DianYuan2ID;

            WatchHouseConfigEFModel vWatchHouseConfigEFModel = new WatchHouseConfigEFModel()
            {
                GangTingID = GanTingID,
                GangTingMC = GanTingMC,
                GangTingLX = GanTingLX,

                GuanGaoPing1IP = Led1IP,
                GuanGao1Gao    = LED1Gao,
                GuanGao1Kuang  = LED1Kuan,

                GuanGaoPing2IP = Led2IP,
                GuanGao2Gao    = Led2Gao,
                GuanGao2Kuang  = Led2Kuan,

                DianYuan1ID = DianYuanID1,
                DianYuan2ID = DianYuanID2,
                ID          = ID,
                OrderID     = convertWatchHouseLXToOrderID(GanTingLX)
            };

            m_BasicDBClass.TransactionBegin();
            if (vResult = m_BasicDBClass.UpdateRecord(vWatchHouseConfigEFModel))
            {
                if (DianYuanID1 != vOldDianYuanID1)
                {
                    m_BasicDBClass.DeleteRecordCustom <PowerSwithConfigEFModel>(string.Format("DianYuanID='{0}'", vOldDianYuanID1));
                    if (SwitchInfoTable1 != null)
                    {
                        foreach (DataRow vTempSwitch in SwitchInfoTable1.Rows)
                        {
                            PowerSwithConfigEFModel vModel = new PowerSwithConfigEFModel();
                            vModel.DianYuanID = DianYuanID1;
                            CommClass.ConvertDataRowToStruct(ref vModel, vTempSwitch);
                            vResult = m_BasicDBClass.InsertRecord(vModel) > 0 ? true : false;

                            if (!vResult)
                            {
                                m_BasicDBClass.TransactionRollback();
                                break;
                            }
                        }
                    }
                }
                else if (SwitchInfoTable1 != null)
                {
                    foreach (DataRow vTempSwitch in SwitchInfoTable1.Rows)
                    {
                        PowerSwithConfigEFModel vModel = new PowerSwithConfigEFModel();
                        vModel.DianYuanID = DianYuanID1;

                        switch (vTempSwitch.RowState)
                        {
                        case DataRowState.Added:
                            CommClass.ConvertDataRowToStruct(ref vModel, vTempSwitch);
                            vResult = m_BasicDBClass.InsertRecord(vModel) > 0 ? true : false;
                            break;

                        case DataRowState.Deleted:
                            vTempSwitch.RejectChanges();
                            int vID = (int)vTempSwitch["ID"];
                            vResult = m_BasicDBClass.DeleteRecordByPrimaryKey <PowerSwithConfigEFModel>(vID);
                            vTempSwitch.Delete();
                            break;

                        case DataRowState.Modified:
                            CommClass.ConvertDataRowToStruct(ref vModel, vTempSwitch);
                            vResult = m_BasicDBClass.UpdateRecord(vModel);
                            break;
                        }
                        if (!vResult)
                        {
                            m_BasicDBClass.TransactionRollback();
                            break;
                        }
                    }
                }



                if (DianYuanID2 != vOldDianYuanID2)
                {
                    m_BasicDBClass.DeleteRecordCustom <PowerSwithConfigEFModel>(string.Format("DianYuanID='{0}'", vOldDianYuanID2));
                    foreach (DataRow vTempSwitch in SwitchInfoTable2.Rows)
                    {
                        PowerSwithConfigEFModel vModel = new PowerSwithConfigEFModel();
                        vModel.DianYuanID = DianYuanID1;
                        CommClass.ConvertDataRowToStruct(ref vModel, vTempSwitch);
                        vResult = m_BasicDBClass.InsertRecord(vModel) > 0 ? true : false;
                        if (!vResult)
                        {
                            m_BasicDBClass.TransactionRollback();
                            break;
                        }
                    }
                }
                else if (SwitchInfoTable2 != null)
                {
                    foreach (DataRow vTempSwitch in SwitchInfoTable2.Rows)
                    {
                        PowerSwithConfigEFModel vModel = new PowerSwithConfigEFModel();
                        vModel.DianYuanID = DianYuanID1;
                        CommClass.ConvertDataRowToStruct(ref vModel, vTempSwitch);
                        switch (vTempSwitch.RowState)
                        {
                        case DataRowState.Added:
                            vResult = m_BasicDBClass.InsertRecord(vModel) > 0 ? true : false;
                            break;

                        case DataRowState.Deleted:
                            vResult = m_BasicDBClass.DeleteRecordByPrimaryKey <PowerSwithConfigEFModel>(vModel.ID);
                            break;

                        case DataRowState.Modified:
                            vResult = m_BasicDBClass.UpdateRecord(vModel);
                            break;
                        }
                        if (!vResult)
                        {
                            m_BasicDBClass.TransactionRollback();
                            break;
                        }
                    }
                }

                if (vResult)
                {
                    m_BasicDBClass.TransactionCommit();
                    if (SwitchInfoTable1 != null)
                    {
                        SwitchInfoTable1.AcceptChanges();
                    }
                    if (SwitchInfoTable2 != null)
                    {
                        SwitchInfoTable2.AcceptChanges();
                    }
                }
                else
                {
                    OutInfo = "修改岗亭数据失败";
                }
            }
            return(vResult);
        }
Exemplo n.º 8
0
        public bool Add(int GanTingID, string GanTingMC, string GanTingLX,
                        string Led1IP, int LED1Gao, int LED1Kuan, string Led2IP, int LED2Gao, int LED2Kuan,
                        string DianYuanID1, string DianYuanID2, DataTable SwitchInfoTable1, DataTable SwitchInfoTable2,
                        ref string OutInfo)
        {
            bool vResult = false;

            if (!findGanTing(GanTingID, DianYuanID1))
            {
                m_BasicDBClass.TransactionBegin();
                WatchHouseConfigEFModel vWatchHouseConfigEFModel = new WatchHouseConfigEFModel()
                {
                    GangTingID = GanTingID,
                    GangTingMC = GanTingMC,
                    GangTingLX = GanTingLX,

                    GuanGaoPing1IP = Led1IP,
                    GuanGao1Gao    = LED1Gao,
                    GuanGao1Kuang  = LED1Kuan,

                    GuanGaoPing2IP = Led2IP,
                    GuanGao2Gao    = LED2Gao,
                    GuanGao2Kuang  = LED2Kuan,

                    DianYuan1ID    = DianYuanID1,
                    DianYuan2ID    = DianYuanID2,
                    ShouFeiZhangID = 1,
                    OrderID        = convertWatchHouseLXToOrderID(GanTingLX)
                };
                vResult = m_BasicDBClass.InsertRecord(vWatchHouseConfigEFModel) > 0;
                //开关1
                if (vResult && SwitchInfoTable1 != null)
                {
                    foreach (DataRow vTempSwitch in SwitchInfoTable1.Rows)
                    {
                        PowerSwithConfigEFModel vModel = new PowerSwithConfigEFModel();
                        vModel.DianYuanID = DianYuanID1;
                        CommClass.ConvertDataRowToStruct(ref vModel, vTempSwitch);
                        switch (vTempSwitch.RowState)
                        {
                        case DataRowState.Added:
                            vResult = m_BasicDBClass.InsertRecord(vModel) > 0 ? true : false;
                            break;

                        case DataRowState.Deleted:
                            vResult = m_BasicDBClass.DeleteRecordByPrimaryKey <PowerSwithConfigEFModel>(vModel.ID);
                            break;

                        case DataRowState.Modified:
                            vResult = m_BasicDBClass.UpdateRecord(vModel);
                            break;
                        }
                        if (!vResult)
                        {
                            break;
                        }
                    }
                }
                //开关2
                if (vResult && SwitchInfoTable2 != null)
                {
                    foreach (DataRow vTempSwitch in SwitchInfoTable2.Rows)
                    {
                        PowerSwithConfigEFModel vModel = new PowerSwithConfigEFModel();
                        vModel.DianYuanID = DianYuanID1;
                        CommClass.ConvertDataRowToStruct(ref vModel, vTempSwitch);
                        switch (vTempSwitch.RowState)
                        {
                        case DataRowState.Added:
                            vResult = m_BasicDBClass.InsertRecord(vModel) > 0 ? true : false;
                            break;

                        case DataRowState.Deleted:
                            vResult = m_BasicDBClass.DeleteRecordByPrimaryKey <PowerSwithConfigEFModel>(vModel.ID);
                            break;

                        case DataRowState.Modified:
                            vResult = m_BasicDBClass.UpdateRecord(vModel);
                            break;
                        }
                        if (!vResult)
                        {
                            break;
                        }
                    }
                }

                if (vResult)
                {
                    m_BasicDBClass.TransactionCommit();
                    if (SwitchInfoTable1 != null)
                    {
                        SwitchInfoTable1.AcceptChanges();
                    }
                }
                else
                {
                    m_BasicDBClass.TransactionRollback();
                    OutInfo = "增加岗亭数据失败";
                }
            }
            else
            {
                OutInfo = "存在相同编号的岗亭或者电源";
            }
            return(vResult);
        }