Ejemplo n.º 1
0
        private void BindAccountRegionList()
        {
            try
            {
                if (CheckBoxAllRegions.Checked)
                {
                    PanelSelectRegion.Visible = false;
                }
                else
                {
                    PanelSelectRegion.Visible = true;
                }

                RepeaterRegions.DataSource = AccountRegion.GetAccountRegionListByAccountId(this.accountId);
                RepeaterRegions.DataBind();
            }
            catch (System.Data.SqlClient.SqlException sqlEx)
            {
                LabelError.Text = "";
                for (int i = 0; i < sqlEx.Errors.Count; i++)
                {
                    LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
                }
                PanelError.Visible = true;
            }
        }
Ejemplo n.º 2
0
        public static Uri SetupSingleRegionAccount(
            string accountName,
            Cosmos.ConsistencyLevel consistencyLevel,
            Mock <IHttpHandler> mockHttpHandler,
            out string primaryRegionEndpoint)
        {
            primaryRegionEndpoint = $"https://{accountName}-eastus.documents.azure.com";
            AccountRegion region = new AccountRegion()
            {
                Name     = "East US",
                Endpoint = primaryRegionEndpoint
            };

            AccountProperties accountProperties = new AccountProperties()
            {
                Id = accountName,
                WriteLocationsInternal = new Collection <AccountRegion>()
                {
                    region
                },
                ReadLocationsInternal = new Collection <AccountRegion>()
                {
                    region
                },
                EnableMultipleWriteLocations = false,
                Consistency = new AccountConsistency()
                {
                    DefaultConsistencyLevel = consistencyLevel
                },
                SystemReplicationPolicy = new ReplicationPolicy()
                {
                    MinReplicaSetSize = 3,
                    MaxReplicaSetSize = 4
                },
                ReadPolicy = new ReadPolicy()
                {
                    PrimaryReadCoefficient   = 1,
                    SecondaryReadCoefficient = 1
                },
                ReplicationPolicy = new ReplicationPolicy()
                {
                    AsyncReplication  = false,
                    MinReplicaSetSize = 3,
                    MaxReplicaSetSize = 4
                }
            };


            Uri endpointUri = new Uri($"https://{accountName}.documents.azure.com");

            mockHttpHandler.Setup(x => x.SendAsync(
                                      It.Is <HttpRequestMessage>(x => x.RequestUri == endpointUri),
                                      It.IsAny <CancellationToken>()))
            .Returns <HttpRequestMessage, CancellationToken>((request, cancellationToken) => Task.FromResult(new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(JsonConvert.SerializeObject(accountProperties))
            }));
            return(endpointUri);
        }
Ejemplo n.º 3
0
        protected void CheckBoxAllRegions_CheckedChanged(object sender, EventArgs e)
        {
            if (CheckBoxAllRegions.Checked)
            {
                AccountRegion.LinkAll(this.accountId, this.Master.LoggedOnAccount);
            }
            else
            {
                AccountRegion.DeleteAll(this.accountId);
            }

            BindAccountRegionList();
        }
Ejemplo n.º 4
0
 protected void ButtonAddRegion_Click(object sender, EventArgs e)
 {
     try
     {
         if (DropDownListRegion.Items.Count > 0)
         {
             AccountRegion.InsertAccountRegion(this.accountId, DropDownListRegion.SelectedItem.ToString(), this.Master.LoggedOnAccount);
             BindAccountRegionList();
         }
     }
     catch (System.Data.SqlClient.SqlException sqlEx)
     {
         LabelError.Text = "";
         for (int i = 0; i < sqlEx.Errors.Count; i++)
         {
             LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
         }
         PanelError.Visible = true;
     }
 }
Ejemplo n.º 5
0
 protected void RepeaterRegions_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     try
     {
         switch (e.CommandName.ToLower())
         {
         case "remove":
         {
             AccountRegion.DeleteAccountRegionByAccountRegionId(Convert.ToInt32(e.CommandArgument));
             BindAccountRegionList();
             break;
         }
         }
     }
     catch (System.Data.SqlClient.SqlException sqlEx)
     {
         LabelError.Text = "";
         for (int i = 0; i < sqlEx.Errors.Count; i++)
         {
             LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
         }
         PanelError.Visible = true;
     }
 }