public static void Save(XmlImportIngredient ingredient, string menuitemguid, string menuitemname)
        {
            var db = new Database("RedRobin");

            var records = db.Fetch<XmlIngredientsXref>(" where xmlguid=@0 and xmlmenuitemguid=@1", ingredient.ItemIngredientGuid, menuitemguid);

            if (records.Count >= 1) return;
            var insert = new XmlIngredientsXref();
            insert.xmlguid = new Guid(ingredient.ItemIngredientGuid);
            insert.xmlingredientname = ingredient.ItemIngredientName;
            insert.xmlmenuitemguid = new Guid(menuitemguid);
            insert.xmlmenuitemname = menuitemname;
            insert.Save();
        }
Esempio n. 2
0
        public static void Save(XmlImportIngredient ingredient, string menuitemguid, string menuitemname)
        {
            var db = new Database("RedRobin");

            var records = db.Fetch <XmlIngredientsXref>(" where xmlguid=@0 and xmlmenuitemguid=@1", ingredient.ItemIngredientGuid, menuitemguid);

            if (records.Count >= 1)
            {
                return;
            }
            var insert = new XmlIngredientsXref();

            insert.xmlguid           = new Guid(ingredient.ItemIngredientGuid);
            insert.xmlingredientname = ingredient.ItemIngredientName;
            insert.xmlmenuitemguid   = new Guid(menuitemguid);
            insert.xmlmenuitemname   = menuitemname;
            insert.Save();
        }
Esempio n. 3
0
        private static void MatchNewXmlToOldImport()
        {
            Console.WriteLine("starting");
            try
            {
                var xmlitems = XmlService.ParseXml(@"C:\root\dev\Spring Menu XML for Customizer 2.29.2012.xml");


                var db = new PetaPoco.Database("RedRobin");
                foreach (XmlMenuItem xmlMenuItem in xmlitems) //foreach item in the xml
                {
                    var mxr = new XmlMenuItemsXref();
                    mxr.xmlguid     = new Guid(xmlMenuItem.ItemGuid);
                    mxr.xmlitemname = xmlMenuItem.ItemName;
                    Console.WriteLine("Xml Item: " + xmlMenuItem.ItemName);

                    var importmenuitem = GetMenuItemByName(xmlMenuItem.ItemName); //get the previous import item

                    if (importmenuitem != null)                                   // new in xml or can't find mapping by name
                    {
                        MenuItem menuitem = null;
                        try
                        {
                            menuitem = db.Fetch <MenuItem>("select * from menuitems where DataObjectId=@0", importmenuitem.ItemGuid).SingleOrDefault();
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }

                        if (menuitem != null) // means the xmlimport and the database do not match
                        {
                            Console.WriteLine("Menu Item: " + menuitem.name);

                            mxr.menuitemguid = menuitem.DataObjectId;
                            mxr.menuitemname = menuitem.name;
                        }
                    }

                    mxr.Insert();

                    foreach (var xmlIngredient in xmlMenuItem.Ingredients)
                    {
                        Console.WriteLine("Xml Ingredient Item: " + xmlIngredient.ItemIngredientName);

                        var ixr = new XmlIngredientsXref();
                        ixr.xmlguid           = new Guid(xmlIngredient.ItemIngredientGuid);
                        ixr.xmlingredientname = xmlIngredient.ItemIngredientName;

                        if (importmenuitem != null)
                        {
                            var db2 = new PetaPoco.Database("RedRobin");

                            var importingredientitem = GetIngredients(xmlIngredient.ItemIngredientName, importmenuitem.XmlImportMenuItemId); //get xml import ingredient
                            if (importingredientitem != null)                                                                                //mean couldn't find this ingredient, deal with later
                            {
                                Ingredient ingredientitem = null;
                                try
                                {
                                    ingredientitem = db2.Fetch <Ingredient>("select * from ingredients where DataObjectId=@0", importingredientitem.ItemIngredientGuid).SingleOrDefault();
                                }
                                catch (Exception exception)
                                {
                                    Console.WriteLine(exception);
                                }

                                if (ingredientitem != null) //means no match in database
                                {
                                    ixr.igredientname   = ingredientitem.managename;
                                    ixr.ingredientsguid = ingredientitem.DataObjectId;
                                }
                            }
                        }

                        ixr.xmlmenuitemguid = new Guid(xmlMenuItem.ItemGuid);
                        ixr.xmlmenuitemname = xmlMenuItem.ItemName;
                        ixr.Insert();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.WriteLine("Press any key to exit");
            Console.ReadLine();
        }