Example #1
0
 private void BtnCloudConnect_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (!string.IsNullOrEmpty(txtCloudAccountName.Text) && comboProvider.SelectedItem != null)
         {
             if (ServerInfo.Instance.CloudAccounts.Any(a => a.Name == txtCloudAccountName.Text && a.CloudID != WorkingAccount.CloudID))
             {
                 Utils.ShowErrorMessage(Properties.Resources.CloudAccounts_CloudNameAlreadyExists);
                 return;
             }
             WorkingAccount.Provider         = ((ServerInfo.CloudProvider)comboProvider.SelectedItem).Name;
             WorkingAccount.Name             = txtCloudAccountName.Text;
             WorkingAccount.ConnectionString = null;
             Task.Factory.StartNew(() =>
             {
                 try
                 {
                     WorkingAccount.FileSystem = WorkingAccount.Connect(this);
                     SetConnectStatus();
                 }
                 catch (Exception ex)
                 {
                     Application.Current.Dispatcher.Invoke(() => { TextStatus.Text = ex.Message; });
                 }
             });
         }
     }
     catch (Exception ex)
     {
         Utils.ShowErrorMessage(ex);
     }
 }
Example #2
0
        private void BtnCloudConnect_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(txtCloudAccountName.Text) && comboProvider.SelectedItem != null)
                {
                    if (ServerInfo.Instance.CloudAccounts.Any(
                            a => a.Name == txtCloudAccountName.Text && a.CloudID != WorkingAccount.CloudID))
                    {
                        Utils.ShowErrorMessage(Shoko.Commons.Properties.Resources.CloudAccounts_CloudNameAlreadyExists);
                        return;
                    }
                    WorkingAccount.Provider         = ((ServerInfo.CloudProvider)comboProvider.SelectedItem).Name;
                    WorkingAccount.Name             = txtCloudAccountName.Text;
                    WorkingAccount.ConnectionString = null;
                    Task.Factory.StartNew(() =>
                    {
                        try
                        {
                            WorkingAccount.FileSystem = WorkingAccount.Connect();
                            SetConnectStatus();
                        }

                        catch (ReflectionTypeLoadException ex)
                        {
                            StringBuilder sb = new StringBuilder();
                            foreach (Exception exSub in ex.LoaderExceptions)
                            {
                                sb.AppendLine(exSub.Message);
                                FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
                                if (exFileNotFound != null)
                                {
                                    if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
                                    {
                                        sb.AppendLine("Fusion Log:");
                                        sb.AppendLine(exFileNotFound.FusionLog);
                                    }
                                }
                                sb.AppendLine();
                            }
                            Application.Current.Dispatcher.Invoke(() => { TextStatus.Text = sb.ToString(); });
                            logger.Error(sb.ToString());
                            //Display or log the error based on your application.
                        }
                        catch (Exception ex)
                        {
                            Application.Current.Dispatcher.Invoke(() => { TextStatus.Text = ex.Message; });
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }