public static List<StyleEntity> GetQuickFills(QuickFillCore quickFillCore) { var styleEntities = new List<StyleEntity> (); var quickFillElements = quickFillCore.QuickFillEntity.Elements; var quickFillNames = quickFillCore.QuickFillNames; /* * It's used for correct retrievment of styleType and styleCategory values. * The problem is that by default the subheader contains the 'id' of the style * and not the actual value. We fetch all available LineLists and then retrieve * the actual value of styleType and styleCategory with LookupManager.GetLookupValueByKey() */ var lists = LineListManager.GetRemoteLineLists(""); var listsLookups = lists.lookups; var workflowLookups = StyleManager.GetLookups (true); //Console.WriteLine ("QuickFills: " + quickFillElements.Count); for (int i = 0; i < quickFillElements.Count; i++) { //Console.WriteLine ("Element #" + i); //Console.WriteLine ("Element name " + quickFillNames[i]); var styleEntity = new StyleEntity (); styleEntity.Name = quickFillNames [i]; foreach (var item in quickFillElements[i]) { //Console.WriteLine ("Heading: {0} SubHeading: {1}", item.Key, item.Value); var heading = item.Key; if (heading == "StyleType") { var styleTypeID = item.Value; var styleTypeValue = LookupManager.GetLookupValueByKey (listsLookups, "styletype", styleTypeID); if(!styleEntity.DictStyleTypeID.ContainsKey(styleTypeValue)) styleEntity.DictStyleTypeID.Add (styleTypeValue, styleTypeID); //styleEntity.StyleTypeID = styleTypeID; styleEntity.StyleTypeItems = new [] { styleTypeValue }; } if (heading == "StyleCategory") { var styleCategoryID = item.Value; var styleCategoryValue = LookupManager.GetLookupValueByKey (listsLookups, "stylecategory", styleCategoryID); if(!styleEntity.DictStyleCategoryID.ContainsKey(styleCategoryValue)) styleEntity.DictStyleCategoryID.Add (styleCategoryValue, styleCategoryID); styleEntity.StyleCategoryItems = new [] { styleCategoryValue }; } if (heading == "SizeClass") styleEntity.SizeClassItems = new [] { item.Value }; if (heading == "SizeRange") styleEntity.SizeRangeItems = new [] { item.Value }; if (heading == "Description") styleEntity.Description = item.Value; if (heading == "WorkflowType") { var workflowTypeID = item.Value; var workflowTypeValue = LookupManager.GetLookupValueByKey(workflowLookups, "styleworkflowid", workflowTypeID); if(!styleEntity.DictWorkflowTypeID.ContainsKey(workflowTypeValue)) styleEntity.DictWorkflowTypeID.Add (workflowTypeValue, workflowTypeID); styleEntity.WorkflowTypeItems = new [] { workflowTypeValue }; } } styleEntities.Add (styleEntity); } Console.WriteLine ("Style Ents: " + styleEntities.Count); return styleEntities; }
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; }