//private static void OnSmartWatchConnected(Device device)
        //{
        //    IOTService service = GetOTService();
        //    try
        //    {
        //        var smartWatchInfo = service.GetSmartWatchUser(device.ClientUniqueID);
        //        if (smartWatchInfo.Succeeded)
        //        {
        //            DeleteAllMessages(device.ClientUniqueID);
        //            lock (_clientMessagesLock)
        //            {
        //                if (!clients.ContainsKey(device.ClientUniqueID))
        //                {
        //                    clients.Add(device.ClientUniqueID, new ClientRepository
        //                    {
        //                        UserName = device.Username,
        //                        Password = device.Password,
        //                        Equipment = smartWatchInfo.Equipment,
        //                        WorkArea = smartWatchInfo.WorkArea,
        //                        Role = smartWatchInfo.Role
        //                    });
        //                }
        //            }
        //            SendDPICheck(device);
        //        }
        //        else
        //        {
        //            SendMessage(device.ClientUniqueID, OTMessageType.Warning, "Username o Password errati", string.Empty);
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        var x = e.Message;
        //    }

        //}

        private static MessagePriority GetPriority(OTMessageType messageType)
        {
            switch (messageType)
            {
            case OTMessageType.DPIBoots:
                return(MessagePriority.Informational);

            case OTMessageType.DPIGloves:
                return(MessagePriority.Informational);

            case OTMessageType.DPIHelmet:
                return(MessagePriority.Informational);

            case OTMessageType.DPITools:
                return(MessagePriority.Informational);

            case OTMessageType.MaterialCall:
                return(MessagePriority.Hight);

            case OTMessageType.TeamLeaderCall:
                return(MessagePriority.Hight);

            case OTMessageType.Serial:
                return(MessagePriority.Normal);

            case OTMessageType.Warning:
                return(MessagePriority.Warning);

            case OTMessageType.AcceptedCall:
                return(MessagePriority.Informational);

            default:
                return(MessagePriority.Normal);
            }
        }
        private static bool SendMessage <TData>(string clientId, OTMessageType messageType, string text, string image64, TData messageData)
        {
            bool           isCall = messageType.Equals(OTMessageType.TeamLeaderCall) || messageType.Equals(OTMessageType.MaterialCall);
            MessageOptions mo     = new MessageOptions
            {
                Vibration = isCall || messageType.Equals(OTMessageType.Warning)
            };

            if (!string.IsNullOrEmpty(image64))
            {
                mo.Image64 = image64;
            }
            PushMessage pm = new PushMessage()
            {
                ClientUniqueID  = clientId,
                MessagePriority = GetPriority(messageType),
                ACKType         = ACKType.Boolean,
                UsingACK        = true,
                MessageOptions  = mo,
                Type            = MessageType.SingleMessageServerToClient,
                ServerMessageId = $"{messageType}_{Guid.NewGuid()}",
                MessageText     = string.IsNullOrEmpty(text) ? null : text
            };
            string messageId;
            bool   succeeded = false;

            lock (_deviceConnectorLock)
            {
                //var x = JsonConvert.DeserializeObject<List<PushMessage>>(File.ReadAllText(StaticRepository.CheckRepository(ConfigurationManager.AppSettings["DataPath"], ConfigurationManager.AppSettings["DataFileName"])));

                succeeded = _deviceConnector.SendMessage(pm, out messageId);
            }
            if (succeeded)
            {
                AddToClientRepository(pm, messageData);
            }
            return(succeeded);
        }
 private static bool SendMessage(string clientId, OTMessageType messageType, string text, string image64)
 {
     return(SendMessage <object>(clientId, messageType, text, image64, null));
 }