Ejemplo n.º 1
0
    /// <summary>
    /// Creates web template. Called when the "Create template" button is pressed.
    /// </summary>
    private bool CreateWebTemplate()
    {
        // Create new web template object
        WebTemplateInfo newTemplate = new WebTemplateInfo();

        // Set the properties
        newTemplate.WebTemplateDisplayName = "My new template";
        newTemplate.WebTemplateName        = "MyNewTemplate";
        newTemplate.WebTemplateDescription = "This is web template created by API Exapmle";
        newTemplate.WebTemplateFileName    = "~\\App_Data\\Templates\\MyNewTemplate";
        newTemplate.WebTemplateLicenses    = "F;S;B;N;C;P;R;E;U;";
        newTemplate.WebTemplatePackages    = "ECM;SCN;ADV;DOC;";

        // Set the web template order
        DataSet webTemplates = WebTemplateInfoProvider.GetWebTemplates(null, null, 0, "WebTemplateID", false);

        if (!DataHelper.DataSourceIsEmpty(webTemplates))
        {
            newTemplate.WebTemplateOrder = webTemplates.Tables[0].Rows.Count + 1;
        }
        else
        {
            newTemplate.WebTemplateOrder = 1;
        }

        // Save the web template
        WebTemplateInfoProvider.SetWebTemplateInfo(newTemplate);

        return(true);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Gets and bulk updates web templates. Called when the "Get and bulk update templates" button is pressed.
    /// Expects the CreateWebTemplate method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateWebTemplates()
    {
        // Prepare the parameters
        string where = "WebTemplateName LIKE N'MyNewTemplate%'";

        // Get the data
        DataSet templates = WebTemplateInfoProvider.GetWebTemplates(where, null);

        if (!DataHelper.DataSourceIsEmpty(templates))
        {
            // Loop through the individual items
            foreach (DataRow templateDr in templates.Tables[0].Rows)
            {
                // Create object from DataRow
                WebTemplateInfo modifyTemplate = new WebTemplateInfo(templateDr);

                // Update the properties
                modifyTemplate.WebTemplateDisplayName = modifyTemplate.WebTemplateDisplayName.ToUpper();

                // Save the changes
                WebTemplateInfoProvider.SetWebTemplateInfo(modifyTemplate);
            }

            return(true);
        }

        return(false);
    }
    /// <summary>
    /// Data bind.
    /// </summary>
    public void ReloadData()
    {
        if (WebTemplateInfoProvider.IsAnyTemplatePresent())
        {
            DataSet dsTemplates = WebTemplateInfoProvider.GetWebTemplates(null, "WebTemplateOrder", 0, null, true);
            if (!DataHelper.DataSourceIsEmpty(dsTemplates))
            {
                string firstTemplateName = "";
                int    firstTemplateId   = 0;

                // Find first allowed template
                foreach (DataRow row in dsTemplates.Tables[0].Rows)
                {
                    string templateEditions = ValidationHelper.GetString(row["WebTemplateLicenses"], "");
                    string templatePackages = ValidationHelper.GetString(row["WebTemplatePackages"], "");
                    if (IsTemplateAllowed(templateEditions, templatePackages))
                    {
                        firstTemplateName = ValidationHelper.GetString(row["WebTemplateName"], "");
                        firstTemplateId   = ValidationHelper.GetInteger(row["WebTemplateID"], 0);
                        break;
                    }
                }

                // Bind the list
                rptSites.DataSource = dsTemplates;
                rptSites.DataBind();

                // Select Corporate site by default
                if (string.IsNullOrEmpty(hdnLastSelected.Value) || (hdnLastSelected.Value == "0"))
                {
                    ltlScriptAfter.Text += ScriptHelper.GetScript("SelectTemplate('tpl" + firstTemplateId + "','" + firstTemplateName + "');");
                }
            }
        }
        else
        {
            plcInfo.Visible      = true;
            lblInfo.Text         = ResHelper.GetFileString("Install.TemplatesWarning");
            radWizard.Enabled    = false;
            radTemplate.Enabled  = false;
            plcTemplates.Visible = false;
            radExisting.Checked  = true;
        }
    }
Ejemplo n.º 4
0
    public void ReloadData()
    {
        // Load the data
        DataSet templates = WebTemplateInfoProvider.GetWebTemplates(null, "WebTemplateOrder", 0, "WebTemplateID,WebTemplateDisplayName,WebTemplateDescription,WebTemplateFileName", true);

        ucSelector.DataSource        = templates;
        ucSelector.IDColumn          = "WebTemplateID";
        ucSelector.DisplayNameColumn = "WebTemplateDisplayName";
        ucSelector.DescriptionColumn = "WebTemplateDescription";

        if (ucSelector.SelectedId == 0)
        {
            if (!DataHelper.DataSourceIsEmpty(templates))
            {
                int firstTemplateId = ValidationHelper.GetInteger(templates.Tables[0].Rows[0]["WebTemplateID"], 0);
                ucSelector.SelectedId = firstTemplateId;
            }
        }

        ucSelector.DataBind();
    }
Ejemplo n.º 5
0
    /// <summary>
    /// Handles btnOK's OnClick event - Update web template info DB.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Finds whether required fields are not empty
        string result = new Validator().NotEmpty(txtWebTemplateDisplayName.Text, GetString("Administration-WebTemplate_New.ErrorEmptyWebTemplateDisplayName"))
                        .NotEmpty(txtWebTemplateName.Text, GetString("Administration-WebTemplate_New.ErrorEmptyWebTemplateName"))
                        .NotEmpty(txtWebTemplateFileName.Text, GetString("Administration-PageLayout_New.ErrorEmptyWebTemplateFileName"))
                        .NotEmpty(txtWebTemplateDescription.Text, GetString("Administration-PageLayout_New.ErrorEmptyWebTemplateDescription")).Result;

        if (!ucLicenseSelector.IsValid())
        {
            result = GetString("Administration-WebTemplate_New.ErrorEmptyWebTemplateNameLicenses");
        }

        if (result == string.Empty)
        {
            WebTemplateInfo wi = WebTemplateInfoProvider.GetWebTemplateInfo(txtWebTemplateName.Text);
            // Check if entered code name is unique
            if (wi == null || wi.WebTemplateId == webTemplateId)
            {
                // New web template info
                if ((wi == null) && (currentWebTemplateInfo == null))
                {
                    wi = new WebTemplateInfo();
                    DataSet ds = WebTemplateInfoProvider.GetWebTemplates(null, null, 0, "WebTemplateID", false);
                    if (!DataHelper.DataSourceIsEmpty(ds))
                    {
                        wi.WebTemplateOrder = ds.Tables[0].Rows.Count + 1;
                    }
                    else
                    {
                        wi.WebTemplateOrder = 1;
                    }
                }
                // Current template info
                else
                {
                    wi = currentWebTemplateInfo;
                }

                wi.WebTemplateId          = webTemplateId;
                wi.WebTemplateDisplayName = txtWebTemplateDisplayName.Text;
                wi.WebTemplateName        = txtWebTemplateName.Text;
                wi.WebTemplateDescription = txtWebTemplateDescription.Text;
                wi.WebTemplateFileName    = txtWebTemplateFileName.Text;
                wi.WebTemplateLicenses    = (string)ucLicenseSelector.Value;
                wi.WebTemplatePackages    = (string)ucLicensePackageSelector.Value;
                try
                {
                    WebTemplateInfoProvider.SetWebTemplateInfo(wi);
                    URLHelper.Redirect("WebTemplate_Edit.aspx?webtemplateid=" + wi.WebTemplateId + "&saved=1");
                }
                catch (Exception ex)
                {
                    // WebTemplateInfoProvider doesn't make any unique controls
                    ShowError(GetString("general.saveerror"), ex.Message, null);
                }
            }
            else
            {
                ShowError(GetString("Administration-WebTemplate_New.ErrorWebTemplateNameNotUnique"));
            }
        }
        else
        {
            ShowError(result);
        }
    }