// Used in a callback to RootElement, when transitioning to a new window
        private DialogViewController GetCreateStyle(StyleEntity styleEntity)
        {
            var root = styleEntity.Root();
            var dialog = new DialogViewController (root);

            EventHandler backButtonHandler = (s, a) => {
                this.PopToRootViewController (true);
                // Reset indexes when hit "Back" button. Otherwise will be exception because of the indexes
                StyleEntity.ResetIndexes ();
            };
            EventHandler createButtonHandler = (s, a) => HandleCreateNewStyleEvent(styleEntity);

            dialog.NavigationItem.SetLeftBarButtonItem (new UIBarButtonItem ("Back", UIBarButtonItemStyle.Bordered, backButtonHandler), true);
            dialog.NavigationItem.SetRightBarButtonItem (new UIBarButtonItem ("Create", UIBarButtonItemStyle.Bordered, createButtonHandler), true);

            return dialog;
        }
        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 StyleEntity GetManualEntry()
        {
            var lookups = StyleManager.GetLookups (true);

            //lookups.ForEach (l => Console.WriteLine (l.LookupTable + " " + l.value + " " + l.key));

            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 lookups) {
                if (lookup.LookupTable == "styletype")
                {
                    if(!styleEntity.DictStyleTypeID.ContainsKey(lookup.value))
                        styleEntity.DictStyleTypeID.Add (lookup.value, lookup.key);

                    styleTypes.Add (lookup.value);
                }
                if (lookup.LookupTable == "stylecategory")
                {
                    if(!styleEntity.DictStyleCategoryID.ContainsKey(lookup.value))
                        styleEntity.DictStyleCategoryID.Add (lookup.value, lookup.key);

                    styleCategories.Add (lookup.value);
                }
                if (lookup.LookupTable == "sizeclass")
                    sizeClasses.Add (lookup.value);
                if (lookup.LookupTable == "sizerange")
                    sizeRanges.Add (lookup.value);
                if (lookup.LookupTable == "workflowtype")
                {
                    if(!styleEntity.DictWorkflowTypeID.ContainsKey(lookup.value))
                        styleEntity.DictWorkflowTypeID.Add (lookup.value, lookup.key);

                    workflowTypes.Add (lookup.value);
                }
            }

            styleEntity.StyleTypeItems = styleTypes.Distinct().ToArray();
            styleEntity.StyleCategoryItems = styleCategories.Distinct().ToArray();
            styleEntity.SizeClassItems = sizeClasses;
            styleEntity.SizeRangeItems = sizeRanges;
            styleEntity.WorkflowTypeItems = workflowTypes.Distinct().ToArray();

            return styleEntity;
        }
        public static List<StyleEntity> GetDummies()
        {
            var womenTopsStyle = new StyleEntity {
                Name = "Women Tops",
                StyleTypeItems = new[] { "Apparel", "Stuff", "Other" },
                StyleCategoryItems = new[] { "Outerwear", "Hat" },
                SizeClassItems = new[] { "Men", "Women", "Another"},
                SizeRangeItems = new[] { "XS - XL", "XS - XLL"},
                Description    = "Women's Suit Jacket"
            };

            var womenOuterwearStyle = new StyleEntity {
                Name = "Women Outerwear",
                StyleTypeItems = new[] { "Apparel2", "Stuff2", "Other" },
                StyleCategoryItems = new[] { "Outerwear", "Hat", "Sweater" },
                SizeClassItems = new[] { "Men2", "Women", "Another"},
                SizeRangeItems = new[] { "XS - XL", "XS - XLL"},
                Description    = "Women's Outerwear Jacket"
            };

            var womenSweaterStyle = new StyleEntity {
                Name = "Women Sweater",
                StyleTypeItems = new[] { "SomeStuff", "Other" },
                StyleCategoryItems = new[] { "Outerwear", "Hat", "Sweater" },
                SizeClassItems = new[] { "Men2", "Women", "Another"},
                SizeRangeItems = new[] { "XS - XL", "XS - XLL"},
                Description    = "Women's Sweater"
            };

            var emptyStyle = new StyleEntity {
                NumberOfStylesItems = new [] { String.Empty },
                StyleTypeItems = new [] { String.Empty },
                StyleCategoryItems = new [] { String.Empty },
                SizeClassItems = new [] { String.Empty },
                SizeRangeItems = new [] { String.Empty },
                Description = String.Empty
            };

            //var womenTops = new RootElement ("Womens Tops", re => GetCreateStyle (womenTopsStyle));
            return new List<StyleEntity> { womenTopsStyle, womenOuterwearStyle, womenSweaterStyle, emptyStyle };
        }
 public StyleEntityEventArgs(StyleEntity styleEntity)
 {
     _styleEntity = styleEntity;
 }
        private void HandleCreateNewStyleEvent(StyleEntity styleEntity)
        {
            var handler = this.Created;

            if (handler != null)
                handler (this, new StyleEntityEventArgs(styleEntity));
        }
Example #7
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;
        }
Example #8
0
        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;
        }