Esempio n. 1
0
 protected void OnAuthRequest(AuthEventArgs evt)
 {
     if (this.AuthRequest != null)
     {
         this.AuthRequest(this, evt);
     }
 }
Esempio n. 2
0
        private void BackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                string msg = string.Format("System error while loading directory: {0}", e.Error.Message);
                Log.Error(msg, e.Error);
                this.ViewModel.Status = msg;
            }
            else
            {
                ListDirectoryResult result = (ListDirectoryResult)e.Result;
                switch (result.StatusCode)
                {
                case ResultStatusCode.RetryAuthentication:
                    // Request login- first login will be initiated from here after failing 1st call to pscp which attemps key based auth
                    AuthEventArgs authEvent = new AuthEventArgs
                    {
                        UserName = this.Session.Username,
                        Password = this.Session.Password
                    };
                    this.OnAuthRequest(authEvent);
                    if (authEvent.Handled)
                    {
                        // retry listing
                        this.Session.Username = authEvent.UserName;
                        this.Session.Password = authEvent.Password;
                        this.LoadDirectory(result.Path);
                    }
                    break;

                case ResultStatusCode.Success:
                    // list files
                    string msg = result.MountCount > 0
                            ? string.Format("{0} items", result.MountCount)
                            : string.Format("{0} files {1} directories", result.FileCount, result.DirCount);
                    this.ViewModel.Status      = string.Format("{0} @ {1}", msg, DateTime.Now);
                    this.CurrentPath           = result.Path;
                    this.ViewModel.CurrentPath = result.Path.Path;
                    BaseViewModel.UpdateList(this.ViewModel.Files, result.Files);
                    break;

                case ResultStatusCode.Error:
                    string errMsg = result.ErrorMsg != null
                            ? result.ErrorMsg
                            : result.Error != null
                                ? string.Format("Error listing directory, {0}", result.Error.Message)
                                : "Unknown Error listing directory";

                    Log.Error(errMsg, result.Error);
                    this.ViewModel.Status = errMsg;
                    break;

                default:
                    Log.InfoFormat("Unknown result '{0}'", result.StatusCode);
                    break;
                }
            }
            this.ViewModel.BrowserState = BrowserState.Ready;
        }
Esempio n. 3
0
 void Presenter_AuthRequest(object sender, AuthEventArgs e)
 {
     // present login
     using (dlgLogin login = new dlgLogin(e.UserName))
     {
         login.StartPosition = FormStartPosition.CenterParent;
         if (login.ShowDialog(this) == DialogResult.OK)
         {
             e.UserName = login.Username;
             e.Password = login.Password;
             e.Handled  = true;
         }
         else
         {
             Log.InfoFormat("Login canceled.  Closing parent form");
             this.ParentForm.Close();
         }
     }
 }
Esempio n. 4
0
 void Presenter_AuthRequest(object sender, AuthEventArgs e)
 {
     // present login
     using (dlgLogin login = new dlgLogin(e.UserName))
     {
         login.StartPosition = FormStartPosition.CenterParent;
         if (login.ShowDialog(this) == DialogResult.OK)
         {
             e.UserName = login.Username;
             e.Password = login.Password;
             e.Handled = true;
         }
         else
         {
             Log.InfoFormat("Login canceled.  Closing parent form");
             this.ParentForm.Close();
         }
     }
 }
Esempio n. 5
0
 protected void OnAuthRequest(AuthEventArgs evt)
 {
     this.AuthRequest?.Invoke(this, evt);
 }
 private void BackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     if (e.Error != null)
     {
         string msg = string.Format("System error while loading directory: {0}", e.Error.Message);
         Log.Error(msg, e.Error);
         this.ViewModel.Status = msg;
     }
     else
     {
         ListDirectoryResult result = (ListDirectoryResult)e.Result;
         switch (result.StatusCode)
         {
             case ResultStatusCode.RetryAuthentication:
                 // Request login- first login will be initiated from here after failing 1st call to pscp which attemps key based auth
                 AuthEventArgs authEvent = new AuthEventArgs
                 {
                     UserName = this.Session.Username,
                     Password = this.Session.Password
                 };
                 this.OnAuthRequest(authEvent);
                 if (authEvent.Handled)
                 {
                     // retry listing
                     this.Session.Username = authEvent.UserName;
                     this.Session.Password = authEvent.Password;
                     this.LoadDirectory(result.Path);
                 }
                 break;
             case ResultStatusCode.Success:
                 // list files
                 string msg = result.MountCount > 0
                     ? string.Format("{0} items", result.MountCount)
                     : string.Format("{0} files {1} directories", result.FileCount, result.DirCount);
                 this.ViewModel.Status = string.Format("{0} @ {1}", msg, DateTime.Now);
                 this.CurrentPath = result.Path;
                 this.ViewModel.CurrentPath = result.Path.Path;
                 BrowserViewModel.UpdateList(this.ViewModel.Files, result.Files);
                 break;
             case ResultStatusCode.Error:
                 string errMsg = result.ErrorMsg != null
                     ? result.ErrorMsg
                     : result.Error != null
                         ? string.Format("Error listing directory, {0}", result.Error.Message)
                         : "Unknown Error listing directory";
                 Log.Error(errMsg, result.Error);
                 this.ViewModel.Status = errMsg;
                 break;
             default:
                 Log.InfoFormat("Unknown result '{0}'", result.StatusCode);
                 break;
         }
     }
     this.ViewModel.BrowserState = BrowserState.Ready;
 }
 protected void OnAuthRequest(AuthEventArgs evt)
 {
     if (this.AuthRequest != null)
     {
         this.AuthRequest(this, evt);
     }
 }