/// <summary> /// Generates complete filter where condition. /// </summary> private string GenerateWhereCondition() { var whereCondition = new WhereCondition(); // Create WHERE condition for basic filter int contactStatus = ValidationHelper.GetInteger(fltAccountStatus.Value, -1); if (fltAccountStatus.Value == null) { whereCondition = whereCondition.WhereNull("AccountStatusID"); } else if (contactStatus > 0) { whereCondition = whereCondition.WhereEquals("AccountStatusID", contactStatus); } whereCondition = whereCondition .Where(fltName.GetCondition()) .Where(fltEmail.GetCondition()) .Where(fltContactName.GetCondition()); if (IsAdvancedMode) { whereCondition = whereCondition .Where(fltCity.GetCondition()) .Where(fltPhone.GetCondition()) .Where(fltCreated.GetCondition()) .Where(GetOwnerCondition(fltOwner)) .Where(GetCountryCondition(fltCountry)) .Where(GetStateCondition(fltState)); } return(whereCondition.ToString(true)); }
/// <summary> /// Creates where condition for SKUs listing. /// </summary> private WhereCondition GetWhereCondition() { // Display ONLY products - not product options var where = new WhereCondition().WhereNull("SKUOptionCategoryID"); // Select only products without documents if ((NodeID <= 0) && DisplayTreeInProducts) { where.WhereNotIn("SKUID", SKUInfoProvider.GetSKUs().Column("SKUID").From("View_CMS_Tree_Joined").WhereNotNull("NodeSKUID").And().WhereEquals("NodeSiteID", SiteContext.CurrentSiteID)); } // Ordinary user can see only product from departments he can access var cui = MembershipContext.AuthenticatedUser; if (!cui.IsGlobalAdministrator && !cui.IsAuthorizedPerResource("CMS.Ecommerce", "AccessAllDepartments")) { where.Where(w => w.WhereNull("SKUDepartmentID").Or().WhereIn("SKUDepartmentID", new IDQuery <UserDepartmentInfo>("DepartmentID").WhereEquals("UserID", cui.UserID))); } // Reflect "Allow global products" setting var siteWhere = new WhereCondition().WhereEquals("SKUSiteID", SiteContext.CurrentSiteID); if (AllowGlobalObjects) { siteWhere.Or().WhereNull("SKUSiteID"); } return(where.Where(siteWhere)); }
/// <summary> /// Get where condition for unigrid /// </summary> /// <returns>Where condition</returns> private WhereCondition GetWhereCondition() { string productNameFilter = txtProductName.Text; string productCodeFilter = txtProductCode.Text; // To display ONLY product - not product options var where = new WhereCondition().WhereTrue("SKUEnabled").And().WhereNull("SKUOptionCategoryID"); if (!string.IsNullOrEmpty(productNameFilter)) { // Condition to get also products with variants that contains where.Where(w => w.WhereContains("SKUName", productNameFilter) .Or() .WhereIn("SKUID", new IDQuery <SKUInfo>("SKUParentSKUID").WhereContains("SKUName", productNameFilter))); } if (productCodeFilter != "") { // Condition to get also products with variants that contains where.Where(w => w.WhereContains("SKUNumber", productCodeFilter).Or().WhereIn("SKUID", new IDQuery <SKUInfo>("SKUParentSKUID").WhereContains("SKUNumber", productCodeFilter))); } if (departmentElem.SelectedID > 0) { where.WhereEquals("SKUDepartmentID", departmentElem.SelectedID); } where.Where(SKUInfoProvider.ProviderObject.AddSiteWhereCondition(string.Empty, SiteContext.CurrentSiteID, ECommerceSettings.ALLOW_GLOBAL_PRODUCTS, true)); return(where); }
/// <summary> /// Creates where condition for SKUs listing. /// </summary> private WhereCondition GetWhereCondition() { // Display ONLY products - not product options var where = new WhereCondition().WhereNull("SKUOptionCategoryID"); // Select only products without documents if ((NodeID <= 0) && DisplayTreeInProducts) { where.WhereNotIn("SKUID", SKUInfoProvider.GetSKUs() .Column("NodeSKUID") .From(SystemViewNames.View_CMS_Tree_Joined) .WhereNotNull("NodeSKUID").And().WhereEquals("NodeSiteID", SiteContext.CurrentSiteID)); } // Ordinary user can see only product from departments he can access var cui = MembershipContext.AuthenticatedUser; if (!cui.IsGlobalAdministrator && !cui.IsAuthorizedPerResource(ModuleName.ECOMMERCE, EcommercePermissions.PRODUCTS_ACCESSALLDEPARTMENTS)) { where.Where(w => w.WhereNull("SKUDepartmentID").Or().WhereIn("SKUDepartmentID", new IDQuery <UserDepartmentInfo>("DepartmentID").WhereEquals("UserID", cui.UserID))); } // Reflect "Allow global products" setting var siteWhere = InitSiteWhereCondition("SKUSiteID"); return(where.Where(siteWhere)); }
/// <summary> /// Get where condition for unigrid /// </summary> /// <returns>Where condition</returns> private WhereCondition GetWhereCondition() { string productNameFilter = txtProductName.Text; // To display ONLY product - not product options var where = new WhereCondition().WhereTrue("SKUEnabled").And().WhereNull("SKUOptionCategoryID"); if (!string.IsNullOrEmpty(productNameFilter)) { // Alias for COM_SKU var variants = new QuerySourceTable("COM_SKU", "variants"); // Get IDs of products containing filter text; search among variants too var ids = new IDQuery <SKUInfo>() .Columns(new QueryColumn("COM_SKU.SKUID")) .Source(s => s.LeftJoin(variants, "COM_SKU.SKUID", "variants.SKUParentSKUID", new WhereCondition() .WhereContains("variants.SKUName", productNameFilter) .Or() .WhereContains("variants.SKUNumber", productNameFilter))) .Where( new WhereCondition() .WhereContains("COM_SKU.SKUName", productNameFilter) .Or() .WhereContains("COM_SKU.SKUNumber", productNameFilter)); // Add the condition where.Where(w => w.WhereIn("SKUID", ids)); } where.Where(GetSiteWhereCondition(SiteContext.CurrentSiteID)); return(where); }
private string CreateWhereCondition(string originalWhere) { var where = new WhereCondition(); where.Where(new WhereCondition(originalWhere) { WhereIsComplex = true }); // Add where conditions from filters where.Where(new WhereCondition(nameFilter.WhereCondition) { WhereIsComplex = true }); string objType = ValidationHelper.GetString(objTypeSelector.Value, ""); if (!String.IsNullOrEmpty(objType)) { #pragma warning disable BH2000 // Method 'WhereLike()' or 'WhereNotLike()' should not be used used. where.WhereLike("VersionObjectType", objType); #pragma warning restore BH2000 // Method 'WhereLike()' or 'WhereNotLike()' should not be used used. } int userId = ValidationHelper.GetInteger(userSelector.Value, 0); if (userId > 0) { where.WhereEquals("VersionDeletedByUserID", userId); } // Get older than value if (DisplayDateTimeFilter) { DateTime olderThan = DateTime.Now.Date.AddDays(1); int dateTimeValue = ValidationHelper.GetInteger(txtFilter.Text, 0); switch (drpFilter.SelectedIndex) { case 0: olderThan = olderThan.AddDays(-dateTimeValue); break; case 1: olderThan = olderThan.AddDays(-dateTimeValue * 7); break; case 2: olderThan = olderThan.AddMonths(-dateTimeValue); break; case 3: olderThan = olderThan.AddYears(-dateTimeValue); break; } where.WhereLessOrEquals("VersionDeletedWhen", olderThan); } return(where.ToString(true)); }
/// <summary> /// Creates where condition according to values selected in filter. /// </summary> private WhereCondition GenerateWhereCondition() { var where = new WhereCondition(); where.And().Where(fltTaskTitle.GetCondition()); TaskTypeEnum taskType = (TaskTypeEnum)taskTypeSelector.Value.ToInteger(0); if (taskType != TaskTypeEnum.All) { where.WhereStartsWith("TaskType", TaskHelper.GetTaskTypeString(taskType)); } fltTimeBetween.Column = "TaskTime"; where.Where(fltTimeBetween.GetCondition()); var selected = ValidationHelper.GetInteger(userSelector.Value, -1); GetStagingTasksByUser(where, selected); var taskGroupSelected = ValidationHelper.GetInteger(stagingTaskGroupSelector.Value, -1); GetStagingTasksByTaskGroup(where, taskGroupSelected); return(where); }
private string GetWhereCondition() { var where = new WhereCondition(); // Display name/Code name string displayName = txtClassDisplayName.Text.Trim(); if (!String.IsNullOrEmpty(displayName)) { where .Where(w => w.WhereContains("ClassDisplayName", displayName) .Or() .WhereContains("ClassName", displayName)); } // Table name string tableName = txtClassTableName.Text.Trim(); if (!String.IsNullOrEmpty(tableName)) { where .WhereContains("ClassTableName", tableName); } return(where.ToString(true)); }
private DataSet GetRecycleBinSeletedItems(BinSettingsContainer settings, string columns) { var where = new WhereCondition(); switch (settings.CurrentWhat) { case What.AllObjects: if (IsSingleSite) { where.WhereNull("VersionObjectSiteID"); } if (settings.Site != null) { where.Or().WhereEquals("VersionObjectSiteID", settings.Site.SiteID); } // Wrap filter condition with brackets where.Where(new WhereCondition(filter.WhereCondition) { WhereIsComplex = true }); where = GetWhereCondition(where); break; case What.SelectedObjects: // Restore selected objects var toRestore = settings.SelectedItems; where.WhereIn("VersionID", toRestore); break; } return(ObjectVersionHistoryInfoProvider.GetRecycleBin(where.ToString(true), OrderBy, -1, columns)); }
/// <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 default where condition for product documents listing. /// </summary> private WhereCondition GetDocumentWhereCondition() { var where = new WhereCondition().WhereNotNull("NodeSKUID"); if (ShowSections) { where.Or().WhereIn("NodeClassID", new IDQuery <DataClassInfo>("ClassID").WhereTrue("ClassIsProductSection")); } // Prepare site condition var siteWhere = InitSiteWhereCondition("SKUSiteID"); if (ShowSections) { siteWhere.Or().Where(w => w.WhereNull("SKUSiteID").And().WhereNull("SKUID")); } // Combine where conditions where.Where(siteWhere); if (docList.Node != null) { where.WhereStartsWith("NodeAliasPath", docList.Node.NodeAliasPath.TrimEnd('/') + "/"); } return(where); }
/// <summary> /// Loads export histories list. /// </summary> private void LoadExportHistories() { lstExports.Items.Clear(); var where = new WhereCondition(); int siteId = ValidationHelper.GetInteger(siteSelector.Value, 0); if (siteId != 0) { where.Where("ExportSiteID", QueryOperator.Equals, siteSelector.Value); } else { where.WhereNull("ExportSiteID"); } var histories = ExportHistoryInfo.Provider.Get() .Where(where) .OrderByDescending("ExportDateTime") .Columns(new [] { "ExportDateTime", "ExportFileName", "ExportID" }); if (DataHelper.DataSourceIsEmpty(histories)) { return; } radExport.Enabled = true; foreach (DataRow dr in histories.Tables[0].Rows) { lstExports.Items.Add(new ListItem(ValidationHelper.GetString(dr["ExportDateTime"], "yyyy-mm-ddd") + " - " + ValidationHelper.GetString(dr["ExportFileName"], "filename"), ValidationHelper.GetString(dr["ExportID"], null))); } }
/// <summary> /// Creates default where condition for product documents listing. /// </summary> private WhereCondition GetDocumentWhereCondition() { var where = new WhereCondition().WhereNotNull("NodeSKUID"); if (ShowSections) { where.Or().WhereIn("NodeClassID", new IDQuery <DataClassInfo>("ClassID").WhereTrue("ClassIsProductSection")); } // Prepare site condition var siteWhere = new WhereCondition().WhereEquals("SKUSiteID", SiteContext.CurrentSiteID); if (AllowGlobalObjects) { siteWhere.Or().WhereNull("SKUSiteID"); } else if (ShowSections) { siteWhere.Or().Where(w => w.WhereNull("SKUSiteID").And().WhereNull("SKUID")); } // Combine where conditions where.Where(siteWhere); if (docList.Node != null) { string path = docList.Node.NodeAliasPath ?? ""; where.WhereStartsWith("NodeAliasPath", path); } return(where); }
/// <summary> /// Gets current where condition. /// </summary> /// <returns>Where condition determining documents to process</returns> private string GetCurrentWhere() { var documentIds = docElem.UniGrid.SelectedItems; // Prepare the where condition var condition = new WhereCondition(); if (mCurrentWhat == What.SelectedDocuments) { // Get where for selected documents condition.WhereIn("DocumentID", documentIds.ToList()); } else { if (!string.IsNullOrEmpty(filterDocuments.WhereCondition)) { // Add filter condition condition.Where(filterDocuments.WhereCondition); } // Select documents only under current workflow condition.WhereIn("DocumentWorkflowStepID", new IDQuery <WorkflowStepInfo>().WhereEquals("StepWorkflowID", WorkflowId)); } return(condition.ToString(true)); }
/// <summary> /// Reloads the data in the selector. /// </summary> /// <param name="reloadUniSelector">If true, UniSelector is also reloaded</param> public void ReloadData(bool reloadUniSelector = false) { uniSelector.IsLiveSite = IsLiveSite; var where = new WhereCondition(); if (OnlyDocumentTypes) { where.WhereEquals("ClassIsDocumentType", 1); } else if (OnlyCustomTables) { where.WhereEquals("ClassIsCustomTable", 1); } if (mSiteId != null) { where.WhereIn("ClassID", ClassSiteInfo.Provider.Get().Column("ClassID").WhereEquals("SiteID", mSiteId)); } // Combine default where condition with external if (!String.IsNullOrEmpty(WhereCondition)) { where.Where(WhereCondition); } uniSelector.WhereCondition = where.ToString(true); if (reloadUniSelector) { uniSelector.Reload(true); } }
/// <summary> /// Generates complete filter where condition. /// </summary> private string GenerateWhereCondition() { var whereCondition = new WhereCondition(); whereCondition = whereCondition .Where(fltFormerUrlPath.GetCondition()); // Create WHERE condition for advanced filter if (IsAdvancedMode) { whereCondition = whereCondition .Where(fltModified.GetCondition()) .Where(fltPageName.GetCondition()) .Where(fltType.GetCondition()); } return(whereCondition.ToString(true)); }
/// <summary> /// Creates filter condition and raise filter change event. /// </summary> private void FilterData() { WhereCondition where = new WhereCondition(); int paging = 0; string order = string.Empty; // Build where condition according to drop-downs settings if (statusSelector.SelectedID > 0) { where.WhereEquals("SKUPublicStatusID", statusSelector.SelectedID); } if (manufacturerSelector.SelectedID > 0) { where.WhereEquals("SKUManufacturerID", manufacturerSelector.SelectedID); } if (chkStock.Checked) { where.Where(w => w.WhereNull("SKUTrackInventory") .Or() .WhereGreaterThan("SKUAvailableItems", 0) .Or() .WhereIn("SKUID", new IDQuery <SKUInfo>("SKUParentSKUID").WhereGreaterThan("SKUAvailableItems", 0))); } if (!string.IsNullOrEmpty(txtSearch.Text)) { where.WhereContains("SKUName", txtSearch.Text); } // Process drpSort drop-down if (ValidationHelper.GetInteger(drpPaging.SelectedValue, 0) > 0) { paging = ValidationHelper.GetInteger(drpPaging.SelectedValue, 0); } if (!string.IsNullOrEmpty(drpSort.SelectedValue)) { order = drpSort.SelectedValue; } // Set where condition WhereCondition = where.ToString(true); if (paging > 0) { // Set paging PageSize = paging; } if (!string.IsNullOrEmpty(order)) { // Set sorting OrderBy = GetOrderBy(order); } }
protected void gridElem_OnBeforeDataReload() { // Filter records by tag group ID var where = new WhereCondition().WhereEquals("TagGroupID", groupId); if (!String.IsNullOrEmpty(gridElem.CompleteWhereCondition)) { where.Where(gridElem.CompleteWhereCondition); } gridElem.WhereCondition = where.ToString(true); }
/// <summary> /// Returns where condition filtering OlderThan or HowOld. /// </summary> private void AddDateWhereCondition(WhereCondition where) { if (OlderThan > 0) { // OlderThan parameter if (OlderThan > SQL_DATE_TIME_LIMIT) { OlderThan = SQL_DATE_TIME_LIMIT; } var olderThan = DateTime.Now.AddDays(-Math.Abs(OlderThan)); where.Where("OrderDate", QueryOperator.LessOrEquals, olderThan); } else if ((HowOld > 0) && (HowOld < SQL_DATE_TIME_LIMIT)) { // HowOld parameter var from = DateTime.Now.AddDays(-Math.Abs(HowOld)); where.Where("OrderDate", QueryOperator.LargerOrEquals, from); } }
protected void Page_Load(object sender, EventArgs e) { PageTitle.TitleText = GetString("newsletter_issue_openedby.title"); issueId = QueryHelper.GetInteger("objectid", 0); if (issueId == 0) { RequestHelper.EndResponse(); } IssueInfo issue = IssueInfoProvider.GetIssueInfo(issueId); EditedObject = issue; // Prevent accessing issues from sites other than current site if (issue.IssueSiteID != SiteContext.CurrentSiteID) { RedirectToResourceNotAvailableOnSite("Issue with ID " + issueId); } // Issue is the main A/B test issue isMainABTestIssue = issue.IssueIsABTest && !issue.IssueIsVariant; if (isMainABTestIssue) { // Initialize variant selector in the filter fltOpenedBy.IssueId = issue.IssueID; if (RequestHelper.IsPostBack()) { // Get issue ID from variant selector issueId = fltOpenedBy.IssueId; } // Reset ID for main issue, grid will show data from main and winner variant issues if (issueId == issue.IssueID) { issueId = 0; } } var where = new WhereCondition(); if (issueId > 0) { where.Where("IssueID", QueryOperator.Equals, issueId); } where.And(new WhereCondition(fltOpenedBy.WhereCondition)); UniGrid.QueryParameters = where.Parameters; UniGrid.WhereCondition = where.WhereCondition; UniGrid.Pager.DefaultPageSize = PAGESIZE; UniGrid.Pager.ShowPageSize = false; UniGrid.FilterLimit = 1; UniGrid.OnExternalDataBound += UniGrid_OnExternalDataBound; UniGrid.OnBeforeDataReload += UniGrid_OnBeforeDataReload; }
/// <summary> /// Returns complete WHERE condition. /// </summary> protected WhereCondition GetCompleteWhereCondition() { var allRecords = UniSelector.US_ALL_RECORDS.ToString(); var customWhere = ValidationHelper.GetString(GetValue("WhereCondition"), ""); var where = new WhereCondition(); // Do not select product options and select only enabled products where.WhereNull("SKUOptionCategoryID") .WhereTrue("SKUEnabled"); // Get products only with specified public status if (!String.IsNullOrEmpty(ProductPublicStatusName) && (ProductPublicStatusName != allRecords)) { var pStatusSiteID = ECommerceSettings.UseGlobalPublicStatus(SiteName) ? 0 : SiteInfoProvider.GetSiteID(SiteName); where.WhereEquals("SKUPublicStatusID", new IDQuery <PublicStatusInfo>("PublicStatusID") .WhereEquals("PublicStatusSiteID".AsColumn().IsNull(0), pStatusSiteID) .WhereEquals("PublicStatusName", ProductPublicStatusName) .TopN(1) ); } // Get products only with specified internal status if (!String.IsNullOrEmpty(ProductInternalStatusName) && (ProductInternalStatusName != allRecords)) { var iStatusSiteID = ECommerceSettings.UseGlobalInternalStatus(SiteName) ? 0 : SiteInfoProvider.GetSiteID(SiteName); where.WhereEquals("SKUInternalStatusID", new IDQuery <InternalStatusInfo>("InternalStatusID") .WhereEquals("InternalStatusSiteID".AsColumn().IsNull(0), iStatusSiteID) .WhereEquals("InternalStatusName", ProductInternalStatusName) .TopN(1) ); } // Get products only from specified department if (!String.IsNullOrEmpty(ProductDepartmentName) && (ProductDepartmentName != allRecords)) { var dept = DepartmentInfoProvider.GetDepartmentInfo(ProductDepartmentName, SiteName); var departmentID = (dept != null) ? dept.DepartmentID : 0; where.WhereEquals("SKUDepartmentID", departmentID); } // Include user custom WHERE condition if (customWhere.Trim() != "") { where.Where(customWhere); } return(where); }
/// <summary> /// Adds role condition to given <paramref name="whereCondition"/>. /// </summary> private void AddRoleCondition(WhereCondition whereCondition) { var assignedRolesSelectionMode = drpTypeSelectInRoles.SelectedValue; var unassignedRolesSelectionMode = drpTypeSelectNotInRoles.SelectedValue; var assignedRoles = selectRoleElem.Value.ToString(); var unassignedRoles = selectNotInRole.Value.ToString(); whereCondition .Where(GetRolesSelectorCondition(assignedRolesSelectionMode, assignedRoles)) .WhereNot(GetRolesSelectorCondition(unassignedRolesSelectionMode, unassignedRoles)); }
/// <summary> /// Builds a SQL condition for filtering the discount list, and returns it. /// </summary> /// <returns>A SQL condition for filtering the discount list.</returns> private string GetFilterWhereCondition() { string discountStatus = drpStatus.SelectedValue; var condition = new WhereCondition(); /* Active discounts */ if (discountStatus == "0") { condition.Where(GetActiveQuery()); } /* Disabled discounts */ else if (discountStatus == "1") { condition.WhereNot(GetEnabledDiscounts()); } /* Finished discounts */ else if (discountStatus == "2") { condition.Where(GetEnabledDiscounts()) .WhereLessThan(GetColumn("DiscountValidTo"), DateTime.Now) .WhereNot(GetIncompleteDiscounts()) .Or(GetDiscountsWithCouponsExceeded()); } /* Scheduled discounts */ else if (discountStatus == "3") { condition.Where(GetEnabledDiscounts()) .WhereGreaterThan(GetColumn("DiscountValidFrom"), DateTime.Now) .WhereNot(GetIncompleteDiscounts()); } /* Incomplete discounts */ else if (discountStatus == "4") { condition.Where(GetEnabledDiscounts()) .Where(GetIncompleteDiscounts()); } return(condition.ToString(true)); }
/// <summary> /// Gets where condition for selecting relationship names /// </summary> private WhereCondition GetRelationshipNameCondition() { var relationshipNameCondition = new WhereCondition(); if (!UseAdHocRelationshipName) { relationshipNameCondition.Where(new WhereCondition().WhereFalse("RelationshipNameIsAdHoc").Or().WhereNull("RelationshipNameIsAdHoc")); } relationshipNameCondition.WhereEquals("RelationshipName", RelationshipName); return(relationshipNameCondition); }
/// <summary> /// Generates complete filter where condition. /// </summary> private string GenerateWhereCondition() { var whereCondition = new WhereCondition(); whereCondition = whereCondition .Where(fltContactStatus.GetWhereCondition()) .Where(fltFirstName.GetCondition()) .Where(fltLastName.GetCondition()) .Where(fltEmail.GetCondition()); // Only contacts that were replicated to SalesForce leads if (radSalesForceLeadReplicationStatus.SelectedIndex == 1) { whereCondition = whereCondition.WhereNotNull("ContactSalesForceLeadID"); } // Only contacts that were not replicated to SalesForce leads else if (radSalesForceLeadReplicationStatus.SelectedIndex == 2) { whereCondition = whereCondition.WhereNull("ContactSalesForceLeadID"); } // Create WHERE condition for advanced filter (id needed) if (IsAdvancedMode) { whereCondition = whereCondition .Where(fltMiddleName.GetCondition()) .Where(fltCity.GetCondition()) .Where(fltPhone.GetCondition()) .Where(fltCreated.GetCondition()) .Where(GetOwnerCondition(fltOwner)) .Where(GetCountryCondition(fltCountry)) .Where(GetStateCondition(fltState)); } return(whereCondition.ToString(true)); }
/// <summary> /// Generates WHERE condition. /// </summary> private WhereCondition GenerateWhereCondition() { var where = new WhereCondition(); string name = txtName.Text; if (String.IsNullOrEmpty(name)) { return(where); } // Get filter operator (LIKE, NOT LIKE, =, !=) switch (filter.SelectedValue) { default: where.Where(w => w.WhereContains("CategoryDisplayName", name).Or().WhereContains("CategoryLiveSiteDisplayName", name)); break; case WhereBuilder.EQUAL: where.Where(w => w.WhereEquals("CategoryDisplayName", name).Or().WhereEquals("CategoryLiveSiteDisplayName", name)); break; case WhereBuilder.NOT_LIKE: where.Where(w => w.WhereNotContains("CategoryDisplayName", name).Or().WhereNull("CategoryDisplayName")) .And() .Where(w => w.WhereNotContains("CategoryLiveSiteDisplayName", name).Or().WhereNull("CategoryLiveSiteDisplayName")); break; case WhereBuilder.NOT_EQUAL: where.Where(w => w.WhereNotEquals("CategoryDisplayName", name).Or().WhereNull("CategoryDisplayName")) .And() .Where(w => w.WhereNotEquals("CategoryLiveSiteDisplayName", name).Or().WhereNull("CategoryLiveSiteDisplayName")); break; } return(where); }
/// <summary> /// Creates WHERE condition for VersionObjectSiteID column. /// </summary> private WhereCondition GetVersionObjectSiteIDWhereCondition() { var where = new WhereCondition(); if (IsSingleSite || (SiteName == "##global##")) { where.Where("VersionObjectSiteID", QueryUnaryOperator.IsNull); } if (CurrentSite != null) { where.Or().Where("VersionObjectSiteID", QueryOperator.Equals, CurrentSite.SiteID); } return(where); }
/// <summary> /// Gets where condition for selecting relationship names /// </summary> private WhereCondition GetRelationshipNameCondition() { var relationshipNameCondition = new WhereCondition(); if (!UseAdHocRelationshipName) { relationshipNameCondition.Where(new WhereCondition()); if (!String.IsNullOrEmpty(RelationshipName)) { relationshipNameCondition.WhereEquals("RelationshipName", RelationshipName); } } return(relationshipNameCondition); }
/// <summary> /// Returns where condition. /// </summary> /// <param name="customWhere">Custom WHERE condition</param> private WhereCondition GetWhereCondition(string customWhere) { SiteInfo si; var where = new WhereCondition(); // Get required site data if (!String.IsNullOrEmpty(SiteName)) { si = SiteInfoProvider.GetSiteInfo(SiteName); } else { si = SiteContext.CurrentSite; } if (si != null) { // Build where condition var classWhere = new WhereCondition(); // Get documents of the specified class only - without coupled data !!! if (!String.IsNullOrEmpty(ClassNames)) { string[] classNames = ClassNames.Trim(';').Split(';'); foreach (string className in classNames) { classWhere.WhereEquals("ClassName", className).Or(); } } where.WhereIn("NodeSKUID", new IDQuery <OrderItemInfo>("OrderItemSKUID").Source(s => s.Join <SKUInfo>("OrderItemSKUID", "SKUID") .Join <OrderInfo>("COM_OrderItem.OrderItemOrderID", "OrderID")) .WhereTrue("SKUEnabled") .WhereNull("SKUOptionCategoryID") .WhereEquals("OrderSiteID", si.SiteID) .Where(classWhere)); // Add custom WHERE condition if (!String.IsNullOrEmpty(customWhere)) { where.Where(customWhere); } } return(where); }
protected override void OnInit(EventArgs e) { base.OnInit(e); currentSite = SiteContext.CurrentSite; currentUser = MembershipContext.AuthenticatedUser; // Check 'Manage' permission var manageBlogs = currentUser.IsAuthorizedPerResource("cms.blog", "Manage"); // There is no sense to display (ALL) in blogs DDL when // user does not have manage blogs permission if (!manageBlogs) { DisplayAllRecord = false; } var condition = new WhereCondition().WhereEquals("NodeSiteID", currentSite.SiteID); if (!currentUser.IsGlobalAdministrator && !manageBlogs) { condition.Where(BlogHelper.GetBlogsWhere(currentUser.UserID, currentUser.UserName, null)); } // Culture priority column to handle duplicities var culturePriority = new RowNumberColumn("CulturePriority", "BlogID"); culturePriority.PartitionBy = "NodeID"; // Init Blog selector uniSelector.DisplayNameFormat = "{%BlogName%}"; uniSelector.SelectionMode = SelectionModeEnum.SingleDropDownList; uniSelector.WhereCondition = condition.ToString(true); uniSelector.ReturnColumnName = "BlogID"; uniSelector.AdditionalColumns = culturePriority.ToString(); uniSelector.ObjectType = "cms.blog"; uniSelector.ResourcePrefix = "unisiteselector"; uniSelector.AllowEmpty = false; uniSelector.AllowAll = false; uniSelector.OnAfterRetrieveData += uniSelector_OnAfterRetrieveData; // Preselect my blogs if (IsInMydesk && !RequestHelper.IsPostBack()) { uniSelector.Value = "##MYBLOGS##"; } }
/// <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 the web part list. /// </summary> /// <param name="forceLoad">if set to <c>true</c>, reload the control even if the control has been already loaded</param> protected void LoadWebParts(bool forceLoad) { if (!dataLoaded || forceLoad) { var repeaterWhere = new WhereCondition(); /* The order is category driven => first level category display name is used for all nodes incl. sub-nodes */ string categoryOrder = @" (SELECT CMS_WebPartCategory.CategoryDisplayName FROM CMS_WebPartCategory WHERE CMS_WebPartCategory.CategoryPath = (CASE WHEN (CHARINDEX('/', ObjectPath, 0) > 0) AND (CHARINDEX('/', ObjectPath, CHARINDEX('/', ObjectPath, 0) + 1) = 0) THEN ObjectPath ELSE SUBSTRING(ObjectPath, 0, LEN(ObjectPath) - (LEN(ObjectPath) - CHARINDEX('/', ObjectPath, CHARINDEX('/', ObjectPath, 0) + 1))) END)) "; // Set query repeater repItems.SelectedColumns = " ObjectID, DisplayName, ObjectType, ParentID, ThumbnailGUID, IconClass, ObjectLevel, WebPartDescription, WebPartSkipInsertProperties"; repItems.OrderBy = categoryOrder + ", ObjectType DESC, DisplayName"; // Setup the where condition if (SelectedCategory == CATEGORY_RECENTLY_USED) { // Recently used category RenderRecentlyUsedWebParts(true); } else { // Specific web part category int selectedCategoryId = ValidationHelper.GetInteger(SelectedCategory, 0); if (selectedCategoryId > 0) { WebPartCategoryInfo categoryInfo = WebPartCategoryInfoProvider.GetWebPartCategoryInfoById(selectedCategoryId); if (categoryInfo != null) { string firstLevelCategoryPath = String.Empty; // Select also all subcategories (using "/%") string categoryPath = categoryInfo.CategoryPath; if (!categoryPath.EndsWith("/")) { categoryPath += "/"; } // Do not limit items if not root category is selected if (!categoryInfo.CategoryPath.EqualsCSafe("/")) { limitItems = false; } // Get all web parts for the selected category and its subcategories if (categoryPath.EqualsCSafe("/")) { repeaterWhere.Where(repItems.WhereCondition).Where(w => w .WhereEquals("ObjectType", "webpart") .Or() .WhereEquals("ObjectLevel", 1) ).Where(w => w .WhereEquals("ParentID", selectedCategoryId) .Or() .WhereIn("ParentID", WebPartCategoryInfoProvider.GetCategories().WhereStartsWith("CategoryPath", categoryPath)) ); // Set caching for query repeater repItems.ForceCacheMinutes = true; repItems.CacheMinutes = 24 * 60; repItems.CacheDependencies = "cms.webpart|all\ncms.webpartcategory|all"; // Show Recently used category RenderRecentlyUsedWebParts(false); } else { // Prepare where condition -- the part that restricts web parts repeaterWhere.WhereEquals("ObjectType", "webpart") .Where(w => w .WhereEquals("ParentID", selectedCategoryId) .Or() .WhereIn("ParentID", WebPartCategoryInfoProvider.GetCategories().WhereStartsWith("CategoryPath", categoryPath)) ); // Get first level category path firstLevelCategoryPath = categoryPath.Substring(0, categoryPath.IndexOf('/', 2)); var selectedCategoryWhere = new WhereCondition(); // Distinguish special categories if (categoryPath.StartsWithCSafe(CATEGORY_UIWEBPARTS, true)) { if (!categoryPath.EqualsCSafe(firstLevelCategoryPath + "/", true)) { // Currently selected category is one of subcategories string specialCategoryPath = firstLevelCategoryPath; firstLevelCategoryPath = categoryPath.Substring(CATEGORY_UIWEBPARTS.Length + 1).TrimEnd('/'); selectedCategoryWhere.WhereEquals("ObjectPath", specialCategoryPath + "/" + firstLevelCategoryPath); } else { // Currently selected category is root category selectedCategoryWhere.WhereStartsWith("ObjectPath", firstLevelCategoryPath); } } else { // All web part category selectedCategoryWhere.WhereEquals("ObjectPath", firstLevelCategoryPath); } repeaterWhere.Or().Where(w => w .WhereEquals("ObjectType", "webpartcategory") .WhereEquals("ObjectLevel", 1) .Where(selectedCategoryWhere) ); // Set caching for query repeater repItems.CacheMinutes = 0; repItems.ForceCacheMinutes = true; } } } // Do not display "Widget only" web parts in the toolbar repItems.WhereCondition = new WhereCondition() .Where(repeaterWhere) .Where(w => w .WhereNull("WebPartType") .Or() .WhereNotEquals("WebPartType", (int)WebPartTypeEnum.WidgetOnly) ) .ToString(true); // Limit items if required if (limitItems) { repItems.SelectTopN = DEFAULT_WEBPART_COUNT; } repItems.ReloadData(false); repItems.DataBind(); } dataLoaded = true; } }
/// <summary> /// Returns where condition. /// </summary> /// <param name="customWhere">Custom WHERE condition</param> private WhereCondition GetWhereCondition(string customWhere) { SiteInfo si; var where = new WhereCondition(); // Get required site data if (!String.IsNullOrEmpty(SiteName)) { si = SiteInfoProvider.GetSiteInfo(SiteName); } else { si = SiteContext.CurrentSite; } if (si != null) { // Build where condition var classWhere = new WhereCondition(); // Get documents of the specified class only - without coupled data !!! if (!String.IsNullOrEmpty(ClassNames)) { string[] classNames = ClassNames.Trim(';').Split(';'); foreach (string className in classNames) { classWhere.WhereEquals("ClassName", className).Or(); } } where.WhereIn("NodeSKUID", new IDQuery<OrderItemInfo>("OrderItemSKUID").Source(s => s.Join<SKUInfo>("OrderItemSKUID", "SKUID") .Join<OrderInfo>("COM_OrderItem.OrderItemOrderID", "OrderID")) .WhereTrue("SKUEnabled") .WhereNull("SKUOptionCategoryID") .WhereEquals("OrderSiteID", si.SiteID) .Where(classWhere)); // Add custom WHERE condition if (!String.IsNullOrEmpty(customWhere)) { where.Where(customWhere); } } return where; }
/// <summary> /// Builds a SQL condition for filtering the discount list, and returns it. /// </summary> /// <returns>A SQL condition for filtering the discount list.</returns> private string GetFilterWhereCondition() { string discountStatus = drpStatus.SelectedValue; var condition = new WhereCondition(); /* Active discounts */ if (discountStatus == "0") { condition.Where(GetActiveQuery()); } /* Disabled discounts */ else if (discountStatus == "1") { condition.WhereNot(GetEnabledDiscounts()); } /* Finished discounts */ else if (discountStatus == "2") { condition.Where(GetEnabledDiscounts()) .WhereLessThan(GetColumn("DiscountValidTo"), DateTime.Now) .WhereNot(GetIncompleteDiscounts()) .Or(GetDiscountsWithCouponsExceeded()); } /* Scheduled discounts */ else if (discountStatus == "3") { condition.Where(GetEnabledDiscounts()) .WhereGreaterThan(GetColumn("DiscountValidFrom"), DateTime.Now) .WhereNot(GetIncompleteDiscounts()); } /* Incomplete discounts */ else if (discountStatus == "4") { condition.Where(GetEnabledDiscounts()) .Where(GetIncompleteDiscounts()); } return condition.ToString(true); }
/// <summary> /// Creates where condition for SKUs listing. /// </summary> private WhereCondition GetWhereCondition() { // Display ONLY products - not product options var where = new WhereCondition().WhereNull("SKUOptionCategoryID"); // Select only products without documents if ((NodeID <= 0) && DisplayTreeInProducts) { where.WhereNotIn("SKUID", SKUInfoProvider.GetSKUs().Column("SKUID").From("View_CMS_Tree_Joined").WhereNotNull("NodeSKUID").And().WhereEquals("NodeSiteID", SiteContext.CurrentSiteID)); } // Ordinary user can see only product from departments he can access var cui = MembershipContext.AuthenticatedUser; if (!cui.IsGlobalAdministrator && !cui.IsAuthorizedPerResource("CMS.Ecommerce", "AccessAllDepartments")) { where.Where(w => w.WhereNull("SKUDepartmentID").Or().WhereIn("SKUDepartmentID", new IDQuery<UserDepartmentInfo>("DepartmentID").WhereEquals("UserID", cui.UserID))); } // Reflect "Allow global products" setting var siteWhere = new WhereCondition().WhereEquals("SKUSiteID", SiteContext.CurrentSiteID); if (AllowGlobalObjects) { siteWhere.Or().WhereNull("SKUSiteID"); } return where.Where(siteWhere); }
/// <summary> /// Get where condition for unigrid /// </summary> /// <returns>Where condition</returns> private WhereCondition GetWhereCondition() { string productNameFilter = txtProductName.Text; // To display ONLY product - not product options var where = new WhereCondition().WhereTrue("SKUEnabled").And().WhereNull("SKUOptionCategoryID"); if (!string.IsNullOrEmpty(productNameFilter)) { // Condition to get also products with variants that contains where.Where(w => w.WhereContains("SKUName", productNameFilter) .Or() .WhereContains("SKUNumber", productNameFilter) .Or() .WhereIn("SKUID", new IDQuery<SKUInfo>("SKUParentSKUID").WhereContains("SKUName", productNameFilter).Or().WhereContains("SKUNumber", productNameFilter)) ); } where.Where(SKUInfoProvider.ProviderObject.AddSiteWhereCondition(string.Empty, SiteContext.CurrentSiteID, ECommerceSettings.ALLOW_GLOBAL_PRODUCTS, true)); return where; }
/// <summary> /// Reloads the data. /// </summary> /// <param name="forceReload">If true, the data is reloaded even when already loaded</param> public void ReloadData(bool forceReload) { if (!dataLoaded || forceReload) { drpWebpart.Items.Clear(); if (DisplayNone) { drpWebpart.Items.Add(new ListItem(ResHelper.GetString("General.SelectNone"), "")); } // Do not retrieve webparts WhereCondition condition = new WhereCondition(WhereCondition); if (!ShowWebparts) { condition.WhereEquals("ObjectType", "webpartcategory"); } if (!ShowInheritedWebparts) { condition.WhereNull("WebPartParentID"); } if (!String.IsNullOrEmpty(RootPath)) { string rootPath = RootPath.TrimEnd('/'); condition.Where(new WhereCondition().WhereEquals("ObjectPath", rootPath).Or().WhereStartsWith("ObjectPath", rootPath + "/")); } ds = WebPartCategoryInfoProvider.GetCategoriesAndWebparts(condition.ToString(true), "DisplayName", 0, "ObjectID, DisplayName, ParentID, ObjectType"); if (!DataHelper.DataSourceIsEmpty(ds)) { int counter = 0; // Make special collection for "tree mapping" Dictionary<int, SortedList<string, object[]>> categories = new Dictionary<int, SortedList<string, object[]>>(); // Fill collection from dataset foreach (DataRow dr in ds.Tables[0].Rows) { int parentId = ValidationHelper.GetInteger(dr["ParentID"], 0); int id = ValidationHelper.GetInteger(dr["ObjectID"], 0); string name = ResHelper.LocalizeString(ValidationHelper.GetString(dr["DisplayName"], String.Empty)); string type = ValidationHelper.GetString(dr["ObjectType"], String.Empty); // Skip webpart, take only WebpartCategory if (type == "webpart") { continue; } SortedList<string, object[]> list; categories.TryGetValue(parentId, out list); // Sub categories list not created yet if (list == null) { list = new SortedList<string, object[]>(); categories.Add(parentId, list); } list.Add(name + "_" + counter, new object[] { id, name }); counter++; } // Start filling the dropdown from the root(parentId = 0) int level = 0; // Root is not shown, start indentation later if (!ShowRoot) { level = -1; } AddSubCategories(categories, 0, level); } dataLoaded = true; } }
private DataSet GetRecycleBinSeletedItems(BinSettingsContainer settings, string columns) { var where = new WhereCondition(); switch (settings.CurrentWhat) { case What.AllObjects: if (IsSingleSite) { where.WhereNull("VersionObjectSiteID"); } if (settings.Site != null) { where.Or().WhereEquals("VersionObjectSiteID", settings.Site.SiteID); } // Wrap filter condition with brackets where.Where(new WhereCondition(filter.WhereCondition) { WhereIsComplex = true }); where = GetWhereCondition(where); break; case What.SelectedObjects: // Restore selected objects var toRestore = settings.SelectedItems; where.WhereIn("VersionID", toRestore); break; } return ObjectVersionHistoryInfoProvider.GetRecycleBin(where.ToString(true), OrderBy, -1, columns); }
/// <summary> /// Creates where condition according to values selected in filter. /// </summary> private WhereCondition GenerateWhereCondition() { var where = new WhereCondition(); where.And().Where(fltTaskTitle.GetCondition()); TaskTypeEnum taskType = (TaskTypeEnum)taskTypeSelector.Value.ToInteger(0); if (taskType != TaskTypeEnum.All) { where.WhereStartsWith("TaskType", TaskHelper.GetTaskTypeString(taskType)); } fltTimeBetween.Column = "TaskTime"; where.Where(fltTimeBetween.GetCondition()); var selected = ValidationHelper.GetInteger(userSelector.Value, -1); GetStagingTasksByUser(where, selected); var taskGroupSelected = ValidationHelper.GetInteger(stagingTaskGroupSelector.Value, -1); GetStagingTasksByTaskGroup(where, taskGroupSelected); return where; }
/// <summary> /// Checks if page is not already assigned. /// </summary> /// <param name="filledVariantPath">Variant path filled in form</param> private void CheckDoublePageAssignment(string filledVariantPath) { string originalVariantPath = ValidationHelper.GetString(ABVariant.GetOriginalValue("ABVariantPath"), ""); //Check if variantPath is changed if (originalVariantPath != filledVariantPath) { var condition = new WhereCondition() .WhereEquals("ABVariantTestID", ABTest.ABTestID) .WhereEquals("ABVariantPath", filledVariantPath); if (ABVariant.ABVariantID > 0) { condition.Where("ABVariantID", QueryOperator.NotEquals, ABVariant.ABVariantID); } var variants = ABVariantInfoProvider.GetVariants().Where(condition).TopN(1); if (variants.Any()) { ShowError(GetString("abtesting.variantpath.alreadyassigned")); form.StopProcessing = true; } } }
/// <summary> /// Gets where condition for selecting relationship names /// </summary> private WhereCondition GetRelationshipNameCondition() { var relationshipNameCondition = new WhereCondition(); if (!UseAdHocRelationshipName) { relationshipNameCondition.Where(new WhereCondition().WhereFalse("RelationshipNameIsAdHoc").Or().WhereNull("RelationshipNameIsAdHoc")); if (!String.IsNullOrEmpty(RelationshipName)) { relationshipNameCondition.WhereEquals("RelationshipName", RelationshipName); } } else { relationshipNameCondition.WhereEquals("RelationshipName", AdHocRelationshipName); } return relationshipNameCondition; }
/// <summary> /// PageLoad event handler. /// </summary> protected void Page_Load(object sender, EventArgs e) { // Object type cannot be defined in xml definition -> it would ignore code behind configuration UniGridRelationship.ObjectType = (IsAdHocRelationship) ? RelationshipInfo.OBJECT_TYPE_ADHOC : RelationshipInfo.OBJECT_TYPE; if (StopProcessing) { UniGridRelationship.StopProcessing = StopProcessing; return; } // Set tree node from Form object if ((TreeNode == null) && (Form != null) && (Form.EditedObject != null)) { var node = Form.EditedObject as TreeNode; if ((node != null) && (Form.Mode == FormModeEnum.Update)) { TreeNode = node; } else { ShowInformation(GetString("relationship.editdocumenterror")); } } if (TreeNode != null) { InitUniGrid(); int nodeId = TreeNode.NodeID; // Add relationship name condition var condition = new WhereCondition().WhereIn("RelationshipNameID", new IDQuery<RelationshipNameInfo>().Where(GetRelationshipNameCondition())); // Switch sides is disabled if (!AllowSwitchSides) { condition.WhereEquals(DefaultSide ? "RightNodeID" : "LeftNodeID", nodeId); } else { condition.Where(new WhereCondition().WhereEquals("RightNodeID", nodeId).Or().WhereEquals("LeftNodeID", nodeId)); } InitFilterVisibility(); UniGridRelationship.WhereCondition = condition.ToString(true); if (ShowAddRelation) { btnNewRelationship.OnClientClick = GetAddRelatedDocumentScript() + " return false;"; } else { pnlNewLink.Visible = false; } } else { UniGridRelationship.StopProcessing = true; UniGridRelationship.Visible = false; btnNewRelationship.Enabled = false; } if (RequestHelper.IsPostBack()) { string target = Request[Page.postEventSourceID]; if ((target != pnlUpdate.ClientID) && (target != pnlUpdate.UniqueID)) { return; } string action = Request[Page.postEventArgumentID]; if (string.IsNullOrEmpty(action)) { return; } switch (action.ToLowerCSafe()) { // Insert from 'Select document' dialog case "insertfromselectdocument": SaveRelationship(); break; } } else { bool inserted = QueryHelper.GetBoolean("inserted", false); if (inserted) { ShowConfirmation(GetString("relationship.wasadded")); } } }
/// <summary> /// Creates filter condition and raise filter change event. /// </summary> private void FilterData() { WhereCondition where = new WhereCondition(); int paging = 0; string order = string.Empty; // Build where condition according to drop-downs settings if (statusSelector.SelectedID > 0) { where.WhereEquals("SKUPublicStatusID", statusSelector.SelectedID); } if (manufacturerSelector.SelectedID > 0) { where.WhereEquals("SKUManufacturerID", manufacturerSelector.SelectedID); } if (chkStock.Checked) { where.Where(w => w.WhereNull("SKUTrackInventory") .Or() .WhereGreaterThan("SKUAvailableItems", 0) .Or() .WhereIn("SKUID", new IDQuery<SKUInfo>("SKUParentSKUID").WhereGreaterThan("SKUAvailableItems", 0))); } if (!string.IsNullOrEmpty(txtSearch.Text)) { where.WhereContains("SKUName", txtSearch.Text); } // Process drpSort drop-down if (ValidationHelper.GetInteger(drpPaging.SelectedValue, 0) > 0) { paging = ValidationHelper.GetInteger(drpPaging.SelectedValue, 0); } if (!string.IsNullOrEmpty(drpSort.SelectedValue)) { order = drpSort.SelectedValue; } // Set where condition WhereCondition = where.ToString(true); if (paging > 0) { // Set paging PageSize = paging; } if (!string.IsNullOrEmpty(order)) { // Set sorting OrderBy = GetOrderBy(order); } }
/// <summary> /// Merges given where condition with additional settings. /// </summary> /// <param name="where">Original where condition</param> /// <returns>New where condition</returns> private WhereCondition GetWhereCondition(WhereCondition where) { // Create version condition var condition = new WhereCondition().WhereNotNull("VersionDeletedWhen"); // Add recycle bin condition (ensure correct parentheses wrapping) condition.Where(where); // Filter by object name if (!string.IsNullOrEmpty(ObjectDisplayName)) { condition.WhereContains("VersionObjectDisplayName", ObjectDisplayName); } // Filter by object type if (!String.IsNullOrEmpty(ObjectType)) { condition.WhereContains("VersionObjectType", ObjectType); } return condition; }
/// <summary> /// Returns where condition based on webpart fields. /// </summary> private WhereCondition GetWhereCondition() { // Orders from current site var where = new WhereCondition() .WhereEquals("OrderSiteID", SiteContext.CurrentSiteID); // Order status filter var status = OrderStatusInfoProvider.GetOrderStatusInfo(OrderStatus, SiteContext.CurrentSiteName); if (status != null) { where.WhereEquals("OrderStatusID", status.StatusID); } // Customer or company like filter if (!string.IsNullOrEmpty(CustomerOrCompany)) { where.WhereIn("OrderCustomerID", new IDQuery<CustomerInfo>() .Where("CustomerFirstName + ' ' + CustomerLastName + ' ' + CustomerFirstName LIKE N'%"+ SqlHelper.EscapeLikeText(SqlHelper.EscapeQuotes(CustomerOrCompany)) + "%'") .Or() .WhereContains("CustomerCompany", CustomerOrCompany)); } // Filter for orders with note if (HasNote) { where.WhereNotEmpty("OrderNote"); } // Payment method filter var payment = PaymentOptionInfoProvider.GetPaymentOptionInfo(PaymentMethod, SiteContext.CurrentSiteName); if (payment != null) { where.WhereEquals("OrderPaymentOptionID", payment.PaymentOptionID); } // Payment status filter switch (PaymentStatus.ToLowerCSafe()) { case PAY_STATUS_NOT_PAID: where.Where(new WhereCondition().WhereFalse("OrderIsPaid").Or().WhereNull("OrderIsPaid")); break; case PAY_STATUS_PAID: where.WhereTrue("OrderIsPaid"); break; } // Currency filter var currencyObj = CurrencyInfoProvider.GetCurrencyInfo(Currency, SiteContext.CurrentSiteName); if (currencyObj != null) { where.WhereEquals("OrderCurrencyID", currencyObj.CurrencyID); } // Min price in main currency filter if (MinPriceInMainCurrency > 0) { where.Where("OrderTotalPriceInMainCurrency", QueryOperator.LargerOrEquals, MinPriceInMainCurrency); } // Max price in main currency filter if (MaxPriceInMainCurrency > 0) { where.Where("OrderTotalPriceInMainCurrency", QueryOperator.LessOrEquals, MaxPriceInMainCurrency); } // Shipping option filter var shipping = ShippingOptionInfoProvider.GetShippingOptionInfo(ShippingOption, SiteContext.CurrentSiteName); if (shipping != null) { where.WhereEquals("OrderShippingOptionID", shipping.ShippingOptionID); } // Shipping country filter if (!string.IsNullOrEmpty(ShippingCountry) && ShippingCountry != "0") { AddCountryWhereCondition(where); } // Date filter AddDateWhereCondition(where); return where; }
/// <summary> /// Reloads the data in the selector. /// </summary> public void ReloadData() { uniSelector.IsLiveSite = IsLiveSite; if (!DisplayNoDataMessage) { uniSelector.ZeroRowsText = string.Empty; } // Need to set uni-selector value again after basic form reload if (AllowMultipleChoice) { uniSelector.Value = mMultipleChoiceValue; } var where = new WhereCondition(); if (ProductOptionCategoryID > 0) { where.WhereEquals("SKUOptionCategoryID", ProductOptionCategoryID); } else { var productSiteWhere = new WhereCondition(); // Add global products if (DisplayGlobalProducts) { productSiteWhere.Where(w => w.WhereNull("SKUOptionCategoryID") .WhereNull("SKUSiteID")); } // Add site specific products if (DisplaySiteProducts) { productSiteWhere.Or().Where(w => w.WhereNull("SKUOptionCategoryID") .WhereEquals("SKUSiteID", SiteID)); } where.Where(productSiteWhere); } // Exclude standard products if needed if (!DisplayStandardProducts) { where.WhereNotEquals("SKUProductType", SKUProductTypeEnum.Product.ToStringRepresentation()); } // Exclude memberships if needed if (!DisplayMemberships) { where.WhereNotEquals("SKUProductType", SKUProductTypeEnum.Membership.ToStringRepresentation()); } // Exclude e-products if needed if (!DisplayEproducts) { where.WhereNotEquals("SKUProductType", SKUProductTypeEnum.EProduct.ToStringRepresentation()); } // Exclude donations if needed if (!DisplayDonations) { where.WhereNotEquals("SKUProductType", SKUProductTypeEnum.Donation.ToStringRepresentation()); } // Exclude bundles if needed if (!DisplayBundles) { where.WhereNotEquals("SKUProductType", SKUProductTypeEnum.Bundle.ToStringRepresentation()); } // Exclude products with product options if needed if (DisplayOnlyProductsWithoutOptions) { where.WhereNotIn("SKUID", new IDQuery<SKUOptionCategoryInfo>("SKUID")); } if (DisplayProductOptions && (ProductOptionCategoryID <= 0)) { var optionsSiteWhere = new WhereCondition(); // Add global options if (DisplayGlobalOptions) { optionsSiteWhere.Where(w => w.WhereNotNull("SKUOptionCategoryID") .WhereNull("SKUSiteID")); } // Add site specific options if (DisplaySiteOptions) { optionsSiteWhere.Or().Where(w => w.WhereNotNull("SKUOptionCategoryID") .WhereEquals("SKUSiteID", SiteID)); } where.Or().Where(optionsSiteWhere); where = new WhereCondition().Where(where); } // Filter out only product from users departments if (UserID > 0) { where.WhereIn("SKUDepartmentID", new IDQuery<UserDepartmentInfo>("DepartmentID").WhereEquals("UserID", UserID).Or().WhereNull("SKUDepartmentID")); } // Filter out only enabled items if (DisplayOnlyEnabled) { where.WhereTrue("SKUEnabled"); } if (!DisplayProductOptions && (ProductOptionCategoryID <= 0)) { where.WhereNull("SKUOptionCategoryID"); } if (DisplayProductVariants) { // Do not display parent product in selector where.WhereNotIn("SKUID", new IDQuery<SKUInfo>("SKUParentSKUID").WhereNotNull("SKUParentSKUID")); } else { // Do not display variants where.WhereNull("SKUParentSKUID"); } // Add items which have to be on the list var additionalList = AdditionalItems.Split(new[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); if (additionalList.Length > 0) { var ids = ValidationHelper.GetIntegers(additionalList, 0); where.Or().WhereIn("SKUID", ids); } // Selected value must be on the list if (SKUID > 0) { where.Or().WhereEquals("SKUID", SKUID); } uniSelector.WhereCondition = where.ToString(true); }
/// <summary> /// Reloads the data in the selector. /// </summary> /// <param name="reloadUniSelector">If true, UniSelector is also reloaded</param> public void ReloadData(bool reloadUniSelector = false) { uniSelector.IsLiveSite = IsLiveSite; var where = new WhereCondition(); if (OnlyDocumentTypes) { where.WhereEquals("ClassIsDocumentType", 1); } else if (OnlyCustomTables) { where.WhereEquals("ClassIsCustomTable", 1); } if (mSiteId != null) { where.WhereIn("ClassID", ClassSiteInfoProvider.GetClassSites().Column("ClassID").WhereEquals("SiteID", mSiteId)); } // Combine default where condition with external if (!String.IsNullOrEmpty(WhereCondition)) { where.Where(WhereCondition); } uniSelector.WhereCondition = where.ToString(true); if (reloadUniSelector) { uniSelector.Reload(true); } }
/// <summary> /// Creates where condition according to values selected in filter. /// </summary> private WhereCondition GenerateWhereCondition() { var where = new WhereCondition(); string productNameColumnName = (ParentNode != null) ? "DocumentName" : "SKUName"; // Append name/number condition var nameOrNumber = txtNameOrNumber.Text.Trim().Truncate(txtNameOrNumber.MaxLength); if (!string.IsNullOrEmpty(nameOrNumber)) { // condition to get also products with variants that contains where.Where(k => k.Where(w => w.WhereContains(productNameColumnName, nameOrNumber) .Or() .WhereContains("SKUNumber", nameOrNumber)) .Or() .Where(v => v.WhereIn("SKUID", new IDQuery<SKUInfo>("SKUParentSKUID").WhereContains("SKUName", nameOrNumber) .Or() .WhereContains("SKUNumber", nameOrNumber)))); } // Append site condition if (allowGlobalProducts && (siteElem.SiteID != UniSelector.US_GLOBAL_AND_SITE_RECORD)) { // Restrict SKUSiteID only for products not for product section (full listing mode) int selectedSiteID = (siteElem.SiteID > 0) ? siteElem.SiteID : 0; where.Where(w => w.Where("ISNULL(SKUSiteID, 0) = " + selectedSiteID).Or().WhereNull("SKUID")); } // Append department condition if (departmentElem.SelectedID > 0) { where.WhereEquals("SKUDepartmentID", departmentElem.SelectedID); } else if (departmentElem.SelectedID == -5) { where.WhereNull("SKUDepartmentID"); } // Append one level condition if (ParentNode != null) { if (!chkShowAllChildren.Checked) { where.WhereEquals("NodeParentID", ParentNode.NodeID).And().WhereEquals("NodeLevel", ParentNode.NodeLevel + 1); } } // Handle advanced mode fields if (IsAdvancedMode) { // Append product type condition if ((selectProductTypeElem.Value != null) && (selectProductTypeElem.Value.ToString() != "ALL")) { where.WhereEquals("SKUProductType", selectProductTypeElem.Value); } // Manufacturer value if (manufacturerElem.SelectedID != UniSelector.US_ALL_RECORDS) { where.Where("ISNULL(SKUManufacturerID, 0) = " + manufacturerElem.SelectedID); } // Supplier value if (supplierElem.SelectedID != UniSelector.US_ALL_RECORDS) { where.Where("ISNULL(SKUSupplierID, 0) = " + supplierElem.SelectedID); } // Internal status value if (internalStatusElem.SelectedID != UniSelector.US_ALL_RECORDS) { where.Where("ISNULL(SKUInternalStatusID, 0) = " + internalStatusElem.SelectedID); } // Store status value if (publicStatusElem.SelectedID != UniSelector.US_ALL_RECORDS) { where.Where("ISNULL(SKUPublicStatusID, 0) = " + publicStatusElem.SelectedID); } // Append needs shipping condition int needsShipping = ValidationHelper.GetInteger(ddlNeedsShipping.SelectedValue, -1); if (needsShipping >= 0) { where.Where("ISNULL(SKUNeedsShipping, 0) = " + needsShipping); } // Append allow for sale condition int allowForSale = ValidationHelper.GetInteger(ddlAllowForSale.SelectedValue, -1); if (allowForSale >= 0) { where.WhereEquals("SKUEnabled", allowForSale); } // When in document mode if (ParentNode != null) { int docTypeId = ValidationHelper.GetInteger(drpDocTypes.SelectedValue, 0); if (docTypeId > 0) { // Append document type condition where.WhereEquals("NodeClassID", docTypeId); } } } return where; }
/// <summary> /// Generates complete filter where condition. /// </summary> private string GenerateWhereCondition() { var whereCondition = new WhereCondition(); // Create WHERE condition for basic filter int contactStatus = ValidationHelper.GetInteger(fltContactStatus.Value, -1); if (fltContactStatus.Value == null) { whereCondition = whereCondition.WhereNull("ContactStatusID"); } else if (contactStatus > 0) { whereCondition = whereCondition.WhereEquals("ContactStatusID", contactStatus); } whereCondition = whereCondition .Where(fltFirstName.GetCondition()) .Where(fltLastName.GetCondition()) .Where(fltEmail.GetCondition()); // Only monitored contacts if (radMonitored.SelectedIndex == 1) { whereCondition = whereCondition.WhereTrue("ContactMonitored"); } // Only not monitored contacts else if (radMonitored.SelectedIndex == 2) { whereCondition = whereCondition.WhereEqualsOrNull("ContactMonitored", 0); } // Only contacts that were replicated to SalesForce leads if (radSalesForceLeadReplicationStatus.SelectedIndex == 1) { whereCondition = whereCondition.WhereNotNull("ContactSalesForceLeadID"); } // Only contacts that were not replicated to SalesForce leads else if (radSalesForceLeadReplicationStatus.SelectedIndex == 2) { whereCondition = whereCondition.WhereNull("ContactSalesForceLeadID"); } // Create WHERE condition for advanced filter (id needed) if (IsAdvancedMode) { whereCondition = whereCondition .Where(fltMiddleName.GetCondition()) .Where(fltCity.GetCondition()) .Where(fltPhone.GetCondition()) .Where(fltCreated.GetCondition()) .Where(GetOwnerCondition(fltOwner)) .Where(GetCountryCondition(fltCountry)) .Where(GetStateCondition(fltState)); if (!String.IsNullOrEmpty(txtIP.Text)) { var nestedIpQuery = IPInfoProvider.GetIps().WhereLike("IPAddress", SqlHelper.EscapeLikeText(SqlHelper.EscapeQuotes(txtIP.Text))); whereCondition = whereCondition.WhereIn("ContactID", nestedIpQuery.Column("IPOriginalContactID")).Or().WhereIn("ContactID", nestedIpQuery.Column("IPActiveContactID")); } } // When "merged/not merged" filter is hidden or in advanced mode display contacts according to filter or in basic mode don't display merged contacts if ((HideMergedFilter && NotMerged) || (IsAdvancedMode && !HideMergedFilter && !chkMerged.Checked) || (!HideMergedFilter && !NotMerged && !IsAdvancedMode)) { whereCondition = whereCondition .Where( new WhereCondition( new WhereCondition() .WhereNull("ContactMergedWithContactID") .WhereGreaterOrEquals("ContactSiteID", 0) ) .Or( new WhereCondition() .WhereNull("ContactGlobalContactID") .WhereNull("ContactSiteID") )); } // Hide contacts merged into global contact when displaying list of available contacts for global contact if (HideMergedIntoGlobal) { whereCondition = whereCondition.WhereNull("ContactGlobalContactID"); } if (!DisableGeneratingSiteClause) { // Filter by site if (!plcSite.Visible) { // Filter site objects if (SiteID > 0) { whereCondition = whereCondition.WhereEquals("ContactSiteID", SiteID); } // Filter only global objects else if (SiteID == UniSelector.US_GLOBAL_RECORD) { whereCondition = whereCondition.WhereNull("ContactSiteID"); } } // Filter by site filter else { // Only global objects if (SelectedSiteID == UniSelector.US_GLOBAL_RECORD) { whereCondition = whereCondition.WhereNull("ContactSiteID"); } // Global and site objects else if (SelectedSiteID == UniSelector.US_GLOBAL_AND_SITE_RECORD) { whereCondition = whereCondition.WhereEqualsOrNull("ContactSiteID", SiteContext.CurrentSiteID); } // Site objects else if (SelectedSiteID != UniSelector.US_ALL_RECORDS) { whereCondition = whereCondition.WhereEquals("ContactSiteID", mSelectedSiteID); } } } return whereCondition.ToString(true); }
/// <summary> /// Returns SQL WHERE condition depending on selected checkboxes. /// </summary> /// <returns>Returns SQL WHERE condition</returns> public string GetWhereCondition() { var where = new WhereCondition(); // Contacts checked if (chkContacts.Checked) { where.Where(GetContactWhereCondition()); } // Address checked if (chkAddress.Checked) { where.Where(GetAddressWhereCondition()); } // Email address checked if (chkEmail.Checked) { string domain = ContactHelper.GetEmailDomain(CurrentAccount.AccountEmail); if (!String.IsNullOrEmpty(domain)) { var emailWhere = new WhereCondition().WhereEndsWith("AccountEmail", "@" + domain); where.Where(emailWhere); } } // URL checked if (chkURL.Checked && !String.IsNullOrEmpty(CurrentAccount.AccountWebSite)) { var urlWhere = new WhereCondition().WhereContains("AccountWebSite", URLHelper.CorrectDomainName(CurrentAccount.AccountWebSite)); where.Where(urlWhere); } // Phone & fax checked if (chkPhone.Checked && (!String.IsNullOrEmpty(CurrentAccount.AccountPhone) || !String.IsNullOrEmpty(CurrentAccount.AccountFax))) { where.Where(GetPhoneWhereCondition()); } if ((!chkContacts.Checked && !chkAddress.Checked && !chkEmail.Checked && !chkURL.Checked && !chkPhone.Checked) || (String.IsNullOrEmpty(where.WhereCondition))) { return "(1 = 0)"; } // Filter out current account where.WhereNotEquals("AccountID", CurrentAccount.AccountID); // Filter out merged records where.Where(w => w.Where(x => x.WhereNull("AccountMergedWithAccountID") .WhereNull("AccountGlobalAccountID") .WhereGreaterThan("AccountSiteID", 0)) .Or(y => y.WhereNull("AccountGlobalAccountID") .WhereNull("AccountSiteID"))); // For global object use siteselector's value if (plcSite.Visible) { mSelectedSiteID = UniSelector.US_ALL_RECORDS; if (siteSelector.Visible) { mSelectedSiteID = siteSelector.SiteID; } else if (siteOrGlobalSelector.Visible) { mSelectedSiteID = siteOrGlobalSelector.SiteID; } // Only global objects if (mSelectedSiteID == UniSelector.US_GLOBAL_RECORD) { where.WhereNull("AccountSiteID"); } // Global and site objects else if (mSelectedSiteID == UniSelector.US_GLOBAL_AND_SITE_RECORD) { where.Where(w => w.WhereNull("AccountSiteID").Or().WhereEquals("AccountSiteID", SiteContext.CurrentSiteID)); } // Site objects else if (mSelectedSiteID != UniSelector.US_ALL_RECORDS) { where.WhereEquals("AccountSiteID", mSelectedSiteID); } } // Filter out accounts from different sites else { // Site accounts only if (CurrentAccount.AccountSiteID > 0) { where.WhereEquals("AccountSiteID", CurrentAccount.AccountSiteID); } // Global accounts only else { where.WhereNull("AccountSiteID"); } } return where.ToString(expand: true); }
/// <summary> /// Deletes activities. /// </summary> private void Delete(object parameter) { var whereCondition = new WhereCondition(WhereCondition); try { var restrictedSitesCondition = CheckSitePermissions(whereCondition); DeleteActivities(whereCondition.Where(restrictedSitesCondition)); } catch (ThreadAbortException ex) { string state = ValidationHelper.GetString(ex.ExceptionState, string.Empty); if (state != CMSThread.ABORT_REASON_STOP) { LogExceptionToEventLog(ex); } } catch (Exception ex) { LogExceptionToEventLog(ex); } }
/// <summary> /// Creates WHERE condition for VersionObjectSiteID column. /// </summary> private WhereCondition GetVersionObjectSiteIDWhereCondition() { var where = new WhereCondition(); if (IsSingleSite || (SiteName == "##global##")) { where.Where("VersionObjectSiteID", QueryUnaryOperator.IsNull); } if (CurrentSite != null) { where.Or().Where("VersionObjectSiteID", QueryOperator.Equals, CurrentSite.SiteID); } return where; }
/// <summary> /// Creates default where condition for product documents listing. /// </summary> private WhereCondition GetDocumentWhereCondition() { var where = new WhereCondition().WhereNotNull("NodeSKUID"); if (ShowSections) { where.Or().WhereIn("NodeClassID", new IDQuery<DataClassInfo>("ClassID").WhereTrue("ClassIsProductSection")); } // Prepare site condition var siteWhere = new WhereCondition().WhereEquals("SKUSiteID", SiteContext.CurrentSiteID); if (AllowGlobalObjects) { siteWhere.Or().WhereNull("SKUSiteID"); } else if (ShowSections) { siteWhere.Or().Where(w => w.WhereNull("SKUSiteID").And().WhereNull("SKUID")); } // Combine where conditions where.Where(siteWhere); if (docList.Node != null) { string path = docList.Node.NodeAliasPath ?? ""; where.WhereStartsWith("NodeAliasPath", path); } return where; }
/// <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 = Representing.ToEnum<SKUProductTypeEnum>(); string productTypeString = productTypeEnum.ToStringRepresentation(); where.WhereEquals("SKUProductType", productTypeString); } // Product number filter if (!string.IsNullOrEmpty(ProductNumber)) { where.WhereContains("SKUNumber", ProductNumber); } // Department filter DepartmentInfo di = DepartmentInfoProvider.GetDepartmentInfo(Department, CurrentSiteName); di = di ?? DepartmentInfoProvider.GetDepartmentInfo(Department, null); if (di != null) { where.Where(GetColumnWhereCondition("SKUDepartmentID", new WhereCondition().WhereEquals("SKUDepartmentID", di.DepartmentID))); } // Manufacturer filter ManufacturerInfo mi = ManufacturerInfoProvider.GetManufacturerInfo(Manufacturer, CurrentSiteName); mi = mi ?? ManufacturerInfoProvider.GetManufacturerInfo(Manufacturer, null); if (mi != null) { where.Where(GetColumnWhereCondition("SKUManufacturerID", new WhereCondition().WhereEquals("SKUManufacturerID", mi.ManufacturerID))); } // 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 = PublicStatusInfoProvider.GetPublicStatusInfo(PublicStatus, CurrentSiteName); if (psi != null) { where.Where(GetColumnWhereCondition("SKUPublicStatusID", new WhereCondition().WhereEquals("SKUPublicStatusID", psi.PublicStatusID))); } // Internal status filter InternalStatusInfo isi = InternalStatusInfoProvider.GetInternalStatusInfo(InternalStatus, 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; }
/// <summary> /// Generates WHERE condition. /// </summary> private WhereCondition GenerateWhereCondition() { var where = new WhereCondition(); string name = txtName.Text; if (String.IsNullOrEmpty(name)) { return where; } // Get filter operator (LIKE, NOT LIKE, =, !=) switch (filter.SelectedValue) { default: where.Where(w => w.WhereContains("CategoryDisplayName", name).Or().WhereContains("CategoryLiveSiteDisplayName", name)); break; case WhereBuilder.EQUAL: where.Where(w => w.WhereEquals("CategoryDisplayName", name).Or().WhereEquals("CategoryLiveSiteDisplayName", name)); break; case WhereBuilder.NOT_LIKE: where.Where(w => w.WhereNotContains("CategoryDisplayName", name).Or().WhereNull("CategoryDisplayName")) .And() .Where(w => w.WhereNotContains("CategoryLiveSiteDisplayName", name).Or().WhereNull("CategoryLiveSiteDisplayName")); break; case WhereBuilder.NOT_EQUAL: where.Where(w => w.WhereNotEquals("CategoryDisplayName", name).Or().WhereNull("CategoryDisplayName")) .And() .Where(w => w.WhereNotEquals("CategoryLiveSiteDisplayName", name).Or().WhereNull("CategoryLiveSiteDisplayName")); break; } return where; }
/// <summary> /// PageLoad event handler. /// </summary> protected void Page_Load(object sender, EventArgs e) { if (StopProcessing) { UniGridRelationship.StopProcessing = StopProcessing; } else { // Set tree node from Form object if ((TreeNode == null) && (Form != null) && (Form.EditedObject != null)) { TreeNode node = Form.EditedObject as TreeNode; if ((node != null) && (Form.Mode == FormModeEnum.Update)) { TreeNode = node; } else { ShowError(GetString("relationship.editdocumenterror")); } } if (TreeNode != null) { // Set unigrid UniGridRelationship.OnExternalDataBound += UniGridRelationship_OnExternalDataBound; UniGridRelationship.OnBeforeDataReload += UniGridRelationship_OnBeforeDataReload; UniGridRelationship.OnAction += UniGridRelationship_OnAction; UniGridRelationship.ZeroRowsText = GetString("relationship.nodatafound"); UniGridRelationship.ShowActionsMenu = !IsLiveSite; int nodeId = TreeNode.NodeID; bool oneRelationshipName = !string.IsNullOrEmpty(RelationshipName); WhereCondition condition = new WhereCondition(); if (oneRelationshipName) { condition.WhereIn("RelationshipNameID", new IDQuery<RelationshipNameInfo>().WhereEquals("RelationshipName", RelationshipName)); } // Switch sides is disabled if (!AllowSwitchSides) { condition.WhereEquals(DefaultSide ? "RightNodeID" : "LeftNodeID", nodeId); } else { condition.Where(new WhereCondition().WhereEquals("RightNodeID", nodeId).Or().WhereEquals("LeftNodeID", nodeId)); } UniGridRelationship.WhereCondition = condition.ToString(true); if (ShowAddRelation) { btnNewRelationship.OnClientClick = GetAddRelatedDocumentScript() + " return false;"; } else { pnlNewLink.Visible = false; } } else { UniGridRelationship.StopProcessing = true; UniGridRelationship.Visible = false; pnlNewLink.Visible = false; } if (RequestHelper.IsPostBack()) { string target = Request[Page.postEventSourceID]; if ((target == pnlUpdate.ClientID) || (target == pnlUpdate.UniqueID)) { string action = Request[Page.postEventArgumentID]; if (!string.IsNullOrEmpty(action)) { switch (action.ToLowerCSafe()) { // Insert from 'Select document' dialog case "insertfromselectdocument": SaveRelationship(); break; } } } } else { bool inserted = QueryHelper.GetBoolean("inserted", false); if (inserted) { ShowConfirmation(GetString("relationship.wasadded")); } } } }
/// <summary> /// Returns complete WHERE condition. /// </summary> protected WhereCondition GetCompleteWhereCondition() { string allRecords = UniSelector.US_ALL_RECORDS.ToString(); string customWhere = ValidationHelper.GetString(GetValue("WhereCondition"), ""); var where = new WhereCondition(); // Do not select product options and select only enabled products where.WhereNull("SKUOptionCategoryID").And().WhereTrue("SKUEnabled"); // Get products only with specified public status if (ProductPublicStatusName != allRecords) { int pStatusSiteID = ECommerceSettings.UseGlobalPublicStatus(SiteName) ? 0 : SiteInfoProvider.GetSiteID(SiteName); where.WhereEquals("SKUPublicStatusID", new IDQuery<PublicStatusInfo>("PublicStatusID").Where("ISNULL(PublicStatusSiteID, 0) = " + pStatusSiteID).And().WhereEquals("PublicStatusName", ProductPublicStatusName).TopN(1)); } // Get products only with specified internal status if (ProductInternalStatusName != allRecords) { int iStatusSiteID = ECommerceSettings.UseGlobalInternalStatus(SiteName) ? 0 : SiteInfoProvider.GetSiteID(SiteName); where.WhereEquals("SKUInternalStatusID", new IDQuery<InternalStatusInfo>("InternalStatusID").Where("ISNULL(InternalStatusSiteID, 0) = " + iStatusSiteID).And().WhereEquals("InternalStatusName", ProductInternalStatusName).TopN(1)); } // Get products only from specified department if (!string.IsNullOrEmpty(ProductDepartmentName) && (ProductDepartmentName != allRecords)) { DepartmentInfo dept = DepartmentInfoProvider.GetDepartmentInfo(ProductDepartmentName, SiteName); int departmentID = (dept != null) ? dept.DepartmentID : 0; where.WhereEquals("SKUDepartmentID", departmentID); } // Include user custom WHERE condition if (customWhere.Trim() != "") { where.Where(customWhere); } return where; }
private string GetWhereCondition() { var where = new WhereCondition(); // Display name/Code name string displayName = txtClassDisplayName.Text.Trim(); if (!String.IsNullOrEmpty(displayName)) { where .Where(w => w.WhereContains("ClassDisplayName", displayName) .Or() .WhereContains("ClassName", displayName)); } // Table name string tableName = txtClassTableName.Text.Trim(); if (!String.IsNullOrEmpty(tableName)) { where .WhereContains("ClassTableName", tableName); } return where.ToString(true); }