protected void Page_Load(object sender, EventArgs e) { if (StopProcessing) { // No actions if processing is stopped } else { //Check view permission if (!CheckViewPermissions(UIContext.EditedObject as BaseInfo)) { editElem.StopProcessing = true; editElem.Visible = false; return; } if (!CheckEditPermissions()) { editElem.Enabled = false; editElem.ShowError(GetString("ui.notauthorizemodified")); } editElem.OnAfterDefinitionUpdate += new EventHandler(editElem_OnAfterDefinitionUpdate); if (DisplayedControls != String.Empty) { editElem.DisplayedControls = EnumStringRepresentationExtensions.ToEnum <FieldEditorControlsEnum>(DisplayedControls); } if (FieldEditorMode != String.Empty) { editElem.Mode = EnumStringRepresentationExtensions.ToEnum <FieldEditorModeEnum>(FieldEditorMode); } editElem.ShowQuickLinks = ShowQuickLinks; BaseInfo bi = UIContext.EditedObject as BaseInfo; // Set the form defintion to the FieldEditor if ((bi != null) && (ParametersColumnName != String.Empty)) { // Set properties for webpart switch (editElem.Mode) { case FieldEditorModeEnum.WebPartProperties: case FieldEditorModeEnum.SystemWebPartProperties: editElem.WebPartId = bi.Generalized.ObjectID; break; } editElem.FormDefinition = ValidationHelper.GetString(bi.GetValue(ParametersColumnName), String.Empty); } ScriptHelper.HideVerticalTabs(Page); } }
/// <summary> /// Tries to export data in the given format. /// </summary> /// <param name="format">Format name</param> /// <param name="isPreview">Indicates if export is only preview (first 100 items)</param> private void TryExport(string format, bool isPreview = false) { try { ExportData(EnumStringRepresentationExtensions.ToEnum <DataExportFormatEnum>(format), isPreview ? (int?)100 : null); } catch (Exception ex) { AddAlert(ex.Message); } }
/// <summary> /// Creates where condition according to values selected in filter. /// </summary> public override string GetWhereCondition() { var where = new WhereCondition(); var oper = EnumStringRepresentationExtensions.ToEnum <QueryOperator>(drpLanguage.SelectedValue); var val = ValidationHelper.GetString(cultureElem.Value, null); if (String.IsNullOrEmpty(val)) { val = "##ANY##"; } if (val != "##ANY##") { // Create base query var tree = new TreeProvider(); var query = tree.SelectNodes() .All() .Column("NodeID"); switch (val) { case "##ALL##": { var cultureCount = SiteCultures.Tables[0].Rows.Count; query.GroupBy("NodeID").Having(string.Format("(COUNT(NodeID) {0} {1})", oper.ToStringRepresentation(), cultureCount)); where.WhereIn("NodeID", query); } break; default: { query.WhereEquals("DocumentCulture", val); if (oper == QueryOperator.NotEquals) { where.WhereNotIn("NodeID", query); } else { where.WhereIn("NodeID", query); } } break; } } else if (oper == QueryOperator.NotEquals) { where.NoResults(); } return(where.ToString(true)); }
private void GridView_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var dataRow = UniGridFunctions.GetDataRowView(e.Row); string messageType = ValidationHelper.GetString(dataRow["type"], String.Empty); if (EnumStringRepresentationExtensions.ToEnum <MessageTypeEnum>(messageType) == MessageTypeEnum.Error) { e.Row.CssClass = "error"; } } }
/// <summary> /// On external data-bound event handler. /// </summary> /// <param name="sender">Sender</param> /// <param name="sourceName">Action what is called</param> /// <param name="parameter">Parameter</param> /// <returns>Result object</returns> protected object gridValidationResult_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName.ToLower(CultureHelper.EnglishCulture)) { case "source": if (parameter is DBNull) { return(parameter); } const string LINE_BREAK_SIGN = "\u21A9"; string source = (string)parameter; var drv = UniGridFunctions.GetDataRowView(sender as DataControlFieldCell); int highlightStartIndex = Convert.ToInt32(drv["highlightStart"]); int highlightLength = Convert.ToInt32(drv["highlightLength"]); var messageType = EnumStringRepresentationExtensions.ToEnum <MessageTypeEnum>(Convert.ToString(drv["type"])); // Get parts to be able to highlight code in the code extract IEnumerable <string> parts = new List <string>(new[] { source.Substring(0, highlightStartIndex), source.Substring(highlightStartIndex, highlightLength), source.Substring(highlightStartIndex + highlightLength) }); // HTML encode each part parts = parts.Select(HttpUtility.HtmlEncode).ToList(); // Update the second (~ highlighted) part var partList = parts as List <string>; partList[1] = $"<strong class=\"{messageType.ToStringRepresentation()}\">{partList[1]}</strong>"; source = String.Concat(parts); source = source.Replace("\n", LINE_BREAK_SIGN); return($@"<div class=""Source"">{source}</div>"); case "message": return(HttpUtility.HtmlEncode(parameter)); case "type": var typeEnum = EnumStringRepresentationExtensions.ToEnum <MessageTypeEnum>((string)parameter); return(typeEnum.ToLocalizedString("validation.html.messagetype")); } return(parameter); }
/// <summary> /// Gets where condition. /// </summary> public override string GetWhereCondition() { EnsureChildControls(); var value = ValidationHelper.GetString(Value, String.Empty); string op = drpOperator.SelectedValue; bool isTimeSpan = false; // No condition if (String.IsNullOrWhiteSpace(value) || String.IsNullOrEmpty(op) || !(ValidationHelper.IsDouble(value) || (isTimeSpan = ValidationHelper.IsTimeSpan(value)))) { return(null); } // Convert value to default culture format value = DataHelper.ConvertValueToDefaultCulture(value, !isTimeSpan ? typeof(double) : typeof(TimeSpan)); if (String.IsNullOrEmpty(WhereConditionFormat)) { // Get default where condition object typedValue; if (isTimeSpan) { typedValue = ValidationHelper.GetTimeSpanSystem(value, TimeSpan.MinValue); } else { typedValue = ValidationHelper.GetDoubleSystem(value, Double.NaN); } return(new WhereCondition(FieldInfo.Name, EnumStringRepresentationExtensions.ToEnum <QueryOperator>(op), typedValue).ToString(true)); } try { // Return custom where condition return(String.Format(WhereConditionFormat, FieldInfo.Name, value, op)); } catch (Exception ex) { // Log exception Service.Resolve <IEventLogService>().LogException("NumberFilter", "GetWhereCondition", ex); } return(null); }
/// <summary> /// Handles the OnAfterValidate event of the Control control. /// </summary> void Control_OnAfterValidate(object sender, EventArgs e) { PageTemplateInfo pti = Control.EditedObject as PageTemplateInfo; if (pti == null) { return; } String result = String.Empty; PageTemplateTypeEnum type = EnumStringRepresentationExtensions.ToEnum <PageTemplateTypeEnum>((Control.GetFieldValue("PageTemplateType") as String)); // Check dashboard prerequisites if ((pti.PageTemplateId > 0) && (type == PageTemplateTypeEnum.Dashboard)) { // Check valid zones PageTemplateInstance inst = pti.TemplateInstance; if (inst != null) { foreach (WebPartZoneInstance zone in inst.WebPartZones) { switch (zone.WidgetZoneType) { case WidgetZoneTypeEnum.Dashboard: case WidgetZoneTypeEnum.None: continue; } result = ResHelper.GetString("template.dashboardinvalidzone"); break; } } } if (result != String.Empty) { Control.StopProcessing = true; CMSPage pg = Control.Page as CMSPage; if (pg != null) { pg.ShowError(result); Control.StopProcessing = true; } } }
/// <summary> /// External data binding handler. /// </summary> private object Control_OnExternalDataBound(object sender, string sourcename, object parameter) { switch (sourcename.ToLowerCSafe()) { case "editionname": string edition = ValidationHelper.GetString(parameter, "").ToUpperCSafe(); try { return(LicenseHelper.GetEditionName(EnumStringRepresentationExtensions.ToEnum <ProductEditionEnum>(edition))); } catch { return("#UNKNOWN#"); } case "expiration": var row = (DataRowView)parameter; LicenseKeyInfo licenseInfo = new LicenseKeyInfo(); licenseInfo.LoadLicense(ValidationHelper.GetString(row["LicenseKey"], string.Empty), ValidationHelper.GetString(row["LicenseDomain"], string.Empty)); if (licenseInfo.LicenseGuid == null) { return(ResHelper.GetString(Convert.ToString(row["LicenseExpiration"]))); } else { // subtract grace period for subscription license return(licenseInfo.ExpirationDateReal.AddDays(-SUBSCRIPTION_LICENSE_EXPIRATION_GRACE_DAYS).ToString(LicenseKeyInfo.LICENSE_EXPIRATION_DATE_FORMAT, CultureInfo.InvariantCulture)); } case "licenseservers": int count = ValidationHelper.GetInteger(parameter, -1); if (count == LicenseKeyInfo.SERVERS_UNLIMITED) { return(ResHelper.GetString("general.unlimited")); } if (count > 0) { return(count.ToString()); } return(String.Empty); } return(parameter); }
protected object OptionCategoryGrid_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName.ToLowerCSafe()) { // Convert selection type to text case "categoryselectiontype": switch (ValidationHelper.GetString(parameter, "").ToLowerCSafe()) { case "dropdown": return(GetString("OptionCategory_List.DropDownList")); case "checkboxhorizontal": return(GetString("OptionCategory_List.checkboxhorizontal")); case "checkboxvertical": return(GetString("OptionCategory_List.checkboxvertical")); case "radiobuttonhorizontal": return(GetString("OptionCategory_List.radiobuttonhorizontal")); case "radiobuttonvertical": return(GetString("OptionCategory_List.radiobuttonvertical")); case "textbox": return(GetString("optioncategory_selectiontype.textbox")); case "textarea": return(GetString("optioncategory_selectiontype.textarea")); } break; case "categorytype": return(EnumStringRepresentationExtensions.ToEnum <OptionCategoryTypeEnum>(ValidationHelper.GetString(parameter, "")).ToLocalizedString("com.optioncategorytype")); case "categorydisplayname": OptionCategoryInfo category = new OptionCategoryInfo(((DataRowView)parameter).Row); return(HTMLHelper.HTMLEncode(category.CategoryFullName)); } return(parameter); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (Form != null) { // Option category type currently selected in the form OptionCategoryType = EnumStringRepresentationExtensions.ToEnum <OptionCategoryTypeEnum>(ValidationHelper.GetString(Form.FieldControls[OptionCategoryTypeColumn].Value, "")); if (OptionCategoryType != OriginalOptionCategoryType) { // Delete all options and fill drop down list according to the current category type drpSelectionTypeEnum.Items.Clear(); ConfigureSelectionTypeControl(); // Remember category type OriginalOptionCategoryType = OptionCategoryType; } } }
/// <summary> /// Page_Load event handler /// </summary> protected void Page_Load(object sender, EventArgs e) { // Hide the control if it shouldn't be processed or required document type data are not available if (StopProcessing || (DocumentType == null)) { pnlIcons.Visible = false; lblControlHidden.Visible = true; return; } lstOptions.SelectedIndexChanged += lstOptions_SelectedIndexChanged; if (Form != null) { InitializeControl(); iconType = EnumStringRepresentationExtensions.ToEnum <IconTypeEnum>(lstOptions.SelectedValue); } CheckFieldEmptiness = false; }
/// <summary> /// Reads option category configuration fields. /// </summary> private void GetSelectorConfiguration() { if (Form != null) { // Display price adjustment if (Form.FieldControls.Contains(OptionCategoryDisplayPriceColumn)) { DisplayPrice = ValidationHelper.GetBoolean(Form.FieldControls[OptionCategoryDisplayPriceColumn].Value, false); } // Default record text if (Form.FieldControls.Contains(OptionCategoryDefaultRecordColumn)) { AdditionalOptionText = ValidationHelper.GetString(Form.FieldControls[OptionCategoryDefaultRecordColumn].Value, "").Trim(); } // Selection type if (Form.FieldControls.Contains(OptionCategorySelectionTypeColumn)) { SelectionType = EnumStringRepresentationExtensions.ToEnum <OptionCategorySelectionTypeEnum>(ValidationHelper.GetString(Form.FieldControls[OptionCategorySelectionTypeColumn].Value, "")); } } }
private KeyValuePair <TileAction, int> ParseEventArguments(string eventArgument) { var args = eventArgument.Split(new[] { SEPARATOR }, StringSplitOptions.RemoveEmptyEntries); return(new KeyValuePair <TileAction, int>(EnumStringRepresentationExtensions.ToEnum <TileAction>(args[0]), ValidationHelper.GetInteger(args[1], CREATE_FROM_SCRATCH_ID))); }
/// <summary> /// Perform search. /// </summary> protected void Search() { if (StopProcessing) { // Do nothing } else { // Check if the search was triggered bool searchAllowed = SearchOnEachPageLoad || QueryHelper.Contains("searchtext"); // Get query strings string searchText = QueryHelper.GetString("searchtext", ""); // Check whether string passes text requirements settings bool searchTextIsNotEmptyOrNotRequired = (!SearchTextRequired || !String.IsNullOrEmpty(searchText)); // Proceed when search was triggered and search text is passing requirements settings. // Requirements setting could be overridden on this level by obsolete web.config key. The reason is backward compatibility. // Search text required web part setting was introduced after this web.config key. Key default value was at the time set to true. // This default value had the same effect as this new web part setting. When someone changed the web.config key to false and then upgraded the solution, // required web part setting with default value true would override previous behavior. That's the reason why this obsolete key can override this setting. if (searchAllowed && (searchTextIsNotEmptyOrNotRequired || !SearchHelper.SearchOnlyWhenContentPresent)) { string searchMode = QueryHelper.GetString("searchMode", ""); SearchModeEnum searchModeEnum = EnumStringRepresentationExtensions.ToEnum <SearchModeEnum>(searchMode); // Get current culture string culture = CultureCode; if (string.IsNullOrEmpty(culture)) { culture = ValidationHelper.GetString(ViewState["CultureCode"], LocalizationContext.PreferredCultureCode); } var siteName = SiteContext.CurrentSiteName; // Get default culture string defaultCulture = CultureHelper.GetDefaultCultureCode(siteName); // Resolve path string path = Path; if (!string.IsNullOrEmpty(path)) { path = MacroResolver.ResolveCurrentPath(Path); } // Prepare search text var docCondition = new DocumentSearchCondition(DocumentTypes, culture, defaultCulture, CombineWithDefaultCulture); var searchCond = SearchCondition; if (!string.IsNullOrEmpty(FilterSearchCondition) && (searchModeEnum == SearchModeEnum.AnyWordOrSynonyms)) { // Make sure the synonyms are expanded before the filter condition is applied (filter condition is Lucene syntax, cannot be expanded) searchCond = SearchSyntaxHelper.ExpandWithSynonyms(searchCond, docCondition.Culture); } var condition = new SearchCondition(searchCond + FilterSearchCondition, searchModeEnum, SearchOptions, docCondition, DoFuzzySearch); searchText = SearchSyntaxHelper.CombineSearchCondition(searchText, condition); // Get positions and ranges for search method int startPosition = 0; int numberOfProceeded = 100; int displayResults = 100; if (pgr.PageSize != 0 && pgr.GroupSize != 0) { // Reset pager if needed if (mResetPager) { pgr.CurrentPage = 1; } startPosition = (pgr.CurrentPage - 1) * pgr.PageSize; // Only results covered by current page group are proccessed (filtered) for performance reasons. This may cause decrease of the number of results while paging. numberOfProceeded = (((pgr.CurrentPage / pgr.GroupSize) + 1) * pgr.PageSize * pgr.GroupSize) + pgr.PageSize; displayResults = pgr.PageSize; } if ((MaxResults > 0) && (numberOfProceeded > MaxResults)) { numberOfProceeded = MaxResults; } // Combine regular search sort with filter sort string srt = ValidationHelper.GetString(SearchSort, String.Empty).Trim(); string filterSrt = ValidationHelper.GetString(FilterSearchSort, String.Empty).Trim(); if (!String.IsNullOrEmpty(filterSrt)) { if (!String.IsNullOrEmpty(srt)) { srt += ", "; } srt += filterSrt; } // Prepare parameters SearchParameters parameters = new SearchParameters { SearchFor = searchText, SearchSort = srt, Path = path, ClassNames = DocumentTypes, CurrentCulture = culture, DefaultCulture = defaultCulture, CombineWithDefaultCulture = CombineWithDefaultCulture, CheckPermissions = CheckPermissions, SearchInAttachments = SearchInAttachments, User = MembershipContext.AuthenticatedUser, SearchIndexes = Indexes, StartingPosition = startPosition, DisplayResults = displayResults, NumberOfProcessedResults = numberOfProceeded, NumberOfResults = 0, AttachmentWhere = AttachmentsWhere, AttachmentOrderBy = AttachmentsOrderBy, BlockFieldOnlySearch = BlockFieldOnlySearch, }; // Search var results = SearchHelper.Search(parameters); int numberOfResults = parameters.NumberOfResults; if ((MaxResults > 0) && (numberOfResults > MaxResults)) { numberOfResults = MaxResults; } // Limit displayed results according to MaxPages property var maxDisplayedResultsOnMaxPages = MaxPages * PageSize; // Apply only if MaxPages and PageSize properties are set if ((maxDisplayedResultsOnMaxPages > 0) && (numberOfResults > maxDisplayedResultsOnMaxPages)) { numberOfResults = maxDisplayedResultsOnMaxPages; } // Fill repeater with results repSearchResults.DataSource = results.Items; repSearchResults.PagerForceNumberOfResults = numberOfResults; PagerForceNumberOfResults = numberOfResults; repSearchResults.DataBind(); // Call page binding event if (OnPageBinding != null) { OnPageBinding(this, null); } // Show no results found ? if (numberOfResults == 0) { if (ShowParsingErrors) { Exception searchError = results.LastError; if (searchError != null) { ShowError(GetString("smartsearch.searcherror") + " " + HTMLHelper.HTMLEncode(searchError.Message)); } } lblNoResults.Text = NoResultsText; lblNoResults.Visible = true; } } else { if (!String.IsNullOrEmpty(SearchTextValidationFailedText) && searchAllowed) { pnlSearchResults.AddCssClass(SearchTextValidationFailedCssClass); lblNoResults.Text = SearchTextValidationFailedText; lblNoResults.Visible = true; } else { Visible = false; } } // Invoke search completed event if (OnSearchCompleted != null) { OnSearchCompleted(Visible); } } }
protected void Page_Load(object sender, EventArgs e) { if (StopProcessing) { return; } string localizationCulture = PortalHelper.GetUILocalizationCulture(); uniMenu.ResourceCulture = localizationCulture; // Handle the pre-selection mPreselectedItem = QueryHelper.GetString(QueryParameterName, ""); if (mPreselectedItem.StartsWith("cms.", StringComparison.OrdinalIgnoreCase)) { mPreselectedItem = mPreselectedItem.Substring(4); } uniMenu.HighlightItem = mPreselectedItem; // If element name is not set, use root module element string elemName = ElementName; if (String.IsNullOrEmpty(elemName)) { elemName = ModuleName.Replace(".", ""); } // Get the UI elements DataSet ds = UIElementInfoProvider.GetChildUIElements(ModuleName, elemName); if (!DataHelper.DataSourceIsEmpty(ds)) { FilterElements(ds); // Prepare the list of elements foreach (DataRow dr in ds.Tables[0].Rows) { string url = ValidationHelper.GetString(dr["ElementTargetURL"], ""); UIElementTypeEnum type = EnumStringRepresentationExtensions.ToEnum <UIElementTypeEnum>(ValidationHelper.GetString(dr["ElementType"], "")); Group group = new Group(); if (url.EndsWith("ascx", StringComparison.OrdinalIgnoreCase) && (type == UIElementTypeEnum.UserControl)) { group.ControlPath = url; } else { group.UIElementID = ValidationHelper.GetInteger(dr["ElementID"], 0); } group.CssClass = "ContentMenuGroup"; if (GenerateElementCssClass) { string name = ValidationHelper.GetString(dr["ElementName"], String.Empty).Replace(".", String.Empty); group.CssClass += " ContentMenuGroup" + name; group.SeparatorCssClass = "UniMenuSeparator" + name; } group.Caption = ResHelper.LocalizeString(ValidationHelper.GetString(dr["ElementCaption"], ""), localizationCulture); if (group.Caption == String.Empty) { group.Caption = ResHelper.LocalizeString(ValidationHelper.GetString(dr["ElementDisplayName"], ""), localizationCulture); } uniMenu.Groups.Add(group); } // Raise groups created event RaiseOnGroupsCreated(this, uniMenu.Groups); // Button created & filtered event handler uniMenu.OnButtonCreating += uniMenu_OnButtonCreating; uniMenu.OnButtonCreated += uniMenu_OnButtonCreated; uniMenu.OnButtonFiltered += uniMenu_OnButtonFiltered; } // Add editing icon in development mode if (SystemContext.DevelopmentMode && MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) && !DisableEditIcon) { var link = PortalUIHelper.GetResourceUIElementLink(ModuleName, ElementName); if (!String.IsNullOrEmpty(link)) { ltlAfter.Text += $"<div class=\"UIElementsLink\" >{link}</div>"; } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Get current index id int indexId = QueryHelper.GetInteger("indexId", 0); // Get current index info object SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(indexId); if (sii?.IndexProvider.Equals(SearchIndexInfo.AZURE_SEARCH_PROVIDER, StringComparison.OrdinalIgnoreCase) ?? false) { ShowInformation(GetString("smartsearch.searchpreview.azure.unavailable")); searchPnl.Visible = false; return; } // Show information about limited features of smart search preview ShowInformation(GetString("smartsearch.searchpreview.limitedfeatures")); // Show warning if indes isn't ready yet if ((sii != null) && (SearchIndexInfoProvider.GetIndexStatus(sii) == IndexStatusEnum.NEW)) { ShowWarning(GetString("srch.index.needrebuild")); } if (!RequestHelper.IsPostBack()) { // Get current search text from query string string searchText = QueryHelper.GetString("searchtext", ""); // Check whether search text is defined if (!string.IsNullOrEmpty(searchText)) { // Get current search mode from query string string searchMode = QueryHelper.GetString("searchmode", ""); SearchModeEnum searchModeEnum = EnumStringRepresentationExtensions.ToEnum <SearchModeEnum>(searchMode); // Check whether index info exists if (sii != null) { // Keep search text in search textbox //txtSearchFor.Text = searchText; var condition = new SearchCondition(null, searchModeEnum, SearchOptionsEnum.FullSearch); searchText = SearchSyntaxHelper.CombineSearchCondition(searchText, condition); // Get positions and ranges for search method int startPosition = 0; int numberOfProceeded = 100; int displayResults = 100; if (pgrSearch.CurrentPageSize != 0 && pgrSearch.GroupSize != 0) { startPosition = (pgrSearch.CurrentPage - 1) * pgrSearch.CurrentPageSize; numberOfProceeded = (((pgrSearch.CurrentPage / pgrSearch.GroupSize) + 1) * pgrSearch.CurrentPageSize * pgrSearch.GroupSize) + pgrSearch.CurrentPageSize; displayResults = pgrSearch.CurrentPageSize; } // Prepare parameters SearchParameters parameters = new SearchParameters() { SearchFor = searchText, SearchSort = null, Path = null, ClassNames = null, CurrentCulture = "##ALL##", DefaultCulture = null, CombineWithDefaultCulture = false, CheckPermissions = false, SearchInAttachments = false, User = MembershipContext.AuthenticatedUser, SearchIndexes = sii.IndexName, StartingPosition = startPosition, DisplayResults = displayResults, NumberOfProcessedResults = numberOfProceeded, NumberOfResults = 0, AttachmentWhere = null, AttachmentOrderBy = null, }; // Search var results = SearchHelper.Search(parameters); // Fill repeater with results repSearchResults.DataSource = results.Items; repSearchResults.PagerForceNumberOfResults = parameters.NumberOfResults; repSearchResults.DataBind(); // Show now results found ? if (parameters.NumberOfResults == 0) { lblNoResults.Text = "<br />" + GetString("srch.results.noresults.preview"); lblNoResults.Visible = true; Exception searchError = results.LastError; if (searchError != null) { pnlError.Visible = true; lblError.Text = GetString("smartsearch.searcherror") + " " + searchError.Message; } } } } // Fill CMSDropDownList option with values ControlsHelper.FillListControlWithEnum <SearchModeEnum>(drpSearchMode, "srch.dialog", useStringRepresentation: true); drpSearchMode.SelectedValue = QueryHelper.GetString("searchmode", EnumHelper.GetDefaultValue <SearchModeEnum>().ToStringRepresentation()); // Set up search text txtSearchFor.Text = QueryHelper.GetString("searchtext", ""); } }
/// <summary> /// Handles the SelectedIndexChanged event of the lstOptions control. /// </summary> private void lstOptions_SelectedIndexChanged(object sender, EventArgs e) { iconType = EnumStringRepresentationExtensions.ToEnum <IconTypeEnum>(lstOptions.SelectedValue); }
object categoryGrid_OnExternalDataBound(object sender, string sourceName, object parameter) { OptionCategoryInfo category; // Formatting columns switch (sourceName.ToLowerCSafe()) { case "categorydisplayname": category = OptionCategoryInfo.Provider.Get(ValidationHelper.GetInteger(parameter, 0)); return(HTMLHelper.HTMLEncode(category.CategoryFullName)); case "categorytype": return(EnumStringRepresentationExtensions.ToEnum <OptionCategoryTypeEnum>(ValidationHelper.GetString(parameter, "")).ToLocalizedString("com.optioncategorytype")); case "optionscounts": category = OptionCategoryInfo.Provider.Get(ValidationHelper.GetInteger(parameter, 0)); if (category.CategoryType != OptionCategoryTypeEnum.Text) { var tr = new ObjectTransformation("OptionsCounts", category.CategoryID) { DataProvider = countsDataProvider, Transformation = "{% if(AllowAllOptions) { GetResourceString(\"general.all\") } else { FormatString(GetResourceString(\"com.ProductOptions.availableXOfY\"), SelectedOptions, AllOptions) } %}", NoDataTransformation = "{$com.productoptions.nooptions$}", EncodeOutput = false }; return(tr); } return(""); case "edititem": category = new OptionCategoryInfo(((DataRowView)((GridViewRow)parameter).DataItem).Row); CMSGridActionButton btn = sender as CMSGridActionButton; // Disable edit button if category is global and global categories are NOT allowed if (btn != null) { if (!allowedGlobalCat && category.IsGlobal) { btn.Enabled = false; } var query = QueryHelper.BuildQuery("siteId", category.CategorySiteID.ToString(), "productId", ProductID.ToString()); string redirectUrl = ApplicationUrlHelper.GetElementDialogUrl(ModuleName.ECOMMERCE, "EditProductOptionCategory", category.CategoryID, query); btn.OnClientClick = "modalDialog('" + redirectUrl + "','categoryEdit', '1000', '800');"; } break; case "selectoptions": category = new OptionCategoryInfo(((DataRowView)((GridViewRow)parameter).DataItem).Row); CMSGridActionButton btnSelect = sender as CMSGridActionButton; if (btnSelect != null) { // Disable select button if category is type of Text if (category.CategoryType == OptionCategoryTypeEnum.Text) { btnSelect.Enabled = false; } else { var query = QueryHelper.BuildQuery("productId", ProductID.ToString()); // URL of allowed option selector pop-up string urlSelect = ApplicationUrlHelper.GetElementDialogUrl(ModuleName.ECOMMERCE, "ProductOptions.SelectOptions", category.CategoryID, query); // Open allowed options selection dialog btnSelect.OnClientClick = ScriptHelper.GetModalDialogScript(urlSelect, "selectoptions", 1000, 650); } } break; } return(parameter); }
/// <summary> /// Returns where condition based on webpart fields. /// </summary> private WhereCondition GetWhereCondition() { var where = new WhereCondition().WhereEquals("SKUSiteID", SiteContext.CurrentSiteID); // Show products only from current site or global too, based on setting if (ECommerceSettings.AllowGlobalProducts(SiteContext.CurrentSiteName)) { where.Where(w => w.WhereEquals("SKUSiteID", SiteContext.CurrentSiteID).Or().WhereNull("SKUSiteID")); } // Show/hide product variants - it is based on type of inventory tracking for parent product string trackByVariants = TrackInventoryTypeEnum.ByVariants.ToStringRepresentation(); where.Where(v => v.Where(w => w.WhereNull("SKUParentSKUID").And().WhereNotEquals("SKUTrackInventory", trackByVariants)) .Or() .Where(GetParentProductWhereCondition(new WhereCondition().WhereEquals("SKUTrackInventory", trackByVariants)))); // Product type filter if (!string.IsNullOrEmpty(ProductType) && (ProductType != FILTER_ALL)) { if (ProductType == PRODUCT_TYPE_PRODUCTS) { where.WhereNull("SKUOptionCategoryID"); } else if (ProductType == PRODUCT_TYPE_PRODUCT_OPTIONS) { where.WhereNotNull("SKUOptionCategoryID"); } } // Representing filter if (!string.IsNullOrEmpty(Representing) && (Representing != FILTER_ALL)) { SKUProductTypeEnum productTypeEnum = EnumStringRepresentationExtensions.ToEnum <SKUProductTypeEnum>(Representing); string productTypeString = productTypeEnum.ToStringRepresentation(); where.WhereEquals("SKUProductType", productTypeString); } // Product number filter if (!string.IsNullOrEmpty(ProductNumber)) { where.WhereContains("SKUNumber", ProductNumber); } // Department filter DepartmentInfo di = DepartmentInfo.Provider.Get(Department, SiteInfoProvider.GetSiteID(CurrentSiteName)); di = di ?? DepartmentInfo.Provider.Get(Department, 0); if (di != null) { where.Where(GetColumnWhereCondition("SKUDepartmentID", new WhereCondition().WhereEquals("SKUDepartmentID", di.DepartmentID))); } // Manufacturer filter ManufacturerInfo mi = ManufacturerInfo.Provider.Get(Manufacturer, SiteInfoProvider.GetSiteID(CurrentSiteName)); mi = mi ?? ManufacturerInfo.Provider.Get(Manufacturer, 0); if (mi != null) { where.Where(GetColumnWhereCondition("SKUManufacturerID", new WhereCondition().WhereEquals("SKUManufacturerID", mi.ManufacturerID))); } // Brand filter BrandInfo bi = BrandInfoProvider.ProviderObject.Get(Brand, SiteInfoProvider.GetSiteID(CurrentSiteName)); if (bi != null) { where.Where(GetColumnWhereCondition("SKUBrandID", new WhereCondition().WhereEquals("SKUBrandID", bi.BrandID))); } // Collection filter CollectionInfo ci = CollectionInfo.Provider.Get(Collection, SiteInfoProvider.GetSiteID(CurrentSiteName)); if (ci != null) { where.Where(GetColumnWhereCondition("SKUCollectionID", new WhereCondition().WhereEquals("SKUCollectionID", ci.CollectionID))); } // Tax class filter TaxClassInfo tci = TaxClassInfo.Provider.Get(TaxClass, SiteInfoProvider.GetSiteID(CurrentSiteName)); if (tci != null) { where.Where(GetColumnWhereCondition("SKUTaxClassID", new WhereCondition().WhereEquals("SKUTaxClassID", tci.TaxClassID))); } // Supplier filter SupplierInfo si = SupplierInfoProvider.GetSupplierInfo(Supplier, CurrentSiteName); si = si ?? SupplierInfoProvider.GetSupplierInfo(Supplier, null); if (si != null) { where.Where(GetColumnWhereCondition("SKUSupplierID", new WhereCondition().WhereEquals("SKUSupplierID", si.SupplierID))); } // Needs shipping filter if (!string.IsNullOrEmpty(NeedsShipping) && (NeedsShipping != FILTER_ALL)) { if (NeedsShipping == NEEDS_SHIPPING_YES) { where.Where(GetColumnWhereCondition("SKUNeedsShipping", new WhereCondition().WhereTrue("SKUNeedsShipping"))); } else if (NeedsShipping == NEEDS_SHIPPING_NO) { where.Where(GetColumnWhereCondition("SKUNeedsShipping", new WhereCondition().WhereFalse("SKUNeedsShipping").Or().WhereNull("SKUNeedsShipping"))); } } // Price from filter if (PriceFrom > 0) { where.WhereGreaterOrEquals("SKUPrice", PriceFrom); } // Price to filter if (PriceTo > 0) { where.WhereLessOrEquals("SKUPrice", PriceTo); } // Public status filter PublicStatusInfo psi = PublicStatusInfo.Provider.Get(PublicStatus, SiteInfoProvider.GetSiteID(CurrentSiteName)); if (psi != null) { where.Where(GetColumnWhereCondition("SKUPublicStatusID", new WhereCondition().WhereEquals("SKUPublicStatusID", psi.PublicStatusID))); } // Internal status filter InternalStatusInfo isi = InternalStatusInfo.Provider.Get(InternalStatus, SiteInfoProvider.GetSiteID(CurrentSiteName)); if (isi != null) { where.Where(GetColumnWhereCondition("SKUInternalStatusID", new WhereCondition().WhereEquals("SKUInternalStatusID", isi.InternalStatusID))); } // Allow for sale filter if (!string.IsNullOrEmpty(AllowForSale) && (AllowForSale != FILTER_ALL)) { if (AllowForSale == ALLOW_FOR_SALE_YES) { where.WhereTrue("SKUEnabled"); } else if (AllowForSale == ALLOW_FOR_SALE_NO) { where.WhereEqualsOrNull("SKUEnabled", false); } } // Available items filter if (!string.IsNullOrEmpty(AvailableItems)) { int value = ValidationHelper.GetInteger(AvailableItems, int.MaxValue); where.WhereLessOrEquals("SKUAvailableItems", value); } // Needs to be reordered filter if (NeedsToBeReordered) { where.Where(w => w.Where(v => v.WhereNull("SKUReorderAt").And().WhereLessOrEquals("SKUAvailableItems", 0)) .Or() .Where(z => z.WhereNotNull("SKUReorderAt").And().WhereLessOrEquals("SKUAvailableItems".AsColumn(), "SKUReorderAt".AsColumn()))); } return(where); }