示例#1
0
        public MainWindow()
        {
            InitializeComponent();

            warehouse = new Warehouse();
            service   = new ServiceController("Service1");
            aProductData = new AssociatedProductData(warehouse, warehouse.First());
            loadData(aProductData);
        }
示例#2
0
        private void OnElapsedTime(object source, ElapsedEventArgs e)
        {
            var emsend = System.Configuration.ConfigurationManager.AppSettings["emailsender"].ToString();
            var emrec = System.Configuration.ConfigurationManager.AppSettings["emailreciver"].ToString();
            var emsrv = System.Configuration.ConfigurationManager.AppSettings["emailserver"].ToString();
            var empass = System.Configuration.ConfigurationManager.AppSettings["emailpasswd"].ToString();

            Warehouse warehouse = new Warehouse();

            TraceService("Chectking started" + DateTime.Now);
            TraceService("All products:" + warehouse.ToList().Count.ToString() + DateTime.Now);

            var all = warehouse.ToList();

            var act = new AssociatedProductData(warehouse, warehouse.First());

            while (act != null && act.Id != 0)
            {
                if (act.Ammount < act.AlertLevel)
                {
                    MailMessage Message = new MailMessage();

                    Message.From = new MailAddress(emsend);
                    Message.To.Add("*****@*****.**");
                    Message.Subject = "Supply request";
                    Message.Body = "Please supply at least" + (act.AlertLevel - act.Ammount) + " " + act.ProductName + "(" + act.Model + ")" + "!!!";

                    SmtpClient client = new SmtpClient();
                    client.Host = emsrv;
                    client.Port = 587;
                    client.UseDefaultCredentials = false;
                    client.DeliveryMethod = SmtpDeliveryMethod.Network;
                    client.EnableSsl = true;
                    client.Credentials = new NetworkCredential(emsend, empass);
                    client.Send(Message);
                    TraceService("Sending email:" + DateTime.Now);
                }

                act = act.Next();

            }
            TraceService("All products checked " + DateTime.Now);
        }
示例#3
0
 public AssociatedProductData(Warehouse phoneBook, ProductData ProductData)
 {
     this.warehouse = phoneBook;
     LoadProductData(ProductData);
 }
示例#4
0
        static void Main(string[] args)
        {
            Console.WriteLine("!!!");
            string cs = System.Configuration.ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
            Console.WriteLine(cs);

            Warehouse phoneBook = new Warehouse();

            phoneBook.Add(new ProductData { ProductName = "Name1", Model = "Last", BarCode = "4321", ProductType = EnumProductType.Cellphone });

              //          phoneBook.Commit();

            //var viev=phoneBook.db.PhoneBook.ToList();

            var newBarCodes = phoneBook.SearchPhoneByTheProductName("Name1");

            //Edit
            //newBarCode.ProductName = "AAA";
            //phoneBook.Attach(newBarCode);
            //db.Entry(newBarCode).State = EntityState.Modified;

            //db.SaveChanges();

            //var viev2 = db.PhoneBook.ToList();

            var newBarCodes2 = phoneBook.SearchPhoneByTheProductName("Name1");
               // foreach(var newPhNumber in newBarCodes) phoneBook.Del(newPhNumber);

            phoneBook.Commit();

            // Next and Previous

            var listinc = new List<ProductData>();
            var listdec = new List<ProductData>();

            /*
            var vieww = phoneBook.db.PhoneBook.OrderBy(pBook => pBook.Model).ThenBy(pBook => pBook.ProductName).ThenBy(pBook => pBook.Id).ToList();

            var pierwszy = phoneBook.db.PhoneBook.OrderBy(pBook => pBook.Model).ThenBy(pBook => pBook.ProductName).ThenBy(pBook => pBook.Id).First();
            */
            var pierwszy = phoneBook.SearchPhoneByTheProductName("Name1").FirstOrDefault();
            Console.WriteLine(pierwszy.Id + " " + pierwszy.ProductName + "  " + pierwszy.Model + "\n");

                        while (pierwszy != null)
                        {
                            Console.WriteLine(pierwszy.Id+" "+pierwszy.ProductName+"  "+pierwszy.Model+"\n");
                            listinc.Add(pierwszy);
                            pierwszy = pierwszy.Next(phoneBook);
                        }

            var ost = phoneBook.SearchPhoneByTheProductName("Name1").FirstOrDefault();

                        while (ost != null)
                        {
                            listdec.Add(ost);
                            ost = ost.Prev(phoneBook);
                        }
             //*/
                        phoneBook.Commit();

            Console.WriteLine("!!!");
            Console.ReadKey();
        }