Exemplo n.º 1
0
    /// <summary>
    /// Button make version major click.
    /// </summary>
    protected void btnMakeMajor_Click(object sender, EventArgs e)
    {
        if (Object != null)
        {
            // Check permissions
            if (CheckPermissions && !AllowModify)
            {
                ShowError(GetString("History.ErrorNotAllowedToModify"));
                return;
            }

            ObjectVersionHistoryInfo version = ObjectVersionManager.GetLatestVersion(Object.TypeInfo.ObjectType, Object.Generalized.ObjectID);
            if (version != null)
            {
                if (ObjectVersionManager.MakeVersionMajor(version))
                {
                    ShowConfirmation(GetString("objectversioning.makeversionmajorinfo"));
                }

                ReloadData();
            }
            else
            {
                ShowError(GetString("objectversioning.makeversionmajornoversion") + " " + GetString("objectversioning.objecthasnohistory"));
            }
        }
        else
        {
            UIContext.EditedObject = null;
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// Button destroy history click.
    /// </summary>
    protected void btnDestroy_Click(object sender, EventArgs e)
    {
        var obj = Object;

        if (obj != null)
        {
            // Check permissions
            if (CheckPermissions && !AllowDestroy)
            {
                ShowError(GetString("History.ErrorNotAllowedToDestroy"));
                return;
            }

            var ti = obj.TypeInfo;

            ObjectVersionManager.DestroyObjectHistory(ti.ObjectType, obj.Generalized.ObjectID);

            string objType     = GetString("Objecttype." + ti.ObjectType.Replace(".", "_"));
            string description = String.Format(GetString("objectversioning.historydestroyed"), SqlHelper.GetSafeQueryString(obj.Generalized.ObjectDisplayName, false));

            var logData = new EventLogData(EventTypeEnum.Information, objType, "DESTROYHISTORY")
            {
                EventDescription = description,
                EventUrl         = RequestContext.RawURL
            };

            Service.Resolve <IEventLogService>().LogEvent(logData);

            ReloadData();
        }
        else
        {
            UIContext.EditedObject = null;
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// Creates versioned css stylesheet. Called when the "Create versioned object" button is pressed.
    /// </summary>
    private bool CreateVersionedObject()
    {
        // Create new css stylesheet object
        CssStylesheetInfo newStylesheet = new CssStylesheetInfo();

        // Check if object versioning of stylesheet objects is allowed on current site
        if (ObjectVersionManager.AllowObjectVersioning(newStylesheet, CMSContext.CurrentSiteName))
        {
            // Set the properties
            newStylesheet.StylesheetDisplayName = "My new versioned stylesheet";
            newStylesheet.StylesheetName        = "MyNewVersionedStylesheet";
            newStylesheet.StylesheetText        = "Some versioned CSS code";

            // Save the css stylesheet
            CssStylesheetInfoProvider.SetCssStylesheetInfo(newStylesheet);

            // Add css stylesheet to site
            int stylesheetId = newStylesheet.StylesheetID;
            int siteId       = CMSContext.CurrentSiteID;

            CssStylesheetSiteInfoProvider.AddCssStylesheetToSite(stylesheetId, siteId);

            return(true);
        }

        return(false);
    }
    /// <summary>
    /// Load comparison drop-down list with data
    /// </summary>
    private void LoadDropDown()
    {
        drpCompareTo.Items.Clear();

        DataSet dsVersions = ObjectVersionManager.GetObjectHistory(Version.VersionObjectType, Version.VersionObjectID, "VersionID != " + Version.VersionID, "VersionModifiedWhen DESC, VersionNumber DESC", -1, "VersionID, VersionModifiedWhen, VersionNumber");

        // Converting modified time to correct time zone
        if (!DataHelper.DataSourceIsEmpty(dsVersions))
        {
            foreach (DataRow dr in dsVersions.Tables[0].Rows)
            {
                string   verId       = ValidationHelper.GetString(dr["VersionID"], String.Empty);
                string   verNumber   = ValidationHelper.GetString(dr["VersionNumber"], String.Empty);
                DateTime verModified = ValidationHelper.GetDateTime(dr["VersionModifiedWhen"], DataHelper.DATETIME_NOT_SELECTED);
                drpCompareTo.Items.Add(new ListItem(GetVersionNumber(verNumber, verModified), verId));
            }
        }

        // If history to compare is available
        if (drpCompareTo.Items.Count > 0)
        {
            drpCompareTo.Items.Insert(0, "(select version)");
        }
        // Otherwise hide dropdown list
        else
        {
            pnlControl.Visible = false;
        }

        // Pre-select dropdown list
        if (VersionCompare != null)
        {
            drpCompareTo.SelectedValue = VersionCompare.VersionID.ToString();
        }
    }
Exemplo n.º 5
0
    /// <summary>
    /// Button destroy history click.
    /// </summary>
    protected void btnDestroy_Click(object sender, EventArgs e)
    {
        if (Object != null)
        {
            // Check permissions
            if (CheckPermissions && !AllowDestroy)
            {
                lblError.Text     = GetString("History.ErrorNotAllowedToDestroy");
                plcLabels.Visible = true;
                return;
            }
            ObjectVersionManager.DestroyObjectHistory(Object.ObjectType, Object.ObjectID);

            UserInfo currentUser = CMSContext.CurrentUser;
            string   objType     = GetString("Objecttype." + Object.ObjectType.Replace(".", "_"));
            string   description = GetString(String.Format("objectversioning.historydestroyed", SqlHelperClass.GetSafeQueryString(Object.ObjectDisplayName, false)));

            EventLogProvider ev = new EventLogProvider();
            ev.LogEvent(EventLogProvider.EVENT_TYPE_INFORMATION, DateTime.Now, objType, "DESTROYHISTORY", HTTPHelper.GetAbsoluteUri(), description);

            ReloadData();
        }
        else
        {
            CMSPage.EditedObject = null;
        }
    }
Exemplo n.º 6
0
    /// <summary>
    /// Provides version rollback. Called when the "Rollback version" button is pressed.
    /// Expects the CreateVersionedObject method to be run first.
    /// </summary>
    private bool RollbackVersion()
    {
        // Get the css stylesheet
        CssStylesheetInfo stylesheet = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewVersionedStylesheet");

        if (stylesheet != null)
        {
            // Prepare query parameters
            string where = "VersionObjectID =" + stylesheet.StylesheetID + " AND VersionObjectType = '" + stylesheet.ObjectType + "'";
            string orderBy = "VersionModifiedWhen ASC";
            int    topN    = 1;

            // Get dataset with versions according to the parameters
            DataSet versionDS = ObjectVersionHistoryInfoProvider.GetVersionHistories(where, orderBy, topN, null);

            if (!DataHelper.DataSourceIsEmpty(versionDS))
            {
                // Get version
                ObjectVersionHistoryInfo version = new ObjectVersionHistoryInfo(versionDS.Tables[0].Rows[0]);

                // Roll back
                ObjectVersionManager.RollbackVersion(version.VersionID);

                return(true);
            }
        }

        return(false);
    }
    /// <summary>
    /// Raises event postback event
    /// </summary>
    /// <param name="eventArgument">Argument</param>
    public void RaisePostBackEvent(string eventArgument)
    {
        string[] args = eventArgument.Split('|');
        if (args.Length == 2)
        {
            int  rollbackVersionId = ValidationHelper.GetInteger(args[0], 0);
            bool processChilds     = ValidationHelper.GetBoolean(args[1], false);
            if (rollbackVersionId > 0)
            {
                try
                {
                    // Rollback version
                    int newVersionHistoryId = ObjectVersionManager.RollbackVersion(rollbackVersionId, processChilds);

                    lblInfo.Text = GetString("objectversioning.rollbackOK");

                    string url = URLHelper.CurrentURL;

                    // Add URL parameters
                    url = URLHelper.AddParameterToUrl(url, "versionhistoryid", newVersionHistoryId.ToString());
                    url = URLHelper.AddParameterToUrl(url, "comparehistoryid", VersionCompare.VersionID.ToString());
                    url = URLHelper.AddParameterToUrl(url, "rollbackok", "1");
                    url = URLHelper.AddParameterToUrl(url, "showall", processChilds.ToString());
                    url = URLHelper.RemoveParameterFromUrl(url, "hash");
                    url = URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(url));

                    // Prepare URL
                    url = ScriptHelper.GetString(URLHelper.ResolveUrl(url), true);

                    // Prepare script for refresh parent window and this dialog
                    StringBuilder builder = new StringBuilder();
                    builder.Append("if (wopener != null) {\n");

                    string clientId = QueryHelper.GetString("clientid", "");
                    if (!String.IsNullOrEmpty(clientId))
                    {
                        builder.Append("if (wopener.RefreshVersions_", clientId, " != null) {wopener.RefreshVersions_", clientId, "();}",
                                       "if (wopener.RefreshRelatedContent_", clientId, " != null) {wopener.RefreshRelatedContent_", clientId, "();}}");
                    }

                    builder.Append("window.document.location.replace(" + url + ");");

                    string script = ScriptHelper.GetScript(builder.ToString());
                    ScriptHelper.RegisterStartupScript(this, typeof(string), "RefreshAndReload", script);
                }
                catch (Exception ex)
                {
                    lblError.Text = GetString("objectversioning.recyclebin.restorationfailed") + " " + GetString("general.seeeventlog");

                    // Log to event log
                    EventLogProvider.LogException("View object version", "OBJECTRESTORE", ex);
                }
            }
        }
    }
Exemplo n.º 8
0
    /// <summary>
    /// Destroys version history. Called when the "Destroy history" button is pressed.
    /// Expects the CreateVersionedObject method to be run first.
    /// </summary>
    private bool DestroyHistory()
    {
        // Get the css stylesheet
        CssStylesheetInfo stylesheet = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewVersionedStylesheet");

        if (stylesheet != null)
        {
            // Destroy version history
            ObjectVersionManager.DestroyObjectHistory(stylesheet.ObjectType, stylesheet.StylesheetID);

            return(true);
        }

        return(false);
    }
Exemplo n.º 9
0
    protected void EditForm_OnBeforeRedirect(object sender, EventArgs e)
    {
        if (editForm.IsInsertMode)
        {
            WorkflowStepInfoProvider.CreateDefaultWorkflowSteps(CurrentWorkflow);

            // To prevent from creating multiple versions - turn versioning back on
            CurrentWorkflow.Generalized.SupportsVersioning = true;
            // Create one version manually
            if (LicenseHelper.CheckFeature(RequestContext.CurrentDomain, FeatureEnum.ObjectVersioning) && ObjectVersionManager.AllowObjectVersioning(CurrentWorkflow))
            {
                ObjectVersionManager.CreateVersion(CurrentWorkflow, CMSActionContext.CurrentUser.UserID);
            }
        }
    }
Exemplo n.º 10
0
    /// <summary>
    /// Deletes object. Called when the "Delete object" button is pressed.
    /// Expects the CreateVersionedObject method to be run first.
    /// </summary>
    private bool DeleteObject()
    {
        // Get the css stylesheet
        CssStylesheetInfo deleteStylesheet = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewVersionedStylesheet");

        if (deleteStylesheet != null)
        {
            // Check if restoring from recycle bin is allowed on current site
            if (ObjectVersionManager.AllowObjectRestore(deleteStylesheet, CMSContext.CurrentSiteName))
            {
                // Delete the css stylesheet
                CssStylesheetInfoProvider.DeleteCssStylesheetInfo(deleteStylesheet);

                return(true);
            }
        }

        return(false);
    }
Exemplo n.º 11
0
    /// <summary>
    /// Creates new version of the object. Called when the "Ensure version" button is pressed.
    /// Expects the CreateVersionedObject method to be run first.
    /// </summary>
    private bool EnsureVersion()
    {
        // Get the css stylesheet
        CssStylesheetInfo stylesheet = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewVersionedStylesheet");

        if (stylesheet != null)
        {
            // Check if object versioning of stylesheet objects is allowed on current site
            if (ObjectVersionManager.AllowObjectVersioning(stylesheet, CMSContext.CurrentSiteName))
            {
                // Ensure version
                ObjectVersionManager.EnsureVersion(stylesheet, false);

                return(true);
            }
        }

        return(false);
    }
    /// <summary>
    /// Setup versions tab values.
    /// </summary>
    private void SetupVersions(bool dataReload)
    {
        if (!IsLiveSite && (FileInfo != null) && ObjectVersionManager.DisplayVersionsTab(FileInfo))
        {
            tabVersions.Visible = true;
            tabVersions.Style.Add(HtmlTextWriterStyle.Overflow, "auto");
            objectVersionList.Visible = true;
            objectVersionList.Object  = FileInfo;

            // Bind refresh tab script to tab click event
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "TabVersionsOnClick", ScriptHelper.GetScript("$j(document).ready(function () {$j(\"#" + tabVersions.ClientID + "_head\").children().click( function() { $j(\"#" + objectVersionList.RefreshButton.ClientID + "\").click();});})"));

            // Register script to refresh content
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ReloadMediaFileEdit", ScriptHelper.GetScript("function RefreshContent() { var button = document.getElementById('" + btnHidden.ClientID + "'); if (button){button.click();}}"));
        }
        else
        {
            tabVersions.Visible = false;
        }
    }
Exemplo n.º 13
0
    /// <summary>
    /// Destroys latest version from history. Called when the "Destroy version" button is pressed.
    /// Expects the CreateVersionedObject method to be run first.
    /// </summary>
    private bool DestroyVersion()
    {
        // Get the css stylesheet
        CssStylesheetInfo stylesheet = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewVersionedStylesheet");

        if (stylesheet != null)
        {
            // Get the latest version
            ObjectVersionHistoryInfo version = ObjectVersionManager.GetLatestVersion(stylesheet.ObjectType, stylesheet.StylesheetID);

            if (version != null)
            {
                // Destroy the latest version
                ObjectVersionManager.DestroyObjectVersion(version.VersionID);

                return(true);
            }
        }

        return(false);
    }
Exemplo n.º 14
0
    /// <summary>
    /// Creates new version of the object. Called when the "Create version" button is pressed.
    /// Expects the CreateVersionedObject method to be run first.
    /// </summary>
    private bool CreateVersion()
    {
        // Get the css stylesheet
        CssStylesheetInfo newStylesheetVersion = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewVersionedStylesheet");

        if (newStylesheetVersion != null)
        {
            // Check if object versioning of stylesheet objects is allowed on current site
            if (ObjectVersionManager.AllowObjectVersioning(newStylesheetVersion, CMSContext.CurrentSiteName))
            {
                // Update the properties
                newStylesheetVersion.StylesheetDisplayName = newStylesheetVersion.StylesheetDisplayName.ToLower();

                // Create new version
                ObjectVersionManager.CreateVersion(newStylesheetVersion, true);

                return(true);
            }
        }

        return(false);
    }
Exemplo n.º 15
0
    /// <summary>
    /// Restores object from recycle bin. Called when the "Restore object" button is pressed.
    /// Expects the DeleteObject method to be run first.
    /// </summary>
    private bool RestoreObject()
    {
        // Prepare query parameters
        string where = "VersionObjectType = '" + SiteObjectType.CSSSTYLESHEET + "' AND VersionDeletedByUserID = " + CMSContext.CurrentUser.UserID;
        string orderBy = "VersionDeletedWhen DESC";
        int    topN    = 1;

        // Get dataset with versions according to the parameters
        DataSet versionDS = ObjectVersionHistoryInfoProvider.GetVersionHistories(where, orderBy, topN, null);

        if (!DataHelper.DataSourceIsEmpty(versionDS))
        {
            // Get version
            ObjectVersionHistoryInfo version = new ObjectVersionHistoryInfo(versionDS.Tables[0].Rows[0]);

            // Restore the object
            ObjectVersionManager.RestoreObject(version.VersionID, true);

            return(true);
        }

        return(false);
    }
Exemplo n.º 16
0
    /// <summary>
    /// Button make version major click.
    /// </summary>
    protected void btnMakeMajor_Click(object sender, EventArgs e)
    {
        if (Object != null)
        {
            ObjectVersionHistoryInfo version = ObjectVersionManager.GetLatestVersion(Object.ObjectType, Object.ObjectID);
            if (version != null)
            {
                ObjectVersionManager.MakeVersionMajor(version);
                ReloadData();

                lblInfo.Text = GetString("objectversioning.makeversionmajorinfo");
            }
            else
            {
                lblError.Text = GetString("objectversioning.makeversionmajornoversion") + " " + GetString("objectversioning.objecthasnohistory");
            }

            plcLabels.Visible = true;
        }
        else
        {
            CMSPage.EditedObject = null;
        }
    }
    /// <summary>
    /// Button destroy history click.
    /// </summary>
    protected void btnDestroy_Click(object sender, EventArgs e)
    {
        if (Object != null)
        {
            // Check permissions
            if (CheckPermissions && !AllowDestroy)
            {
                ShowError(GetString("History.ErrorNotAllowedToDestroy"));
                return;
            }
            ObjectVersionManager.DestroyObjectHistory(Object.ObjectType, Object.Generalized.ObjectID);

            string objType     = GetString("Objecttype." + Object.ObjectType.Replace(".", "_"));
            string description = String.Format(GetString("objectversioning.historydestroyed"), SqlHelper.GetSafeQueryString(Object.Generalized.ObjectDisplayName, false));

            EventLogProvider.LogEvent(EventType.INFORMATION, objType, "DESTROYHISTORY", description, RequestContext.RawURL);

            ReloadData();
        }
        else
        {
            UIContext.EditedObject = null;
        }
    }
Exemplo n.º 18
0
    /// <summary>
    /// Restores set of given version histories.
    /// </summary>
    /// <param name="recycleBin">DataSet with nodes to restore</param>
    /// <param name="action">Action to be performed</param>
    private void RestoreDataSet(DataSet recycleBin, Action action)
    {
        // Result flags
        bool resultOK = true;

        if (!DataHelper.DataSourceIsEmpty(recycleBin))
        {
            // Restore all objects
            foreach (DataRow dataRow in recycleBin.Tables[0].Rows)
            {
                int versionId = ValidationHelper.GetInteger(dataRow["VersionID"], 0);

                // Log current event
                string taskTitle = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(ValidationHelper.GetString(dataRow["VersionObjectDisplayName"], string.Empty)));

                // Restore object
                if (versionId > 0)
                {
                    GeneralizedInfo restoredObj = null;
                    try
                    {
                        switch (action)
                        {
                        case Action.Restore:
                            restoredObj = ObjectVersionManager.RestoreObject(versionId, true);
                            break;

                        case Action.RestoreToCurrentSite:
                            restoredObj = ObjectVersionManager.RestoreObject(versionId, SiteContext.CurrentSiteID);
                            break;

                        case Action.RestoreWithoutSiteBindings:
                            restoredObj = ObjectVersionManager.RestoreObject(versionId, 0);
                            break;
                        }
                    }
                    catch (CodeNameNotUniqueException ex)
                    {
                        CurrentError = String.Format(GetString("objectversioning.restorenotuniquecodename"), (ex.Object != null) ? "('" + ex.Object.ObjectCodeName + "')" : null);
                        AddLog(CurrentError);
                    }

                    if (restoredObj != null)
                    {
                        AddLog(ResHelper.GetString("general.object", mCurrentCulture) + " '" + taskTitle + "'");
                    }
                    else
                    {
                        // Set result flag
                        if (resultOK)
                        {
                            resultOK = false;
                        }
                    }
                }
            }
        }

        if (resultOK)
        {
            CurrentInfo = ResHelper.GetString("ObjectVersioning.Recyclebin.RestorationOK", mCurrentCulture);
            AddLog(CurrentInfo);
        }
        else
        {
            CurrentError = ResHelper.GetString("objectversioning.recyclebin.restorationfailed", mCurrentCulture);
            AddLog(CurrentError);
        }
    }
Exemplo n.º 19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Test permission for query
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.Reporting", "EditSQLQueries"))
        {
            txtQuery.Enabled = false;
        }
        else
        {
            txtQuery.Enabled = true;
        }

        versionList.OnAfterRollback += new EventHandler(versionList_onAfterRollback);

        // Own javascript tab change handling -> because tab control raises changetab after prerender - too late
        // Own selected tab change handling
        RegisterTabScript(hdnSelectedTab.ClientID, tabControlElem);

        // Register common resize and refresh scripts
        RegisterResizeAndRollbackScript(divFooter.ClientID, divScrolable.ClientID);

        string[,] tabs = new string[4, 4];
        tabs[0, 0]     = GetString("general.general");
        tabs[0, 1]     = "SetHelpTopic('helpTopic', 'report_table_properties')";
        tabs[1, 0]     = GetString("general.preview");
        tabs[0, 1]     = "SetHelpTopic('helpTopic', 'report_table_properties')";

        tabControlElem.Tabs               = tabs;
        tabControlElem.UsePostback        = true;
        CurrentMaster.Title.HelpName      = "helpTopic";
        CurrentMaster.Title.HelpTopicName = "report_table_properties";
        CurrentMaster.Title.TitleCssClass = "PageTitleHeader";

        rfvCodeName.ErrorMessage    = GetString("general.requirescodename");
        rfvDisplayName.ErrorMessage = GetString("general.requiresdisplayname");
        btnApply.Text  = GetString("General.apply");
        btnOk.Text     = GetString("General.OK");
        btnCancel.Text = GetString("General.Cancel");

        int  reportId = QueryHelper.GetInteger("reportid", 0);
        bool preview  = QueryHelper.GetBoolean("preview", false);

        if (reportId > 0)
        {
            reportInfo = ReportInfoProvider.GetReportInfo(reportId);
        }

        // If preview by URL -> select preview tab
        bool isPreview = QueryHelper.GetBoolean("preview", false);

        if (isPreview && !RequestHelper.IsPostBack())
        {
            SelectedTab = 1;
        }

        if (PersistentEditedObject == null)
        {
            if (reportInfo != null) // Must be valid reportid parameter
            {
                string tableName = ValidationHelper.GetString(Request.QueryString["itemname"], "");

                // Try to load tableName from hidden field (adding new graph & preview)
                if (tableName == String.Empty)
                {
                    tableName = txtNewTableHidden.Value;
                }

                if (ValidationHelper.IsIdentifier(tableName))
                {
                    PersistentEditedObject = ReportTableInfoProvider.GetReportTableInfo(reportInfo.ReportName + "." + tableName);
                    tableInfo = PersistentEditedObject as ReportTableInfo;
                }
            }
        }
        else
        {
            tableInfo = PersistentEditedObject as ReportTableInfo;
        }

        if (reportInfo != null)
        {
            // Control text initializations
            if (tableInfo != null)
            {
                CurrentMaster.Title.TitleText  = GetString("Reporting_ReportTable_Edit.TitleText");
                CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Reporting_ReportTable/object.png");

                tableId = tableInfo.TableID;

                if (ObjectVersionManager.DisplayVersionsTab(tableInfo))
                {
                    tabs[2, 0] = GetString("objectversioning.tabtitle");
                    tabs[2, 1] = "SetHelpTopic('helpTopic', 'objectversioning_general');";

                    versionList.Object     = tableInfo;
                    versionList.IsLiveSite = false;
                }
            }
            else // New item
            {
                CurrentMaster.Title.TitleText  = GetString("Reporting_ReportTable_Edit.NewItemTitleText");
                CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Reporting_ReportTable/new.png");

                if (!RequestHelper.IsPostBack())
                {
                    txtPageSize.Text          = "15";
                    txtQueryNoRecordText.Text = GetString("attachmentswebpart.nodatafound");
                    chkExportEnable.Checked   = true;
                }

                newTable = true;
            }

            // Set help key
            CurrentMaster.Title.HelpTopicName = "report_table_properties";

            if (!RequestHelper.IsPostBack())
            {
                DataHelper.FillListControlWithEnum(typeof(PagerButtons), drpPageMode, "PagerButtons.", null);
                // Preselect page numbers paging
                drpPageMode.SelectedValue = ((int)PagerButtons.Numeric).ToString();

                LoadData();
            }
        }

        if ((preview) && (!RequestHelper.IsPostBack()))
        {
            tabControlElem.SelectedTab = 1;
            ShowPreview();
        }

        // In case of preview paging without saving table
        if (RequestHelper.IsPostBack() && tabControlElem.SelectedTab == 1)
        {
            // Reload deafult parameters
            FormInfo fi = new FormInfo(reportInfo.ReportParameters);
            // Get datarow with required columns
            ctrlReportTable.ReportParameters = fi.GetDataRow();
            fi.LoadDefaultValues(ctrlReportTable.ReportParameters, true);

            // Colect data and put them in talbe info
            Save(false);
            ctrlReportTable.TableInfo = tableInfo;
        }
    }
Exemplo n.º 20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Use UI culture for strings
        string culture = MembershipContext.AuthenticatedUser.PreferredUICultureCode;

        // Register dialog script
        ScriptHelper.RegisterDialogScript(Page);

        // Prepare script to display versions dialog
        StringBuilder script = new StringBuilder();

        script.Append(
            @"
function ShowVersionsDialog(objectType, objectId, objectName) {
  modalDialog('", ResolveUrl("~/CMSModules/Objects/Dialogs/ObjectVersionDialog.aspx"), @"' + '?objecttype=' + objectType + '&objectid=' + objectId + '&objectname=' + objectName,'VersionsDialog','800','600');
}"
            );

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ShowVersionDialog", ScriptHelper.GetScript(script.ToString()));

        // Check if template is ASPX one and initialize PageTemplateInfo variable
        bool isAspx = false;

        PageTemplateInfo pti = null;

        if (mPagePlaceholder != null)
        {
            pi = mPagePlaceholder.PageInfo;
        }

        if (pi != null)
        {
            pti = pi.UsedPageTemplateInfo;
            if (pti != null)
            {
                isAspx = pti.IsAspx;
            }
        }

        bool documentExists = ((pi != null) && (pi.DocumentID > 0));

        if ((mPagePlaceholder != null) && (mPagePlaceholder.ViewMode == ViewModeEnum.DesignDisabled))
        {
            // Hide edit layout and edit template if design mode is disabled
            iLayout.Visible   = false;
            iTemplate.Visible = false;
        }
        else
        {
            if ((mPagePlaceholder != null) && (mPagePlaceholder.LayoutTemplate == null))
            {
                // Edit layout
                iLayout.Text = ResHelper.GetString("PlaceholderMenu.IconLayout", culture);
                iLayout.Attributes.Add("onclick", "EditLayout();");

                if ((pti != null) && (pti.LayoutID > 0))
                {
                    LayoutInfo li = LayoutInfoProvider.GetLayoutInfo(pti.LayoutID);

                    // Display layout versions sub-menu
                    if ((li != null) && ObjectVersionManager.DisplayVersionsTab(li))
                    {
                        menuLayout.Visible           = true;
                        iLayout.Text                 = ResHelper.GetString("PlaceholderMenu.IconLayoutMore", culture);
                        lblSharedLayoutVersions.Text = ResHelper.GetString("PlaceholderMenu.SharedLayoutVersions", culture);
                        pnlSharedLayout.Attributes.Add("onclick", GetVersionsDialog(li.TypeInfo.ObjectType, li.LayoutId));
                    }
                }
            }
            else
            {
                iLayout.Visible = false;
            }

            if (documentExists)
            {
                // Template properties
                iTemplate.Text = ResHelper.GetString("PlaceholderMenu.IconTemplate", culture);

                int    templateID = (pti != null) ? pti.PageTemplateId : 0;
                String aliasPath  = (pi != null) ? pi.NodeAliasPath : "";

                String url = ApplicationUrlHelper.GetElementDialogUrl("cms.design", "PageTemplate.EditPageTemplate", templateID, String.Format("aliaspath={0}", aliasPath));
                iTemplate.Attributes.Add("onclick", String.Format("modalDialog('{0}', 'edittemplate', '95%', '95%');", url));

                if (pti != null)
                {
                    // Display template versions sub-menu
                    if (ObjectVersionManager.DisplayVersionsTab(pti))
                    {
                        menuTemplate.Visible     = true;
                        iTemplate.Text           = ResHelper.GetString("PlaceholderMenu.IconTemplateMore", culture);
                        lblTemplateVersions.Text = ResHelper.GetString("PlaceholderMenu.TemplateVersions", culture);
                        pnlTemplateVersions.Attributes.Add("onclick", GetVersionsDialog(pti.TypeInfo.ObjectType, pti.PageTemplateId));
                    }
                }
            }
        }

        if (pti != null)
        {
            if ((!isAspx) && documentExists && pti.IsReusable)
            {
                if (!SynchronizationHelper.UseCheckinCheckout || CurrentPageInfo.UsedPageTemplateInfo.Generalized.IsCheckedOutByUser(MembershipContext.AuthenticatedUser))
                {
                    iClone.Text          = ResHelper.GetString("PlaceholderMenu.IconClone", culture);
                    iClone.OnClientClick = "CloneTemplate(GetContextMenuParameter('pagePlaceholderMenu'));";
                }
            }
            else
            {
                iSaveAsNew.Text = ResHelper.GetString("PageProperties.Save", culture);

                int templateId = pi.UsedPageTemplateInfo.PageTemplateId;
                iSaveAsNew.OnClientClick = String.Format(
                    "modalDialog('{0}?refresh=1&templateId={1}&siteid={2}', 'SaveNewTemplate', 720, 430); return false;",
                    ResolveUrl("~/CMSModules/PortalEngine/UI/Layout/SaveNewPageTemplate.aspx"),
                    templateId,
                    SiteContext.CurrentSiteID);
            }
        }

        iRefresh.Text = ResHelper.GetString("PlaceholderMenu.IconRefresh", culture);
        iRefresh.Attributes.Add("onclick", "RefreshPage();");
    }
Exemplo n.º 21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ucSelectString.Scope               = ReportInfo.OBJECT_TYPE;
        ConnectionStringRow.Visible        = MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.reporting", "SetConnectionString");
        txtQuery.FullScreenParentElementID = pnlWebPartForm_Properties.ClientID;

        // Test permission for query
        txtQuery.Enabled = MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.Reporting", "EditSQLQueries");

        versionList.OnAfterRollback += versionList_onAfterRollback;

        PageTitle.HelpTopicName = HELP_TOPIC_LINK;

        // Register common resize and refresh scripts
        RegisterResizeAndRollbackScript("divFooter", divScrolable.ClientID);

        tabControlElem.TabItems.Add(new UITabItem
        {
            Text = GetString("general.general")
        });

        tabControlElem.TabItems.Add(new UITabItem
        {
            Text = GetString("general.preview")
        });

        tabControlElem.UsePostback = true;

        rfvCodeName.ErrorMessage    = GetString("general.requirescodename");
        rfvDisplayName.ErrorMessage = GetString("general.requiresdisplayname");

        Save += (s, ea) =>
        {
            if (SetData(true))
            {
                ltlScript.Text += ScriptHelper.GetScript("window.RefreshContent();CloseDialog();");
            }
        };

        int  reportId = QueryHelper.GetInteger("reportid", 0);
        bool preview  = QueryHelper.GetBoolean("preview", false);

        if (reportId > 0)
        {
            mReportInfo = ReportInfoProvider.GetReportInfo(reportId);
        }

        // If preview by URL -> select preview tab
        bool isPreview = QueryHelper.GetBoolean("preview", false);

        if (isPreview && !RequestHelper.IsPostBack())
        {
            tabControlElem.SelectedTab = 1;
        }

        if (PersistentEditedObject == null)
        {
            if (mReportInfo != null) // Must be valid reportid parameter
            {
                int id = QueryHelper.GetInteger("objectid", 0);

                // Try to load tableName from hidden field (adding new graph & preview)
                if (id == 0)
                {
                    id = ValidationHelper.GetInteger(txtNewTableHidden.Value, 0);
                }

                if (id > 0)
                {
                    PersistentEditedObject = ReportTableInfoProvider.GetReportTableInfo(id);
                    mReportTableInfo       = PersistentEditedObject as ReportTableInfo;
                }
            }
        }
        else
        {
            mReportTableInfo = PersistentEditedObject as ReportTableInfo;
        }

        if (mReportInfo != null)
        {
            ucSelectString.DefaultConnectionString = mReportInfo.ReportConnectionString;

            // Control text initializations
            if (mReportTableInfo != null)
            {
                PageTitle.TitleText = GetString("Reporting_ReportTable_Edit.TitleText");
                mTableId            = mReportTableInfo.TableID;

                if (ObjectVersionManager.DisplayVersionsTab(mReportTableInfo))
                {
                    tabControlElem.TabItems.Add(new UITabItem
                    {
                        Text = GetString("objectversioning.tabtitle")
                    });

                    versionList.Object     = mReportTableInfo;
                    versionList.IsLiveSite = false;
                }
            }
            else // New item
            {
                PageTitle.TitleText = GetString("Reporting_ReportTable_Edit.NewItemTitleText");
                if (!RequestHelper.IsPostBack())
                {
                    ucSelectString.Value      = String.Empty;
                    txtPageSize.Text          = "15";
                    txtQueryNoRecordText.Text = GetString("attachmentswebpart.nodatafound");
                    chkExportEnable.Checked   = true;
                    chkSubscription.Checked   = true;
                }
            }

            if (!RequestHelper.IsPostBack())
            {
                ControlsHelper.FillListControlWithEnum <PagerButtons>(drpPageMode, "PagerButtons");
                // Preselect page numbers paging
                drpPageMode.SelectedValue = ((int)PagerButtons.Numeric).ToString();

                LoadData();
            }
        }

        if ((preview) && (!RequestHelper.IsPostBack()))
        {
            tabControlElem.SelectedTab = 1;
            ShowPreview();
        }

        // In case of preview paging without saving table
        if (RequestHelper.IsPostBack() && tabControlElem.SelectedTab == 1)
        {
            // Reload default parameters
            FormInfo fi = new FormInfo(mReportInfo.ReportParameters);

            // Get datarow with required columns
            ctrlReportTable.ReportParameters = fi.GetDataRow(false);
            fi.LoadDefaultValues(ctrlReportTable.ReportParameters, true);

            // Collect data and put them in table info
            SetData();
            ctrlReportTable.TableInfo = mReportTableInfo;
        }

        CurrentMaster.PanelContent.RemoveCssClass("dialog-content");
        CurrentMaster.PanelContent.RemoveCssClass("ModalDialogContent");
    }
    /// <summary>
    /// Empties recycle bin.
    /// </summary>
    private void EmptyBin(object parameter)
    {
        // Begin log
        AddLog(ResHelper.GetString("Recyclebin.EmptyingBin", currentCulture));
        BinSettingsContainer settings        = (BinSettingsContainer)parameter;
        CurrentUserInfo      currentUserInfo = settings.User;
        SiteInfo             currentSite     = settings.Site;

        DataSet recycleBin = null;

        string where = IsSingleSite ? "VersionObjectSiteID IS NULL" : null;

        switch (settings.CurrentWhat)
        {
        case What.AllObjects:
            if (currentSite != null)
            {
                where = SqlHelper.AddWhereCondition(where, "VersionObjectSiteID = " + currentSite.SiteID, "OR");
            }
            where = GetWhereCondition(where);
            where = SqlHelper.AddWhereCondition(where, filter.WhereCondition);
            break;

        case What.SelectedObjects:
            List <string> toRestore = ugRecycleBin.SelectedItems;
            // Restore selected objects
            if (toRestore.Count > 0)
            {
                where = SqlHelper.GetWhereCondition("VersionID", toRestore);
            }
            break;
        }
        recycleBin = ObjectVersionHistoryInfoProvider.GetRecycleBin(where, null, -1, "VersionID, VersionObjectType, VersionObjectID, VersionObjectDisplayName, VersionObjectSiteID");

        try
        {
            if (!DataHelper.DataSourceIsEmpty(recycleBin))
            {
                foreach (DataRow dr in recycleBin.Tables[0].Rows)
                {
                    int    versionHistoryId = Convert.ToInt32(dr["VersionID"]);
                    string versionObjType   = Convert.ToString(dr["VersionObjectType"]);
                    string objName          = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(ValidationHelper.GetString(dr["VersionObjectDisplayName"], string.Empty)));
                    string siteName         = null;
                    if (currentSite != null)
                    {
                        siteName = currentSite.SiteName;
                    }
                    else
                    {
                        int siteId = ValidationHelper.GetInteger(dr["VersionObjectSiteID"], 0);
                        siteName = SiteInfoProvider.GetSiteName(siteId);
                    }

                    // Check permissions
                    if (!currentUserInfo.IsAuthorizedPerObject(PermissionsEnum.Destroy, versionObjType, siteName))
                    {
                        CurrentError = String.Format(ResHelper.GetString("objectversioning.Recyclebin.DestructionFailedPermissions", currentCulture), objName);
                        AddLog(CurrentError);
                    }
                    else
                    {
                        AddLog(ResHelper.GetString("general.object", currentCulture) + " '" + objName + "'");

                        // Destroy the version
                        int versionObjId = ValidationHelper.GetInteger(dr["VersionObjectID"], 0);
                        ObjectVersionManager.DestroyObjectHistory(versionObjType, versionObjId);
                        LogContext.LogEvent(EventType.INFORMATION, "Objects", "DESTROYOBJECT", ResHelper.GetString("objectversioning.Recyclebin.objectdestroyed"), RequestContext.RawURL, currentUserInfo.UserID, currentUserInfo.UserName, 0, null, RequestContext.UserHostAddress, (currentSite != null) ? currentSite.SiteID : 0, SystemContext.MachineName, RequestContext.URLReferrer, RequestContext.UserAgent, DateTime.Now);
                    }
                }
                if (!String.IsNullOrEmpty(CurrentError))
                {
                    CurrentError = ResHelper.GetString("objectversioning.recyclebin.errorsomenotdestroyed", currentCulture);
                    AddLog(CurrentError);
                }
                else
                {
                    CurrentInfo = ResHelper.GetString("ObjectVersioning.Recyclebin.DestroyOK", currentCulture);
                    AddLog(CurrentInfo);
                }
            }
        }
        catch (ThreadAbortException ex)
        {
            string state = ValidationHelper.GetString(ex.ExceptionState, string.Empty);
            if (state != CMSThread.ABORT_REASON_STOP)
            {
                // Log error
                CurrentError = "Error occurred: " + ResHelper.GetString("general.seeeventlog", currentCulture);
                AddLog(CurrentError);

                // Log to event log
                LogException("EMPTYINGBIN", ex);
            }
        }
        catch (Exception ex)
        {
            // Log error
            CurrentError = "Error occurred: " + ResHelper.GetString("general.seeeventlog", currentCulture);
            AddLog(CurrentError);

            // Log to event log
            LogException("EMPTYINGBIN", ex);
        }
    }
Exemplo n.º 23
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ucSelectString.Scope               = ReportInfo.OBJECT_TYPE;
        ConnectionStringRow.Visible        = MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.reporting", "SetConnectionString");
        txtQuery.FullScreenParentElementID = pnlWebPartForm_Properties.ClientID;

        // Test permission for query
        txtQuery.Enabled = MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.Reporting", "EditSQLQueries");

        versionList.OnAfterRollback += versionList_onAfterRollback;

        PageTitle.HelpTopicName = HELP_TOPIC_LINK;

        tabControlElem.TabItems.Add(new UITabItem
        {
            Text = GetString("general.general")
        });

        tabControlElem.TabItems.Add(new UITabItem
        {
            Text = GetString("general.preview")
        });

        tabControlElem.UsePostback = true;

        RegisterResizeAndRollbackScript("divFooter", divScrolable.ClientID);

        rfvCodeName.ErrorMessage    = GetString("general.requirescodename");
        rfvDisplayName.ErrorMessage = GetString("general.requiresdisplayname");

        int  reportId = QueryHelper.GetInteger("reportid", 0);
        bool preview  = QueryHelper.GetBoolean("preview", false);

        if (reportId > 0)
        {
            mReportInfo = ReportInfoProvider.GetReportInfo(reportId);
        }

        if (mReportInfo != null) //must be valid reportid parameter
        {
            ucSelectString.DefaultConnectionString = mReportInfo.ReportConnectionString;

            // If preview by URL -> select preview tab
            bool isPreview = QueryHelper.GetBoolean("preview", false);
            if (isPreview && !RequestHelper.IsPostBack())
            {
                tabControlElem.SelectedTab = 1;
            }

            if (PersistentEditedObject == null)
            {
                int id = QueryHelper.GetInteger("objectid", 0);
                if (id > 0)
                {
                    PersistentEditedObject = ReportValueInfoProvider.GetReportValueInfo(id);
                    mReportValueInfo       = PersistentEditedObject as ReportValueInfo;
                }
            }
            else
            {
                mReportValueInfo = PersistentEditedObject as ReportValueInfo;
            }

            if (mReportValueInfo != null)
            {
                PageTitle.TitleText = GetString("Reporting_ReportValue_Edit.TitleText");
                mValueId            = mReportValueInfo.ValueID;

                if (ObjectVersionManager.DisplayVersionsTab(mReportValueInfo))
                {
                    tabControlElem.TabItems.Add(new UITabItem
                    {
                        Text = GetString("objectversioning.tabtitle")
                    });

                    versionList.Object     = mReportValueInfo;
                    versionList.IsLiveSite = false;
                }
            }
            else //new item
            {
                PageTitle.TitleText     = GetString("Reporting_ReportValue_Edit.NewItemTitleText");
                chkSubscription.Checked = true;

                if (!RequestHelper.IsPostBack())
                {
                    ucSelectString.Value = String.Empty;
                }
            }

            if (!RequestHelper.IsPostBack())
            {
                LoadData();
            }
        }
        else
        {
            ShowError(GetString("Reporting_ReportValue_Edit.InvalidReportId"));
        }

        Save += (s, ea) =>
        {
            if (SetData(true))
            {
                ltlScript.Text += ScriptHelper.GetScript("window.RefreshContent();CloseDialog();");
            }
        };

        if (preview && !RequestHelper.IsPostBack())
        {
            tabControlElem.SelectedTab = 1;
            ShowPreview();
        }

        CurrentMaster.PanelContent.RemoveCssClass("dialog-content");
        CurrentMaster.PanelContent.RemoveCssClass("ModalDialogContent");
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ucSelectString.Scope                    = ReportInfo.OBJECT_TYPE;
        ConnectionStringRow.Visible             = MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.reporting", "SetConnectionString");
        txtQueryQuery.FullScreenParentElementID = pnlWebPartForm_Properties.ClientID;

        // Test permission for query
        txtQueryQuery.Enabled = MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.Reporting", "EditSQLQueries");

        versionList.OnAfterRollback += versionList_onAfterRollback;

        // Register script for resize and rollback
        RegisterResizeAndRollbackScript("divFooter", divScrolable.ClientID);

        tabControlElem.TabItems.Add(new UITabItem
        {
            Text = GetString("general.general")
        });

        tabControlElem.TabItems.Add(new UITabItem
        {
            Text = GetString("general.preview")
        });

        tabControlElem.UsePostback = true;

        Title = "ReportGraph Edit";
        PageTitle.HelpTopicName = HELP_TOPIC_LINK;

        rfvCodeName.ErrorMessage    = GetString("general.requirescodename");
        rfvDisplayName.ErrorMessage = GetString("general.requiresdisplayname");

        Save += (s, ea) =>
        {
            if (SetData(true))
            {
                ltlScript.Text += ScriptHelper.GetScript("window.RefreshContent();CloseDialog();");
            }
        };

        int  reportId  = QueryHelper.GetInteger("reportid", 0);
        bool isPreview = QueryHelper.GetBoolean("preview", false);

        // If preview by URL -> select preview tab
        if (isPreview && !RequestHelper.IsPostBack())
        {
            tabControlElem.SelectedTab = 1;
        }

        if (reportId > 0)
        {
            mReportInfo = ReportInfoProvider.GetReportInfo(reportId);
        }

        if (PersistentEditedObject == null)
        {
            if (mReportInfo != null) //must be valid reportid parameter
            {
                int id = QueryHelper.GetInteger("objectid", 0);

                // Try to load graph name from hidden field (adding new graph & preview)
                if (id == 0)
                {
                    id = ValidationHelper.GetInteger(txtNewGraphHidden.Value, 0);
                }

                if (id > 0)
                {
                    PersistentEditedObject = ReportGraphInfoProvider.GetReportGraphInfo(id);
                    mReportGraphInfo       = PersistentEditedObject as ReportGraphInfo;
                }
            }
        }
        else
        {
            mReportGraphInfo = PersistentEditedObject as ReportGraphInfo;
        }

        if (mReportInfo != null)
        {
            ucSelectString.DefaultConnectionString = mReportInfo.ReportConnectionString;
        }

        if (mReportGraphInfo != null)
        {
            PageTitle.TitleText = GetString("Reporting_ReportGraph_EditHTML.TitleText");
            mGraphId            = mReportGraphInfo.GraphID;

            if (ObjectVersionManager.DisplayVersionsTab(mReportGraphInfo))
            {
                tabControlElem.TabItems.Add(new UITabItem
                {
                    Text = GetString("objectversioning.tabtitle")
                });

                versionList.Object     = mReportGraphInfo;
                versionList.IsLiveSite = false;
            }
        }
        else
        {
            PageTitle.TitleText = GetString("Reporting_ReportGraph_EditHTML.NewItemTitleText");
            mNewReport          = true;
        }

        if (!RequestHelper.IsPostBack())
        {
            // Load default data for new report
            if (mNewReport)
            {
                ucSelectString.Value      = String.Empty;
                txtQueryNoRecordText.Text = GetString("attachmentswebpart.nodatafound");
                txtItemValueFormat.Text   = "{%yval%}";
                txtSeriesItemTooltip.Text = "{%ser%}";
                chkExportEnable.Checked   = true;
                chkSubscription.Checked   = true;
            }
            // Otherwise load saved data
            else
            {
                LoadData();
            }
        }

        CurrentMaster.PanelContent.RemoveCssClass("dialog-content");
        CurrentMaster.PanelContent.RemoveCssClass("ModalDialogContent");
    }
Exemplo n.º 25
0
    protected void gridHistory_OnAction(string actionName, object actionArgument)
    {
        int versionHistoryId = ValidationHelper.GetInteger(actionArgument, 0);

        actionName = actionName.ToLowerCSafe();
        switch (actionName.ToLowerCSafe())
        {
        case "rollback":
        case "fullrollback":
            if (versionHistoryId > 0)
            {
                // Check permissions
                if (CheckPermissions && !AllowModify)
                {
                    ShowError(GetString("History.ErrorNotAllowedToModify"));
                }
                else
                {
                    try
                    {
                        var newVersionId = ObjectVersionManager.RollbackVersion(versionHistoryId, (actionName == "fullrollback"));
                        ObjectVersionHistoryInfo newVersion = ObjectVersionHistoryInfo.Provider.Get(newVersionId);

                        // Set object to null because after rollback it doesn't contain current data
                        Object = null;
                        gridHistory.ReloadData();

                        if (OnAfterRollback != null)
                        {
                            OnAfterRollback(this, null);
                        }

                        ShowConfirmation(GetString("objectversioning.rollbackOK"));

                        ScriptHelper.RegisterStartupScript(this, typeof(string), "RefreshContent", ScriptHelper.GetScript("RefreshRelatedContent_" + ClientID + "();"));

                        ScriptHelper.RefreshTabHeader(Page, newVersion.VersionObjectDisplayName);
                    }
                    catch (CodeNameNotUniqueException ex)
                    {
                        ShowError(String.Format(GetString("objectversioning.restorenotuniquecodename"), (ex.Object != null) ? "('" + ex.Object.ObjectCodeName + "')" : null));
                    }
                    catch (Exception ex)
                    {
                        ShowError(GetString("objectversioning.recyclebin.restorationfailed") + " " + GetString("general.seeeventlog"));

                        // Log to event log
                        Service.Resolve <IEventLogService>().LogException("Object version list", "OBJECTRESTORE", ex);
                    }
                }
            }
            break;

        case "destroy":
            if (versionHistoryId > 0)
            {
                // Check permissions
                if (CheckPermissions && !AllowDestroy)
                {
                    ShowError(GetString("History.ErrorNotAllowedToDestroy"));
                }
                else
                {
                    ObjectVersionManager.DestroyObjectVersion(versionHistoryId);
                    ShowConfirmation(GetString("objectversioning.destroyOK"));
                }
            }
            break;
        }
    }
Exemplo n.º 26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Use UI culture for strings
        string culture = CMSContext.CurrentUser.PreferredUICultureCode;

        // Register dialog script
        ScriptHelper.RegisterDialogScript(Page);

        // Prepare script to display versions dialog
        StringBuilder script = new StringBuilder();

        script.Append(
            @"
function ShowVersionsDialog(objectType, objectId, objectName) {
  modalDialog('", ResolveUrl("~/CMSModules/Objects/Dialogs/ObjectVersionDialog.aspx"), @"' + '?objecttype=' + objectType + '&objectid=' + objectId + '&objectname=' + objectName,'VersionsDialog','800','600');
}"
            );

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ShowVersionDialog", ScriptHelper.GetScript(script.ToString()));

        // Check if template is ASPX one and initialize PageTemplateInfo variable
        bool isAspx = false;

        PageTemplateInfo pti = null;

        if (mPagePlaceholder != null)
        {
            pi = mPagePlaceholder.PageInfo;
        }

        if (pi != null)
        {
            pti = pi.UsedPageTemplateInfo;
            if (pti != null)
            {
                isAspx = pti.IsAspx;
            }
        }

        bool documentExists = ((pi != null) && (pi.DocumentID > 0));

        if ((mPagePlaceholder != null) && (mPagePlaceholder.ViewMode == ViewModeEnum.DesignDisabled))
        {
            // Hide edit layout and edit template if design mode is disabled
            iLayout.Visible   = false;
            iTemplate.Visible = false;
        }
        else
        {
            // Wireframe options
            if (documentExists && PortalHelper.IsWireframingEnabled(CMSContext.CurrentSiteName))
            {
                iSepWireframe.Visible = true;

                if (pi.NodeWireframeTemplateID <= 0)
                {
                    // Create wireframe
                    iWireframe.ImageUrl    = GetImageUrl("CMSModules/CMS_Content/EditMenu/16/createwireframe.png");
                    iWireframe.Text        = ResHelper.GetString("Wireframe.Create", culture);
                    iWireframe.RedirectUrl = String.Format("~/CMSModules/Content/CMSDesk/Properties/CreateWireframe.aspx?nodeid={0}&culture={1}", pi.NodeID, pi.DocumentCulture);
                }
                else
                {
                    // Remove wireframe
                    iWireframe.ImageUrl      = GetImageUrl("CMSModules/CMS_Content/EditMenu/16/removewireframe.png");
                    iWireframe.Text          = ResHelper.GetString("Wireframe.Remove", culture);
                    iWireframe.OnClientClick = "if (!confirm('" + GetString("Wireframe.ConfirmRemove") + "')) return false;";
                    iWireframe.Click        += iWireframe_Click;
                }
            }

            if ((mPagePlaceholder != null) && (mPagePlaceholder.LayoutTemplate == null))
            {
                // Edit layout
                iLayout.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/Layout.png");
                iLayout.Text     = ResHelper.GetString("PlaceholderMenu.IconLayout", culture);
                iLayout.Attributes.Add("onclick", "EditLayout();");

                if ((pti != null) && (pti.LayoutID > 0))
                {
                    LayoutInfo li = LayoutInfoProvider.GetLayoutInfo(pti.LayoutID);

                    // Display layout versions sub-menu
                    if ((li != null) && ObjectVersionManager.DisplayVersionsTab(li))
                    {
                        menuLayout.Visible           = true;
                        iLayout.Text                 = ResHelper.GetString("PlaceholderMenu.IconLayoutMore", culture);
                        lblSharedLayoutVersions.Text = ResHelper.GetString("PlaceholderMenu.SharedLayoutVersions", culture);
                        pnlSharedLayout.Attributes.Add("onclick", GetVersionsDialog(li.ObjectType, li.LayoutId));
                    }
                }
            }
            else
            {
                iLayout.Visible = false;
            }

            if (documentExists)
            {
                // Template properties
                iTemplate.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/Template.png");
                iTemplate.Text     = ResHelper.GetString("PlaceholderMenu.IconTemplate", culture);
                iTemplate.Attributes.Add("onclick", "EditTemplate(GetContextMenuParameter('pagePlaceholderMenu'));");

                if (pti != null)
                {
                    // Display template versions sub-menu
                    if (ObjectVersionManager.DisplayVersionsTab(pti))
                    {
                        menuTemplate.Visible     = true;
                        iTemplate.Text           = ResHelper.GetString("PlaceholderMenu.IconTemplateMore", culture);
                        lblTemplateVersions.Text = ResHelper.GetString("PlaceholderMenu.TemplateVersions", culture);
                        pnlTemplateVersions.Attributes.Add("onclick", GetVersionsDialog(pti.ObjectType, pti.PageTemplateId));
                    }
                }
            }
        }

        if (pti != null)
        {
            if ((!isAspx) && documentExists && pti.IsReusable)
            {
                iClone.ImageUrl      = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/Clonetemplate.png");
                iClone.Text          = ResHelper.GetString("PlaceholderMenu.IconClone", culture);
                iClone.OnClientClick = "CloneTemplate(GetContextMenuParameter('pagePlaceholderMenu'));";
            }
            else
            {
                iSaveAsNew.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/saveasnew.png");
                iSaveAsNew.Text     = ResHelper.GetString("PageProperties.Save", culture);

                int templateId = pi.UsedPageTemplateInfo.PageTemplateId;
                iSaveAsNew.OnClientClick = String.Format(
                    "modalDialog('{0}?refresh=1&templateId={1}&siteid={2}{3}', 'SaveNewTemplate', 600, 400); return false;",
                    ResolveUrl("~/CMSModules/PortalEngine/UI/Layout/SaveNewPageTemplate.aspx"),
                    templateId,
                    CMSContext.CurrentSiteID,
                    ((CMSContext.ViewMode == ViewModeEnum.Wireframe) ? "&assign=0" : "")
                    );
            }
        }

        iRefresh.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/Refresh.png");
        iRefresh.Text     = ResHelper.GetString("PlaceholderMenu.IconRefresh", culture);
        iRefresh.Attributes.Add("onclick", "RefreshPage();");
    }
Exemplo n.º 27
0
    /// <summary>
    /// Creates new variant and raises "Add" event if specified.
    /// </summary>
    /// <param name="name">Name of new variant</param>
    /// <param name="issueId">ID of source issue on which the new variant will be based</param>
    private void RaiseOnAddEvent(string name, int issueId)
    {
        // Get main issue (original)
        int       currentIssuedId = IssueID;
        IssueInfo parentIssue     = IssueInfoProvider.GetOriginalIssue(currentIssuedId);

        // Allow modifying issues in idle state only
        if ((parentIssue == null) || (parentIssue.IssueStatus != IssueStatusEnum.Idle))
        {
            return;
        }

        // Get issue content specified by ID (if not found use original)
        IssueInfo contentIssue = null;

        if (issueId > 0)
        {
            if (issueId == parentIssue.IssueID)
            {
                contentIssue = parentIssue;
            }
            else
            {
                contentIssue = IssueInfoProvider.GetIssueInfo(issueId);
            }
        }

        NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo(parentIssue.IssueNewsletterID);

        // ID of the first child (if new A/B test is being created (i.e. parent and 2 children)
        int origVariantId = 0;

        // Check if current issue is variant issue
        if (!parentIssue.IssueIsABTest)
        {
            // Variant issue has not been created yet => create original and 2 child variants
            parentIssue.IssueIsABTest = true;

            // Create 1st variant based on parent issue, the 2nd variant will be created as ordinary variant below
            IssueInfo issueOrigVariant = parentIssue.Clone(true);
            issueOrigVariant.IssueVariantOfIssueID = parentIssue.IssueID;
            issueOrigVariant.IssueVariantName      = GetString("newsletter.abvariantoriginal");
            issueOrigVariant.IssueScheduledTaskID  = 0;
            IssueInfoProvider.SetIssueInfo(issueOrigVariant);
            // Create scheduled task for variant mail-out and update issue variant
            issueOrigVariant.IssueScheduledTaskID = CreateScheduledTask(issueOrigVariant);
            IssueInfoProvider.SetIssueInfo(issueOrigVariant);
            // Update parent issue
            IssueInfoProvider.SetIssueInfo(parentIssue);
            try
            {
                ObjectVersionManager.DestroyObjectHistory(parentIssue.ObjectType, parentIssue.IssueID);
            }
            catch (Exception ex)
            {
                EventLogProvider.LogException("Newsletter-AddVariant", "EXCEPTION", ex);
            }

            origVariantId = issueOrigVariant.IssueID;
        }

        // Variant issue has been created => create new variant only
        IssueInfo issueVariant = (contentIssue != null ? contentIssue.Clone(true) : parentIssue.Clone(true));

        issueVariant.IssueVariantName      = name;
        issueVariant.IssueVariantOfIssueID = parentIssue.IssueID;

        // Prepare content with empty regions if empty content will be used
        string[] regions = null;
        if ((contentIssue == null) && (newsletter != null))
        {
            EmailTemplateInfo template = EmailTemplateInfoProvider.GetEmailTemplateInfo(newsletter.NewsletterTemplateID);
            if (template != null)
            {
                bool          isValidRegionName;
                List <string> regionNames = new List <string>();
                EmailTemplateHelper.ValidateEditableRegions(template.TemplateBody, out isValidRegionName, out isValidRegionName, regionNames);
                for (int i = regionNames.Count - 1; i >= 0; i--)
                {
                    regionNames[i] = regionNames[i] + "::";
                }
                regions = regionNames.ToArray();
                // Set template ID (i.e. this template with these regions is used for current issue)
                issueVariant.IssueTemplateID = template.TemplateID;
            }
        }

        issueVariant.IssueText            = (contentIssue != null ? contentIssue.IssueText : IssueHelper.GetContentXML(regions));
        issueVariant.IssueScheduledTaskID = 0;
        IssueInfoProvider.SetIssueInfo(issueVariant);

        // Duplicate attachments and replace old guids with new guids in issue text if current variant issue is based on content of another
        if (contentIssue != null)
        {
            List <Guid> guids = new List <Guid>();
            MetaFileInfoProvider.CopyMetaFiles(contentIssue.IssueID, issueVariant.IssueID,
                                               (contentIssue.IssueIsVariant ? IssueInfo.OBJECT_TYPE_VARIANT : IssueInfo.OBJECT_TYPE),
                                               ObjectAttachmentsCategories.ISSUE, IssueInfo.OBJECT_TYPE_VARIANT, ObjectAttachmentsCategories.ISSUE, guids);
            if (guids.Count > 0)
            {
                for (int i = 0; i < guids.Count; i += 2)
                {
                    issueVariant.IssueText = LinkConverter.ReplaceInLink(issueVariant.IssueText, guids[i].ToString(), guids[i + 1].ToString());
                }
            }
        }

        // Create scheduled task for variant mail-out
        issueVariant.IssueScheduledTaskID = CreateScheduledTask(issueVariant);
        // Update issue variant
        IssueInfoProvider.SetIssueInfo(issueVariant);

        if (origVariantId > 0)
        {
            // New A/B test issue created => create new A/B test info
            ABTestInfo abi = new ABTestInfo
            {
                TestIssueID = parentIssue.IssueID, TestSizePercentage = 50, TestWinnerOption = ABTestWinnerSelectionEnum.OpenRate, TestSelectWinnerAfter = 60
            };
            ABTestInfoProvider.SetABTestInfo(abi);

            // Move attachments (meta files) from parent issue to first variant
            MetaFileInfoProvider.MoveMetaFiles(parentIssue.IssueID, origVariantId, IssueInfo.OBJECT_TYPE, ObjectAttachmentsCategories.ISSUE, IssueInfo.OBJECT_TYPE_VARIANT, ObjectAttachmentsCategories.ISSUE);
            MetaFileInfoProvider.MoveMetaFiles(parentIssue.IssueID, origVariantId, IssueInfo.OBJECT_TYPE_VARIANT, ObjectAttachmentsCategories.ISSUE, IssueInfo.OBJECT_TYPE_VARIANT, ObjectAttachmentsCategories.ISSUE);
        }

        if (OnAddVariant != null)
        {
            VariantEventArgs args = new VariantEventArgs(name, issueVariant.IssueID);
            OnAddVariant(this, args);
        }
    }
Exemplo n.º 28
0
    /// <summary>
    /// Empties recycle bin.
    /// </summary>
    private void EmptyBin(BinSettingsContainer settings)
    {
        // Begin log
        AddLog(ResHelper.GetString("Recyclebin.EmptyingBin", mCurrentCulture));

        try
        {
            DataSet recycleBin = GetRecycleBinSeletedItems(settings, "VersionID, VersionObjectType, VersionObjectID, VersionObjectDisplayName, VersionObjectSiteID");
            if (!DataHelper.DataSourceIsEmpty(recycleBin))
            {
                foreach (DataRow dr in recycleBin.Tables[0].Rows)
                {
                    string   versionObjType = Convert.ToString(dr["VersionObjectType"]);
                    string   objName        = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(ValidationHelper.GetString(dr["VersionObjectDisplayName"], string.Empty)));
                    SiteInfo currentSite    = settings.Site;

                    string siteName;
                    if (currentSite != null)
                    {
                        siteName = currentSite.SiteName;
                    }
                    else
                    {
                        int siteId = ValidationHelper.GetInteger(dr["VersionObjectSiteID"], 0);
                        siteName = SiteInfoProvider.GetSiteName(siteId);
                    }

                    // Check permissions
                    UserInfo currentUserInfo = settings.User;
                    if (!currentUserInfo.IsAuthorizedPerObject(PermissionsEnum.Destroy, versionObjType, siteName))
                    {
                        CurrentError = String.Format(ResHelper.GetString("objectversioning.Recyclebin.DestructionFailedPermissions", mCurrentCulture), objName);
                        AddLog(CurrentError);
                    }
                    else
                    {
                        AddLog(ResHelper.GetString("general.object", mCurrentCulture) + " '" + objName + "'");

                        // Destroy the version
                        int versionObjId = ValidationHelper.GetInteger(dr["VersionObjectID"], 0);
                        ObjectVersionManager.DestroyObjectHistory(versionObjType, versionObjId);
                        LogContext.LogEventToCurrent(EventType.INFORMATION, "Objects", "DESTROYOBJECT", String.Format(ResHelper.GetString("objectversioning.Recyclebin.objectdestroyed"), objName), RequestContext.RawURL, currentUserInfo.UserID, currentUserInfo.UserName, 0, null, RequestContext.UserHostAddress, (currentSite != null) ? currentSite.SiteID : 0, SystemContext.MachineName, RequestContext.URLReferrer, RequestContext.UserAgent, DateTime.Now);
                    }
                }
                if (!String.IsNullOrEmpty(CurrentError))
                {
                    CurrentError = ResHelper.GetString("objectversioning.recyclebin.errorsomenotdestroyed", mCurrentCulture);
                    AddLog(CurrentError);
                }
                else
                {
                    CurrentInfo = ResHelper.GetString("ObjectVersioning.Recyclebin.DestroyOK", mCurrentCulture);
                    AddLog(CurrentInfo);
                }
            }
        }
        catch (ThreadAbortException ex)
        {
            if (!CMSThread.Stopped(ex))
            {
                // Log error
                CurrentError = "Error occurred: " + ResHelper.GetString("general.seeeventlog", mCurrentCulture);
                AddLog(CurrentError);

                // Log to event log
                LogException("EMPTYINGBIN", ex);
            }
        }
        catch (Exception ex)
        {
            // Log error
            CurrentError = "Error occurred: " + ResHelper.GetString("general.seeeventlog", mCurrentCulture);
            AddLog(CurrentError);

            // Log to event log
            LogException("EMPTYINGBIN", ex);
        }
    }
Exemplo n.º 29
0
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void ugRecycleBin_OnAction(string actionName, object actionArgument)
    {
        int versionHistoryId = ValidationHelper.GetInteger(actionArgument, 0);

        actionName = actionName.ToLowerCSafe();

        switch (actionName)
        {
        case "restorechilds":
        case "restorewithoutbindings":
        case "restorecurrentsite":
            try
            {
                if (MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.globalpermissions", "RestoreObjects"))
                {
                    switch (actionName)
                    {
                    case "restorechilds":
                        ObjectVersionManager.RestoreObject(versionHistoryId, true);
                        break;

                    case "restorewithoutbindings":
                        ObjectVersionManager.RestoreObject(versionHistoryId, 0);
                        break;

                    case "restorecurrentsite":
                        ObjectVersionManager.RestoreObject(versionHistoryId, SiteContext.CurrentSiteID);
                        break;
                    }

                    ShowConfirmation(GetString("ObjectVersioning.Recyclebin.RestorationOK"));
                }
                else
                {
                    ShowError(ResHelper.GetString("objectversioning.recyclebin.restorationfailedpermissions"));
                }
            }
            catch (CodeNameNotUniqueException ex)
            {
                ShowError(String.Format(GetString("objectversioning.restorenotuniquecodename"), (ex.Object != null) ? "('" + ex.Object.ObjectCodeName + "')" : null));
            }
            catch (Exception ex)
            {
                ShowError(GetString("objectversioning.recyclebin.restorationfailed") + GetString("general.seeeventlog"));

                // Log to event log
                LogException("OBJECTRESTORE", ex);
            }
            break;

        case "destroy":
            ObjectVersionHistoryInfo verInfo = ObjectVersionHistoryInfoProvider.GetVersionHistoryInfo(versionHistoryId);
            if (verInfo != null)
            {
                // Get object site name
                string siteName = (CurrentSite != null) ? CurrentSite.SiteName : SiteInfoProvider.GetSiteName(verInfo.VersionObjectSiteID);

                if (CurrentUser.IsAuthorizedPerObject(PermissionsEnum.Destroy, verInfo.VersionObjectType, siteName))
                {
                    ObjectVersionManager.DestroyObjectHistory(verInfo.VersionObjectType, verInfo.VersionObjectID);
                    ShowConfirmation(GetString("ObjectVersioning.Recyclebin.DestroyOK"));
                }
                else
                {
                    ShowError(String.Format(ResHelper.GetString("objectversioning.recyclebin.destructionfailedpermissions"), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(verInfo.VersionObjectDisplayName))));
                }
            }
            break;
        }

        ugRecycleBin.ResetSelection();
    }
Exemplo n.º 30
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Use UI culture for strings
        string culture = CMSContext.CurrentUser.PreferredUICultureCode;

        // Register dialog script
        ScriptHelper.RegisterDialogScript(Page);

        // Prepare script to display versions dialog
        StringBuilder script = new StringBuilder();

        script.Append(
            @"
function ShowVersionsDialog(objectType, objectId, objectName) {
  modalDialog('", ResolveUrl("~/CMSModules/Objects/Dialogs/ObjectVersionDialog.aspx"), @"' + '?objecttype=' + objectType + '&objectid=' + objectId + '&objectname=' + objectName,'VersionsDialog','800','600');
}"
            );

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ShowVersionDialog", ScriptHelper.GetScript(script.ToString()));

        // Check if template is ASPX one and initialize PageTemplateInfo variable
        bool             isAspx = false;
        PageInfo         pi     = null;
        PageTemplateInfo pti    = null;

        if (mPagePlaceholder != null)
        {
            pi = mPagePlaceholder.PageInfo;
        }

        if (pi != null)
        {
            pti = pi.PageTemplateInfo;
            if (pti != null)
            {
                isAspx = pti.IsAspx;
            }
        }

        if ((mPagePlaceholder != null) && (mPagePlaceholder.ViewMode == ViewModeEnum.DesignDisabled))
        {
            // Hide edit layout and edit template if design mode is disabled
            this.pnlLayout.Visible   = false;
            this.pnlTemplate.Visible = false;
        }
        else
        {
            if ((mPagePlaceholder != null) && (mPagePlaceholder.LayoutTemplate == null))
            {
                // Edit layout
                this.imgLayout.ImageUrl      = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/Layout.png");
                this.lblLayout.Text          = ResHelper.GetString("PlaceholderMenu.IconLayout", culture);
                this.imgLayout.AlternateText = this.lblLayout.Text;
                //this.lblLayout.ToolTip = GetString("WebPartMenu.Layout", culture);
                this.pnlLayout.Attributes.Add("onclick", "EditLayout();");

                if ((pti != null) && (pti.LayoutID > 0))
                {
                    LayoutInfo li = LayoutInfoProvider.GetLayoutInfo(pti.LayoutID);

                    // Display layout versions sub-menu
                    if ((li != null) && ObjectVersionManager.DisplayVersionsTab(li))
                    {
                        menuLayout.Visible           = true;
                        lblLayout.Text               = ResHelper.GetString("PlaceholderMenu.IconLayoutMore", culture);
                        lblSharedLayoutVersions.Text = ResHelper.GetString("PlaceholderMenu.SharedLayoutVersions", culture);
                        pnlSharedLayout.Attributes.Add("onclick", GetVersionsDialog(li.ObjectType, li.LayoutId));
                    }
                }
            }
            else
            {
                this.pnlLayout.Visible = false;
            }

            // Template properties
            this.imgTemplate.ImageUrl      = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/Template.png");
            this.lblTemplate.Text          = ResHelper.GetString("PlaceholderMenu.IconTemplate", culture);
            this.imgTemplate.AlternateText = this.lblTemplate.Text;
            //this.lblTemplate.ToolTip = GetString("WebPartMenu.Template", culture);
            this.pnlTemplate.Attributes.Add("onclick", "EditTemplate(GetContextMenuParameter('pagePlaceholderMenu'));");

            if (pti != null)
            {
                // Display template versions sub-menu
                if (ObjectVersionManager.DisplayVersionsTab(pti))
                {
                    menuTemplate.Visible     = true;
                    lblTemplate.Text         = ResHelper.GetString("PlaceholderMenu.IconTemplateMore", culture);
                    lblTemplateVersions.Text = ResHelper.GetString("PlaceholderMenu.TemplateVersions", culture);
                    pnlTemplateVersions.Attributes.Add("onclick", GetVersionsDialog(pti.ObjectType, pti.PageTemplateId));
                }
            }
        }

        if (!isAspx)
        {
            this.imgClone.ImageUrl      = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/Clonetemplate.png");
            this.lblClone.Text          = ResHelper.GetString("PlaceholderMenu.IconClone", culture);
            this.imgClone.AlternateText = this.lblClone.Text;
            //this.lblClone.ToolTip = GetString("WebPartMenu.Clone", culture);
            this.pnlClone.Attributes.Add("onclick", "CloneTemplate(GetContextMenuParameter('pagePlaceholderMenu'));");
        }
        else
        {
            this.pnlClone.Visible = false;
        }

        this.imgRefresh.ImageUrl      = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/Refresh.png");
        this.lblRefresh.Text          = ResHelper.GetString("PlaceholderMenu.IconRefresh", culture);
        this.imgRefresh.AlternateText = this.lblRefresh.Text;
        //this.lblRefresh.ToolTip = GetString("WebPartMenu.Refresh", culture);
        this.pnlRefresh.Attributes.Add("onclick", "RefreshPage();");
    }