/// <summary> /// Serializes all Profile Definitions /// </summary> /// <param name="xmlTemplate">Reference to XmlDocument context</param> /// <param name="nodeProfileDefinitions">Node to add the serialized objects</param> /// <param name="objportal">Portal to serialize</param> /// <remarks> /// The serialization uses the xml attributes defined in ProfilePropertyDefinition class. /// </remarks> /// <history> /// </history> public void SerializeProfileDefinitions(XmlDocument xmlTemplate, XmlNode nodeProfileDefinitions, PortalInfo objportal) { ListController objListController = new ListController(); XmlSerializer xser = new XmlSerializer(typeof(ProfilePropertyDefinition)); foreach (ProfilePropertyDefinition objProfileProperty in ProfileController.GetPropertyDefinitionsByPortal(objportal.PortalID)) { StringWriter sw = new StringWriter(); xser.Serialize(sw, objProfileProperty); XmlDocument xmlPropertyDefinition = new XmlDocument(); xmlPropertyDefinition.LoadXml(sw.GetStringBuilder().ToString()); XmlNode nodeProfileDefinition = xmlPropertyDefinition.SelectSingleNode("profiledefinition"); nodeProfileDefinition.Attributes.Remove(nodeProfileDefinition.Attributes["xmlns:xsd"]); nodeProfileDefinition.Attributes.Remove(nodeProfileDefinition.Attributes["xmlns:xsi"]); ListEntryInfo objList = objListController.GetListEntryInfo(objProfileProperty.DataType); XmlNode newnode = xmlPropertyDefinition.CreateElement("datatype"); if (objList == null) { newnode.InnerXml = "Unknown"; } else { newnode.InnerXml = objList.Value; } nodeProfileDefinition.AppendChild(newnode); nodeProfileDefinitions.AppendChild(xmlTemplate.ImportNode(nodeProfileDefinition, true)); } }
/// <summary> /// This methods return the text description of the Frequency value /// </summary> /// <param name="value">value of the Frequency</param> /// <returns>text of the Frequency</returns> private string GetBillingFrequencyText(string value) { var ctlEntry = new ListController(); ListEntryInfo entry = ctlEntry.GetListEntryInfo("Frequency", value); return(entry.Text); }
private string GetBillingFrequencyCode(string Value) { ListController ctlEntry = new ListController(); ListEntryInfo entry = ctlEntry.GetListEntryInfo("Frequency", Value); return(entry.Value); }
public void CreateList() { try { //create a placeholder entry for Inventory Reporting Type const string listName = "InventoryReportingType"; var listController = new ListController(); var entry = new ListEntryInfo(); { entry.DefinitionID = -1; entry.ParentID = 0; entry.Level = 0; entry.PortalID = this.PortalId; entry.ListName = listName; entry.Value = "USDA"; entry.Text = "USDA"; entry.SystemList = false; entry.SortOrder = 1; } listController.AddListEntry(entry); } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
public HttpResponseMessage Search(string q) { var portalId = PortalController.GetEffectivePortalId(PortalSettings.PortalId); var controller = new ListController(); ListEntryInfo imageType = controller.GetListEntryInfo("DataType", "Image"); IList <SearchResult> results = new List <SearchResult>(); foreach (var definition in ProfileController.GetPropertyDefinitionsByPortal(portalId) .Cast <ProfilePropertyDefinition>() .Where(definition => definition.DataType != imageType.EntryID)) { AddProperty(results, definition.PropertyName, q); } AddProperty(results, "Email", q); AddProperty(results, "DisplayName", q); AddProperty(results, "Username", q); AddProperty(results, "Password", q); AddProperty(results, "PasswordConfirm", q); AddProperty(results, "PasswordQuestion", q); AddProperty(results, "PasswordAnswer", q); return(Request.CreateResponse(HttpStatusCode.OK, results.OrderBy(sr => sr.id))); }
public void CreateOrganizationList() { try { //create a placeholder entry - uses the most common 5 character password (seed list is 6 characters and above) const string listName = "ClientOrganizations"; var listController = new ListController(); var entry = new ListEntryInfo(); { entry.DefinitionID = -1; entry.ParentID = 0; entry.Level = 0; entry.PortalID = this.PortalId; entry.ListName = listName; entry.Value = "Main Location"; entry.Text = "Main Location"; entry.SystemList = false; entry.SortOrder = 1; } listController.AddListEntry(entry); } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
public IEnumerable <string> Search(int portalId, string searchTerm) { var controller = new ListController(); ListEntryInfo imageType = controller.GetListEntryInfo("DataType", "Image"); List <string> results = new List <string>(); foreach (var definition in ProfileController.GetPropertyDefinitionsByPortal(portalId) .Cast <ProfilePropertyDefinition>() .Where(definition => definition.DataType != imageType.EntryID)) { this.AddProperty(results, definition.PropertyName, searchTerm); } this.AddProperty(results, "Email", searchTerm); this.AddProperty(results, "DisplayName", searchTerm); this.AddProperty(results, "Username", searchTerm); this.AddProperty(results, "Password", searchTerm); this.AddProperty(results, "PasswordConfirm", searchTerm); this.AddProperty(results, "PasswordQuestion", searchTerm); this.AddProperty(results, "PasswordAnswer", searchTerm); return(results); }
/// <summary> /// Adds a single default property definition /// </summary> /// <param name="PortalId">Id of the Portal</param> /// <param name="category">Category of the Property</param> /// <param name="name">Name of the Property</param> private static void AddDefaultDefinition(int PortalId, string category, string name, string strType, int length, ListEntryInfoCollection types) { ListEntryInfo typeInfo = types.Item("DataType." + strType); if (typeInfo == null) { typeInfo = types.Item("DataType.Unknown"); } ProfilePropertyDefinition propertyDefinition = new ProfilePropertyDefinition(); propertyDefinition.DataType = typeInfo.EntryID; propertyDefinition.DefaultValue = ""; propertyDefinition.ModuleDefId = Null.NullInteger; propertyDefinition.PortalId = PortalId; propertyDefinition.PropertyCategory = category; propertyDefinition.PropertyName = name; propertyDefinition.Required = false; propertyDefinition.Visible = true; propertyDefinition.Length = length; _orderCounter += 2; propertyDefinition.ViewOrder = _orderCounter; AddPropertyDefinition(propertyDefinition); }
public static void UpdateSortOrder(ListEntryInfo listEntryInfo) { using (VanjaroRepo db = new VanjaroRepo()) { db.Execute("UPDATE " + Core.Data.Scripts.CommonScript.TablePrefix + "LISTS SET SORTORDER=@0 WHERE ENTRYID=@1 AND LISTNAME=@2", listEntryInfo.SortOrder, listEntryInfo.EntryID, listEntryInfo.ListName); } }
private void AddProperty(ProfilePropertyDefinition property) { var controller = new ListController(); ListEntryInfo imageType = controller.GetListEntryInfo("DataType", "Image"); if (property.DataType != imageType.EntryID) { DnnFormEditControlItem formItem = new DnnFormEditControlItem { ID = property.PropertyName, ResourceKey = String.Format("ProfileProperties_{0}", property.PropertyName), LocalResourceFile = "~/DesktopModules/Admin/Security/App_LocalResources/Profile.ascx.resx", ValidationMessageSuffix = ".Validation", ControlType = EditorInfo.GetEditor(property.DataType), DataMember = "Profile", DataField = property.PropertyName, Visible = property.Visible, Required = property.Required }; //To check if the property has a deafult value if (!String.IsNullOrEmpty(property.DefaultValue)) { formItem.Value = property.DefaultValue; } if (!String.IsNullOrEmpty(property.ValidationExpression)) { formItem.ValidationExpression = property.ValidationExpression; } userForm.Items.Add(formItem); } }
/// ----------------------------------------------------------------------------- /// <summary> /// The GetWriter method instantiates the relevant PackageWriter Installer. /// </summary> /// <param name="package">The associated PackageInfo instance.</param> /// <returns></returns> /// ----------------------------------------------------------------------------- public static PackageWriterBase GetWriter(PackageInfo package) { PackageWriterBase writer = null; switch (package.PackageType) { case "Auth_System": writer = new AuthenticationPackageWriter(package); break; case "Module": writer = new ModulePackageWriter(package); break; case "Container": writer = new ContainerPackageWriter(package); break; case "Skin": writer = new SkinPackageWriter(package); break; case "CoreLanguagePack": case "ExtensionLanguagePack": writer = new LanguagePackWriter(package); break; case "SkinObject": writer = new SkinControlPackageWriter(package); break; case "Provider": writer = new ProviderPackageWriter(package); break; case "Library": writer = new LibraryPackageWriter(package); break; case "Widget": writer = new WidgetPackageWriter(package); break; default: // PackageType is defined in the List var listController = new ListController(); ListEntryInfo entry = listController.GetListEntryInfo("PackageWriter", package.PackageType); if (entry != null && !string.IsNullOrEmpty(entry.Text)) { // The class for the Installer is specified in the Text property writer = (PackageWriterBase)Reflection.CreateObject(entry.Text, "PackageWriter_" + entry.Value); } break; } return(writer); }
/// <Summary>CreateEditor creates the control collection.</Summary> protected override void CreateEditor() { CategoryDataField = "PropertyCategory"; EditorDataField = "DataType"; NameDataField = "PropertyName"; RequiredDataField = "Required"; ValidationExpressionDataField = "ValidationExpression"; ValueDataField = "PropertyValue"; VisibleDataField = "Visible"; VisibilityDataField = "Visibility"; LengthDataField = "Length"; base.CreateEditor(); //We need to wire up the RegionControl to the CountryControl foreach (FieldEditorControl editor in Fields) { if (editor.Editor is DNNRegionEditControl) { ListEntryInfo country = null; foreach (FieldEditorControl checkEditor in Fields) { if (checkEditor.Editor is DNNCountryEditControl) { DNNCountryEditControl countryEdit = (DNNCountryEditControl)checkEditor.Editor; ListController objListController = new ListController(); ListEntryInfoCollection countries = objListController.GetListEntryInfoCollection("Country"); foreach (ListEntryInfo checkCountry in countries) { if (checkCountry.Text == countryEdit.Value.ToString()) { country = checkCountry; break; } } } } //Create a ListAttribute for the Region string countryKey; if (country != null) { countryKey = "Country." + country.Value; } else { countryKey = "Country.Unknown"; } object[] attributes; attributes = new object[1]; attributes[0] = new ListAttribute("Region", countryKey, ListBoundField.Text, ListBoundField.Text); editor.Editor.CustomAttributes = attributes; } } }
/// <Summary> /// RenderViewMode renders the View (readonly) mode of the control /// </Summary> /// <Param name="writer">A HtmlTextWriter.</Param> protected override void RenderViewMode(HtmlTextWriter writer) { ListController objListController = new ListController(); ListEntryInfo entry = null; string entryText = Null.NullString; switch (ValueField) { case ListBoundField.Id: entry = objListController.GetListEntryInfo(Convert.ToInt32(Value)); break; case ListBoundField.Text: entryText = StringValue; break; case ListBoundField.Value: entry = objListController.GetListEntryInfo(ListName, StringValue); break; } ControlStyle.AddAttributesToRender(writer); writer.RenderBeginTag(HtmlTextWriterTag.Span); if (entry != null) { switch (TextField) { case ListBoundField.Id: writer.Write(entry.EntryID.ToString()); break; case ListBoundField.Text: writer.Write(entry.Text); break; case ListBoundField.Value: writer.Write(entry.Value); break; } } else { writer.Write(entryText); } //Close Select Tag writer.RenderEndTag(); }
/// <summary> /// Handles events when clicking image button in the grid (Edit/Up/Down) /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void EntriesGridItemCommand(object source, GridCommandEventArgs e) { try { var ctlLists = new ListController(); int entryID = Convert.ToInt32(((GridDataItem)e.Item).GetDataKeyValue("EntryID")); switch (e.CommandName.ToLower()) { case "delete": Mode = "ListEntries"; DeleteItem(entryID); break; case "edit": Mode = "EditEntry"; ListEntryInfo entry = ctlLists.GetListEntryInfo(entryID); txtEntryID.Text = entryID.ToString(CultureInfo.InvariantCulture); txtParentKey.Text = entry.ParentKey; txtEntryValue.Text = entry.Value; txtEntryText.Text = entry.Text; rowListName.Visible = false; cmdSaveEntry.CommandName = "Update"; if (!SystemList) { cmdDelete.Visible = true; ClientAPI.AddButtonConfirm(cmdDelete, Localization.GetString("DeleteItem")); } else { cmdDelete.Visible = false; } e.Canceled = true; //stop the grid from providing inline editing DataBind(); break; case "up": ctlLists.UpdateListSortOrder(entryID, true); DataBind(); break; case "down": ctlLists.UpdateListSortOrder(entryID, false); DataBind(); break; } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
private static string DisplayDataType(int dataType) { string retValue = Null.NullString; ListController listController = new ListController(); ListEntryInfo definitionEntry = listController.GetListEntryInfo("DataType", dataType); if (definitionEntry != null) { retValue = definitionEntry.Value; } return(retValue); }
public string DisplayDataType(ProfilePropertyDefinition definition) { string retValue = Null.NullString; var listController = new ListController(); ListEntryInfo definitionEntry = listController.GetListEntryInfo("DataType", definition.DataType); if (definitionEntry != null) { retValue = definitionEntry.Value; } return(retValue); }
/// <summary> /// Get text description of Frequency Value /// </summary> protected string FormatFrequency(string frequency) { if (frequency == "N") { return(string.Empty); } var ctlEntry = new ListController(); ListEntryInfo entry = ctlEntry.GetListEntryInfo("Frequency", frequency); return(entry.Text); }
public static string GetEditor(string editorValue) { string editor = "UseSystemType"; var objListController = new ListController(); ListEntryInfo definitionEntry = objListController.GetListEntryInfo("DataType", editorValue); if (definitionEntry != null) { editor = definitionEntry.TextNonLocalized; } return(editor); }
/// <summary> /// Inserts a new status with the given name, in the given portal. /// </summary> /// <param name="statusName">Name of the status.</param> /// <param name="portalId">The portal ID.</param> public static void InsertStatus(string statusName, int portalId) { var listItem = new ListEntryInfo { Text = statusName, Value = statusName, DefinitionID = Null.NullInteger, PortalID = portalId, ListName = Utility.ApplicationStatusListName, }; new ListController().AddListEntry(listItem); }
/// ----------------------------------------------------------------------------- /// <summary> /// The GetDependency method instantiates (and returns) the relevant Dependency. /// </summary> /// <param name="dependencyNav">The manifest (XPathNavigator) for the dependency.</param> /// <returns></returns> /// ----------------------------------------------------------------------------- public static IDependency GetDependency(XPathNavigator dependencyNav) { IDependency dependency = null; string dependencyType = Util.ReadAttribute(dependencyNav, "type"); switch (dependencyType.ToLowerInvariant()) { case "coreversion": dependency = new CoreVersionDependency(); break; case "package": dependency = new PackageDependency(); break; case "managedpackage": dependency = new ManagedPackageDependency(); break; case "permission": dependency = new PermissionsDependency(); break; case "type": dependency = new TypeDependency(); break; default: // Dependency type is defined in the List var listController = new ListController(); ListEntryInfo entry = listController.GetListEntryInfo("Dependency", dependencyType); if (entry != null && !string.IsNullOrEmpty(entry.Text)) { // The class for the Installer is specified in the Text property dependency = (DependencyBase)Reflection.CreateObject(entry.Text, "Dependency_" + entry.Value); } break; } if (dependency == null) { // Could not create dependency, show generic error message dependency = new InvalidDependency(Util.INSTALL_Dependencies); } // Read Manifest dependency.ReadManifest(dependencyNav); return(dependency); }
/// ----------------------------------------------------------------------------- /// <summary> /// GetEditor gets the appropriate Editor based on ID /// properties /// </summary> /// <param name="editorType">The Id of the Editor</param> /// ----------------------------------------------------------------------------- public static string GetEditor(int editorType) { string editor = "UseSystemType"; if (editorType != Null.NullInteger) { var objListController = new ListController(); ListEntryInfo definitionEntry = objListController.GetListEntryInfo("DataType", editorType); if (definitionEntry != null) { editor = definitionEntry.TextNonLocalized; } } return(editor); }
private void AddDashboardControlInstaller() { var listController = new ListController(); ListEntryInfo entry = listController.GetListEntryInfo("Installer", DashboardInstallerName); if (entry == null) { listController.AddListEntry(new ListEntryInfo() { ListName = "Installer", Value = DashboardInstallerName, Text = DashboardInstallerType }); } }
private string GetListValue(string listName, string value) { ListController lc = new ListController(); int entryId; if (int.TryParse(value, out entryId)) { ListEntryInfo item = lc.GetListEntryInfo(listName, entryId); if (item != null) { return(item.Text); } } return(value); }
/// ----------------------------------------------------------------------------- /// <summary> /// Page_Load runs when the control is loaded /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 9/10/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> /// ----------------------------------------------------------------------------- protected override void OnLoad(EventArgs e) { base.OnLoad(e); cmdSearch.Click += OnSearchClick; grdUsers.ItemDataBound += grdUsers_ItemDataBound; grdUsers.ItemCommand += grdUsers_ItemCommand; try { //Add an Action Event Handler to the Skin AddActionHandler(ModuleAction_Click); if (!Page.IsPostBack) { ClientAPI.RegisterKeyCapture(txtSearch, cmdSearch, 13); //Load the Search Combo ddlSearchType.Items.Add(AddSearchItem("Username")); ddlSearchType.Items.Add(AddSearchItem("Email")); ProfilePropertyDefinitionCollection profileProperties = ProfileController.GetPropertyDefinitionsByPortal(PortalId, false, false); foreach (ProfilePropertyDefinition definition in profileProperties) { var controller = new ListController(); ListEntryInfo imageDataType = controller.GetListEntryInfo("DataType", "Image"); if (imageDataType == null || definition.DataType == imageDataType.EntryID) { break; } ddlSearchType.Items.Add(AddSearchItem(definition.PropertyName)); } //Localize the Headers Localization.LocalizeDataGrid(ref grdUsers, LocalResourceFile); BindData(Filter, ddlSearchType.SelectedItem.Value); //Sent controls to current Filter if ((!String.IsNullOrEmpty(Filter) && Filter.ToUpper() != "NONE") && !String.IsNullOrEmpty(FilterProperty)) { txtSearch.Text = Filter; ddlSearchType.SelectedValue = FilterProperty; } } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
/// <Summary> /// GetEditor gets the appropriate Editor based on ID properties /// </Summary> /// <Param name="editorType">The Id of the Editor</Param> public static string GetEditor(int editorType) { string editor = "UseSystemType"; if (editorType != Null.NullInteger) { ListController objListController = new ListController(); ListEntryInfo definitionEntry = objListController.GetListEntryInfo(editorType); if ((definitionEntry != null) && (definitionEntry.ListName == "DataType")) { editor = definitionEntry.Text; } } return(editor); }
public ActionResult UpdateListEntry(UpdateListEntryRequest request) { ActionResult actionResult = new ActionResult(); try { int pid = request.PortalId ?? PortalSettings.PortalId; if (!UserInfo.IsSuperUser && pid != PortalSettings.PortalId) { actionResult.AddError(HttpStatusCode.Unauthorized.ToString(), Components.Constants.AuthFailureMessage); } if (actionResult.IsSuccess) { ListController listController = new ListController(); ListEntryInfo entry = new ListEntryInfo { DefinitionID = Null.NullInteger, PortalID = pid, ListName = request.ListName, Value = request.Value, Text = request.Text, SortOrder = request.EnableSortOrder ? 1 : 0 }; if (request.EntryId.HasValue) { entry.EntryID = request.EntryId.Value; listController.UpdateListEntry(entry); } else { listController.AddListEntry(entry); } actionResult.Data = new { Managers.MemberProfileManager.GetListInfo(request.ListName, PortalSettings.PortalId).Data.Entries }; } } catch (Exception exc) { actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message); } return(actionResult); }
protected override void OnLoad() { base.OnLoad(); View.Model.Groups = RoleController.Instance.GetRoles(PortalId, r => r.Status == RoleStatus.Approved); View.Model.Relationships = RelationshipController.Instance.GetRelationshipsByPortalId(PortalId); View.Model.ProfileProperties = new List <ProfilePropertyDefinition>(); foreach (ProfilePropertyDefinition definition in ProfileController.GetPropertyDefinitionsByPortal(PortalId)) { var controller = new ListController(); ListEntryInfo textType = controller.GetListEntryInfo("DataType", "Text"); ListEntryInfo regionType = controller.GetListEntryInfo("DataType", "Region"); ListEntryInfo countryType = controller.GetListEntryInfo("DataType", "Country"); if (definition.DataType == textType.EntryID || definition.DataType == regionType.EntryID || definition.DataType == countryType.EntryID) { View.Model.ProfileProperties.Add(definition); } } }
internal static void AddDefaultDefinition(int portalId, string category, string name, string type, int length, int viewOrder, UserVisibilityMode defaultVisibility, Dictionary <string, ListEntryInfo> types) { ListEntryInfo typeInfo = types["DataType:" + type] ?? types["DataType:Unknown"]; var propertyDefinition = new ProfilePropertyDefinition(portalId) { DataType = typeInfo.EntryID, DefaultValue = "", ModuleDefId = Null.NullInteger, PropertyCategory = category, PropertyName = name, Required = false, ViewOrder = viewOrder, Visible = true, Length = length, DefaultVisibility = defaultVisibility }; AddPropertyDefinition(propertyDefinition); }
private void AddProperty(ProfilePropertyDefinition property) { var controller = new ListController(); ListEntryInfo imageType = controller.GetListEntryInfo("DataType", "Image"); if (property.DataType != imageType.EntryID) { DnnFormEditControlItem formItem = new DnnFormEditControlItem { ResourceKey = String.Format("ProfileProperties_{0}", property.PropertyName), LocalResourceFile = "~/DesktopModules/Admin/Security/App_LocalResources/Profile.ascx.resx", ControlType = EditorInfo.GetEditor(property.DataType), DataMember = "Profile", DataField = property.PropertyName, Visible = property.Visible, Required = property.Required }; userForm.Items.Add(formItem); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); try { if (!Page.IsPostBack) { ClientAPI.RegisterKeyCapture(txtSearch, cmdSearch, 13); //Load the Search Combo ddlSearchType.Items.Add(AddSearchItem("Username")); ddlSearchType.Items.Add(AddSearchItem("Email")); ddlSearchType.Items.Add(AddSearchItem("DisplayName")); var controller = new ListController(); ListEntryInfo imageDataType = controller.GetListEntryInfo("DataType", "Image"); ProfilePropertyDefinitionCollection profileProperties = ProfileController.GetPropertyDefinitionsByPortal(PortalId, false, false); foreach (ProfilePropertyDefinition definition in profileProperties) { if (imageDataType != null && definition.DataType != imageDataType.EntryID) { ddlSearchType.Items.Add(AddSearchItem(definition.PropertyName)); } } //Sent controls to current Filter if ((!String.IsNullOrEmpty(Filter) && Filter.ToUpper() != "NONE") && !String.IsNullOrEmpty(FilterProperty)) { txtSearch.Text = Filter; var findedItem = ddlSearchType.Items.FindItemByValue(FilterProperty, true); if (findedItem != null) { findedItem.Selected = true; } } } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }