예제 #1
0
        /// <summary>
        /// 点击会话
        /// </summary>
        /// <param name="box">会话控件</param>
        private void click(SessionBox box = null)
        {
            if (id == null)
            {
                id = sessions.OrderBy(i => i.time).Last().id;
            }

            var control = (SessionBox)sceMain.Controls[0].Controls[id];

            if (control == null)
            {
                return;
            }

            control.BackColor = sceMain.Controls[0].BackColor;
            control.Refresh();
            if (box == null)
            {
                box = control;
            }

            box.unRead    = false;
            box.BackColor = Color.White;
            box.Refresh();

            id = box.Name;
            var session = sessions.Find(i => i.id == id);

            session.unRead = false;

            SessionAPI.SetUnreadCountZero(NIMSessionType.kNIMSessionTypeP2P, id, (a, b, c) => { });
            MessagelogAPI.MarkMessagesStatusRead(id, NIMSessionType.kNIMSessionTypeP2P, (a, b, c) => { });
        }
예제 #2
0
 public virtual void AbortOnError(C c)
 {
     lock (this._lockServer)
     {
         if (c != null)
         {
             this._handler.OnClose(c);
             base.RemoveConnection(c._sock);
             if (!c._sock.Connected)
             {
                 c._datasetRequestQueue.Clear();
                 c._curDispatchAttrib = null;
             }
             SessionAPI.Delete(c._uid, false);
             if (c._sslStream != null)
             {
                 c._sslStream.Dispose();
                 c._sslStream = null;
             }
             if (c._sock != null)
             {
                 Common.WriteLine("Socket Aborted: #" + c._sock.Handle, new string[0]);
                 if (c._sock.Connected)
                 {
                     c._sock.Shutdown(SocketShutdown.Both);
                     c._sock.Disconnect(false);
                 }
                 c._sock.Close();
             }
         }
     }
 }
예제 #3
0
 public static void ServiceWillDown()
 {
     lock (DispatchAPI._lockDispatch)
     {
         if (DispatchAPI._ecoHandler != null)
         {
             SessionAPI.ServiceWillStop();
             DispatchAPI._ecoHandler.SendUrgency(null, 0, "servicewilldown");
         }
     }
 }
예제 #4
0
 public static void StopDispatcher()
 {
     lock (DispatchAPI._lockDispatch)
     {
         Common.WriteLine("StopDispatcher ...", new string[0]);
         if (DispatchAPI._ecoHandler != null)
         {
             DispatchAPI._ecoHandler.Stop();
         }
         DispatchAPI._ecoHandler = null;
         ServicesAPI.StopEcoService();
         SessionAPI.StopSessionManager();
         Common.WriteLine("StopDispatcher Done", new string[0]);
     }
 }
예제 #5
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            SessionAPI sessionApi = new SessionAPI();

            string sessionId = await sessionApi.CreateSession(Session);

            // _context.Session.Add(Session);
            // await _context.SaveChangesAsync();

            return(RedirectToPage("./Details", new { id = sessionId }));
        }
예제 #6
0
        protected void RemoveConnection(Socket sock)
        {
            long num = -1L;

            lock (this._lockServer)
            {
                if (this._connections.ContainsKey(sock))
                {
                    C c = this._connections[sock];
                    if (c != null)
                    {
                        num = c._uid;
                    }
                    this._connections.Remove(sock);
                    Interlocked.Decrement(ref this._connected);
                }
            }
            if (num > 0L)
            {
                SessionAPI.Delete(num, false);
            }
        }
예제 #7
0
        public IActionResult Login(string email, string password)
        {
            User       user    = new User();
            SessionAPI session = new SessionAPI();

            try
            {
                user = _dataRepository.Get(email, password);
                if (user == null)
                {
                    return(StatusCode(202, "Unable to process request"));
                }

                session.Email = email;
                session.Name  = user.username;
                session.Token = TokenAPI.GetToken(user.id.ToString());
                return(Ok(session));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, "Unable to process request"));
            }
        }
예제 #8
0
        public static bool StartDispatcher(int port, bool useSSL = true)
        {
            bool result;

            lock (DispatchAPI._lockDispatch)
            {
                try
                {
                    DispatchAPI._isServerRole = true;
                    if (port == 0)
                    {
                        DispatchAPI._localConnection = true;
                    }
                    else
                    {
                        DispatchAPI.ExtractCertificate("MonitorServers.pfx");
                    }
                    SessionAPI.StartSessionManager();
                    DispatchAPI._ecoHandler = new EcoHandler();
                    DispatchAPI._ecoHandler.Start(true);
                    DeviceInfo.cbOnDBUpdated          = new DeviceInfo.DelegateOnDbUpdate(DispatchAPI._ecoHandler.OnReloadDBData);
                    DevAccessCfg._cbOnAutoModeUpdated = new DevAccessCfg.DelegateOnAutoModeUpdate(DispatchAPI._ecoHandler.OnAutoDiscovery);
                    bool flag2 = ServicesAPI.StartEcoService(useSSL, port, DispatchAPI._ecoHandler);
                    result = flag2;
                }
                catch (Exception ex)
                {
                    Common.WriteLine("StartDispatcher: {0}", new string[]
                    {
                        ex.Message
                    });
                    result = false;
                }
            }
            return(result);
        }
예제 #9
0
        public override List <byte[]> PacketReceived(byte[] packet)
        {
            List <byte[]> list       = new List <byte[]>();
            uint          packetType = ecoServerProtocol.getPacketType(this._header);

            if ((ulong)ecoServerProtocol.getPacketType(this._header) == 35328uL)
            {
                int num = (int)ecoServerProtocol.swap16((ushort)BitConverter.ToInt16(this._receiveBuffer, 0));
                ecoServerProtocol.swap16((ushort)BitConverter.ToInt16(this._receiveBuffer, 2));
                SessionAPI.Update((long)num);
                this.AppendResponse(list, 35456, 0, null);
            }
            else
            {
                if ((ulong)ecoServerProtocol.getPacketType(this._header) == 1uL)
                {
                    this.AppendResponse(list, 129, 0, null);
                    if (this._owner != null)
                    {
                        this._owner.ReportMessage(this._owner, this, this._header, packet);
                    }
                }
                else
                {
                    if ((ulong)ecoServerProtocol.getPacketType(this._header) == 35343uL)
                    {
                        if (this._owner != null)
                        {
                            this._owner.ReportMessage(this._owner, this, this._header, packet);
                        }
                    }
                    else
                    {
                        if ((ulong)ecoServerProtocol.getPacketType(this._header) == 35329uL)
                        {
                            if (this._owner != null)
                            {
                                this._owner.ReportMessage(this._owner, this, this._header, packet);
                            }
                        }
                        else
                        {
                            if ((ulong)packetType == 35330uL)
                            {
                                Common.WriteLine("    Logout from ecoClient", new string[0]);
                                int num2 = (int)ecoServerProtocol.swap16((ushort)BitConverter.ToInt16(packet, 0));
                                int num3 = (int)ecoServerProtocol.swap16((ushort)BitConverter.ToInt16(packet, 2));
                                SessionAPI.Logout((long)num2, (long)num3);
                                this.AppendResponse(list, 35458, 0, null);
                            }
                            else
                            {
                                if ((ulong)ecoServerProtocol.getPacketType(this._header) == 35471uL)
                                {
                                    if (this._owner != null)
                                    {
                                        this._owner.ReportMessage(this._owner, this, this._header, packet);
                                    }
                                }
                                else
                                {
                                    if ((ulong)packetType == 35331uL)
                                    {
                                        if (this._owner != null)
                                        {
                                            this._owner.ReportMessage(this._owner, this, this._header, packet);
                                        }
                                    }
                                    else
                                    {
                                        if ((ulong)packetType == 35332uL)
                                        {
                                            if (this._owner != null)
                                            {
                                                this._owner.ReportMessage(this._owner, this, this._header, packet);
                                            }
                                        }
                                        else
                                        {
                                            if ((ulong)packetType != 384uL)
                                            {
                                                if ((ulong)packetType == 385uL)
                                                {
                                                    if (this._owner != null)
                                                    {
                                                        this._owner.ReportMessage(this._owner, this, this._header, packet);
                                                    }
                                                }
                                                else
                                                {
                                                    if ((ulong)packetType == 259uL)
                                                    {
                                                        if (this._owner != null)
                                                        {
                                                            this._owner.ReportMessage(this._owner, this, this._header, packet);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if ((ulong)packetType == 35456uL)
                                                        {
                                                            int num4 = (int)this._receiveBuffer[0];
                                                            if (num4 > 0 && this._owner != null)
                                                            {
                                                                this._owner.ReportMessage(this._owner, this, this._header, packet);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            if ((ulong)packetType == 35457uL)
                                                            {
                                                                if (this._owner != null)
                                                                {
                                                                    this._owner.ReportMessage(this._owner, this, this._header, packet);
                                                                }
                                                            }
                                                            else
                                                            {
                                                                if ((ulong)packetType == 35459uL)
                                                                {
                                                                    Common.WriteLine("    Request ack from ecoServer", new string[0]);
                                                                    int num5 = (int)this._receiveBuffer[0];
                                                                    int num6 = (int)ecoServerProtocol.swap16((ushort)BitConverter.ToInt16(this._receiveBuffer, 1));
                                                                    if (num5 != 0 && (num6 == 4 || num6 == 32 || num6 == 2) && this._owner != null)
                                                                    {
                                                                        this._owner.ReportMessage(this._owner, this, this._header, packet);
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    if ((ulong)packetType == 35458uL)
                                                                    {
                                                                        Common.WriteLine("    Logout ack from ecoServer", new string[0]);
                                                                    }
                                                                    else
                                                                    {
                                                                        if ((ulong)packetType == 35460uL)
                                                                        {
                                                                            Common.WriteLine("    Message ack from ecoServer", new string[0]);
                                                                        }
                                                                        else
                                                                        {
                                                                            if ((ulong)packetType == 35333uL)
                                                                            {
                                                                                Common.WriteLine("    Error Message from ecoServer", new string[0]);
                                                                                this.AppendResponse(list, 35461, 0, null);
                                                                                int num7 = (int)ecoServerProtocol.swap16((ushort)BitConverter.ToInt16(this._receiveBuffer, 0));
                                                                                ecoServerProtocol.swap16((ushort)BitConverter.ToInt16(this._receiveBuffer, 2));
                                                                                if (num7 == 1 && this._owner != null)
                                                                                {
                                                                                    this._owner.ReportMessage(this._owner, this, this._header, packet);
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                if ((ulong)packetType == 386uL)
                                                                                {
                                                                                    if (this._owner != null)
                                                                                    {
                                                                                        this._owner.ReportMessage(this._owner, this, this._header, packet);
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    if ((ulong)packetType == 32uL)
                                                                                    {
                                                                                        int startIndex = 0;
                                                                                        int num8       = (int)ecoServerProtocol.swap16((ushort)BitConverter.ToInt16(packet, startIndex));
                                                                                        base.setKicked(true);
                                                                                        Common.WriteLine("    Be kicked: uid={0}", new string[]
                                                                                        {
                                                                                            num8.ToString()
                                                                                        });
                                                                                        ClientAPI.OnClosed(this, -2);
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        if ((ulong)packetType == 48uL)
                                                                                        {
                                                                                            int startIndex2 = 0;
                                                                                            int num9        = (int)ecoServerProtocol.swap16((ushort)BitConverter.ToInt16(packet, startIndex2));
                                                                                            base.setServiceWillDown(true);
                                                                                            Common.WriteLine("    Service will be down: uid={0}", new string[]
                                                                                            {
                                                                                                num9.ToString()
                                                                                            });
                                                                                            ClientAPI.OnClosed(this, -2);
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            if ((ulong)packetType == 260uL)
                                                                                            {
                                                                                                if (this._owner != null)
                                                                                                {
                                                                                                    this._owner.ReportMessage(this._owner, this, this._header, packet);
                                                                                                }
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                if ((ulong)packetType == 258uL)
                                                                                                {
                                                                                                    this.AppendResponse(list, 386, 0, null);
                                                                                                    if (this._vid >= 0L)
                                                                                                    {
                                                                                                        int num10 = (int)ecoServerProtocol.swap16((ushort)BitConverter.ToInt16(this._receiveBuffer, 0));
                                                                                                        ecoServerProtocol.swap16((ushort)BitConverter.ToInt16(this._receiveBuffer, 2));
                                                                                                        ecoServerProtocol.swap16((ushort)BitConverter.ToInt16(this._receiveBuffer, 4));
                                                                                                        if (num10 > 0)
                                                                                                        {
                                                                                                            this.ReceiveDataset(ref this._sqlContext, packet);
                                                                                                        }
                                                                                                        else
                                                                                                        {
                                                                                                            this.ReceiveDataset(ref this._dsContext, packet);
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(list);
        }
예제 #10
0
 public void GetRecentSessionList()
 {
     SessionAPI.QueryAllRecentSession(OnQuerySessionListCompleted);
 }
예제 #11
0
 public override void DispatchDataset(DispatchAttribute attrib)
 {
     lock (this._lockServer)
     {
         if (attrib != null)
         {
             if (this._connections.Count > 0)
             {
                 if ((attrib.type & 8) != 0)
                 {
                     SessionAPI.AuthorizationUpdate("");
                 }
                 using (Dictionary <Socket, C> .Enumerator enumerator = this._connections.GetEnumerator())
                 {
                     while (enumerator.MoveNext())
                     {
                         KeyValuePair <Socket, C> current = enumerator.Current;
                         C value = current.Value;
                         if ((attrib.uid == 0 && value._vid == 0L) || ((long)attrib.uid == value._uid && (long)attrib.vid == value._vid))
                         {
                             if (attrib.uid == 0 && (attrib.type & 8192) == 0 && SessionAPI.IsUserUAC(value._uid))
                             {
                                 DispatchAttribute copy = attrib.getCopy();
                                 copy.uid = (int)value._uid;
                                 SessionAPI.toTracker(copy);
                                 if (this._handler != null)
                                 {
                                     this._handler.AutoPull4UAC(value);
                                 }
                             }
                             else
                             {
                                 if ((attrib.type & 8192) != 0)
                                 {
                                     bool flag2 = true;
                                     if (attrib.uid == 0 && attrib.operation.StartsWith("USER:"******":");
                                         if (num >= 0)
                                         {
                                             string text = attrib.operation.Substring(num + 1).Trim();
                                             if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(value._userName) || !text.Equals(value._userName, StringComparison.CurrentCultureIgnoreCase))
                                             {
                                                 flag2 = false;
                                             }
                                         }
                                     }
                                     if (flag2)
                                     {
                                         this.SendBroadcast(value, attrib);
                                     }
                                 }
                                 else
                                 {
                                     if (attrib.data != null)
                                     {
                                         bool flag3 = false;
                                         if (attrib.type == 1 && value._isRealTimePending)
                                         {
                                             if (attrib.discard_if_jam <= 0)
                                             {
                                                 Common.WriteLine("XXXXXXXXXXXXXX Important Realtime data can not be discarded", new string[0]);
                                             }
                                             else
                                             {
                                                 flag3 = true;
                                                 string text2 = "";
                                                 if (value._curDispatchAttrib != null)
                                                 {
                                                     text2 += value._curDispatchAttrib.type.ToString();
                                                 }
                                                 int num2 = 0;
                                                 foreach (DispatchAttribute current2 in value._datasetRequestQueue)
                                                 {
                                                     if (num2 == 0)
                                                     {
                                                         text2 += ":";
                                                     }
                                                     else
                                                     {
                                                         text2 += ",";
                                                     }
                                                     text2 += current2.type;
                                                     num2++;
                                                 }
                                                 Common.WriteLine("XXXXXXXXXXXXXX Realtime data is already on the way @DispatchDataset({0}), data discarded", new string[]
                                                 {
                                                     text2
                                                 });
                                             }
                                         }
                                         if (!flag3)
                                         {
                                             DispatchAttribute copy2 = attrib.getCopy();
                                             if (value.setDataSet(copy2))
                                             {
                                                 this.StartDispatch(value);
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     goto IL_315;
                 }
             }
             Common.WriteLine("Dispatch to Nobody", new string[0]);
         }
         IL_315 :;
     }
 }
예제 #12
0
        private void OnSocketReceived(SocketAsyncEventArgs e)
        {
            bool   flag   = false;
            bool   flag2  = true;
            Socket socket = e.AcceptSocket;

            if (e.LastOperation == SocketAsyncOperation.Receive)
            {
                socket = (e.UserToken as Socket);
            }
            C connection = base.GetConnection(socket);

            lock (this._lockServer)
            {
                if (e.SocketError != SocketError.Success || e.BytesTransferred == 0 || !socket.Connected)
                {
                    if (connection != null)
                    {
                        base.RemoveConnection(socket);
                    }
                    ServicesAPI.OnDisconnected(socket);
                    if (e.LastOperation == SocketAsyncOperation.Receive)
                    {
                        if (socket.Connected)
                        {
                            socket.Shutdown(SocketShutdown.Both);
                            socket.Disconnect(false);
                        }
                        socket.Close();
                        e.AcceptSocket = null;
                        e.UserToken    = null;
                        e.Completed   -= new EventHandler <SocketAsyncEventArgs>(this.IO_Completed);
                        this._receiveSocketArgs.Enqueue(e);
                    }
                    Common.WriteLine(this._threadName + ": connection down: " + this._connected, new string[0]);
                    return;
                }
                this._speedMeter.Received(e.BytesTransferred);
                if (connection != null)
                {
                    BufferState bufferState = new BufferState();
                    bufferState._ctx    = connection;
                    bufferState._buffer = e.Buffer;
                    if (bufferState._buffer != null)
                    {
                        Interlocked.Increment(ref this._totalRequests);
                        SessionAPI.Update(connection._uid);
                        int           num  = 0;
                        List <byte[]> list = connection.ReceivedBuffer(bufferState, e.BytesTransferred, ref num);
                        if (list != null)
                        {
                            flag2 = false;
                            foreach (byte[] current in list)
                            {
                                if (!socket.Connected)
                                {
                                    break;
                                }
                                this.StartSend(connection, current);
                            }
                        }
                    }
                }
            }
            if (!flag2)
            {
                if (e.LastOperation == SocketAsyncOperation.Receive)
                {
                    flag = true;
                    lock (this._lockServer)
                    {
                        if (socket.Connected)
                        {
                            flag = socket.ReceiveAsync(e);
                        }
                        else
                        {
                            ServicesAPI.OnDisconnected(socket);
                            if (connection != null)
                            {
                                base.RemoveConnection(socket);
                            }
                            e.AcceptSocket = null;
                            e.UserToken    = null;
                            e.Completed   -= new EventHandler <SocketAsyncEventArgs>(this.IO_Completed);
                            this._receiveSocketArgs.Enqueue(e);
                        }
                    }
                    if (!flag)
                    {
                        this.OnSocketReceived(e);
                    }
                }
                return;
            }
            if (connection != null)
            {
                base.RemoveConnection(socket);
            }
            ServicesAPI.OnDisconnected(socket);
            lock (this._lockServer)
            {
                if (socket.Connected)
                {
                    socket.Shutdown(SocketShutdown.Both);
                    socket.Disconnect(false);
                }
                socket.Close();
            }
            if (e.LastOperation == SocketAsyncOperation.Receive)
            {
                e.AcceptSocket = null;
                e.UserToken    = null;
                e.Completed   -= new EventHandler <SocketAsyncEventArgs>(this.IO_Completed);
                this._receiveSocketArgs.Enqueue(e);
            }
            Common.WriteLine("Receive Processing Error", new string[0]);
        }
예제 #13
0
        public static byte[] AppProtResponse_Srv(int protocal_ID, string para, int fromUID)
        {
            XmlDocument xmlDocument = null;

            if (protocal_ID == 1)
            {
                try
                {
                    List <int> list      = new List <int>();
                    DataTable  dataTable = DBTools.CreateDataTable(para);
                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        for (int j = 0; j < dataTable.Columns.Count; j++)
                        {
                            if (dataTable.Rows[i].ItemArray[j] == DBNull.Value)
                            {
                                list.Add(i);
                                break;
                            }
                        }
                    }
                    if (list.Count > 0)
                    {
                        for (int k = list.Count - 1; k >= 0; k--)
                        {
                            dataTable.Rows.RemoveAt(list[k]);
                        }
                    }
                    dataTable.TableName = "RCI";
                    xmlDocument         = CustomXmlSerializer.Serialize(dataTable, 8, "RCI");
                    goto IL_59A;
                }
                catch (Exception ex)
                {
                    Common.WriteLine("AppProtResponse_Srv---[RCI]: {0}", new string[]
                    {
                        ex.Message
                    });
                    goto IL_59A;
                }
            }
            if (protocal_ID == 2)
            {
                try
                {
                    ArrayList curRacks            = DataSetManager.getCurRacks();
                    Dictionary <long, string> obj = AppData.LoadheatLoadDissipation(curRacks, Convert.ToInt32(para));
                    xmlDocument = CustomXmlSerializer.Serialize(obj, 8, "HEAT");
                    goto IL_59A;
                }
                catch (Exception ex2)
                {
                    Common.WriteLine("AppProtResponse_Srv---[HEAT]: {0}", new string[]
                    {
                        ex2.Message
                    });
                    goto IL_59A;
                }
            }
            if (protocal_ID == 3)
            {
                try
                {
                    DeviceInfo deviceByID = DeviceOperation.getDeviceByID(Convert.ToInt32(para));
                    xmlDocument = CustomXmlSerializer.Serialize(deviceByID, 8, "RemoteCall_getDeviceByID");
                    goto IL_59A;
                }
                catch (Exception ex3)
                {
                    Common.WriteLine("AppProtResponse_Srv---[RemoteCall_getDeviceByID]: {0}", new string[]
                    {
                        ex3.Message
                    });
                    goto IL_59A;
                }
            }
            if (protocal_ID == 4)
            {
                try
                {
                    DeviceInfo      deviceByID2 = DeviceOperation.getDeviceByID(Convert.ToInt32(para));
                    List <PortInfo> obj2        = null;
                    if (deviceByID2 != null)
                    {
                        obj2 = deviceByID2.GetPortInfo();
                    }
                    xmlDocument = CustomXmlSerializer.Serialize(obj2, 8, "RemoteCall_AllPort_in1Dev");
                    goto IL_59A;
                }
                catch (Exception ex4)
                {
                    Common.WriteLine("AppProtResponse_Srv---[RemoteCall_AllPort_in1Dev]: {0}", new string[]
                    {
                        ex4.Message
                    });
                    goto IL_59A;
                }
            }
            if (protocal_ID == 7)
            {
                try
                {
                    List <DeviceInfo> list2 = new List <DeviceInfo>();
                    string[]          array = para.Split(new string[]
                    {
                        ","
                    }, StringSplitOptions.RemoveEmptyEntries);
                    string[] array2 = array;
                    for (int l = 0; l < array2.Length; l++)
                    {
                        string text  = array2[l];
                        string value = text.Trim();
                        if (!string.IsNullOrEmpty(value))
                        {
                            DeviceInfo deviceByID3 = DeviceOperation.getDeviceByID(Convert.ToInt32(value));
                            if (deviceByID3 != null)
                            {
                                list2.Add(deviceByID3);
                            }
                        }
                    }
                    xmlDocument = CustomXmlSerializer.Serialize(list2, 8, "RemoteCall_getDeviceInfoList");
                    goto IL_59A;
                }
                catch (Exception ex5)
                {
                    Common.WriteLine("AppProtResponse_Srv---[RemoteCall_getDeviceInfoList]: {0}", new string[]
                    {
                        ex5.Message
                    });
                    goto IL_59A;
                }
            }
            if (protocal_ID == 100)
            {
                try
                {
                    string[] array3 = para.Split(new char[]
                    {
                        '\n'
                    });
                    switch (array3.Length)
                    {
                    case 1:
                        LogAPI.writeEventLog(array3[0], new string[0]);
                        break;

                    case 2:
                    {
                        string user       = SessionAPI.getUser((long)fromUID);
                        string remoteIP   = SessionAPI.getRemoteIP((long)fromUID);
                        string remoteType = SessionAPI.getRemoteType((long)fromUID);
                        if (array3[0].Equals("0230003", StringComparison.InvariantCultureIgnoreCase))
                        {
                            LogAPI.writeEventLog("0230003", new string[]
                                {
                                    user,
                                    remoteIP
                                });
                        }
                        else
                        {
                            if (!remoteType.Equals("remote", StringComparison.InvariantCultureIgnoreCase))
                            {
                                LogAPI.writeEventLog(array3[0], new string[]
                                    {
                                        array3[1]
                                    });
                            }
                        }
                        break;
                    }

                    case 3:
                        LogAPI.writeEventLog(array3[0], new string[]
                        {
                            array3[1],
                            array3[2]
                        });
                        break;

                    case 4:
                        LogAPI.writeEventLog(array3[0], new string[]
                        {
                            array3[1],
                            array3[2],
                            array3[3]
                        });
                        break;

                    case 5:
                        LogAPI.writeEventLog(array3[0], new string[]
                        {
                            array3[1],
                            array3[2],
                            array3[3],
                            array3[4]
                        });
                        break;

                    case 6:
                        LogAPI.writeEventLog(array3[0], new string[]
                        {
                            array3[1],
                            array3[2],
                            array3[3],
                            array3[4],
                            array3[5]
                        });
                        break;

                    case 7:
                        LogAPI.writeEventLog(array3[0], new string[]
                        {
                            array3[1],
                            array3[2],
                            array3[3],
                            array3[4],
                            array3[5],
                            array3[6]
                        });
                        break;
                    }
                    int num = 1;
                    xmlDocument = CustomXmlSerializer.Serialize(num, 8, "RemoteCall_writeEventLog");
                    goto IL_59A;
                }
                catch (Exception ex6)
                {
                    Common.WriteLine("AppProtResponse_Srv---[RemoteCall_AllPort_in1Dev]: {0}", new string[]
                    {
                        ex6.Message
                    });
                    goto IL_59A;
                }
            }
            if (protocal_ID == 101)
            {
                try
                {
                    int num2 = 1;
                    xmlDocument = CustomXmlSerializer.Serialize(num2, 8, "RemoteCall_setEventFlag");
                    goto IL_59A;
                }
                catch (Exception ex7)
                {
                    Common.WriteLine("AppProtResponse_Srv---[RemoteCall_setEventFlag]: {0}", new string[]
                    {
                        ex7.Message
                    });
                    goto IL_59A;
                }
            }
            if (protocal_ID == 102)
            {
                DataTable allSessions = SessionAPI.getAllSessions();
                xmlDocument = CustomXmlSerializer.Serialize(allSessions, 8, "Sessions");
            }
            else
            {
                if (protocal_ID == 103)
                {
                    string obj3 = "Success";
                    if (!SessionAPI.KillSessions(fromUID, para))
                    {
                        obj3 = "Failed";
                    }
                    xmlDocument = CustomXmlSerializer.Serialize(obj3, 8, "KillSession");
                }
                else
                {
                    if (protocal_ID == 104)
                    {
                        DateTime now = DateTime.Now;
                        xmlDocument = CustomXmlSerializer.Serialize(now, 8, "RemoteCall_getSrvDateTime");
                    }
                    else
                    {
                        if (protocal_ID == 8)
                        {
                            Dictionary <long, List <long> > dictionary = SessionAPI.getDeviceListClone((long)fromUID);
                            if (dictionary == null)
                            {
                                dictionary = new Dictionary <long, List <long> >();
                            }
                            xmlDocument = CustomXmlSerializer.Serialize(dictionary, 8, "RemoteCall_UACDev2Port");
                        }
                    }
                }
            }
IL_59A:
            if (xmlDocument == null)
            {
                return(null);
            }
            byte[] result;
            try
            {
                string outerXml = xmlDocument.OuterXml;
                byte[] bytes    = Encoding.UTF8.GetBytes(outerXml);
                result = bytes;
            }
            catch (Exception ex8)
            {
                Common.WriteLine("AppProtResponse_Srv: #{0}({1}), {2}", new string[]
                {
                    protocal_ID.ToString(),
                    para,
                    ex8.Message
                });
                result = null;
            }
            return(result);
        }