Esempio n. 1
0
 public static void Update(List <dtoProductShelf> updateProductShelves, int codeShop)
 {
     try
     {
         GeneralDB           dB = new GeneralDB();
         List <ProductShelf> productShelves2 = dB.MyDb.ProductShelves.Where(x => x.Shelf.Stand.CodeShop == codeShop).ToList();
         //List<ProductShelf> productShelves2 = dB.MyDb.ProductShelves.ToList();
         // var v = updateProductShelves.Select(p => productShelves2.Where(x => x.CodeProduct == p.CodeProduct ).ToList()).ToList();
         // v.ForEach(x => productShelves2.AddRange(x));
         foreach (var updateItem in updateProductShelves)
         {
             var item = productShelves2.Where(x => x.CodeProduct == updateItem.CodeProduct).FirstOrDefault();
             if (item != null)
             {
                 item.CodeShelf = updateItem.CodeShelf;
             }
         }
         //productShelves2.ForEach(p => p.CodeShelf= updateProductShelves.Where(x => x.CodeProduct == p.CodeProduct && x.CodeShelf == p.CodeShelf).ToList().First().CodeShelf );
         dB.MyDb.SaveChanges();
     }
     catch (Exception e)
     {
         MessageBox.Show("problem cas update");
     }
 }
Esempio n. 2
0
        public static RequestResponse InsertList(List <dtoConnection> connections)
        {
            GeneralDB       dB = new GeneralDB();
            RequestResponse r  = new RequestResponse();

            r.Message = "shop number " + connections[0].CodeShop + "inserted " + connections.Count();
            try
            {
                int c = connections[0].CodeShop;
                r.Result = true;
                connections.ForEach(x => dB.MyDb.Connections.Add(Converts.ToConnection(x)));
                dB.MyDb.SaveChanges();
                //Shop s = dB.MyDb.Shops.Where(x => x.Code == connections[0].CodeShop).First();
                Shop        s     = new Shop();
                List <Shop> shops = dB.MyDb.Shops.ToList();

                for (int i = 0; i < shops.Count(); i++)
                {
                    if (shops[i].Code == c)
                    {
                        s = shops[i];
                        break;
                    }
                }
                r.Data = Converts.ToDtoShop(s);
            }
            catch
            {
                r.Result  = false;
                r.Message = "can't add connections";
            }
            return(r);
        }
Esempio n. 3
0
        public static List <ExtraAlias> GetDepartment()
        {
            GeneralDB         generalDB   = new GeneralDB();
            List <Alias>      aliases     = generalDB.MyDb.Aliases.Where(x => x.Parent == null).ToList();
            List <ExtraAlias> departments = Converts.ToExtraAliases(aliases);

            departments.Remove(departments.Where(x => x.TextAlias == "placeAlias").FirstOrDefault());

            List <dtoProduct> dtoProducts = Converts.ToDtoProducts(generalDB.MyDb.Products.ToList());
            var q = dtoProducts.Where(x => x.Alias.TextAlias == "cash" || x.Alias.TextAlias == "wall" || x.Alias.TextAlias == "סטנד").ToList();

            q.ForEach(x => dtoProducts.Remove(x));
            ExtraAlias e;

            foreach (var item in dtoProducts)
            {
                if (item.Alias.Parent != null && item.Alias.Parent != 0)
                {
                    e = departments.Where(x => x.Code == item.Alias.Parent).First();
                    e.products.Add(item);
                }
            }
            //departments = departments.Where(x => x.products.Count>0).ToList();
            return(departments);
        }
Esempio n. 4
0
        public static bool comparePassword(string str, int code)
        {
            GeneralDB generalDB = new GeneralDB();
            Shop      s         = generalDB.MyDb.Shops.Where(x => x.Code == code).First();

            return(s.Password == str);
        }
Esempio n. 5
0
 public ConnectionManager(LoginQueue loginQueue, SystemManager systemManager, GeneralDB generalDB, Logger logger)
 {
     this.Log           = logger.CreateLogChannel("ConnectionManager");
     this.LoginQueue    = loginQueue;
     this.SystemManager = systemManager;
     this.GeneralDB     = generalDB;
 }
Esempio n. 6
0
        public static List <dtoStand> GetStands(int codeShop)
        {
            GeneralDB generalDB = new GeneralDB();

            //generalDB.MyDb.Shops.First().Stands.First().Shelves.First().ProductShelves.Add();
            return(Converts.ToDtoStands(generalDB.MyDb.Stands.Where(s => s.CodeShop == codeShop).ToList()));
        }
Esempio n. 7
0
        public static List <dtoAlias> GetAliases()
        {
            GeneralDB       db         = new GeneralDB();
            List <dtoAlias> dtoAliases = Converts.ToDtoAliases(db.MyDb.Aliases.ToList());

            return(dtoAliases);
        }
Esempio n. 8
0
        public static List <dtoShop> GetDtoShops()
        {
            GeneralDB   generalDB = new GeneralDB();
            List <Shop> l         = generalDB.MyDb.Shops.ToList();

            return(Converts.ToDtoShops(l));
        }
Esempio n. 9
0
        public static void Update(List <dtoProduct> products)
        {
            GeneralDB      dB        = new GeneralDB();
            List <Product> products2 = dB.MyDb.Products.ToList();

            products.ForEach(x => products2.Where(y => y.Code == x.Code).First().Src = x.Src);
            dB.MyDb.SaveChanges();
        }
Esempio n. 10
0
        public static List <dtoProductShop> GetProdcutsShop(int code)
        {
            GeneralDB             generalDB = new GeneralDB();
            List <dtoProductShop> l         = Converts.ToDtoProductShops(generalDB.MyDb.ProductShops.ToList());

            l = l.Where(x => x.CodeShop == code).ToList();
            return(l);
        }
Esempio n. 11
0
        public NodeContainer(GeneralDB generalDB)
        {
            this.NodeID    = 0;
            this.GeneralDB = generalDB;

            // load constants for the EVE System
            this.Constants = this.GeneralDB.LoadConstants();
        }
Esempio n. 12
0
        public static bool UnloadSolarSystem(int solarSystemID)
        {
            // We should do the unload work here

            // Update the database
            GeneralDB.UnloadSolarSystem(solarSystemID);

            return(true);
        }
Esempio n. 13
0
        public static void Insert(List <dtoProductAlias> productAliases)
        {
            GeneralDB dB = new GeneralDB();

            productAliases.ForEach(x => x.Alias = null);
            List <ProductAlia> productAliases2 = Converts.ToProductAliases(productAliases);

            dB.MyDb.ProductAlias.AddRange(productAliases2);
            dB.MyDb.SaveChanges();
        }
Esempio n. 14
0
        public static void Insert(List <dtoProductShelf> productShelves)
        {
            GeneralDB dB = new GeneralDB();

            productShelves.ForEach(x => x.CodeProduct = x.CodeProduct == 0?null:x.CodeProduct);
            List <ProductShelf> productShelves2 = Converts.ToProductShelves(productShelves);

            dB.MyDb.ProductShelves.AddRange(productShelves2);
            dB.MyDb.SaveChanges();
        }
Esempio n. 15
0
        public bool Insert()
        {
            ProductShop s = Converts.ToProductShop(this);

            GeneralDB generalDB = new GeneralDB();

            generalDB.MyDb.ProductShops.Add(s);
            generalDB.MyDb.SaveChanges();
            return(true);
        }
Esempio n. 16
0
        public IActionResult GetById(long id)
        {
            var item = _context.AZObsItems.FirstOrDefault(t => t.Id == id);

            if (item == null)
            {
                return(NotFound());
            }
            item.Geo = GeneralDB.GetLocation(_context, "AZObsItems", id);
            return(new ObjectResult(item));
        }
Esempio n. 17
0
        public IActionResult Create([FromBody] AZObsItem item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            _context.AZObsItems.Add(item);
            _context.SaveChanges();
            GeneralDB.UpdateLocation(_context, "AZObsItems", item.Geo, item.Id);
            return(CreatedAtRoute("GetAZObs", new { id = item.Id }, item));
        }
Esempio n. 18
0
        public dtoAlias Insert()
        {
            GeneralDB db = new GeneralDB();
            Alias     a  = Converts.ToAlias(this);

            db.MyDb.Aliases.Add(a);
            db.MyDb.SaveChanges();
            a = db.MyDb.Aliases.ToList().Last();
            dtoAlias dtoAlias = Converts.ToDtoAlias(a);

            return(dtoAlias);
        }
Esempio n. 19
0
        public dtoProduct Insert()
        {
            Product s = Converts.ToProduct(this);
            //s.Alias = null;
            GeneralDB generaldb = new GeneralDB();

            generaldb.MyDb.Products.Add(s);
            generaldb.MyDb.SaveChanges();
            s = generaldb.MyDb.Products.ToList().Last();
            dtoProduct d = Converts.ToDtoProduct(s);

            return(d);
        }
Esempio n. 20
0
        public static void Delete(List <dtoProductShop> deleteProductShops)
        {
            GeneralDB generalDB = new GeneralDB();

            foreach (var item in deleteProductShops)
            {
                ProductShelf productShelf = Converts.ToProductShelf(item);
                var          v            = generalDB.MyDb.ProductShelves.Where(x => x.Code == productShelf.Code).FirstOrDefault();
                if (v != null)
                {
                    generalDB.MyDb.ProductShelves.Remove(v);
                }
            }
            generalDB.MyDb.SaveChanges();
        }
Esempio n. 21
0
        public static bool LoadSolarSystem(SolarSystem solarSystem)
        {
            // We should do the load work here
            BootupSolarSystem(solarSystem.itemID);

            // Update the database
            GeneralDB.LoadSolarSystem(solarSystem.itemID);

            // Update the list
            solarSystemsLoaded.Add(solarSystem);

            // Update the ItemManager
            ItemFactory.GetItemManager().LoadItem(solarSystem.itemID);

            return(true);
        }
Esempio n. 22
0
        public static List <Goal> MainComputeTravel(int[] CodeProducts, Point pStart, int numShop, bool endCash, string path)
        {
            CodeShop = numShop;
            GeneralDB dB = new GeneralDB();
            Shop      s  = dB.MyDb.Shops.Where(x => x.Code == numShop).FirstOrDefault();
            List <GetawayProcI_Result> getawayProcI_Results = dB.MyDb.GetawayProcI(numShop).ToList();
            int width  = Convert.ToInt32(s.Walls.Max(x => x.X2)) + 1;
            int height = (int)s.Walls.Max(x => x.Y2) + 1;

            //TODO: להחליט אם מחשבים כאן
            int[][] matShop = MatShopComputer.ComputeMat(s.Walls.ToArray(), s.Stands.ToArray(), s.Getaways.ToArray(), width, height);
            Cell[,] baseDistanceMatrix = dtoShop.ReadDistanceMatrix(s, path);
            // Cell[,] baseDistanceMatrix = DijkstraFunction.ComputeDikjstra(getawayProcI_Results,s.Connections.ToList());
            List <Wall> cashes = null;

            if (endCash)
            {
                cashes = s.Walls.Where(x => x.Alias.TextAlias == "cash").ToList();
            }
            List <Product> product = dB.MyDb.Products.Where(p => CodeProducts.Contains(p.Code)).Distinct().ToList();

            if (pStart == null)
            {
                pStart = UtilitiesFunctions.MidPoint(Converts.ToDtoGetawayI(getawayProcI_Results.Where(x => x.Code == s.CodeGetaway).First()));
            }
            //foreach (var item in productShops)
            //{
            //    MessageBox.Show(item.Product.Alias.TextAlias);
            //}
            //levels
            Dictionary <Stand, List <Product> > ExtraStand = Level1GroupProductsByStand(product.ToArray());
            //TODO: לעשות שיקבץ לאזורים רק אם צריך
            Dictionary <KeyArea, Area> productArea;

            //if (ExtraStand.Count() <= 10)
            //    productArea = Level2NotGroupStandsByArea(ExtraStand, getawayProcI_Results);
            //else
            productArea = Level2GroupStandsByArea(ExtraStand, getawayProcI_Results, s);
            List <KeyValuePair <KeyArea, Area> > productAreaList = Level3ConvertDictToList(pStart, productArea, matShop, getawayProcI_Results, s.Connections.ToList(), cashes, Convert.ToInt32(s.CodeGetaway), s.Stands.ToList(), s);

            Cell[,] matrix      = Level4ComputeDistanceMatrix(productAreaList, baseDistanceMatrix, pStart, cashes);
            Cell[,] matrixToTsp = Level5CutMatrix(matrix, productAreaList.Count, matrix.GetLength(1));

            return(Level6ComputeGoalsTravel(matrix, matrixToTsp, matrix.GetLength(1) - matrixToTsp.GetLength(1) - 1, matrixToTsp.GetLength(1), productAreaList, getawayProcI_Results, pStart, cashes.Count()));
        }
Esempio n. 23
0
        /// <summary>
        /// the method constructs a dictionary from the Contacts DataTable, id - websiteID and websiteName
        /// </summary>
        public static Dictionary <int, string> GetContacts()
        {
            DataTable contactsdt = GeneralDB.ReturnContacts();

            if (contactsdt == null)
            {
                return(null);
            }
            Dictionary <int, string> ContactDic = new Dictionary <int, string>();

            foreach (DataRow row in contactsdt.Rows)
            {
                int    Contactid   = (int)row["WebsiteID"];
                string ContactName = (string)row["WebsiteName"].ToString();
                ContactDic.Add(Contactid, ContactName);
            }
            return(ContactDic);
        }
Esempio n. 24
0
        public static void GetAliasesShopProduct(int codeShop, List <ExtraAlias> extraAliases, List <Product> products)
        {
            GeneralDB         generalDB   = new GeneralDB();
            List <dtoProduct> dtoProducts = Converts.ToDtoProducts(products);
            ExtraAlias        e;
            int?codeAlias;

            foreach (var product in dtoProducts)
            {
                codeAlias = product.CodeAlias;
                e         = extraAliases.Where(eAlias => eAlias.Code == codeAlias).First();
                e.products.Add(product);
                if (product.ProductAlias != null)
                {
                    product.ProductAlias.ForEach(productAlias => extraAliases.Where(eAlias => eAlias.Code == productAlias.Alias.Code).ToList().First().products.Add(product));
                }
            }
        }
Esempio n. 25
0
        /// <summary>
        /// the method constructs a dictionary from a Countries DataTable, id - lang,  counryname - name of language
        /// </summary>
        public static Dictionary <int, string> GetCountries()
        {
            DataTable countriesdt = GeneralDB.ReturnCountries();

            if (countriesdt == null)
            {
                return(null);
            }
            Dictionary <int, string> CountryDic = new Dictionary <int, string>();

            foreach (DataRow row in countriesdt.Rows)
            {
                int    countryid   = (int)row["ID"];
                string CountryName = (string)row["Name"].ToString();
                CountryDic.Add(countryid, CountryName);
            }
            return(CountryDic);
        }
Esempio n. 26
0
        public static bool LoadUnloadedSolarSystems()
        {
            // Get all the solarSystems not loaded and load them
            List <int> solarSystems = GeneralDB.GetUnloadedSolarSystems();

            // Load the not-loaded solar systems
            foreach (int solarSystemID in solarSystems)
            {
                // We can assume we dont have it in the list, as we've queryed for the non-loaded solarSystems
                SolarSystem solarSystem = new SolarSystem(ItemDB.LoadItem(solarSystemID), ItemDB.GetSolarSystemInfo(solarSystemID)); // Create the solarSystem class

                if (LoadSolarSystem(solarSystem) == false)
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 27
0
        /// <summary>
        /// the method constructs a dictionary from a language DataTable, id - lang,  langname - name of language
        /// </summary>

        public static Dictionary <int, string> GetLang()
        {
            DataTable Langdt = GeneralDB.Returnlanguages();

            if (Langdt == null)
            {
                return(null);
            }
            Dictionary <int, string> langDic = new Dictionary <int, string>();

            foreach (DataRow row in Langdt.Rows)
            {
                int    langid   = (int)row["ID"];
                string LangName = (string)row["LangName"].ToString();
                langDic.Add(langid, LangName);
            }
            return(langDic);
        }
Esempio n. 28
0
        /*   public RequestResponse Update()
         * {
         * //TODO: לעשות שיעדכן ולא יוסיף שוב נתונים כפולים
         *  RequestResponse r = new RequestResponse();
         * Shop s =Converts.ToShop(this,"");
         *
         * //generalDB.Shops.Add(s);
         * MessageBox.Show("befor you have "+generalDB.MyDb.Shops.Count());
         * generalDB.MyDb.Shops.Add(s);
         * generalDB.MyDb.SaveChanges();
         * MessageBox.Show("after you have "+generalDB.MyDb.Shops.Count());
         *  s=   generalDB.MyDb.Shops.ToList().Last();
         * dtoShop dtos = Converts.ToDtoShop(s);
         * dtos.Connections = new List<dtoConnection>();
         * r.Data = dtos;
         * //כאן לעשות לקובץ זמל את דיקסטרת החנות
         * WriteDistanceMatrix(s);
         *
         * //Matrix m = new Matrix();
         * //int width = Convert.ToInt32(s.Walls.Max(x => x.X2));
         * //int height = (int)s.Walls.Max(x => x.Y2);
         * //m.Mat = MatShopComputer.ComputeMat(s.Walls.ToArray(), s.Stands.ToArray(), s.Getaways.ToArray(), width, height);
         *
         * return r;
         * }*/

        public static int [][] GetMap(int Code)
        {
            GeneralDB g = new GeneralDB();
            Shop      s = g.MyDb.Shops.Where(x => x.Code == Code).FirstOrDefault();

            if (s == null)
            {
                return(null);
            }
            int[][] matShop = new int[1][];
            try
            {
                var x = Convert.ToInt32(s.Walls.Max(a => a.X2));
                var y = Convert.ToInt32(s.Walls.Max(b => b.Y2));
                matShop = MatShopComputer.ComputeMat(s.Walls.ToArray(), s.Stands.ToArray(), s.Getaways.ToArray(), x + 1, y + 1);
            }
            catch { MessageBox.Show("erro"); }
            return(matShop);
        }
Esempio n. 29
0
        public List <Goal> DOmain(List <Product> products, Point pStart, Wall cash, int numShop, List <GetawayProcI_Result> getaways, List <Connection> connections)
        {
            string path = @"C:\ProgramData\superQuick";

            CodeShop = numShop;
            GeneralDB DB   = new GeneralDB();
            Shop      shop = DB.MyDb.Shops.Where(x => x.Code == numShop).First();
            List <GetawayProcI_Result> getawayProcI_Results = DB.MyDb.GetawayProcI(1).ToList();

            Cell[,] distanceMatrix = DijkstraFunction.ComputeDikjstra(DB.MyDb.GetawayProcI(1).ToList(), shop.Connections.ToList());
            //Cell[,] distanceMatrix = dtoShop.ReadDistanceMatrix(shop,path);
            ShopWayEntities shopWay = new ShopWayEntities();

            pStart.X = 8; pStart.Y = 22;
            int[][]  matShop = MatShopComputer.ComputeMat(shop.Walls.ToArray(), shop.Stands.ToArray(), shop.Getaways.ToArray(), 29, 29);
            string[] arr     = { "מים", "שוגי", "ציפס קידס", "קורונפלקס", "כריות", "סוכריות אדומות", "במבה", "תן צאפ", "ביסלי", "ציפס מקסיקני", "פופקורן", "במבה אדומה", "דוריטוס" };
            //string[] arr = { "watter", "shugi", "chips kids", "coronflex", "cariot", "red swits", "bamba", "ten chap", "bisli", "chips meksicani", "popcoren", "red bamba", "new snak" };
            //List<Product> productsTrap = DB.MyDb.Products.Where(x => arr.Contains(x.Alias.TextAlias) && x.GetProductShops().Where(y => y.CodeShop == numShop).ToList().Count > 0).ToList();
            List <ProductShop> productShops = shop.GetProductShop();
            bool           b            = productShops.Where(x => x.Code == 1).FirstOrDefault() != null;
            List <Product> productsShop = shop.ProductShops.Select(x => x.Product).ToList();

            List <Product> productsTrap = productsShop.Where(x => arr.Contains(x.Alias.TextAlias)).ToList();
            //List<Product> productsTrap&& productShops.Where(y=>y.CodeProduct==x.Code).FirstOrDefault()!=null).ToList();
            Dictionary <Stand, List <Product> > ExtraStand = Level1GroupProductsByStand(productsTrap.ToArray());
            Dictionary <KeyArea, Area>          productArea;

            //TODO: לעשות שלא יקבץ לאזורים אם לא צריך
            //if (ExtraStand.Count()<=10)
            //    productArea= Level2NotGroupStandsByArea(ExtraStand, getawayProcI_Results);
            //else
            productArea = Level2GroupStandsByArea(ExtraStand, getawayProcI_Results, shop);
            List <Wall> cashes = shop.Walls.Where(w => w.Alias.TextAlias == "cash").ToList();
            List <KeyValuePair <KeyArea, Area> > productAreaList = Level3ConvertDictToList(pStart, productArea, matShop, getaways, connections, cashes, Convert.ToInt32(shop.CodeGetaway), shop.Stands.ToList(), shop);

            Cell[,] matrix      = Level4ComputeDistanceMatrix(productAreaList, distanceMatrix, pStart, cashes);
            Cell[,] matrixToTsp = Level5CutMatrix(matrix, productAreaList.Count, matrix.GetLength(1));
            return(Level6ComputeGoalsTravel(matrix, matrixToTsp, matrix.GetLength(1) - matrixToTsp.GetLength(1) - 1, matrixToTsp.GetLength(1), productAreaList, getawayProcI_Results, pStart, cashes.Count()));
        }
Esempio n. 30
0
        public static List <ExtraAlias> GetAliasesShop(int codeShop)
        {
            GeneralDB          generalDB    = new GeneralDB();
            Shop               s            = generalDB.MyDb.Shops.Where(x => x.Code == codeShop).First();
            List <ProductShop> productShops = s.ProductShops;
            Product            pr           = productShops[0].Product;
            List <Product>     products     = s.ProductShops.Select(x => x.Product).ToList();
            List <ExtraAlias>  extraAliases = new List <ExtraAlias>();
            ExtraAlias         e;

            foreach (var item in products)
            {
                if (item.Code == 191)
                {
                    s = s;
                }
                foreach (var item1 in item.ProductAlias)
                {
                    e = Converts.ToExtraAlias(item1.Alias);
                    if (item1.Alias.Parent == null && item1.Alias.Color != null)
                    {
                        e.Color = item1.Alias.Color;
                    }
                    else if (item1.Alias.Parent != null)
                    {
                        e.Color = item1.Alias.Alias2.Color;
                    }
                    extraAliases.Add(Converts.ToExtraAlias(item1.Alias));
                }
                extraAliases.Add(Converts.ToExtraAlias(item.Alias));
            }
            extraAliases.Distinct();
            extraAliases = extraAliases
                           .GroupBy(p => p.Code)
                           .Select(g => g.First())
                           .ToList();
            GetAliasesShopProduct(codeShop, extraAliases, products);
            return(extraAliases);
        }