コード例 #1
0
        private void BindExistingDatabases()
        {
            string resourceGroup = GetSelectedDatabaseResourceGroup();

            if (String.IsNullOrEmpty(resourceGroup))
            {
                return; // application does not require database
            }
            // databases
            WebApplicationGalleryParamControl databaseControl = FindParameterControlByTag(DeploymentParameterWellKnownTag.DBName);

            if (databaseControl != null && databaseMode.SelectedValue == "existing")
            {
                // bind databases
                SqlDatabase[] databases = ES.Services.DatabaseServers.GetSqlDatabases(PanelSecurity.PackageId, resourceGroup, false);

                // disable regexp validator
                databaseControl.ValidationKind &= ~DeploymentParameterValidationKind.RegularExpression;

                // enable enumeration
                List <string> databaseNames = new List <string>();
                databaseNames.Add(""); // add empty database
                foreach (SqlDatabase database in databases)
                {
                    databaseNames.Add(database.Name);
                }

                databaseControl.ValidationKind  |= DeploymentParameterValidationKind.Enumeration;
                databaseControl.ValidationString = String.Join(",", databaseNames.ToArray());

                // fill users list
                WebApplicationGalleryParamControl userControl = FindParameterControlByTag(DeploymentParameterWellKnownTag.DBUserName);
                if (userControl != null)
                {
                    SqlUser[] users = ES.Services.DatabaseServers.GetSqlUsers(PanelSecurity.PackageId, resourceGroup, false);

                    // disable regexp validator
                    userControl.ValidationKind &= ~DeploymentParameterValidationKind.RegularExpression;

                    // enable enumeration
                    List <string> userNames = new List <string>();
                    userNames.Add(""); // add empty username
                    foreach (SqlUser user in users)
                    {
                        userNames.Add(user.Name);
                    }

                    userControl.ValidationKind  |= DeploymentParameterValidationKind.Enumeration;
                    userControl.ValidationString = String.Join(",", userNames.ToArray());

                    // username password
                    WebApplicationGalleryParamControl userPasswordControl = FindParameterControlByTag(DeploymentParameterWellKnownTag.DBUserPassword);
                    if (userPasswordControl != null)
                    {
                        userPasswordControl.WellKnownTags &= ~DeploymentParameterWellKnownTag.New;
                    }
                }
            }
        }
コード例 #2
0
        protected void repParams_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            WebApplicationGalleryParamControl paramControl = e.Item.FindControl("param") as WebApplicationGalleryParamControl;

            if (paramControl != null)
            {
                paramControl.BindParameter(e.Item.DataItem as DeploymentParameter);
            }
        }
コード例 #3
0
 private WebApplicationGalleryParamControl FindParameterControlByTag(DeploymentParameterWellKnownTag tag)
 {
     foreach (RepeaterItem item in repParams.Items)
     {
         WebApplicationGalleryParamControl paramControl = item.FindControl("param") as WebApplicationGalleryParamControl;
         if (paramControl != null && (paramControl.WellKnownTags & tag) == tag)
         {
             return(paramControl);
         }
     }
     return(null);
 }
コード例 #4
0
        private List <DeploymentParameter> GetParameters()
        {
            // get the information about selected database engine
            string resourceGroup = GetSelectedDatabaseResourceGroup();
            DeploymentParameterWellKnownTag databaseEngine = GetSelectedDatabaseEngine();

            // collect parameters
            List <DeploymentParameter> parameters = new List <DeploymentParameter>();

            foreach (RepeaterItem item in repParams.Items)
            {
                WebApplicationGalleryParamControl paramControl = item.FindControl("param") as WebApplicationGalleryParamControl;
                if (paramControl != null)
                {
                    // store parameter in the collection
                    DeploymentParameter param = paramControl.GetParameter();
                    parameters.Add(param);

                    // set database engine flag
                    param.WellKnownTags &= ~databaseEngineTags; // reset all database flags
                    param.WellKnownTags |= databaseEngine;      // set seleced
                }
            }

            // add the information about selected resource group
            if (!String.IsNullOrEmpty(resourceGroup))
            {
                parameters.Add(new DeploymentParameter()
                {
                    Name          = DeploymentParameter.ResourceGroupParameterName,
                    Value         = resourceGroup,
                    WellKnownTags = databaseEngine
                });
            }

            return(parameters);
        }