Exemplo n.º 1
0
        static StoredSettings()
        {
            TranslationManager.Instance.LanguageChanged += OnLanguageChanged;
            IVtsWebService client = Infrastructure.Container.GetInstance <IVtsWebService>();

            try
            {
                if (client.CheckConnection() == "ok")
                {
                    string login        = AgentIsolatedStorageHelper.Login;
                    string passwordHash = AgentIsolatedStorageHelper.PasswordHash;
                    if (String.IsNullOrEmpty(login) || String.IsNullOrEmpty(passwordHash))
                    {
                        return;
                    }
                    UserDto userDto = client.AuthenticateUser(login, passwordHash);
                    if (userDto != null)
                    {
                        storedUser = UserAssembler.FromDtoToDomainObject(userDto);
                    }
                    else
                    {
                        Log.Warn("Could not log on with stored credentials!");
                    }
                    TranslationManager.Instance.CurrentLanguageEnum =
                        AgentIsolatedStorageHelper.Language;
                }
            }
            catch (Exception p)
            {
                Log.Error(p.Message);
            }
        }
Exemplo n.º 2
0
        private List <string> SelectSupportedVehicles(List <string> allVins)
        {
            IVtsWebService service         = Infrastructure.Container.GetInstance <IVtsWebService>();
            List <string>  unsupportedVins = service.
                                             CheckVinsReturnUnsupported(allVins.ToArray()).ToList();
            List <string> result = new List <string>();

            foreach (string vin in allVins)
            {
                if (unsupportedVins.Contains(vin,
                                             StringComparer.InvariantCultureIgnoreCase))
                {
                    // report unsupported vehicle
                    new List <PsaTraceSignature>();
                    List <PsaTrace> tracesToGetSignatures = traceInfos.
                                                            Where(t => t.Trace.Vin == vin).
                                                            Select(t => t.Trace).ToList();
                    List <PsaTraceSignature> signaturesOfTracesForUnsupportedVehicle =
                        GetTraceSignaturesForTracesList(tracesToGetSignatures);
                    StatusUpdated.Invoke(DataSynchronizationStatus.VehicleUnsupported,
                                         signaturesOfTracesForUnsupportedVehicle);
                }
                else
                {
                    result.Add(vin);
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        private void RegisterAndAssociateNewVehicles(List <string> vins)
        {
            IVtsWebService service = Infrastructure.Container.GetInstance <IVtsWebService>();

            service.RegisterVehicles(vins.ToArray());
            service.AssociateVehiclesWithUser(vins.ToArray(),
                                              LoggedUserContext.LoggedUser.Login,
                                              LoggedUserContext.LoggedUser.PasswordHash);
        }
Exemplo n.º 4
0
 private void UpdateMileage()
 {
     try
     {
         IVtsWebService client = Infrastructure.Container.GetInstance <IVtsWebService>();
         client.UpdateVehicleMileage(Vin, Mileage);
     }
     catch (Exception e)
     {
         Log.Error(e, "Cannot update vehicle's mileage.");
     }
 }
Exemplo n.º 5
0
        private void CheckConnectionInBackground(object sender, DoWorkEventArgs doWorkEventArgs)
        {
            IVtsWebService service = Infrastructure.Container.GetInstance <IVtsWebService>();

            try
            {
                string connectionResult = service.CheckConnection();
                if (String.Equals(connectionResult, "ok",
                                  StringComparison.InvariantCultureIgnoreCase))
                {
                    connectionIsOk = true;
                }
            }
            catch (Exception)
            {
                connectionIsOk = false;
            }
        }
Exemplo n.º 6
0
        public void TriggerUsernameValidation()
        {
            textBlock.Text = String.Empty;
            progressBarCircular.Visibility = Visibility.Visible;
            IVtsWebService client = Infrastructure.Container.GetInstance <IVtsWebService>();

            try
            {
                string username = UsernameInput;
                if (String.IsNullOrEmpty(username))
                {
                    progressBarCircular.Visibility = Visibility.Collapsed;
                    textBlock.Text      = String.Empty;
                    IsUsernameValidated = false;
                    return;
                }
                bool occupied = client.CheckUsernameAvailability(username);
                if (!occupied)
                {
                    progressBarCircular.Visibility = Visibility.Collapsed;
                    textBlock.Text       = "Available";
                    textBlock.Foreground = new SolidColorBrush(Colors.Green);
                    IsUsernameValidated  = true;
                }
                else
                {
                    progressBarCircular.Visibility = Visibility.Collapsed;
                    textBlock.Text       = "Occupied";
                    textBlock.Foreground = new SolidColorBrush(Colors.Red);
                    IsUsernameValidated  = false;
                }
            }
            catch (Exception e)
            {
                progressBarCircular.Visibility = Visibility.Collapsed;
                Log.Error(e, e.Message);
                ErrorWindow wnd = new ErrorWindow(e, e.Message);
                wnd.Owner = MainWindowKeeper.MainWindowInstance as Window;
                wnd.ShowDialog();
            }
        }
Exemplo n.º 7
0
 public UserController(IVtsWebService service)
 {
     this.service = service;
 }
Exemplo n.º 8
0
 public VehiclesController(IVtsWebService service)
 {
     this.service = service;
 }
Exemplo n.º 9
0
        private void GoForward()
        {
            if (IsRegister)
            {
                User user = new User();
                user.Login          = Username;
                user.PasswordHash   = Sha256Hash.Calculate(PasswordText);
                user.Role           = UserRole.Partner;
                user.RegisteredDate = DateTime.Now;
                user.Email          = Email;

                user.Name    = "???";
                user.Phone   = "???";
                user.Profile = null;
                user.Surname = "???";

                UserDto        userDto = UserAssembler.FromDomainObjectToDto(user);
                IVtsWebService service = Infrastructure.Container.GetInstance <IVtsWebService>();
                try
                {
                    service.RegisterUser(userDto);
                    UserDto userDtoNew = service.AuthenticateUser(Username,
                                                                  Sha256Hash.Calculate(PasswordText));
                    User userNew = UserAssembler.FromDtoToDomainObject(userDtoNew);
                    LoggedUserContext.LoggedUser = userNew;
                    StoredSettings.Current       = userNew;
                }
                catch (Exception e)
                {
                    Log.Error(e, e.Message);
                    ErrorWindow wnd = new ErrorWindow(e.Message);
                    wnd.Owner = MainWindowKeeper.MainWindowInstance as Window;
                    wnd.ShowDialog();
                }
            }
            else if (IsLogon)
            {
                VtsWebServiceClient service = new VtsWebServiceClient();
                try
                {
                    UserDto userDto = service.AuthenticateUser(Username,
                                                               Sha256Hash.Calculate(PasswordText));
                    if (userDto != null)
                    {
                        User user = UserAssembler.FromDtoToDomainObject(userDto);
                        LoggedUserContext.LoggedUser = user;
                        StoredSettings.Current       = user;
                    }
                    else
                    {
                        ShowIncorrectCredentialsText();
                    }
                }
                catch (Exception e)
                {
                    Log.Error(e, e.Message);
                    ErrorWindow wnd = new ErrorWindow(e.Message);
                    wnd.Owner = MainWindowKeeper.MainWindowInstance as Window;
                    wnd.ShowDialog();
                }
            }
        }