public static int SendToDesktop(string ccmac, string deskmac, string instruction, int strategyid, int strategydeskid)
        {
            int result = 0;
            Dictionary <string, string> DatatoSend = new Dictionary <string, string>();

            DatatoSend.Add("Type", "Command");
            DatatoSend.Add("Code", instruction);
            DatatoSend.Add("CCmac", ccmac.ToUpper());
            DatatoSend.Add("Deskmac", deskmac.ToUpper());
            var s = JsonSerializer.Serialize(DatatoSend);

            Console.WriteLine("data sending to desktop client: " + s);
            try
            {
                var obj = Clients.Where(x => x.Value.MacAddress == deskmac.ToUpper()).Select(x => x.Value.workSocket).FirstOrDefault();
                if (obj != null)
                {
                    byte[] b = Encoding.ASCII.GetBytes(s);
                    Send(obj, b);
                    if (!WaitList.ContainsKey(ccmac.ToUpper()))
                    {
                        var w = new WaitListClass()
                        {
                            StrategyDescId = strategydeskid,
                            Strategyid     = strategyid, TimeofExec = DateTime.Now,
                            Command        = instruction
                        };
                        WaitList.Add(ccmac.ToUpper(), w);
                    }

                    result = 1;
                }
                else
                {
                    result = 0;
                }
            }
            catch (Exception ex)
            {
                if (!WaitList.ContainsKey(ccmac.ToUpper()))
                {
                    var w = new WaitListClass()
                    {
                        StrategyDescId = strategydeskid,
                        Strategyid     = strategyid,
                        TimeofExec     = DateTime.Now,
                        Command        = instruction
                    };
                    WaitList.Add(ccmac.ToUpper(), w);
                }
                File.AppendAllText(docPath, Environment.NewLine + DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToShortTimeString() + "Error in Sendtodesktop: " + ex.StackTrace);
            }
            return(result);
        }
        /// <summary>
        /// Checks if the shutdwon instruction is sent to desktop client or not
        /// </summary>
        private static async Task CheckShutdownInstruction()
        {
            WaitListClass data = null;
            Dictionary <string, string> DatatoSend = new Dictionary <string, string>();

            try
            {
                lock (WaitList)
                {
                    var val = WaitList.Select(x => x.Value);

                    var machineMacList = WaitList.Where(x => DateTime.Now.Subtract(x.Value.TimeofExec).TotalSeconds >= 35).Select(x => x.Key).ToList();
                    foreach (var m in machineMacList)
                    {
                        data = WaitList.Where(x => x.Key == m).Select(x => x.Value).FirstOrDefault();
                        WaitList.Remove(m);
                        var deskmac = DesktopList.Where(x => x.Value == m).Select(x => x.Key).FirstOrDefault();
                        DatatoSend.Add("Type", "Command");
                        DatatoSend.Add("Code", "ExeShutdown");//
                        DatatoSend.Add("CCmac", m.ToUpper());
                        DatatoSend.Add("Deskmac", deskmac.ToUpper());
                        var    t    = System.Text.Json.JsonSerializer.Serialize(DatatoSend);
                        byte[] b    = Encoding.UTF8.GetBytes(t);
                        var    sock = Clients.Where(x => x.Value.MacAddress == deskmac).Select(x => x.Value.workSocket).FirstOrDefault();
                        Send(sock, b);
                    }
                }
                if (data != null)
                {
                    var stid     = data.Strategyid;
                    var stdescid = data.StrategyDescId;
                    var instr    = data.Inst;
                    var equipid  = data.EquipmentId;
                    await AsyncTcpListener.ReceiveMacFromDesktop(data.Ccmac, "CloseStrategy", stid, stdescid, instr, equipid);
                }
            }
            catch (Exception ex)
            {
                loggerFile.Debug(Environment.NewLine + DateTime.Now.ToLongDateString() + " "
                                 + DateTime.Now.ToLongTimeString() + " Error Message in CheckShutdownInstruction() : " +
                                 ex.Message + "  inner details : " + ex.InnerException + " stack trace: " + ex.StackTrace);
            }
        }