public WcfCrmClient(WcfConnectionProperties connectionProperties, ClientCredential userCredentials)
 {
     _connectionProperties = connectionProperties;
     _clientCredential = userCredentials;
 }
 public AppPreferences()
 {
     ClientCredential = new ClientCredential();
     ConnectionProperties = new WcfConnectionProperties();
 }
 public void Login(ClientCredential user)
 {
     try
     {
         _server.Login(user);
     }
     catch (Exception ex)
     {
         Messenger.Default.Send(new NotificationMessage(ex.Message, MainViewModel.ShowWcfWarningWindow));
     }
 }
 public void Disconnect(ClientCredential user)
 {
     try
     {
         _server.Disconnect(user);
     }
     catch (Exception) { }
 }
        public void Disconnect(ClientCredential user)
        {
            if (user == null)
                return;

            var client = _clients.FirstOrDefault(cl => cl.Value.Credential.PhoneNumber.Equals(user.PhoneNumber) && cl.Value.Credential.UserName.Equals(user.UserName));
            if (client.Key != null)
            {
                CrmClient removedClient;
                _clients.TryRemove(client.Key, out removedClient);

                OnNotificationReceived(new NotificationEventArgs() { Notification = string.Format("Client disconnected: {0} ({1})", user.UserName, user.PhoneNumber) });
            }
        }
        public void Login(ClientCredential user)
        {
            var callback = GetContext();
            var client = new CrmClient(callback, user);

            if (_clients.TryAdd(callback, client))
                client.Disconnected += ClientDisconnected;

            OnNotificationReceived(new NotificationEventArgs() { Notification = string.Format("New client connected: {0} ({1})", user.UserName, user.PhoneNumber) });
        }
 public CrmClient(ICrmClient client, ClientCredential credential)
 {
     Credential = credential;
     Client = client;
 }