Exemple #1
0
        public static List<StyleEntity> GetQuickFills(QuickFillCore quickFillCore)
        {
            var styleEntities = new List<StyleEntity> ();

            var quickFillElements = quickFillCore.QuickFillEntity.Elements;
            var quickFillNames = quickFillCore.QuickFillNames;

            var sePopulator = new StyleEntityPopulator();
            IList<string> restrainedStyleTypes = sePopulator.restrainedStyleTypes;
            IList<string> restrainedStyleCategories = sePopulator.restrainedStyleCategories;
            /*
             * It's used for correct retrievement of styleType, styleCategory and styleworkflowid values.
             * The problem is that by default the subheader contains the 'id' of the style
             * and not the actual value. We fetch all style lookups and then retrieve
             * the actual value of styleType, styleCategory and styleworkflowid with LookupManager.GetLookupValueByKey()
            */
            var styleLookups = StyleManager.GetLookups (true);
            //var divisionID = LineListStyleTabScreen.Item.json["LineFolderDivisionID"].ToString();
            //Console.WriteLine (divisionID);
            //var t = styleLookups.Where (l => l.value2 == divisionID).ToList ();//.ForEach (l => Console.WriteLine (l.LookupTable + " " + l.value + " " + l.value2));
            styleLookups.ForEach (sl => Console.WriteLine (!string.IsNullOrEmpty(sl.value2) ? sl.LookupTable + " " + sl.key + " " + sl.value + " " + sl.value2 : " "));
            //Console.WriteLine (t.Count);

            for (int i = 0; i < quickFillElements.Count; i++) {
                var styleEntity = new StyleEntity ();
                styleEntity.Name = quickFillNames [i];

                styleEntity.InitItemsWithList ();

                foreach (var item in quickFillElements[i])
                {
                    var heading = item.Key;

                    if (heading == "StyleType")
                    {
                        var styleTypeID = item.Value;

                        sePopulator.PopulateInitialQuickFill (styleTypeID, styleLookups, "styletype", styleEntity.DictStyleTypeID, styleEntity.StyleTypeItems, restrainedStyleTypes);
                        sePopulator.PopulateAdditionalQuickFill (styleLookups, "styletype", styleEntity.DictStyleTypeID, styleEntity.StyleTypeItems, restrainedStyleTypes);
                        sePopulator.CheckPopulation (styleEntity.StyleTypeItems);
                    }
                    if (heading == "StyleCategory")
                    {
                        var styleCategoryID = item.Value;

                        sePopulator.PopulateInitialQuickFill (styleCategoryID, styleLookups, "stylecategory", styleEntity.DictStyleCategoryID, styleEntity.StyleCategoryItems, restrainedStyleCategories);
                        sePopulator.PopulateAdditionalQuickFill (styleLookups, "stylecategory", styleEntity.DictStyleCategoryID, styleEntity.StyleCategoryItems, restrainedStyleCategories);
                        sePopulator.CheckPopulation (styleEntity.StyleCategoryItems);
                    }
                    if (heading == "SizeClass")
                    {
                        // Instead of PopulateInitialQuickFill, because we don't need ids
                        styleEntity.SizeClassItems.Add(item.Value);

                        // Pass null if you don't need ids
                        sePopulator.PopulateAdditionalQuickFill (styleLookups, "sizeclass", null, styleEntity.SizeClassItems);
                    }
                    if (heading == "SizeRange")
                    {
                        styleEntity.SizeRangeItems.Add(item.Value);

                        sePopulator.PopulateAdditionalQuickFill (styleLookups, "sizerange", null, styleEntity.SizeRangeItems);
                    }
                    if (heading == "WorkflowType")
                    {
                        var workflowTypeID = item.Value;
                        sePopulator.PopulateInitialQuickFill (workflowTypeID, styleLookups, "styleworkflowid", styleEntity.DictWorkflowTypeID, styleEntity.WorkflowTypeItems);
                        sePopulator.PopulateAdditionalQuickFill (styleLookups, "styleworkflowid", styleEntity.DictWorkflowTypeID, styleEntity.WorkflowTypeItems);
                    }
                    if (heading == "Description") {
                        styleEntity.Description = item.Value;
                    }
                }

                styleEntities.Add (styleEntity);
            }

            return styleEntities;
        }