Ejemplo n.º 1
0
    /// <summary>
    /// Returns where condition.
    /// </summary>
    /// <param name="customWhere">Custom WHERE condition</param>
    private string GetWhereCondition(string customWhere)
    {
        SiteInfo si = null;

        // Get required site data
        if (SiteName != "")
        {
            si = SiteInfoProvider.GetSiteInfo(SiteName);
        }
        else
        {
            si = SiteContext.CurrentSite;
        }

        if (si != null)
        {
            // Build where condition
            string where = "SELECT OrderItemSKUID FROM COM_OrderItem JOIN COM_SKU ON COM_OrderItem.OrderItemSKUID = COM_SKU.SKUID JOIN COM_Order ON COM_OrderItem.OrderItemOrderID = COM_Order.OrderID WHERE (COM_SKU.SKUEnabled = 1) AND (COM_SKU.SKUOptionCategoryID IS NULL) AND (COM_Order.OrderSiteID = " + si.SiteID + ")";

            // Get documents of the specified class only - without coupled data !!!
            if (ClassNames != "")
            {
                int    i         = 0;
                string tempWhere = "";

                string[] classNames = ClassNames.Trim(';').Split(';');
                foreach (string className in classNames)
                {
                    if (i > 0)
                    {
                        tempWhere += " OR ";
                    }
                    tempWhere += "(ClassName = '" + SqlHelper.GetSafeQueryString(className, false) + "')";

                    i++;
                }

                if (tempWhere != "")
                {
                    where += " AND (" + tempWhere + ")";
                }
            }

            where = "NodeSKUID IN (" + where + ")";

            // Add custom WHERE condition
            if (customWhere != "")
            {
                where += " AND (" + customWhere + ")";
            }

            return(where);
        }
        return("");
    }
    /// <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);
    }