private void button3_Click(object sender, EventArgs e) { dtoShop s1 = new dtoShop() { Code = 80, Connections = null, NameShop = "ממתקולד" }; dtoShop s2 = new dtoShop() { Code = 80, Connections = null, NameShop = "סופרזול" }; dtoShop s3 = new dtoShop() { Code = 80, Connections = null, NameShop = "ממתיק" }; dtoShop s4 = new dtoShop() { Code = 80, Connections = null, NameShop = "מספרה" }; s1.Insert("1234", path); s2.Insert("1234", path); s3.Insert("1234", path); s4.Insert("1234", path); MessageBox.Show("הוספו 3 " + s2.NameShop); ShopWayEntities sho = new ShopWayEntities(); dataGridView1.DataSource = sho.Shops.ToList(); }
//יוצר XML private void button6_Click(object sender, EventArgs e) { ShopWayEntities shopWayEntities = new ShopWayEntities(); Shop s2 = shopWayEntities.Shops.ToList().First(); dtoShop s3 = Converts.ToDtoShop(s2); XmlSerializer xml = new XmlSerializer(typeof(dtoShop)); StreamWriter sw = new StreamWriter(@"E:\Data\shop.xml"); xml.Serialize(sw, s3); }
private void button1_Click(object sender, EventArgs e) { ShopWayEntities shopWayEntities = new ShopWayEntities(); //List<Alias> aliases = new List<Alias>(); //aliases = shopWayEntities.Aliases.ToList(); //treeView1.CreateObjRef(aliases[0]); //dataGridView1.DataSource = dtoShop.GetDtoShops(); //stopwatch.Start(); //int y = rec(1); //MessageBox.Show(y.ToString() + " is " + stopwatch.Elapsed.Minutes.ToString()); int[] arr = { 1, 2, 3, 4, 5, 6 }; arr.OrderBy(g => randomNum(1, 5)); string str = ""; arr.ToList().ForEach(a => str = str + ' ' + a); //MessageBox.Show(str); Bll.Logic.TravelComputer l = new TravelComputer(); List <Goal> listans = l.DOmain(shopWayEntities.Products.ToList(), new Point(), shopWayEntities.Walls.ToList().Last(), shopWayEntities.Shops.First().Code, shopWayEntities.GetawayProcI(1).ToList(), shopWayEntities.Connections.ToList()); string s = ":" + "המסלול שלך" + "\n"; string p = ""; for (int i = 0; i < listans.Count(); i++) { s += " kind: " + listans[i].kind + " code: " + listans[i].num + " point: (" + listans[i].midPoint.X + "," + listans[i].midPoint.Y + ")" + "\n"; if (listans[i].kind == 's' && listans[i].products != null) { MessageBox.Show("i am stand number " + listans[i].num + "and i have product " + listans[i].products[0].Alias.TextAlias); } } MessageBox.Show(s); //ShopWayEntities s = new ShopWayEntities(); //dataGridView1.DataSource = s.Products.ToList(); }
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())); }