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; }
public static StyleEntity GetManualEntry() { var sePopulator = new StyleEntityPopulator(); var restrainedStyleTypes = sePopulator.restrainedStyleTypes; var restrainedStyleCategories = sePopulator.restrainedStyleCategories; var lookups = StyleManager.GetLookups(true); var linelistslookups = LineListManager.GetLookups (true); var styleTypes = new List<string> (); var styleCategories = new List<string> (); var sizeClasses = new List<string> (); var sizeRanges = new List<string> (); var workflowTypes = new List<string> (); var styleEntity = new StyleEntity (); foreach (var lookup in linelistslookups) { if (lookup.LookupTable == "styletype") { sePopulator.PopulateManualEntry (lookup.key, lookup.value, styleEntity.DictStyleTypeID, styleTypes, restrainedStyleTypes); //sePopulator.CheckPopulation (styleTypes); } } foreach (var lookup in lookups) { // if (lookup.LookupTable == "styletype") { // sePopulator.PopulateManualEntry (lookup.key, lookup.value, styleEntity.DictStyleTypeID, styleTypes, restrainedStyleTypes); // //sePopulator.CheckPopulation (styleTypes); // } if (lookup.LookupTable == "stylecategory") { sePopulator.PopulateManualEntry (lookup.key, lookup.value, styleEntity.DictStyleCategoryID, styleCategories, restrainedStyleCategories); sePopulator.CheckPopulation (styleCategories); } if (lookup.LookupTable == "sizeclass") sizeClasses.Add (lookup.value); if (lookup.LookupTable == "sizerange") sizeRanges.Add (lookup.value); if (lookup.LookupTable == "workflowtype") { sePopulator.PopulateManualEntry (lookup.key, lookup.value, styleEntity.DictWorkflowTypeID, workflowTypes); } } styleEntity.StyleTypeItems = styleTypes.Distinct().ToArray(); styleEntity.StyleCategoryItems = styleCategories.Distinct().ToArray(); styleEntity.SizeClassItems = sizeClasses; styleEntity.SizeRangeItems = sizeRanges; styleEntity.WorkflowTypeItems = workflowTypes.Distinct().ToArray(); return styleEntity; }