/// <summary> /// Gets score for specified contacts. /// </summary> private DataSet GetScore(DataSet ds) { ds.Tables[0].Columns.Add("Score"); StringBuilder contacts = new StringBuilder(); foreach (DataRow dr in ds.Tables[0].Rows) { int contactID = ValidationHelper.GetInteger(dr["SessionContactID"], 0); if (contactID > 0) { contacts.Append(contactID + ","); } } string contactList = contacts.ToString(); if (!String.IsNullOrEmpty(contactList)) { contactList = contactList.Substring(0, contactList.Length - 1); GeneralizedInfo contactScore = CMSObjectHelper.GetReadOnlyObject("om.contactscorelist"); DataSet result = contactScore.GetData(null, String.Format("ContactID IN ({0}) AND ScoreID = {1}", contactList, filter.SelectedScore), null, -1, "ContactID,ScoreValue", false); if (!DataHelper.DataSourceIsEmpty(result)) { foreach (DataRow dr in result.Tables[0].Rows) { DataRow[] row = ds.Tables[0].Select("SessionContactID =" + dr["ContactID"]); row[0]["Score"] = dr["ScoreValue"]; } } } return(ds); }
protected void Page_Load(object sender, EventArgs e) { btnClose.Text = GetString("General.Close"); bool noCompare = ValidationHelper.GetBoolean(QueryHelper.GetString("nocompare", string.Empty), false); // Initialize view version control viewVersion.NoComparison = noCompare; int versionId = ValidationHelper.GetInteger(QueryHelper.GetString("versionhistoryid", string.Empty), 0); viewVersion.VersionCompareID = ValidationHelper.GetInteger(QueryHelper.GetString("comparehistoryid", string.Empty), 0); // Get version to initialize title ObjectVersionHistoryInfo version = ObjectVersionHistoryInfoProvider.GetVersionHistoryInfo(versionId); if (version != null) { string objectType = version.VersionObjectType; string objType = GetString("ObjectType." + objectType.Replace(".", "_")); string title = String.Format(GetString("objectversioning.viewversion.title"), objType, HTMLHelper.HTMLEncode(ResHelper.LocalizeString(version.VersionObjectDisplayName))); // Set title - do not display context help when comparison not available string helpTopic = noCompare ? null : "objectversioning_viewversion"; this.SetTitle("CMSModules/CMS_ObjectVersioning/viewversion.png", title, helpTopic, "Object versioning - View version"); viewVersion.Version = version; // Exclude site binding table data GeneralizedInfo infoObj = TranslationHelper.GetReadOnlyObject(objectType); viewVersion.ExcludedTableNames = CMSObjectHelper.GetTableName(infoObj.TypeInfo.SiteBindingObject); } // Set what data should be displayed bool showAll = ValidationHelper.GetBoolean(QueryHelper.GetBoolean("showall", false), false); viewVersion.ObjectDataOnly = !showAll; }
private void InitializeTitleLabel() { BaseInfo bindingType = CMSObjectHelper.GetReadOnlyObject(BindingObjectType); if (bindingType != null) { string otherSide = bindingType.TypeInfo.ParentObjectType; string safeOtherSide = TranslationHelper.GetSafeClassName(otherSide); string friendlyType = GetString("objecttasks." + safeOtherSide); if (friendlyType.Length > 0) { char firstChar = friendlyType[0]; if (char.IsUpper(firstChar)) { if (friendlyType.Length > 1) { char secondChar = friendlyType[1]; if (!char.IsUpper(secondChar)) { friendlyType = friendlyType.ToLowerCSafe(); } } } } lblAvialable.Text = string.Format(GetString("site_edit_siteobjects.objectsavailable"), friendlyType); } }
private BaseInfo GetInfoFromHiddenValues() { var objectType = ValidationHelper.GetString(hdnObjectType.Value, null); var objectId = ValidationHelper.GetInteger(hdnObjectId.Value, 0); return(CMSObjectHelper.GetObjectById(objectType, objectId)); }
void UniSelector_OnItemsSelected(object sender, EventArgs e) { try { int processId = ValidationHelper.GetInteger(ucSelector.Value, 0); AutomationManager manager = AutomationManager.GetInstance(CurrentUser); var infoObj = CMSObjectHelper.GetObjectById(listElem.ObjectType, listElem.ObjectID); using (CMSActionContext context = new CMSActionContext()) { context.AllowAsyncActions = false; manager.StartProcess(infoObj, processId); } } catch (ProcessRecurrenceException ex) { ShowError(ex.Message); } catch (Exception ex) { LogAndShowError("Automation", "STARTPROCESS", ex); } listElem.UniGrid.ReloadData(); pnlUpdate.Update(); }
/// <summary> /// Fills given drop-down list with the items of particular type. /// </summary> private void DisplayAvailableItems() { if (RelatedObject != null) { // Prepare the site where string where = null; if (RelatedObject.SiteIDColumn != TypeInfo.COLUMN_NAME_UNKNOWN) { int selectedSiteId = -1; // Add where if (CMSObjectHelper.GetSiteBindingObject(RelatedObject) == null) { selectedSiteId = ValidationHelper.GetInteger(siteSelector.Value, -1); } if (selectedSiteId == 0) { where = RelatedObject.SiteIDColumn + " IS NULL"; } else { where = RelatedObject.SiteIDColumn + " = " + selectedSiteId; } } // Load the object selectors if (ActiveLeft) { // Active left selector selLeftObj.Enabled = true; selLeftObj.ObjectType = RelatedObject.ObjectType; selLeftObj.WhereCondition = where; selLeftObj.Reload(true); if (!selLeftObj.HasData) { selLeftObj.DropDownSingleSelect.Items.Add(new ListItem(GetString("General.NoneAvailable"), "")); selLeftObj.Enabled = false; } } else { // Active right selector selRightObj.Enabled = true; selRightObj.ObjectType = RelatedObject.ObjectType; selRightObj.WhereCondition = where; selRightObj.Reload(true); if (!selRightObj.HasData) { selRightObj.DropDownSingleSelect.Items.Add(new ListItem(GetString("General.NoneAvailable"), "")); selRightObj.Enabled = false; } } } }
/// <summary> /// Loads variables and objects. /// </summary> private void LoadControls() { // Display default name filter if (useDefaultNameFilter) { lblSearch.ResourceString = resourcePrefix + ".entersearch|general.entersearch"; btnSearch.ResourceString = "general.search"; pnlSearch.Visible = true; if (!RequestHelper.IsPostBack()) { ScriptHelper.RegisterStartupScript(this, typeof(string), "Focus", ScriptHelper.GetScript("try{document.getElementById('" + txtSearch.ClientID + "').focus();}catch(err){}")); } } // Load objects if (!String.IsNullOrEmpty(objectType)) { iObjectType = CMSObjectHelper.GetReadOnlyObject(objectType); if (iObjectType == null) { throw new Exception("[UniSelector.SelectionDialog]: Object type '" + objectType + "' not found."); } if (returnColumnName == null) { returnColumnName = iObjectType.IDColumn; } } if (!RequestHelper.IsPostBack()) { uniGrid.Pager.DefaultPageSize = itemsPerPage; } uniGrid.GridName = dialogGridName; uniGrid.GridView.EnableViewState = false; // Show the OK button if needed switch (selectionMode) { case SelectionModeEnum.Multiple: case SelectionModeEnum.MultipleTextBox: case SelectionModeEnum.MultipleButton: { pnlAll.Visible = true; lnkSelectAll.Text = GetString("UniSelector.SelectAll"); lnkDeselectAll.Text = GetString("UniSelector.DeselectAll"); } break; } }
/// <summary> /// Gets the where condition for the selected object type. /// </summary> /// <param name="selectedObjectType">Selected object type</param> public string GetWhereCondition(string selectedObjectType) { if (Object != null) { string where = null; if (RelatedObject != null) { // Get the site name if ((RelatedObject.SiteIDColumn != TypeInfo.COLUMN_NAME_UNKNOWN) && (CMSObjectHelper.GetSiteBindingObject(RelatedObject) == null)) { if (siteSelector.DropDownSingleSelect.Items.Count == 0) { siteSelector.Value = CMSContext.CurrentSiteID; } if (siteSelector.HasData) { // Set the site name for registration int selectedSiteId = ValidationHelper.GetInteger(siteSelector.Value, 0); if (selectedSiteId >= 0) { string siteWhere = QueryProvider.GetQuery(RelatedObject.ObjectType + ".selectall", RelatedObject.IDColumn, SqlHelperClass.GetSiteIDWhereCondition(RelatedObject.SiteIDColumn, selectedSiteId), null, 0); // Where condition for the left object string rightWhere = ObjectRelationshipInfoProvider.GetWhereCondition(ObjectID, ObjectType, 0, false, true, selectedObjectType); rightWhere += " AND RelationshipLeftObjectID IN (" + siteWhere + ")"; // Where condition for the left object string leftWhere = ObjectRelationshipInfoProvider.GetWhereCondition(ObjectID, ObjectType, 0, true, false, selectedObjectType); leftWhere += " AND RelationshipRightObjectID IN (" + siteWhere + ")"; // --- Add site conditions here where = SqlHelperClass.AddWhereCondition(leftWhere, rightWhere, "OR"); } } } } if (String.IsNullOrEmpty(where)) { // Get using regular where where = ObjectRelationshipInfoProvider.GetWhereCondition(ObjectID, ObjectType, 0, true, true, selectedObjectType); } return(where); } return(null); }
/// <summary> /// Setup controls /// </summary> private void SetupControls() { if (!RequestHelper.IsPostBack()) { LoadDropDown(); chkDisplayAllData.Checked = !ObjectDataOnly; } drpCompareTo.SelectedIndexChanged += drpCompareTo_SelectedIndexChanged; if (!NoComparison) { ObjectDataOnly = !chkDisplayAllData.Checked; } SyncHelper sh = SyncHelper.GetInstance(); sh.OperationType = OperationTypeEnum.Versioning; // Get object version DataSet DataSet dsObject = sh.GetDataSet(Version.VersionXML, TaskTypeEnum.UpdateObject, Version.VersionObjectType); DataSet dsCompare = null; // Get object compare version DataSet if (VersionCompare != null) { dsCompare = sh.GetDataSet(VersionCompare.VersionXML, TaskTypeEnum.UpdateObject, VersionCompare.VersionObjectType); } // Filter out data if necessary if (ObjectDataOnly) { // Get object data table name GeneralizedInfo obj = CMSObjectHelper.GetReadOnlyObject(Version.VersionObjectType); string objectTable = CMSObjectHelper.GetTableName(obj); dsObject = CreateTableDataSet(dsObject, objectTable, obj); dsCompare = CreateTableDataSet(dsCompare, objectTable, obj); } // Switch version data to ensure lower version is on the left side if ((Version != null) && (VersionCompare != null) && (VersionCompare.VersionID < Version.VersionID)) { viewDataSet.DataSet = dsCompare; viewDataSet.CompareDataSet = dsObject; } else { viewDataSet.DataSet = dsObject; viewDataSet.CompareDataSet = dsCompare; } }
/// <summary> /// Registers NamedDataSource to a given resolver under the specified name. /// </summary> /// <param name="resolver">Resolver object</param> /// <param name="name">Name of the macro - object will be accessible by this name in the resolver</param> /// <param name="className">Class name of the object (for the AutoCompletion to work properly)</param> private static void RegisterObject(this MacroResolver resolver, string name, string className) { BaseInfo obj = CMSObjectHelper.GetReadOnlyObject(className); if (obj != null) { resolver.SetNamedSourceData(name, obj); } else { resolver.SetNamedSourceData(name, new SimpleDataClass(className)); } }
private void gridState_OnAction(string actionName, object actionArgument) { switch (actionName.ToLowerCSafe()) { case "delete": int stateId = ValidationHelper.GetInteger(actionArgument, 0); AutomationManager manager = AutomationManager.GetInstance(CurrentUser); var obj = CMSObjectHelper.GetObjectById(ObjectType, ObjectID); var state = AutomationStateInfoProvider.GetAutomationStateInfo(stateId); manager.RemoveProcess(obj, state); break; } }
/// <summary> /// Returns true if any of the types is included in the package. /// </summary> public bool IsAnyIncluded(string objectTypes, bool siteObjects) { var types = CMSObjectHelper.GetTypes(objectTypes); foreach (string type in types) { if (Settings.IsIncluded(type, siteObjects)) { return(true); } } return(false); }
/// <summary> /// Refreshes the selection of site. /// </summary> protected void RefreshNewSiteSelection() { if (RelatedObject != null) { if ((RelatedObject.SiteIDColumn != TypeInfo.COLUMN_NAME_UNKNOWN) && (CMSObjectHelper.GetSiteBindingObject(RelatedObject) == null)) { pnlSite.Visible = true; siteSelector_OnSelectionChanged(null, null); } else { pnlSite.Visible = false; } } }
private void SetTheValue() { // Get binding object BaseInfo bindingObj = CMSObjectHelper.GetObject(BindingObjectType); // Build where condition (select only bindings of the current site) string where = bindingObj.TypeInfo.SiteIDColumn + "=" + SiteID; // Initialize selector from retrieved data DataSet ds = bindingObj.Generalized.GetData(null, where, null, 0, null, false); currentValues = TextHelper.Join(";", SystemDataHelper.GetStringValues(ds.Tables[0], bindingObj.TypeInfo.ParentIDColumn)); if (!RequestHelper.IsPostBack()) { Value = currentValues; } }
/// <summary> /// Fills dropdown list with column names /// </summary> protected void SetupControl() { drpColumn.Items.Clear(); // Get object by object type GeneralizedInfo generalObject = CMSObjectHelper.GetObject(ObjectType); if (generalObject != null) { FormInfo fi = FormHelper.GetFormInfo(generalObject.ObjectClassName, false); if (fi != null) { // Get fields except the primary key var fields = fi.GetFields(true, ShowAllColumns).Where(f => !f.PrimaryKey); // Sort fields by visibility and caption or name fields = fields.OrderByDescending(f => f.Visible).ThenBy(f => UseColumnCaption ? (string.IsNullOrEmpty(f.Caption) ? f.Name : f.Caption) : f.Name); foreach (FormFieldInfo field in fields) { if (UseColumnCaption && !String.IsNullOrEmpty(field.Caption)) { drpColumn.Items.Add(new ListItem(field.Caption, field.Name)); } else { drpColumn.Items.Add(field.Name); } } } } if (selectedColumn != String.Empty) { // Select selected column ListItem item = drpColumn.Items.FindByValue(ValidationHelper.GetString(selectedColumn, String.Empty)); if (item != null) { item.Selected = true; } } }
protected void Page_Load(object sender, EventArgs e) { if (StopProcessing) { // Do not load the data } else { // Get the base object GeneralizedInfo info = CMSObjectHelper.GetReadOnlyObject(ObjectType); if (info != null) { DataSet ds = info.GetData(null, info.IDColumn + " = " + this.ObjectID, null, 0, null, false); if (!DataHelper.DataSourceIsEmpty(ds)) { ds.Tables[0].TableName = ValidationHelper.GetIdentifier(info.ObjectClassName); DisplayData(ds); } } } }
/// <summary> /// Returns true if the contact voted in the poll. /// </summary> /// <param name="contact">Contact which should be checked</param> /// <param name="pollName">Poll name</param> /// <param name="answer">Poll answer text</param> /// <param name="lastXDays">Constraint for last X days (if zero or negative value is given, no constraint is applied)</param> public static bool VotedInPoll(object contact, string pollName, string answer, int lastXDays) { int pollId = ValidationHelper.GetInteger(CMSMacroMethods.GetObjectID(PredefinedObjectType.POLL, pollName, CMSContext.CurrentSiteName, true), 0); if (!string.IsNullOrEmpty(answer)) { ContactInfo ci = contact as ContactInfo; if (ci == null) { return(false); } string where = GetActivityWhere(PredefinedActivityType.POLL_VOTING, null, lastXDays, "ActivityItemID = " + pollId, ci.ContactID); DataSet ds = ActivityInfoProvider.GetActivities(where, null, 0, "ActivityValue"); if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataRow dr in ds.Tables[0].Rows) { string[] answers = ValidationHelper.GetString(dr[0], "").Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (string a in answers) { BaseInfo pollAnswer = CMSObjectHelper.GetObjectById("polls.pollanswer", ValidationHelper.GetInteger(a, 0)); if (pollAnswer != null) { if (pollAnswer.GetStringValue("AnswerText", "").EqualsCSafe(answer, true)) { return(true); } } } } } return(false); } else { return(DidActivity(contact, PredefinedActivityType.POLL_VOTING, null, lastXDays, "ActivityItemID = " + pollId)); } }
protected void Page_Load(object sender, EventArgs e) { // Excluded binding types string[] excludedBindingObjects = { SiteObjectType.CULTURESITE.ToLowerCSafe() }; // Get site bindings string[] otherBindingTypes = SiteInfo.TYPEINFO.OtherBindingObjectTypes.Split(';'); for (int i = 0; i < otherBindingTypes.Length; i++) { string type = otherBindingTypes[i]; if (!excludedBindingObjects.Contains(type.ToLowerCSafe())) { // Create binding object out of type BaseInfo bindingType = CMSObjectHelper.GetReadOnlyObject(type); if ((bindingType != null) && bindingType.TypeInfo.IsSiteBinding) { // Get other side of the site binding string otherSide = bindingType.TypeInfo.ParentObjectType; string safeOtherSide = TranslationHelper.GetSafeClassName(otherSide); // Build URL string url = "Site_SiteObjects_Content.aspx?siteid=" + QueryHelper.GetInteger("siteid", 0) + "&objecttype=" + otherSide + "&bindingtype=" + type; url = URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(url)); // Initialize tab TabItem tab = new TabItem { Text = GetString("objecttasks." + safeOtherSide), RedirectUrl = url }; CurrentMaster.Tabs.AddTab(tab); } } } CurrentMaster.Tabs.UrlTarget = "content"; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); GeneralizedInfo parentObject = CMSObjectHelper.GetObject(currentObject.ParentObjectType); // Check if object or parent are site related if (((parentObject != null) && (parentObject.SiteIDColumn != TypeInfo.COLUMN_NAME_UNKNOWN)) || (currentObject.SiteIDColumn != TypeInfo.COLUMN_NAME_UNKNOWN)) { // Initialize site selector siteSelector.Reload(false); siteSelector.PostbackOnDropDownChange = true; siteSelector.DropDownSingleSelect.SelectedIndexChanged += new EventHandler(DropDownSingleSelect_SelectedIndexChanged); // Check if global is allowed else select current site if (((parentObject != null) && parentObject.TypeInfo.SupportsGlobalObjects) || (currentObject.TypeInfo.SupportsGlobalObjects)) { siteSelector.AllowGlobal = true; } else { if (!URLHelper.IsPostback()) { siteSelector.Value = CMSContext.CurrentSiteID; } } } else { plcSite.Visible = false; } if ((parentObject != null) && (parentObject.SiteIDColumn != TypeInfo.COLUMN_NAME_UNKNOWN)) { // Get site where condition parentSelector.WhereCondition = siteSelector.GetSiteWhereCondition(parentObject.SiteIDColumn); parentSelector.Reload(true); } }
/// <summary> /// Initialize filter controls. /// </summary> private void SetupControl() { if ((Parameters != null) && (Parameters["ObjectType"] != null)) { // Get current object currentObject = CMSObjectHelper.GetObject(ValidationHelper.GetString(Parameters["ObjectType"], String.Empty)); // Check if object is not null and has parent object if ((currentObject != null) && !String.IsNullOrEmpty(currentObject.ParentObjectType)) { lblParent.ResourceString = "objecttype." + currentObject.ParentObjectType.Replace(".", "_"); // Set parent object selector properties parentSelector.ObjectType = currentObject.ParentObjectType; parentSelector.DropDownSingleSelect.AutoPostBack = true; parentSelector.OnSelectionChanged += new EventHandler(parentSelector_OnSelectionChanged); } else { plcParentObject.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { if (ActivityHelper.AuthorizedReadActivity(CMSContext.CurrentSiteID, true)) { if (!QueryHelper.ValidateHash("hash")) { return; } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.ECOMMERCE)) { return; } int orderId = QueryHelper.GetInteger("orderid", 0); // Get order object BaseInfo order = CMSObjectHelper.GetObjectById(PredefinedObjectType.ORDER, orderId); if (order != null) { ltl.Text = order.GetStringValue("OrderInvoice", ""); } } }
protected object grid_OnExternalDataBound(object sender, string sourceName, object parameter) { DataRowView drv = null; if (parameter is DataRowView) { drv = (DataRowView)parameter; } else if (parameter is GridViewRow) { drv = (DataRowView)((GridViewRow)parameter).DataItem; } var objectSettingsId = ValidationHelper.GetInteger(drv["ObjectSettingsID"], 0); if ((tmpObjectSettings == null) || (tmpObjectSettings.ObjectSettingsID != objectSettingsId)) { tmpObjectSettings = ObjectSettingsInfoProvider.GetObjectSettingsInfo(objectSettingsId); tmpInfo = CMSObjectHelper.GetObjectById(tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID); } contextResolver.SetNamedSourceData("EditedObject", tmpInfo); switch (sourceName.ToLowerCSafe()) { case "edit": var editButton = (CMSImageButton)sender; var url = tmpInfo.Generalized.GetEditingPageURL(); if (!string.IsNullOrEmpty(url)) { url = contextResolver.ResolveMacros(url); url = CMSContext.ResolveDialogUrl(url); var queryString = URLHelper.GetQuery(url); url = URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(queryString)); editButton.OnClientClick = string.Format("modalDialog('{0}', 'objectEdit', '85%', '85%');", url); } else { editButton.Enabled = false; } break; case "checkin": var checkinButton = (CMSImageButton)sender; checkinButton.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/16/checkin.png"); if (tmpInfo.TypeInfo.SupportsLocking) { checkinButton.Attributes["onclick"] = GetConfirmScript(GetString("ObjectEditMenu.CheckInConfirmation"), tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID, btnCheckIn); } else { checkinButton.Enabled = false; } break; case "undocheckout": var undoCheckoutButton = (CMSImageButton)sender; undoCheckoutButton.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/16/undocheckout.png"); if (tmpInfo.TypeInfo.SupportsLocking) { undoCheckoutButton.Attributes["onclick"] = GetConfirmScript(CMSObjectManager.GetUndoCheckOutConfirmation(tmpInfo, null), tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID, btnUndoCheckOut); } else { undoCheckoutButton.Enabled = false; } break; } return(parameter); }
protected void Page_Load(object sender, EventArgs e) { backup = QueryHelper.GetBoolean("backup", false); // Check permissions if (backup) { if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.globalpermissions", "BackupObjects", CMSContext.CurrentSiteName)) { RedirectToCMSDeskAccessDenied("cms.globalpermissions", "BackupObjects"); } } else if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.globalpermissions", "ExportObjects", CMSContext.CurrentSiteName)) { RedirectToCMSDeskAccessDenied("cms.globalpermissions", "ExportObjects"); } // Register script for pendingCallbacks repair ScriptHelper.FixPendingCallbacks(Page); // Async control events binding ucAsyncControl.OnFinished += ucAsyncControl_OnFinished; ucAsyncControl.OnError += ucAsyncControl_OnError; if (!IsCallback) { try { // Delete temporary files ExportProvider.DeleteTemporaryFiles(); } catch (Exception ex) { DisplayError(ex); } if (backup) { SetTitle("CMSModules/CMS_ImportExport/backupobject.png", GetString("BackupObject.Title"), null, null); } else { SetTitle("CMSModules/CMS_ImportExport/exportobject.png", GetString("ExportObject.Title"), null, null); } // Display BETA warning lblBeta.Visible = CMSContext.IsBetaVersion(); lblBeta.Text = string.Format(GetString("export.BETAwarning"), CMSContext.GetFriendlySystemVersion(false)); // Get data from parameters objectId = ValidationHelper.GetInteger(Request.QueryString["objectId"], 0); objectType = ValidationHelper.GetString(Request.QueryString["objectType"], ""); // Get the object infoObj = CMSObjectHelper.GetReadOnlyObject(objectType); if (infoObj == null) { plcExportDetails.Visible = false; lblIntro.Text = GetString("ExportObject.ObjectTypeNotFound"); lblIntro.CssClass = "ErrorLabel"; return; } // Get exported object exportObj = infoObj.GetObject(objectId); if (exportObj == null) { plcExportDetails.Visible = false; lblIntro.Text = GetString("ExportObject.ObjectNotFound"); lblIntro.CssClass = "ErrorLabel"; btnOk.Visible = false; return; } // Store display name exportObjectDisplayName = HTMLHelper.HTMLEncode(exportObj.ObjectDisplayName); if (backup) { lblIntro.Text = string.Format(GetString("BackupObject.Intro"), ResHelper.LocalizeString(exportObjectDisplayName)); } else { lblIntro.Text = string.Format(GetString("ExportObject.Intro"), ResHelper.LocalizeString(exportObjectDisplayName)); } btnOk.Click += btnOk_Click; if (!RequestHelper.IsPostBack()) { lblIntro.Visible = true; lblFileName.Visible = true; txtFileName.Text = GetExportFileName(exportObj, backup); if (backup) { btnOk.Text = GetString("General.backup"); } else { btnOk.Text = GetString("General.export"); } btnCancel.Text = GetString("General.Close"); } string path = null; if (backup) { path = ImportExportHelper.GetObjectBackupFolder(exportObj); targetFolder = Server.MapPath(path); targetUrl = ResolveUrl(path) + "/" + txtFileName.Text; } else { targetFolder = ImportExportHelper.GetSiteUtilsFolder() + "Export"; path = ImportExportHelper.GetSiteUtilsFolderRelativePath(); if (path != null) { string externalUrl = null; string fullPath = path + "Export/" + txtFileName.Text; // Handle external storage URL if (StorageHelper.IsExternalStorage(fullPath)) { externalUrl = File.GetFileUrl(fullPath, CMSContext.CurrentSiteName); } // Ensure default target URL if not set if (string.IsNullOrEmpty(externalUrl)) { targetUrl = ResolveUrl(path) + "Export/" + txtFileName.Text; } else { targetUrl = externalUrl; } } else { targetUrl = null; } } } }
/// <summary> /// Gets new table header cell which contains label and rollback image. /// </summary> /// <param name="suffixID">ID suffix</param> /// <param name="documentID">Document ID</param> /// <param name="versionID">Version history ID</param> /// <param name="action">Action</param> private TableHeaderCell GetRollbackTableHeaderCell(string suffixID, ObjectVersionHistoryInfo objectVersion) { TableHeaderCell tblHeaderCell = new TableHeaderCell(); // Label Label lblValue = new Label(); lblValue.ID = "lbl" + suffixID; lblValue.Text = HTMLHelper.HTMLEncode(GetVersionNumber(objectVersion.VersionNumber, objectVersion.VersionModifiedWhen)); // Panel Panel pnlLabel = new Panel(); pnlLabel.ID = "pnlLabel" + suffixID; pnlLabel.CssClass = "LeftAlign"; pnlLabel.Controls.Add(lblValue); tblHeaderCell.Controls.Add(pnlLabel); // Add rollback controls if user authorized to modify selected object if (UserInfoProvider.IsAuthorizedPerObject(objectVersion.VersionObjectType, PermissionsEnum.Modify, CMSContext.CurrentSiteName, CMSContext.CurrentUser)) { // Rollback panel Panel pnlImage = new Panel(); pnlImage.ID = "pnlRollback" + suffixID; pnlImage.CssClass = "RightAlign"; // Rollback image Image imgRollback = new Image(); imgRollback.ID = "imgRollback" + suffixID; string tooltip = null; string confirmText = null; var info = CMSObjectHelper.GetObjectById(Version.VersionObjectType, Version.VersionObjectID); var rollbackEnabled = !CMSObjectHelper.IsCheckedOutByOtherUser(info); // Set image action and description according to roll back type if (chkDisplayAllData.Checked) { tooltip = GetString("objectversioning.versionlist.versionfullrollbacktooltip"); confirmText = GetString("objectversioning.versionlist.confirmfullrollback"); imgRollback.ImageUrl = GetImageUrl(rollbackEnabled ? "CMSModules/CMS_RecycleBin/restorechilds.png" : "CMSModules/CMS_RecycleBin/restorechildsdisabled.png"); } else { tooltip = GetString("history.versionrollbacktooltip"); confirmText = GetString("Unigrid.ObjectVersionHistory.Actions.Rollback.Confirmation"); imgRollback.ImageUrl = GetImageUrl(rollbackEnabled ? "Design/Controls/UniGrid/Actions/undo.png" : "Design/Controls/UniGrid/Actions/undodisabled.png"); } imgRollback.AlternateText = tooltip; imgRollback.ToolTip = tooltip; imgRollback.Style.Add("cursor", "pointer"); // Prepare onclick script if (rollbackEnabled) { var confirmScript = "if (confirm(\"" + confirmText + "\")) { "; confirmScript += ControlsHelper.GetPostBackEventReference(this, objectVersion.VersionID + "|" + chkDisplayAllData.Checked) + "; return false; }"; imgRollback.Attributes.Add("onclick", confirmScript); } pnlImage.Controls.Add(imgRollback); tblHeaderCell.Controls.Add(pnlImage); } return(tblHeaderCell); }
/// <summary> /// Reloads all data. /// </summary> public override void ReloadData(bool forceLoad) { if (CurrentReport != null) { // Load labels if (!RequestHelper.IsPostBack() || forceLoad) { // Create query parameters string query = "?ObjectID=" + CurrentReport.ReportObjectID; // Set link value string url = CurrentReport.ReportURL; if (CurrentReport.ReportCulture != String.Empty) { url = URLHelper.AddParameterToUrl(url, URLHelper.LanguageParameterName, CurrentReport.ReportCulture); } lnkUrlValue.Text = HTMLHelper.HTMLEncode(url); lnkUrlValue.NavigateUrl = url; lnkUrlValue.ToolTip = HTMLHelper.HTMLEncode(url); lnkUrlValue.Target = "_blank"; // Set culture value CultureInfo ci = CultureHelper.GetCultureInfo(CurrentReport.ReportCulture); lblCultureValue.Text = (ci != null) ? ci.DisplayName : ResHelper.Dash; // Set site value SiteInfo si = SiteInfoProvider.GetSiteInfo(CurrentReport.ReportSiteID); lblSiteValue.Text = (si != null) ? HTMLHelper.HTMLEncode(si.DisplayName) : ResHelper.Dash; // Set title lblTitleValue.Text = HTMLHelper.HTMLEncode(CurrentReport.ReportTitle); // Set labels if (!string.IsNullOrEmpty(CurrentReport.ReportObjectType)) { lblObjectTypeValue.Text = GetString("ObjectType." + ImportExportHelper.GetSafeObjectTypeName(CurrentReport.ReportObjectType)); query += "&ObjectType=" + CurrentReport.ReportObjectType; if ((CurrentReport.ReportObjectID > 0) && (CurrentReport.ReportObjectType.ToLowerCSafe() != DocumentObjectType.DOCUMENT)) { pnlLink.Visible = true; } } else { lblObjectTypeValue.Text = ResHelper.Dash; } // Get object display name lblObjectNameValue.Text = ResHelper.Dash; string objectType = CurrentReport.ReportObjectType; int objectId = CurrentReport.ReportObjectID; if ((objectId > 0) && !string.IsNullOrEmpty(objectType) && !objectType.EqualsCSafe(DocumentObjectType.DOCUMENT, true)) { GeneralizedInfo obj = CMSObjectHelper.GetObjectById(objectType, objectId); if ((obj != null) && !string.IsNullOrEmpty(obj.ObjectDisplayName)) { lblObjectNameValue.Text = HTMLHelper.HTMLEncode(obj.ObjectDisplayName); } } // Set Reported by label lblReportedByValue.Text = ResHelper.Dash; if (CurrentReport.ReportUserID != 0) { UserInfo ui = UserInfoProvider.GetUserInfo(CurrentReport.ReportUserID); lblReportedByValue.Text = (ui != null) ? HTMLHelper.HTMLEncode(ui.FullName) : GetString("general.NA"); } // Set other parameters lblReportedWhenValue.Text = CurrentReport.ReportWhen.ToString(); if ((CurrentReport.ReportObjectID > 0) && (!string.IsNullOrEmpty(CurrentReport.ReportObjectType)) && AbuseReportInfoProvider.IsObjectTypeSupported(CurrentReport.ReportObjectType)) { lnkShowDetails.Visible = true; string detailUrl = "~/CMSModules/AbuseReport/AbuseReport_ObjectDetails.aspx" + query; lnkShowDetails.NavigateUrl = URLHelper.AddParameterToUrl(detailUrl, "hash", QueryHelper.GetHash(detailUrl)); } Control postback = ControlsHelper.GetPostBackControl(Page); CMSPage page = Page as CMSPage; // Not post-back not caused by OK button or Save action in header if ((postback != btnOk) && ((page == null) || (postback != page.HeaderActions))) { txtCommentValue.Text = CurrentReport.ReportComment; LoadStatus((int)CurrentReport.ReportStatus); } } } }
/// <summary> /// Clear all hashtables. /// </summary> public static void ClearHashtables() { CMSObjectHelper.ClearHashtables(); }
/// <summary> /// Compare DataSets. /// </summary> /// <param name="ds">Original DataSet</param> /// <param name="compareDs">DataSet to compare</param> private void CompareDataSets(DataSet ds, DataSet compareDs) { Table = new Table(); SetTable(Table); Table.CssClass += " NoSideBorders"; // Ensure same tables in DataSets EnsureSameTables(ds, compareDs); EnsureSameTables(compareDs, ds); // Prepare list of tables SortedDictionary <string, string> tables = new SortedDictionary <string, string>(); foreach (DataTable dt in ds.Tables) { string excludedTableNames = (ExcludedTableNames != null) ? ";" + ExcludedTableNames.Trim(';').ToLowerCSafe() + ";" : ""; string tableName = dt.TableName; if (!DataHelper.DataSourceIsEmpty(ds.Tables[tableName]) || !DataHelper.DataSourceIsEmpty(CompareDataSet.Tables[tableName])) { if (!excludedTableNames.Contains(";" + tableName.ToLowerCSafe() + ";")) { tables.Add(GetString("ObjectType." + tableName), tableName); } } } // Generate the tables foreach (string tableName in tables.Values) { DataTable dt = ds.Tables[tableName].Copy(); DataTable dtCompare = CompareDataSet.Tables[tableName].Copy(); if (dt.PrimaryKey.Length <= 0) { continue; } // Add table heading if ((tables.Count > 1) || (ds.Tables.Count > 1)) { AddTableHeaderRow(Table, GetTableHeaderText(dt), ((Table.Rows.Count > 0) ? "TableSeparator " : "") + "NoSideBorders"); } while (dt.Rows.Count > 0 || dtCompare.Rows.Count > 0) { // Add table header row TableCell labelCell = new TableHeaderCell(); labelCell.Text = GetString("General.FieldName"); TableCell valueCell = new TableHeaderCell(); valueCell.Text = GetString("General.Value"); TableCell valueCompare = new TableHeaderCell(); valueCompare.Text = GetString("General.Value"); AddRow(Table, labelCell, valueCell, valueCompare, "UniGridHead", false); DataRow srcDr = null; DataRow dstDr = null; if ((tables.Count == 1) && (dt.Rows.Count == 1) && (dtCompare.Rows.Count == 1)) { srcDr = dt.Rows[0]; dstDr = dtCompare.Rows[0]; } else { if (!DataHelper.DataSourceIsEmpty(dt)) { srcDr = dt.Rows[0]; dstDr = dtCompare.Rows.Find(GetPrimaryColumnsValue(dt, srcDr)); } else { dstDr = dtCompare.Rows[0]; srcDr = dt.Rows.Find(GetPrimaryColumnsValue(dtCompare, dstDr)); } // If match not find, try to find in guid column if ((srcDr == null) || (dstDr == null)) { DataTable dtToSearch = null; DataRow drTocheck = null; if (srcDr == null) { dtToSearch = dt; drTocheck = dstDr; } else { dtToSearch = dtCompare; drTocheck = srcDr; } GeneralizedInfo infoObj = CMSObjectHelper.GetObject(drTocheck, dt.TableName.Replace("_", ".")); if ((infoObj != null) && ((infoObj.CodeNameColumn != TypeInfo.COLUMN_NAME_UNKNOWN) || (infoObj.GUIDColumn != TypeInfo.COLUMN_NAME_UNKNOWN))) { DataRow[] rows = dtToSearch.Select(infoObj.CodeNameColumn + "='" + drTocheck[infoObj.CodeNameColumn] + "'"); if (rows.Length > 0) { if (srcDr == null) { srcDr = rows[0]; } else { dstDr = rows[0]; } } else { rows = dtToSearch.Select(infoObj.GUIDColumn + "='" + drTocheck[infoObj.GUIDColumn] + "'"); if (rows.Length > 0) { if (srcDr == null) { srcDr = rows[0]; } else { dstDr = rows[0]; } } } } } } // Add values bool even = false; foreach (DataColumn dc in dt.Columns) { // Get content values string fieldContent = GetRowColumnContent(srcDr, dc, true); string fieldCompareContent = GetRowColumnContent(dstDr, dc, true); if (ShowAllFields || !String.IsNullOrEmpty(fieldContent) || !String.IsNullOrEmpty(fieldCompareContent)) { // Initialize comparators TextComparison comparefirst = new TextComparison(); comparefirst.SynchronizedScrolling = false; comparefirst.ComparisonMode = TextComparisonModeEnum.PlainTextWithoutFormating; comparefirst.EnsureHTMLLineEndings = true; TextComparison comparesecond = new TextComparison(); comparesecond.SynchronizedScrolling = false; comparesecond.RenderingMode = TextComparisonTypeEnum.DestinationText; comparesecond.EnsureHTMLLineEndings = true; comparefirst.PairedControl = comparesecond; // Set comparator content comparefirst.SourceText = fieldContent; comparefirst.DestinationText = fieldCompareContent; // Create set of cells labelCell = new TableCell(); labelCell.Text = "<strong>" + dc.ColumnName + "</strong>"; valueCell = new TableCell(); valueCell.Controls.Add(comparefirst); valueCompare = new TableCell(); valueCompare.Controls.Add(comparesecond); // Add comparison row AddRow(Table, labelCell, valueCell, valueCompare, null, even); even = !even; } } // Remove rows from tables if (srcDr != null) { dt.Rows.Remove(srcDr); } if (dstDr != null) { dtCompare.Rows.Remove(dstDr); } if (dt.Rows.Count > 0 || dtCompare.Rows.Count > 0) { TableCell emptyCell = new TableCell(); emptyCell.Text = " "; AddRow(Table, emptyCell, null, null, "TableSeparator", false); even = false; } } } plcContent.Controls.Add(Table); }
/// <summary> /// Bind the data. /// </summary> public void Bind() { if (!string.IsNullOrEmpty(ObjectType)) { pnlGrid.Visible = true; selectionEnabled = ((ObjectType != LicenseObjectType.LICENSEKEY) || !Settings.IsOlderVersion); lblTasks.Text = GetString("Export.Tasks"); if (selectionEnabled) { // Initilaize strings btnAllTasks.Text = GetString("ImportExport.All"); btnNoneTasks.Text = GetString("export.none"); } pnlTaskLinks.Visible = selectionEnabled; // Get object info GeneralizedInfo info = CMSObjectHelper.GetReadOnlyObject(ObjectType); if (info != null) { plcGrid.Visible = true; codeNameColumnName = info.CodeNameColumn; displayNameColumnName = info.DisplayNameColumn; // Task fields TemplateField taskCheckBoxField = (TemplateField)gvTasks.Columns[0]; taskCheckBoxField.HeaderText = GetString("General.Process"); BoundField titleField = (BoundField)gvTasks.Columns[1]; titleField.HeaderText = GetString("Export.TaskTitle"); BoundField typeField = (BoundField)gvTasks.Columns[2]; typeField.HeaderText = GetString("general.type"); BoundField timeField = (BoundField)gvTasks.Columns[3]; timeField.HeaderText = GetString("Export.TaskTime"); // Load tasks DataSet ds = DataSource; if (!DataHelper.DataSourceIsEmpty(ds) && !DataHelper.DataSourceIsEmpty(ds.Tables["Export_Task"]) && (ValidationHelper.GetBoolean(Settings.GetSettings(ImportExportHelper.SETTINGS_TASKS), true))) { plcTasks.Visible = true; gvTasks.DataSource = ds.Tables["Export_Task"]; // Set correct ID for direct page contol pagerElem.DirectPageControlID = ((float)ds.Tables["Export_Task"].Rows.Count / pagerElem.CurrentPageSize > 20.0f) ? "txtPage" : "drpPage"; // Call page binding event if (OnPageBinding != null) { OnPageBinding(this, null); } gvTasks.DataBind(); } else { plcTasks.Visible = false; } } else { plcGrid.Visible = false; } // Disable license selection bool enable = !((ObjectType == LicenseObjectType.LICENSEKEY) && Settings.IsOlderVersion); gvTasks.Enabled = enable; pnlTaskLinks.Enabled = enable; } else { pnlGrid.Visible = false; } }
/// <summary> /// Bind the data. /// </summary> public void Bind() { sbAvailable = null; if (!string.IsNullOrEmpty(ObjectType)) { pnlGrid.Visible = true; // Initialize strings btnAllTasks.Text = GetString("ImportExport.All"); btnNoneTasks.Text = GetString("export.none"); lblTasks.Text = GetString("Export.Tasks"); // Get object info GeneralizedInfo info = CMSObjectHelper.GetReadOnlyObject(ObjectType); if (info != null) { plcGrid.Visible = true; codeNameColumnName = info.CodeNameColumn; displayNameColumnName = info.DisplayNameColumn; // Task fields TemplateField taskCheckBoxField = (TemplateField)gvTasks.Columns[0]; taskCheckBoxField.HeaderText = GetString("General.Export"); TemplateField titleField = (TemplateField)gvTasks.Columns[1]; titleField.HeaderText = GetString("Export.TaskTitle"); BoundField typeField = (BoundField)gvTasks.Columns[2]; typeField.HeaderText = GetString("general.type"); BoundField timeField = (BoundField)gvTasks.Columns[3]; timeField.HeaderText = GetString("Export.TaskTime"); // Load tasks int siteId = (SiteObject ? Settings.SiteId : 0); DataSet ds = ExportTaskInfoProvider.SelectTaskList(siteId, ObjectType, null, "TaskTime DESC", 0, null, CurrentOffset, CurrentPageSize, ref pagerForceNumberOfResults); // Set correct ID for direct page contol pagerElem.DirectPageControlID = ((float)pagerForceNumberOfResults / pagerElem.CurrentPageSize > 20.0f) ? "txtPage" : "drpPage"; // Call page binding event if (OnPageBinding != null) { OnPageBinding(this, null); } if (!DataHelper.DataSourceIsEmpty(ds) && (ValidationHelper.GetBoolean(Settings.GetSettings(ImportExportHelper.SETTINGS_TASKS), true))) { plcTasks.Visible = true; gvTasks.DataSource = ds; gvTasks.DataBind(); } else { plcTasks.Visible = false; } } else { plcGrid.Visible = false; } } else { pnlGrid.Visible = false; } }
public static void Update60() { EventLogProvider evp = new EventLogProvider(); evp.LogEvent("I", DateTime.Now, "Upgrade to 6.0", "Upgrade - Start"); DataClassInfo dci = null; #region "CMS.UserSettings" try { dci = DataClassInfoProvider.GetDataClass("cms.usersettings"); if (dci != null) { FormInfo fi = new FormInfo(dci.ClassFormDefinition); if (fi != null) { FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = "UserAuthenticationGUID"; ffi.DataType = FormFieldDataTypeEnum.GUID; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "UserBounces"; ffi.DataType = FormFieldDataTypeEnum.Integer; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.TextBoxControl; ffi.Visible = false; ffi.Caption = "UserBounces"; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "UserLinkedInID"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 100; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "UserLogActivities"; ffi.DataType = FormFieldDataTypeEnum.Boolean; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "UserPasswordRequestHash"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 100; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); dci.ClassFormDefinition = fi.GetXmlDefinition(); TableManager tm = new TableManager(dci.ClassConnectionString); dci.ClassXmlSchema = tm.GetXmlSchema("CMS_UserSettings"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); tm.RefreshCustomViews("CMS_UserSettings"); } } } catch (Exception ex) { evp.LogEvent("CMS.UserSettings - Upgrade", "Upgrade", ex); } #endregion #region "Ecommerce - Customer" try { dci = DataClassInfoProvider.GetDataClass("ecommerce.customer"); if (dci != null) { FormInfo fi = new FormInfo(dci.ClassFormDefinition); if (fi != null) { FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = "CustomerSiteID"; ffi.DataType = FormFieldDataTypeEnum.Integer; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.TextBoxControl; ffi.Visible = false; fi.AddFormField(ffi); TableManager tm = new TableManager(dci.ClassConnectionString); dci.ClassFormDefinition = fi.GetXmlDefinition(); dci.ClassXmlSchema = tm.GetXmlSchema("COM_Customer"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); tm.RefreshCustomViews("COM_Customer"); } } } catch (Exception ex) { evp.LogEvent("Ecommerce.Customer - Upgrade", "Upgrade", ex); } #endregion #region "Ecommerce - Order" try { dci = DataClassInfoProvider.GetDataClass("ecommerce.order"); if (dci != null) { FormInfo fi = new FormInfo(dci.ClassFormDefinition); if (fi != null) { FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = "OrderCulture"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 10; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "OrderIsPaid"; ffi.DataType = FormFieldDataTypeEnum.Boolean; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "OrderTotalPriceInMainCurrency"; ffi.DataType = FormFieldDataTypeEnum.Decimal; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = fi.GetFormField("OrderStatusID"); if (ffi != null) { ffi.AllowEmpty = true; fi.UpdateFormField("OrderStatusID", ffi); } ffi = fi.GetFormField("OrderShippingAddressID"); if (ffi != null) { ffi.AllowEmpty = true; fi.UpdateFormField("OrderShippingAddressID", ffi); } dci.ClassFormDefinition = fi.GetXmlDefinition(); TableManager tm = new TableManager(dci.ClassConnectionString); dci.ClassXmlSchema = tm.GetXmlSchema("COM_Order"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); tm.RefreshCustomViews("COM_Order"); } } } catch (Exception ex) { evp.LogEvent("Ecommerce.Order - Upgrade", "Upgrade", ex); } #endregion #region "Ecommerce - OrderItem" try { dci = DataClassInfoProvider.GetDataClass("ecommerce.orderitem"); if (dci != null) { FormInfo fi = new FormInfo(dci.ClassFormDefinition); if (fi != null) { FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = "OrderItemBundleGUID"; ffi.DataType = FormFieldDataTypeEnum.GUID; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "OrderItemIsPrivate"; ffi.DataType = FormFieldDataTypeEnum.Boolean; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "OrderItemPrice"; ffi.DataType = FormFieldDataTypeEnum.Decimal; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "OrderItemSendNotification"; ffi.DataType = FormFieldDataTypeEnum.Boolean; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "OrderItemSKU"; ffi.DataType = FormFieldDataTypeEnum.LongText; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "OrderItemText"; ffi.DataType = FormFieldDataTypeEnum.LongText; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "OrderItemTotalPriceInMainCurrency"; ffi.DataType = FormFieldDataTypeEnum.Decimal; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "OrderItemValidTo"; ffi.DataType = FormFieldDataTypeEnum.DateTime; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); dci.ClassFormDefinition = fi.GetXmlDefinition(); TableManager tm = new TableManager(dci.ClassConnectionString); dci.ClassXmlSchema = tm.GetXmlSchema("COM_OrderItem"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); tm.RefreshCustomViews("COM_OrderItem"); } } } catch (Exception ex) { evp.LogEvent("Ecommerce.OrderItem - Upgrade", "Upgrade", ex); } #endregion #region "Ecommerce - Shopping cart item" try { dci = DataClassInfoProvider.GetDataClass("ecommerce.shoppingcartitem"); if (dci != null) { FormInfo fi = new FormInfo(dci.ClassFormDefinition); if (fi != null) { FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = "CartItemBundleGUID"; ffi.DataType = FormFieldDataTypeEnum.GUID; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "CartItemIsPrivate"; ffi.DataType = FormFieldDataTypeEnum.Boolean; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "CartItemPrice"; ffi.DataType = FormFieldDataTypeEnum.Decimal; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "CartItemText"; ffi.DataType = FormFieldDataTypeEnum.LongText; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "CartItemValidTo"; ffi.DataType = FormFieldDataTypeEnum.DateTime; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = fi.GetFormField("CartItemGuid"); if (ffi != null) { ffi.AllowEmpty = true; fi.UpdateFormField("CartItemGuid", ffi); } dci.ClassFormDefinition = fi.GetXmlDefinition(); TableManager tm = new TableManager(dci.ClassConnectionString); dci.ClassXmlSchema = tm.GetXmlSchema("COM_ShoppingCartSKU"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); tm.RefreshCustomViews("COM_ShoppingCartSKU"); } } } catch (Exception ex) { evp.LogEvent("Ecommerce.ShoppingCartItem - Upgrade", "Upgrade", ex); } #endregion #region "Ecommerce - SKU" try { dci = DataClassInfoProvider.GetDataClass("ecommerce.sku"); if (dci != null) { FormInfo fi = new FormInfo(dci.ClassFormDefinition); if (fi != null) { FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = "SKUBundleInventoryType"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 50; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUConversionName"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 100; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUConversionValue"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 200; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUMaxDownloads"; ffi.DataType = FormFieldDataTypeEnum.Integer; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUMaxItemsInOrder"; ffi.DataType = FormFieldDataTypeEnum.Integer; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUMaxPrice"; ffi.DataType = FormFieldDataTypeEnum.Decimal; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUMembershipGUID"; ffi.DataType = FormFieldDataTypeEnum.GUID; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUMinPrice"; ffi.DataType = FormFieldDataTypeEnum.Decimal; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUNeedsShipping"; ffi.DataType = FormFieldDataTypeEnum.Boolean; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUPrivateDonation"; ffi.DataType = FormFieldDataTypeEnum.Boolean; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUProductType"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 50; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUSiteID"; ffi.DataType = FormFieldDataTypeEnum.Integer; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUValidFor"; ffi.DataType = FormFieldDataTypeEnum.Integer; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUValidity"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 50; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "SKUValidUntil"; ffi.DataType = FormFieldDataTypeEnum.DateTime; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); ffi = fi.GetFormField("SKUDepartmentID"); if (ffi != null) { ffi.AllowEmpty = true; fi.UpdateFormField("SKUDepartmentID", ffi); } dci.ClassFormDefinition = fi.GetXmlDefinition(); TableManager tm = new TableManager(dci.ClassConnectionString); dci.ClassXmlSchema = tm.GetXmlSchema("COM_SKU"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); tm.RefreshCustomViews("COM_SKU"); } } } catch (Exception ex) { evp.LogEvent("Ecommerce.SKU - Upgrade", "Upgrade", ex); } #endregion #region "Community - Group" try { dci = DataClassInfoProvider.GetDataClass("Community.Group"); if (dci != null) { FormInfo fi = new FormInfo(dci.ClassFormDefinition); if (fi != null) { FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = "GroupLogActivity"; ffi.DataType = FormFieldDataTypeEnum.Boolean; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.CheckBoxControl; ffi.Visible = true; ffi.DefaultValue = "true"; ffi.Caption = "GroupLogActivity"; fi.AddFormField(ffi); dci.ClassFormDefinition = fi.GetXmlDefinition(); TableManager tm = new TableManager(dci.ClassConnectionString); dci.ClassXmlSchema = tm.GetXmlSchema("Community_Group"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); tm.RefreshCustomViews("Community_Group"); } } } catch (Exception ex) { evp.LogEvent("Community.Group - Upgrade", "Upgrade", ex); } #endregion #region "Newsletter - Subscriber" try { dci = DataClassInfoProvider.GetDataClass("newsletter.subscriber"); if (dci != null) { FormInfo fi = new FormInfo(dci.ClassFormDefinition); if (fi != null) { FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = "SubscriberBounces"; ffi.DataType = FormFieldDataTypeEnum.Boolean; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.LabelControl; ffi.Visible = false; fi.AddFormField(ffi); dci.ClassFormDefinition = fi.GetXmlDefinition(); TableManager tm = new TableManager(dci.ClassConnectionString); dci.ClassXmlSchema = tm.GetXmlSchema("Newsletter_Subscriber"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); tm.RefreshCustomViews("Newsletter_Subscriber"); } } } catch (Exception ex) { evp.LogEvent("Newsletter.Subscriber - Upgrade", "Upgrade", ex); } #endregion #region "CMS.Document" try { dci = DataClassInfoProvider.GetDataClass("cms.document"); if (dci != null) { SearchSettings ss = dci.ClassSearchSettingsInfos; SearchSettingsInfo ssi = ss.GetSettingsInfo("42f446ee-9818-4596-8124-54a38f64aa05"); if (ssi != null) { ssi.Searchable = true; ss.SetSettingsInfo(ssi); } DataClassInfoProvider.SetDataClass(dci); } } catch (Exception ex) { evp.LogEvent("CMS.Document - Upgrade", "Upgrade", ex); } #endregion // Set the path to the upgrade package mUpgradePackagePath = HttpContext.Current.Server.MapPath("~/CMSSiteUtils/Import/upgrade_55R2_60.zip"); mWebsitePath = HttpContext.Current.Server.MapPath("~/"); TableManager dtm = new TableManager(null); // Update all views dtm.RefreshDocumentViews(); // Set data version ObjectHelper.SetSettingsKeyValue("CMSDataVersion", "6.0"); // Clear hashtables CMSObjectHelper.ClearHashtables(); // Clear the cache CacheHelper.ClearCache(null, true); // Drop the routes CMSMvcHandler.DropAllRoutes(); // Init the Mimetype helper (required for the Import) MimeTypeHelper.LoadMimeTypes(); CMSThread thread = new CMSThread(Upgrade60Import); thread.Start(); }