Example #1
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);
            }
        }