Esempio n. 1
0
 private void ValidateLogin(WorkerTask.WorkFinishedHandler handler, string login, string password)
 {
     worker.EnqueueTask(new WorkerTask(
         (args) =>
         {
             var log = args[0] as string;
             var pass = args[1] as string;
             try
             {
                 using (var proxy = new WorkChannel())
                 {
                     var result = proxy.GetUser(new EmptyRequest() { Login = log, Password = pass });
                     if (result == null) return null;
                     return result.Data;
                 }
             }
             catch(Exception exc)
             {
                 Console.WriteLine(exc.Message);
                 return exc;
             }
         },handler, login, password));
 }
 public void Load()
 {
     ModifiedPasssword = ModifiedUserData = false;
     Worker.EnqueueTask(new WorkerTask((args) =>
     {
         var user = args[0] as User;
         try
         {
             if (user == null)
                 throw new PizzaNetException(Utils.Messages.NO_USER_LOGGED_IN);
             using (var proxy = new WorkChannel())
             {
                 return proxy.GetUser(new EmptyRequest { Login = user.Email, Password = user.Password });
             }
         }
         catch (Exception e)
         {
             return e;
         }
     }, (s, args) =>
     {
         if (args.Result is Exception)
         {
             Utils.HandleException(args.Result as Exception);
             return;
         }
         var u = args.Result as SingleItemResponse<UserDTO>;
         if (u == null)
         {
             Utils.showError(String.Format(Utils.Messages.NO_USER_FOUND_FORMAT, ClientConfig.CurrentUser.Email));
             return;
         }
         ClientConfig.CurrentUser.UpdateWithUserDTO(u.Data);
         this.User = ClientConfig.CurrentUser;
         CurrentPassword = PasswordRepeated = NewPassword = "";
         Password = ClientConfig.CurrentUser.Password;
     }, ClientConfig.CurrentUser));
 }