Revision 65282d58 trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs

b/trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs
12 12
using Hardcodet.Wpf.TaskbarNotification;
13 13
using Pithos.Client.WPF.Configuration;
14 14
using Pithos.Client.WPF.FileProperties;
15
using Pithos.Client.WPF.Preferences;
15 16
using Pithos.Client.WPF.SelectiveSynch;
16 17
using Pithos.Client.WPF.Services;
17 18
using Pithos.Client.WPF.Shell;
......
509 510
						if (AbandonRetry(monitor, retries))
510 511
							return;
511 512

  
512
						if (IsUnauthorized(exc))
513
						{
514
							var message = String.Format("API Key Expired for {0}. Starting Renewal",monitor.UserName);                            
515
							Log.Error(message,exc);
516
							TryAuthorize(monitor,retries).Wait();
517
						}
518
						else
519
						{
520
							TryLater(monitor, exc,retries);
521
						}
513
                        HttpStatusCode statusCode =HttpStatusCode.OK;
514
			            var response = exc.Response as HttpWebResponse;
515
                        if(response!=null)
516
					        statusCode = response.StatusCode;
517

  
518
                        switch (statusCode)
519
                        {
520
                            case HttpStatusCode.Unauthorized:
521
                                var message = String.Format("API Key Expired for {0}. Starting Renewal",
522
                                                            monitor.UserName);
523
                                Log.Error(message, exc);
524
                                TryAuthorize(monitor, retries).Wait();
525
                                break;
526
                            case HttpStatusCode.ProxyAuthenticationRequired:
527
                                TryAuthenticateProxy(monitor,retries);
528
                                break;
529
                            default:
530
                                TryLater(monitor, exc, retries);
531
                                break;
532
                        }
522 533
					}
523 534
					catch (Exception exc)
524 535
					{
......
531 542
			});
532 543
		}
533 544

  
534
		private bool AbandonRetry(PithosMonitor monitor, int retries)
545
	    private void TryAuthenticateProxy(PithosMonitor monitor,int retries)
546
	    {
547
	        Execute.OnUIThread(() =>
548
	                               {
549
	                                   var proxyAccount = new ProxyAccountViewModel(this.Settings);
550
	                                   if (true == _windowManager.ShowDialog(proxyAccount))
551
	                                   {
552
                                           
553
	                                       StartMonitor(monitor, retries);
554
	                                       NotifyOfPropertyChange(() => Accounts);
555
	                                   }
556
	                               });
557
	    }
558

  
559
	    private bool AbandonRetry(PithosMonitor monitor, int retries)
535 560
		{
536 561
			if (retries > 1)
537 562
			{

Also available in: Unified diff