Пример #1
0
        public static void DecideCommandResponse(string[] CommandData)
        {
            RequestCommadType requestCommandType = (RequestCommadType)int.Parse(CommandData[0]);

            if (RegisteredClients == null)
            {
                RegisteredClients = new List <LCDClient>();
            }

            switch (requestCommandType)
            {
            case RequestCommadType.ClientRegister:
                var registerITClient = from x in RegisteredClients
                                       //where x.IPAdres.ToString() == CommandData[2]
                                       where x.ATID.ToString() == CommandData[1]
                                       select x;

                if (registerITClient == null || registerITClient.Count() == 0)
                {
                    #region Note

                    #endregion

                    LCDClient lcdClient = new LCDClient(Convert.ToInt16(CommandData[1]), CommandData[2], Convert.ToInt16(CommandData[3]));

                    if (lcdClient.IsRegistrable)
                    {
                        RegisteredClients.Add(lcdClient);

                        QLUClientCommunicating.SendResult(
                            QLUClientCommunicating.RequestCommadType.ClientRegister,
                            true,
                            "QLU client register işlemi başarılı",
                            lcdClient.IPAdres
                            );

                        StreamWriter sr = new StreamWriter(@"c:\lcdler.txt", true);
                        sr.WriteLine(DateTime.Now.ToString() + " Register " + lcdClient.ATID.ToString() + "; " + lcdClient.IPAdres.ToString() + "; ");
                        sr.Flush();
                        sr.Close();
                    }
                    else
                    {
                        QLUClientCommunicating.SendResult(
                            QLUClientCommunicating.RequestCommadType.ClientRegister,
                            false,
                            lcdClient.FailedMessage,
                            lcdClient.IPAdres
                            );
                        StreamWriter sr = new StreamWriter(@"c:\lcdler.txt", true);
                        sr.WriteLine(DateTime.Now.ToString() + " Kaydolamadı " + lcdClient.ATID.ToString() + "; " + lcdClient.IPAdres.ToString() + "; ");
                        sr.Flush();
                        sr.Close();
                    }
                }
                break;

            case RequestCommadType.ClientUnRegister:
                var removeITClient = from x in RegisteredClients
                                     //where x.IPAdres.ToString() == CommandData[2]
                                     where x.ATID.ToString() == CommandData[1]
                                     select x;

                foreach (LCDClient item in removeITClient.ToList())
                {
                    RegisteredClients.Remove(item);

                    StreamWriter sr = new StreamWriter(@"c:\lcdler.txt", true);
                    sr.WriteLine(DateTime.Now.ToString() + " unRegister " + item.ATID.ToString() + "; " + item.IPAdres.ToString() + "; ");
                    sr.Flush();
                    sr.Close();
                }


                break;

            default:
                break;
            }
        }
Пример #2
0
 public static void RemoveLCDClient(LCDClient _lcdClient)
 {
     RegisteredClients.Remove(_lcdClient);
 }