Beispiel #1
0
 private void barLargeButtonItem3_ItemClick(object sender, ItemClickEventArgs e)
 {
     if (((this.SwitchModuleSM == null) && (ServerSystemInfo.SerialComInfoList != null)) && (ServerSystemInfo.SerialComInfoList.Count != 0))
     {
         SerialComConfig config = (from t in ServerSystemInfo.SerialComInfoList
                                   where t.SerialComType == 1
                                   select t).FirstOrDefault <SerialComConfig>();
         if (config != null)
         {
             this.SwitchModuleSM = new SysManager(config.SerialComInfo.Key, config.SerialComInfo.Value);
         }
     }
     if (ServerSystemInfo.ModuleId == ServerSystemInfo.SoftModuleId)
     {
         CMessageInfo.ShowMessage("该模块已连接!", "模块切换", 1);
         if ((this.client != null) && (this.buffer != null))
         {
             PaidComm.SendBack(this.client, this.buffer, 0);
         }
     }
     else if (CheckInfo.PcCheckState)
     {
         CMessageInfo.ShowMessage("学生机考核进行中,无法操作!", "模块切换", 1);
     }
     else if (CheckInfo.PaidCheckState)
     {
         CMessageInfo.ShowMessage("平板用户考核进行中,无法操作!", "模块切换", 1);
     }
     else
     {
         string msg = string.Empty;
         if (this.SwitchModuleSM.ConnectModule(int.Parse(this._dr["Id"].ToString())))
         {
             ServerSystemInfo.ModuleName   = this._dr["ModuleName"].ToString();
             ServerSystemInfo.ModuleIdBuff = int.Parse(this._dr["Id"].ToString());
             CMessageInfo.ShowMessage("模块切换成功!", "模块切换", 1);
             if ((this.client != null) && (this.buffer != null))
             {
                 PaidComm.SendBack(this.client, this.buffer, 0);
             }
             SysManager.ModuleId = ServerSystemInfo.ModuleId;
             SysManager.ResetFaultPoint();
             msg = string.Format("切换模块[{0}]成功", ServerSystemInfo.ModuleName);
         }
         else
         {
             CMessageInfo.ShowMessage("模块连接失败,请重试!", "模块切换", 1);
             msg = string.Format("切换模块[{0}]失败", this._dr["ModuleName"].ToString());
             if ((this.client != null) && (this.buffer != null))
             {
                 PaidComm.SendBack(this.client, this.buffer, 1);
             }
         }
         this.da.WriteLog(LoginInfo.UserName, msg);
     }
 }
Beispiel #2
0
        public static void SocketListen()
        {
            DataAccess access  = new DataAccess();
            TcpService service = new TcpService();
            DataTable  list    = access.GetList("select * from serverinfo where id=1");

            if ((list != null) && (list.Rows.Count != 0))
            {
                int port = int.Parse(list.Rows[0]["port1"].ToString());
                int num2 = int.Parse(list.Rows[0]["port2"].ToString());
                service.Run(port);
                PaidComm.Run(num2);
            }
            else
            {
                service.Run(0x1f90);
                PaidComm.Run(0x1f91);
            }
        }
Beispiel #3
0
        private void barLargeButtonItem7_ItemClick(object sender, ItemClickEventArgs e)
        {
            MapLocation location = new MapLocation();

            if (ServerSystemInfo.ModuleId == ServerSystemInfo.SoftModuleId)
            {
                if (CheckInfo.PcCheckState)
                {
                    CMessageInfo.ShowMessage("学生机考核进行中,不能操作", "故障设置", 2);
                }
                else if (CheckInfo.PaidCheckState)
                {
                    CMessageInfo.ShowMessage("平板用户考核进行中,不能操作", "故障设置", 2);
                }
                else
                {
                    foreach (DataRow row in ((DataTable)this.gridControl1.DataSource).Rows)
                    {
                        if (row[0].ToString() == "True")
                        {
                            bool flag     = string.Compare(row["NormalIsBreak"].ToString(), "False", true) != 0;
                            int  moduleId = ServerSystemInfo.ModuleId;
                            int  pointId  = int.Parse(row[1].ToString().Trim());
                            if (row["FaultPattern"].ToString() == "故障指令")
                            {
                                CMessageInfo.ShowMessage("请选择故障指令", "故障设置", 2);
                                return;
                            }
                            if (row["FaultPattern"].ToString() != row["PointState"].ToString())
                            {
                                int data      = int.Parse(this.table.Select(" OrderName='" + row["FaultPattern"].ToString() + "'").First <DataRow>()["OrderId"].ToString());
                                int orderCode = location.DataToCoder(data);
                                if (SysManager.SetFaultPoint(pointId, orderCode))
                                {
                                    row["PointState"] = row["FaultPattern"].ToString().Trim();
                                    if (((row["PointState"].ToString() == "通路") && !flag) || ((row["PointState"].ToString() == "断路") && flag))
                                    {
                                        row["IsNormal"] = "正常";
                                    }
                                    else
                                    {
                                        row["IsNormal"] = "有故障";
                                    }
                                    if ((this.client != null) && (this.buffer != null))
                                    {
                                        this.buffer[3] = (byte)moduleId;
                                        this.buffer[4] = 1;
                                        this.buffer[5] = (byte)pointId;
                                        PaidComm.SendBack(this.client, this.buffer, 0);
                                    }
                                    this.da.WriteLog(LoginInfo.UserName, string.Format("成功设置故障[{2}]:模块为[{0}],故障点为[{1}]", ServerSystemInfo.ModuleName, row["name"].ToString(), row["FaultPattern"].ToString()));
                                }
                                else
                                {
                                    row["PointState"] = "设置故障失败";
                                    if ((this.client != null) && (this.buffer != null))
                                    {
                                        this.buffer[3] = (byte)moduleId;
                                        this.buffer[4] = 1;
                                        this.buffer[5] = (byte)pointId;
                                        PaidComm.SendBack(this.client, this.buffer, 1);
                                    }
                                    this.da.WriteLog(LoginInfo.UserName, string.Format("设置故障[{2}]失败:模块为[{0}],故障点为[{1}]", ServerSystemInfo.ModuleName, row["name"].ToString(), row["FaultPattern"].ToString()));
                                }
                            }
                            else
                            {
                                if ((this.client != null) && (this.buffer != null))
                                {
                                    this.buffer[3] = (byte)moduleId;
                                    this.buffer[4] = 1;
                                    this.buffer[5] = (byte)pointId;
                                    PaidComm.SendBack(this.client, this.buffer, 0);
                                }
                                this.da.WriteLog(LoginInfo.UserName, string.Format("成功设置故障[{2}]:模块为[{0}],故障点为[{1}]", ServerSystemInfo.ModuleName, row["name"].ToString(), row["FaultPattern"].ToString()));
                            }
                            this.gridControl1.RefreshDataSource();
                        }
                    }
                    if ((this.client != null) && (this.buffer != null))
                    {
                        PaidComm.SendBack(this.client, this.buffer, 0);
                    }
                }
            }
            else
            {
                if ((this.client != null) && (this.buffer != null))
                {
                    PaidComm.SendBack(this.client, this.buffer, 1);
                }
                CMessageInfo.ShowMessage("对不起,您要操作的模块和接入的模块不一致。请接入该系统模块后再尝试", "故障设置", 1);
            }
        }