Пример #1
0
        public void Write(string categoryTitle, int categoryWeight, int selectedScore, decimal categoryScore)
        {
            CategoryTitle.Write(categoryTitle);
            CategoryWeight.Write(categoryWeight.ToString());
            RunFonts runFonts1 = new RunFonts {
                Ascii = "Wingdings"
            };
            RunProperties runProperties1 = new RunProperties();

            runProperties1.Append(runFonts1);
            switch (selectedScore)
            {
            case 1:
                CategoryRating1.Write("\u2713", true, runProperties1);
                break;

            case 2:
                CategoryRating2.Write("\u2713", true, runProperties1);
                break;

            case 3:
                CategoryRating3.Write("\u2713", true, runProperties1);
                break;

            case 4:
                CategoryRating4.Write("\u2713", true, runProperties1);
                break;

            default:
                CategoryRating0.Write("\u2713", true, runProperties1);
                break;
            }
            CategoryTotal.Write(categoryScore.ToString());
        }
        public ProductPriceWeight SelectGuideParaByType(string firstType, string secondType, string thirdType)
        {
            var priceWeight           = DalBaoYangPriceGuide.SelectAllWeight();
            var baseValue             = priceWeight.FirstOrDefault(p => p.WeightType.Equals("Base"));
            ProductPriceWeight result = new ProductPriceWeight
            {
                CategoryWeights = new Dictionary <string, List <CategoryWeight> >(),
                BaseWeight      = Tuple.Create(baseValue?.PKID, (int)(baseValue?.WeightValue ?? 0))
            };

            try
            {
                var data = DalBaoYangPriceGuide.SelectGuideParaByType(firstType, secondType, thirdType);
                if (data != null && data.Rows.Count > 0)
                {
                    var dic = data.AsEnumerable()
                              .GroupBy(p => (int)p["ParentOid"])
                              .ToDictionary(t => t.Key, o => o.Select(p => p));
                    foreach (var keyValue in dic)
                    {
                        List <CategoryWeight> categorys = new List <CategoryWeight>();
                        var parentNode = DalBaoYangPriceGuide.SelectProductCategoryByOid(keyValue.Key);
                        foreach (var node in keyValue.Value)
                        {
                            var currentCategory =
                                categorys.FirstOrDefault(p => p.WeightName.Equals(node["Link"].ToString()));
                            var categoryWeight = priceWeight.FirstOrDefault(
                                p => p.WeightType.Equals("Category") &&
                                p.WeightName.Equals(node["Link"].ToString()));
                            if (currentCategory == null)
                            {
                                CategoryWeight category = new CategoryWeight
                                {
                                    Pkid        = categoryWeight?.PKID,
                                    WeightName  = node["Link"].ToString(),
                                    DisplayName = node["Item"].ToString(),
                                    WeightValue = (int)(categoryWeight?.WeightValue ?? 0),
                                };
                                if (!string.IsNullOrWhiteSpace(node["CP_Brand"].ToString()))
                                {
                                    var brand = priceWeight.FirstOrDefault(
                                        p => p.WeightType.Equals("Brand") &&
                                        p.WeightName.Equals(node["CP_Brand"].ToString()) &&
                                        p.CategoryName.Equals(node["Link"].ToString()));
                                    category.Brands = new List <BrandWeight>
                                    {
                                        new BrandWeight
                                        {
                                            Pkid        = brand?.PKID,
                                            WeightName  = node["CP_Brand"].ToString(),
                                            WeightValue = (int)(brand?.WeightValue ?? 0)
                                        }
                                    };
                                }
                                categorys.Add(category);
                            }
                            else
                            {
                                if (!string.IsNullOrWhiteSpace(node["CP_Brand"].ToString()))
                                {
                                    var brand = priceWeight.FirstOrDefault(
                                        p => p.WeightType.Equals("Brand") &&
                                        p.WeightName.Equals(node["CP_Brand"].ToString()) &&
                                        p.CategoryName.Equals(node["Link"].ToString()));
                                    if (currentCategory.Brands == null)
                                    {
                                        currentCategory.Brands = new List <BrandWeight>();
                                    }
                                    currentCategory.Brands.Add(new BrandWeight
                                    {
                                        Pkid        = brand?.PKID,
                                        WeightName  = node["CP_Brand"].ToString(),
                                        WeightValue = (int)(brand?.WeightValue ?? 0)
                                    });
                                }
                            }
                        }
                        result.CategoryWeights[parentNode.Item2] = categorys;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(Level.Error, ex, "SelectGuideParaByType");
            }
            return(result);
        }