Exemple #1
0
        private void AddConnectionTreeNode(string accountEndpoint, AccountSettings accountSettings)
        {
            try
            {
                DocumentClient client = new DocumentClient(new Uri(accountEndpoint), accountSettings.MasterKey,
                                                           new ConnectionPolicy {
                    ConnectionMode = accountSettings.ConnectionMode, ConnectionProtocol = accountSettings.Protocol
                });

                DatabaseAccountNode dbaNode = new DatabaseAccountNode(accountEndpoint, client);
                this.treeView1.Nodes.Add(dbaNode);

                dbaNode.Tag = client.GetDatabaseAccountAsync().Result;
            }
            catch (Exception e)
            {
                Program.GetMain().SetResultInBrowser(null, e.ToString(), true);

                // delete it.
                this.RemoveAccountFromSettings(accountEndpoint);
            }
        }
Exemple #2
0
        private void AddAccountToSettings(string accountEndpoint, AccountSettings accountSettings)
        {
            bool found = false;

            // if the account is not in tree view top level, add it!
            for (int i = 0; i < Settings.Default.AccountSettingsList.Count; i = i + 2)
            {
                if (string.Compare(accountEndpoint, Properties.Settings.Default.AccountSettingsList[i], true) == 0)
                {
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                Settings.Default.AccountSettingsList.Add(accountEndpoint);
                Settings.Default.AccountSettingsList.Add(JsonConvert.SerializeObject(accountSettings));

                Settings.Default.Save();

                AddConnectionTreeNode(accountEndpoint, accountSettings);
            }
        }
 public AccountSettingsForm()
 {
     InitializeComponent();
     AccountSettings = new AccountSettings();
 }
        private void AddConnectionTreeNode(string accountEndpoint, AccountSettings accountSettings)
        {
            try
            {
                DocumentClient client = new DocumentClient(new Uri(accountEndpoint), accountSettings.MasterKey,
                    new ConnectionPolicy { ConnectionMode = accountSettings.ConnectionMode, ConnectionProtocol = accountSettings.Protocol });

                DatabaseAccountNode dbaNode = new DatabaseAccountNode(accountEndpoint, client);
                this.treeView1.Nodes.Add(dbaNode);

                dbaNode.Tag = client.GetDatabaseAccountAsync().Result;

            }
            catch (Exception e)
            {
                Program.GetMain().SetResultInBrowser(null, e.ToString(), true);
            }
        }
        private void AddAccountToSettings(string accountEndpoint, AccountSettings accountSettings)
        {
            bool found = false;
            // if the account is not in tree view top level, add it!
            for (int i = 0; i < Settings.Default.AccountSettingsList.Count; i = i + 2)
            {
                if (string.Compare(accountEndpoint, Properties.Settings.Default.AccountSettingsList[i], StringComparison.OrdinalIgnoreCase) == 0)
                {
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                Settings.Default.AccountSettingsList.Add(accountEndpoint);
                Settings.Default.AccountSettingsList.Add(JsonConvert.SerializeObject(accountSettings));

                Settings.Default.Save();

                AddConnectionTreeNode(accountEndpoint, accountSettings);
            }
        }
 public SettingsForm()
 {
     InitializeComponent();
     AccountSettings = new AccountSettings();
 }
Exemple #7
0
        private void AddConnectionTreeNode(string accountEndpoint, AccountSettings accountSettings)
        {
            try
            {
                string suffix = Constants.ApplicationName + "/" + Constants.ProductVersion;

                DocumentClient client = new DocumentClient(new Uri(accountEndpoint), accountSettings.MasterKey,
                    new ConnectionPolicy { ConnectionMode = accountSettings.ConnectionMode, 
                                           ConnectionProtocol = accountSettings.Protocol,
                                           UserAgentSuffix = suffix
                    });

                DatabaseAccountNode dbaNode = new DatabaseAccountNode(accountEndpoint, client);
                this.treeView1.Nodes.Add(dbaNode);

                // Update the map.
                DocumentClientExtension.AddOrUpdate(client.ServiceEndpoint.Host, accountSettings.IsNameBased);
                if (accountSettings.IsNameBased)
                {
                    dbaNode.ForeColor = Color.Green;
                }
                else
                {
                    dbaNode.ForeColor = Color.Blue;
                }

                // Set the tag to the DatabaseAccount resource object, this might fail if the service is not available.
                dbaNode.Tag = client.GetDatabaseAccountAsync().Result;
            }
            catch (Exception e)
            {
                Program.GetMain().SetResultInBrowser(null, e.ToString(), true);
            }
        }