/// <summary> /// Returns WHERE condition when libraries are being displayed. Sets also group identifier if specified /// </summary> private string GetDisplayedLibrariesCondition() { AvailableLibrariesEnum availableLibrariesEnum; // Get correct libraries availableLibrariesEnum = GlobalLibraries; string libraryName = GlobalLibraryName; var condition = new WhereCondition(); switch (availableLibrariesEnum) { case AvailableLibrariesEnum.OnlySingleLibrary: librarySelector.SiteID = SiteID; return(condition.WhereEquals("LibraryName", libraryName).ToString(true)); case AvailableLibrariesEnum.OnlyCurrentLibrary: int libraryId = (MediaLibraryContext.CurrentMediaLibrary != null) ? MediaLibraryContext.CurrentMediaLibrary.LibraryID : 0; return(condition.WhereEquals("LibraryID", libraryId).ToString(true)); case AvailableLibrariesEnum.None: return(condition.NoResults().ToString(true)); default: librarySelector.SiteID = SiteID; return(String.Empty); } }
/// <summary> /// Exclude main currency and currencies without exchange rate according selector settings. /// </summary> /// <param name="whereCondition">Where condition.</param> protected override string AppendExclusiveWhere(string whereCondition) { // Prepare where condition var where = new WhereCondition(whereCondition); if (DisplayOnlyWithExchangeRate) { var tableInfo = ExchangeTableInfoProvider.GetLastExchangeTableInfo(SiteID); if (tableInfo != null) { where.Where(w => w.WhereEquals("CurrencyID", MainCurrencyID) .Or() .WhereIn("CurrencyID", new IDQuery(ExchangeRateInfo.OBJECT_TYPE, "ExchangeRateToCurrencyID") .WhereEquals("ExchangeTableID", tableInfo.ExchangeTableID) .WhereTrue("CurrencyEnabled"))); } else { where.NoResults(); } } // Exclude site main currency when required if (ExcludeSiteDefaultCurrency && (MainCurrencyID > 0)) { where.WhereNotEquals("CurrencyID", MainCurrencyID); } // Restrict disabled or site not related currencies return(base.AppendExclusiveWhere(where.ToString(true))); }
/// <summary> /// Creates where condition according to values selected in filter. /// </summary> public override string GetWhereCondition() { var where = new WhereCondition(); var oper = drpLanguage.SelectedValue.ToEnum <QueryOperator>(); 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)); }
/// <summary> /// Sets WHERE condition. /// </summary> private string GetWhere() { var where = new WhereCondition(); var oper = EnumStringRepresentationExtensions.ToEnum <QueryOperator>(QueryHelper.GetString("searchlanguage", null)); var val = QueryHelper.GetString("searchculture", "##ANY##"); 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##": { query.GroupBy("NodeID").Having(string.Format("(COUNT(NodeID) {0} {1})", oper.ToStringRepresentation(), SiteCulturesCount)); 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)); }
/// <summary> /// Returns WHERE condition when libraries are being displayed. Sets also group identifier if specified /// </summary> private string GetDisplayedLibrariesCondition() { AvailableLibrariesEnum availableLibrariesEnum; string libraryName = String.Empty; // Get correct libraries if (SelectedGroupID != 0) { availableLibrariesEnum = GroupLibraries; if (groupsSelector != null) { // Get currently selected group ID int groupId = ValidationHelper.GetInteger(groupsSelector.GetValue("GroupID"), 0); if (groupId > 0) { librarySelector.GroupID = groupId; libraryName = GroupLibraryName; } } } else { availableLibrariesEnum = GlobalLibraries; libraryName = GlobalLibraryName; } var condition = new WhereCondition(); switch (availableLibrariesEnum) { case AvailableLibrariesEnum.OnlySingleLibrary: librarySelector.SiteID = SiteID; return(condition.WhereEquals("LibraryName", libraryName).ToString(true)); case AvailableLibrariesEnum.OnlyCurrentLibrary: int libraryId = (MediaLibraryContext.CurrentMediaLibrary != null) ? MediaLibraryContext.CurrentMediaLibrary.LibraryID : 0; return(condition.WhereEquals("LibraryID", libraryId).ToString(true)); case AvailableLibrariesEnum.None: return(condition.NoResults().ToString(true)); default: librarySelector.SiteID = SiteID; return(String.Empty); } }
/// <summary> /// Builds a SQL condition for filtering the variant list, and returns it. /// </summary> /// <returns>A SQL condition for filtering the variant list.</returns> private WhereCondition GetFilterWhereCondition() { var condition = new WhereCondition(); bool allChecked = AllCheckboxesChecked(); string variantNameOrNumber = txtVariantNameNumber.Text; // If there are no options/categories in filter or all options are selected and Name-or-Number search box is empty, empty condition is returned if (((optionToCheckBoxMap.Keys.Count == 0) || allChecked) && (string.IsNullOrEmpty(variantNameOrNumber))) { return(condition); } foreach (KeyValuePair <int, List <int> > pair in SelectedOptionIDs) { // Option ids for current category (pair.Key = current category id) List <int> optionIds = pair.Value; // If there are no selected options in category, whole category is ignored if (optionIds.Count > 0) { // Where condition for selected options from current category condition.WhereIn("SKUID", new IDQuery <VariantOptionInfo>("VariantSKUID").WhereIn("OptionSKUID", optionIds)); } } // Variants with SKUName or Number like text in textbox field if (!string.IsNullOrEmpty(variantNameOrNumber)) { condition.Where(w => w.WhereContains("SKUNumber", variantNameOrNumber).Or().WhereContains("SKUName", variantNameOrNumber)); } // Condition is empty -> not a single option is checked -> grid will be empty if (condition.WhereCondition == null) { condition.NoResults(); } return(condition); }
/// <summary> /// Reloads control. /// </summary> public void ReloadData() { var where = new WhereCondition(WhereCondition); var siteName = SiteID > 0 ? SiteInfoProvider.GetSiteName(SiteID) : SiteContext.CurrentSiteName; var allowGlobal = SettingsKeyInfoProvider.GetBoolValue(siteName + ".cmscmglobalconfiguration"); uniselector.AllowAll = AllowAllItem; if (DisplayAll || DisplaySiteOrGlobal) { // Display all site and global statuses if (DisplayAll && allowGlobal) { // No WHERE condition required } // Display current site and global statuses else if (DisplaySiteOrGlobal && allowGlobal && (SiteID > 0)) { where.WhereEqualsOrNull("AccountStatusSiteID", SiteID); } // Current site else if (SiteID > 0) { where.WhereEquals("AccountStatusSiteID", SiteID); } // Display global statuses else if (allowGlobal) { where.WhereNull("AccountStatusSiteID"); } // Don't display anything if (String.IsNullOrEmpty(where.WhereCondition) && !DisplayAll) { where.NoResults(); } } // Display either global or current site statuses else { // Current site if (SiteID > 0) { where.WhereEquals("AccountStatusSiteID", SiteID); } // Display global statuses else if (((SiteID == UniSelector.US_GLOBAL_RECORD) || (SiteID == UniSelector.US_NONE_RECORD)) && allowGlobal) { where.WhereNull("AccountStatusSiteID"); } // Don't display anything if (String.IsNullOrEmpty(where.WhereCondition)) { where.NoResults(); } } // Do not add condition to empty condition which allows everything if (!String.IsNullOrEmpty(where.WhereCondition)) { string status = ValidationHelper.GetString(Value, ""); if (!String.IsNullOrEmpty(status)) { where.Or().WhereEquals(uniselector.ReturnColumnName, status); } } uniselector.WhereCondition = where.ToString(expand: true); uniselector.Reload(true); }
/// <summary> /// Creates where condition according to values selected in filter. /// </summary> public override string GetWhereCondition() { var where = new WhereCondition(); var oper = drpLanguage.SelectedValue.ToEnum<QueryOperator>(); 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); }
/// <summary> /// Builds a SQL condition for filtering the variant list, and returns it. /// </summary> /// <returns>A SQL condition for filtering the variant list.</returns> private WhereCondition GetFilterWhereCondition() { var condition = new WhereCondition(); bool allChecked = AllCheckboxesChecked(); string variantNameOrNumber = txtVariantNameNumber.Text; // If there are no options/categories in filter or all options are selected and Name-or-Number search box is empty, empty condition is returned if (((optionToCheckBoxMap.Keys.Count == 0) || allChecked) && (string.IsNullOrEmpty(variantNameOrNumber))) { return condition; } foreach (KeyValuePair<int, List<int>> pair in SelectedOptionIDs) { // Option ids for current category (pair.Key = current category id) List<int> optionIds = pair.Value; // If there are no selected options in category, whole category is ignored if (optionIds.Count > 0) { // Where condition for selected options from current category condition.WhereIn("SKUID", new IDQuery<VariantOptionInfo>("VariantSKUID").WhereIn("OptionSKUID", optionIds)); } } // Variants with SKUName or Number like text in textbox field if (!string.IsNullOrEmpty(variantNameOrNumber)) { condition.Where(w => w.WhereContains("SKUNumber", variantNameOrNumber).Or().WhereContains("SKUName", variantNameOrNumber)); } // Condition is empty -> not a single option is checked -> grid will be empty if (condition.WhereCondition == null) { condition.NoResults(); } return condition; }
/// <summary> /// Exclude main currency and currencies without exchange rate according selector settings. /// </summary> /// <param name="whereCondition">Where condition.</param> protected override string AppendExclusiveWhere(string whereCondition) { // Prepare where condition var where = new WhereCondition(whereCondition); if (DisplayOnlyWithExchangeRate) { var tableInfo = ExchangeTableInfoProvider.GetLastExchangeTableInfo(SiteID); if (tableInfo != null) { where.Where(w => w.WhereEquals("CurrencyID", MainCurrencyID) .Or() .WhereIn("CurrencyID", new IDQuery(ExchangeRateInfo.OBJECT_TYPE, "ExchangeRateToCurrencyID") .WhereEquals("ExchangeTableID", tableInfo.ExchangeTableID) .WhereTrue("CurrencyEnabled"))); } else { where.NoResults(); } } // Exclude site main currency when required if (ExcludeSiteDefaultCurrency && (MainCurrencyID > 0)) { where.WhereNotEquals("CurrencyID", MainCurrencyID); } // Restrict disabled or site not related currencies return base.AppendExclusiveWhere(where.ToString(true)); }
/// <summary> /// Returns WHERE condition when libraries are being displayed. Sets also group identifier if specified /// </summary> private string GetDisplayedLibrariesCondition() { AvailableLibrariesEnum availableLibrariesEnum; string libraryName = String.Empty; // Get correct libraries if (SelectedGroupID != 0) { availableLibrariesEnum = GroupLibraries; if (groupsSelector != null) { // Get currently selected group ID int groupId = ValidationHelper.GetInteger(groupsSelector.GetValue("GroupID"), 0); if (groupId > 0) { librarySelector.GroupID = groupId; libraryName = GroupLibraryName; } } } else { availableLibrariesEnum = GlobalLibraries; libraryName = GlobalLibraryName; } var condition = new WhereCondition(); switch (availableLibrariesEnum) { case AvailableLibrariesEnum.OnlySingleLibrary: librarySelector.SiteID = SiteID; return condition.WhereEquals("LibraryName", libraryName).ToString(true); case AvailableLibrariesEnum.OnlyCurrentLibrary: int libraryId = (MediaLibraryContext.CurrentMediaLibrary != null) ? MediaLibraryContext.CurrentMediaLibrary.LibraryID : 0; return condition.WhereEquals("LibraryID", libraryId).ToString(true); case AvailableLibrariesEnum.None: return condition.NoResults().ToString(true); default: librarySelector.SiteID = SiteID; return String.Empty; } }