Ejemplo n.º 1
0
        public static byte[] PaidResult(byte[] socketBt)
        {
            byte[]      buffer   = new byte[5];
            MapLocation location = new MapLocation();

            buffer[0] = 250;
            buffer[4] = 0xfb;
            switch (socketBt[1])
            {
            case 1:
                buffer[1] = 1;
                buffer[2] = (byte)ServerSystemInfo.ModuleId;
                buffer[3] = 0;
                break;

            case 2:
            {
                buffer[1] = 2;
                buffer[2] = socketBt[2];
                int faultPointState = SysManager.GetFaultPointState(socketBt[2]);
                buffer[3] = (byte)location.CoderToData(faultPointState);
                break;
            }

            case 3:
                buffer[1] = 3;
                buffer[2] = socketBt[2];
                buffer[3] = SysManager.SetFaultPoint(socketBt[2], location.DataToCoder(socketBt[3])) ? ((byte)0) : ((byte)1);
                break;

            case 4:
                buffer[1] = 4;
                buffer[2] = 0;
                buffer[3] = SysManager.ResetFaultPoint() ? ((byte)0) : ((byte)1);
                break;

            case 5:
                buffer[1] = 4;
                buffer[2] = 0;
                buffer[3] = SysManager.DeleteFaultPoint(socketBt[3]) ? ((byte)0) : ((byte)1);
                break;
            }
            SysManager._comm.closePort();
            return(buffer);
        }
Ejemplo n.º 2
0
        public void ReciveSocket(ClientInfo clientInfo, SocketInfo socketInfo)
        {
            List <ClientInfo> clientList = new List <ClientInfo>();

            switch (socketInfo.Type)
            {
            case SocketInfoType.SysModule:
            {
                clientList.Clear();
                clientList.Add(clientInfo);
                string msg = string.Format("{0}:{1}", ServerSystemInfo.ModuleId, ServerSystemInfo.SysPattern);
                SysManager.SentToClient(clientList, "Server", SocketInfoType.SysModule, msg);
                return;
            }

            case SocketInfoType.SysPattern:
            case SocketInfoType.CheckItem:
                break;

            case SocketInfoType.BeginCheck:
            {
                CheckInfo item = (CheckInfo)socketInfo.Msg;
                lock (CacheInvoke.CheckPool)
                {
                    CacheInvoke.CheckPool.Add(item);
                }
                if (this.CheckEvent == null)
                {
                    break;
                }
                this.CheckEvent(null, new SocketEventArgs(SocketInfoType.BeginCheck, clientInfo.UserName));
                return;
            }

            case SocketInfoType.EndCheck:
            {
                CheckInfo info2 = (CheckInfo)socketInfo.Msg;
                lock (CacheInvoke.CheckPool)
                {
                    CacheInvoke.CheckPool.Add(info2);
                }
                if (this.CheckEvent != null)
                {
                    this.CheckEvent(null, new SocketEventArgs(SocketInfoType.EndCheck, clientInfo.UserName));
                }
                break;
            }

            case SocketInfoType.ReadPointState:
            {
                MapLocation location = new MapLocation();
                clientList.Clear();
                clientList.Add(clientInfo);
                try
                {
                    string[] strArray = socketInfo.Msg.ToString().Split(new char[] { ':' });
                    if (int.Parse(strArray[0]) != ServerSystemInfo.ModuleId)
                    {
                        string str2 = "模块已变更,无法读取";
                        SysManager.SentToClient(clientList, "Server", SocketInfoType.ReadPointState, str2);
                    }
                    else
                    {
                        StringBuilder builder = new StringBuilder();
                        foreach (string str3 in strArray[1].Split(new char[] { ',' }))
                        {
                            int num2;
                            int faultPointState = SysManager.GetFaultPointState(int.Parse(str3));
                            if (faultPointState == 90)
                            {
                                num2 = 0;
                            }
                            else
                            {
                                num2 = location.CoderToData(faultPointState);
                            }
                            builder.Append(string.Format("{0},", num2));
                        }
                        string str4 = builder.ToString();
                        builder = builder.Remove(str4.LastIndexOf(','), 1);
                        SysManager.SentToClient(clientList, "Server", SocketInfoType.ReadPointState, builder);
                        SysManager._comm.closePort();
                    }
                }
                catch
                {
                    SysManager.SentToClient(clientList, "Server", SocketInfoType.ReadPointState, "0,0,0,0");
                }
                break;
            }

            default:
                return;
            }
        }