/// <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;
        }
    }
예제 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register script for pendingCallbacks repair
        ScriptHelper.FixPendingCallbacks(Page);

        // Handle Import settings
        if (!RequestHelper.IsCallback() && !RequestHelper.IsPostBack())
        {
            // Check if any template is present on the disk
            if (!WebTemplateInfoProvider.IsAnyTemplatePresent())
            {
                selectTemplate.StopProcessing = true;
                pnlWrapper.Visible            = false;
                ShowError(GetString("NewSite.NoWebTemplate"));
            }

            // Initialize import settings
            ImportSettings                       = new SiteImportSettings(MembershipContext.AuthenticatedUser);
            ImportSettings.WebsitePath           = Server.MapPath("~/");
            ImportSettings.PersistentSettingsKey = PersistentSettingsKey;
        }

        if (RequestHelper.IsCallback())
        {
            // Stop processing when callback
            selectTemplate.StopProcessing = true;
            selectMaster.StopProcessing   = true;
        }
        else
        {
            selectTemplate.StopProcessing = (!CausedPostback(PreviousButton) || (wzdImport.ActiveStepIndex != 2)) && (wzdImport.ActiveStepIndex != 1);
            selectMaster.StopProcessing   = (wzdImport.ActiveStepIndex != 5);

            PreviousButton.Enabled = true;
            PreviousButton.Visible = (wzdImport.ActiveStepIndex <= 4);
            NextButton.Enabled     = true;

            // Bind async controls events
            ctrlAsyncSelection.OnFinished += ctrlAsyncSelection_OnFinished;
            ctrlAsyncSelection.OnError    += ctrlAsyncSelection_OnError;

            ctlAsyncImport.OnCancel   += ctlAsyncImport_OnCancel;
            ctlAsyncImport.OnFinished += ctlAsyncImport_OnFinished;

            if (wzdImport.ActiveStepIndex < 4)
            {
                siteDetails.Settings = ImportSettings;
                pnlImport.Settings   = ImportSettings;
            }

            // Javascript functions
            string script = String.Format(
                @"
function Finished(sender) {{
    var errorElement = document.getElementById('{2}');

    var errorText = sender.getErrors();
    if (errorText != '') {{ 
        errorElement.innerHTML = errorText;
        document.getElementById('{4}').style.removeProperty('display');
    }}

    var warningElement = document.getElementById('{3}');
    
    var warningText = sender.getWarnings();
    if (warningText != '') {{ 
        warningElement.innerHTML = warningText;
        document.getElementById('{5}').style.removeProperty('display');
    }}    

    var actDiv = document.getElementById('actDiv');
    if (actDiv != null) {{ 
        actDiv.style.display = 'none'; 
    }}

    BTN_Disable('{0}');
    BTN_Enable('{1}');

    if ((errorText == null) || (errorText == '')) {{ 
        BTN_Enable('{6}');
    }}
}}
",
                CancelButton.ClientID,
                FinishButton.ClientID,
                lblError.LabelClientID,
                lblWarning.LabelClientID,
                pnlError.ClientID,
                pnlWarning.ClientID,
                NextButton.ClientID
                );

            // Register the script to perform get flags for showing buttons retrieval callback
            ScriptHelper.RegisterClientScriptBlock(this, GetType(), "Finished", ScriptHelper.GetScript(script));

            // Add cancel button attribute
            CancelButton.Attributes.Add("onclick", ctlAsyncImport.GetCancelScript(true) + "return false;");

            wzdImport.NextButtonClick     += wzdImport_NextButtonClick;
            wzdImport.PreviousButtonClick += wzdImport_PreviousButtonClick;
            wzdImport.FinishButtonClick   += wzdImport_FinishButtonClick;
        }
    }
예제 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register script for pendingCallbacks repair
        ScriptHelper.FixPendingCallbacks(Page);

        // Handle Import settings
        if (!Page.IsCallback && !RequestHelper.IsPostBack())
        {
            // Check if any template is present on the disk
            if (!WebTemplateInfoProvider.IsAnyTemplatePresent())
            {
                selectTemplate.StopProcessing = true;
                pnlWrapper.Visible            = false;
                lblError.Visible = true;
                lblError.Text    = GetString("NewSite.NoWebTemplate");
            }

            // Initialize virtual path provider
            VirtualPathHelper.Init(Page);

            // Initialize import settings
            ImportSettings                       = new SiteImportSettings(CMSContext.CurrentUser);
            ImportSettings.WebsitePath           = Server.MapPath("~/");
            ImportSettings.PersistentSettingsKey = PersistentSettingsKey;
        }

        if (Page.IsCallback)
        {
            // Stop processing when callback
            selectTemplate.StopProcessing = true;
            selectMaster.StopProcessing   = true;
        }
        else
        {
            selectTemplate.StopProcessing = (CausedPostback(PreviousButton) && (wzdImport.ActiveStepIndex == 2)) ? false : (wzdImport.ActiveStepIndex != 1);
            selectMaster.StopProcessing   = (wzdImport.ActiveStepIndex != 5);

            PreviousButton.Enabled = true;
            PreviousButton.Visible = (wzdImport.ActiveStepIndex <= 4);
            NextButton.Enabled     = true;

            // Bind async controls events
            ctrlAsync.OnFinished  += ctrlAsync_OnFinished;
            ctrlAsync.OnError     += ctrlAsync_OnError;
            ctrlImport.OnFinished += ctrlImport_OnFinished;

            if (wzdImport.ActiveStepIndex < 4)
            {
                siteDetails.Settings = ImportSettings;
                pnlImport.Settings   = ImportSettings;
            }

            // Javascript functions
            string script =
                "var nMessageText = '';\n" +
                "var nErrorText = '';\n" +
                "var nWarningText = '';\n" +
                "var nMachineName = '" + SqlHelperClass.MachineName.ToLowerCSafe() + "';\n" +
                "var getBusy = false; \n" +
                "function GetImportState(cancel) \n" +
                "{ if(window.Activity){window.Activity();} if (getBusy && !cancel) return; getBusy = true; setTimeout(\"getBusy = false;\", 2000); var argument = cancel + ';' + nMessageText.length + ';' + nErrorText.length + ';' + nWarningText.length + ';' + nMachineName; return " + Page.ClientScript.GetCallbackEventReference(this, "argument", "SetImportStateMssg", "argument", true) + " } \n";

            script +=
                "function SetImportStateMssg(rValue, context) \n" +
                "{ \n" +
                "   getBusy = false; \n" +
                "   if(rValue!='') \n" +
                "   { \n" +
                "       var args = context.split(';');\n" +
                "       var values = rValue.split('" + SiteExportSettings.SEPARATOR + "');\n" +
                "       var messageElement = document.getElementById('" + lblProgress.ClientID + "');\n" +
                "       var errorElement = document.getElementById('" + lblError.ClientID + "');\n" +
                "       var warningElement = document.getElementById('" + lblWarning.ClientID + "');\n" +
                "       var messageText = nMessageText;\n" +
                "       messageText = values[1] + messageText.substring(messageText.length - args[1]);\n" +
                "       if(messageText.length > nMessageText.length){ nMessageText = messageElement.innerHTML = messageText; }\n" +
                "       var errorText = nErrorText;\n" +
                "       errorText = values[2] + errorText.substring(errorText.length - args[2]);\n" +
                "       if(errorText.length > nErrorText.length){ nErrorText = errorElement.innerHTML = errorText; }\n" +
                "       var warningText = nWarningText;\n" +
                "       warningText = values[3] + warningText.substring(warningText.length - args[3]);\n" +
                "       if(warningText.length > nWarningText.length){ nWarningText = warningElement.innerHTML = warningText; }\n" +
                "       if((values=='') || (values[0]=='F')) \n" +
                "       { \n" +
                "           StopImportStateTimer(); \n" +
                "           if (!document.importCancelled) { \n" +
                "              if(values[2] == '') { \n" +
                "                  BTN_Enable('" + NextButton.ClientID + "'); \n" +
                "              } \n" +
                "              else { \n" +
                "                  BTN_Enable('" + PreviousButton.ClientID + "'); \n" +
                "              } \n" +
                "              BTN_Disable('" + CancelButton.ClientID + "'); \n" +
                "           } \n" +
                "       } \n" +
                "   } \n" +
                "} \n";

            // Register the script to perform get flags for showing buttons retrieval callback
            ScriptHelper.RegisterClientScriptBlock(this, GetType(), "GetSetImportState", ScriptHelper.GetScript(script));

            // Add cancel button attribute
            CancelButton.Attributes.Add("onclick",
                                        "BTN_Disable('" + CancelButton.ClientID + "'); " +
                                        "CancelImport();" +
                                        ((wzdImport.ActiveStepIndex == 3) ? string.Empty : "BTN_Enable('" + PreviousButton.ClientID + "'); ") +
                                        "document.importCancelled = true;return false;"
                                        );

            wzdImport.NextButtonClick     += wzdImport_NextButtonClick;
            wzdImport.PreviousButtonClick += wzdImport_PreviousButtonClick;
            wzdImport.FinishButtonClick   += wzdImport_FinishButtonClick;
        }
    }