Пример #1
0
 public Department(int _id, int _ownerid, DepartmentFlag _flag, string _ipaddress = "0.0.0.0")
 {
     id        = _id;
     ownerid   = _ownerid;
     ipaddress = _ipaddress;
     flag      = _flag;
     orders    = new List <Cheque>();
 }
Пример #2
0
 public Department(int _ownerid, DepartmentFlag _flag, string _ipaddress = "0.0.0.0")
 {
     id        = new Random().Next(-1, int.MaxValue);
     ownerid   = _ownerid;
     ipaddress = _ipaddress;
     flag      = _flag;
     orders    = new List <Cheque>();
 }
Пример #3
0
 public static IEnumerable <RawItem> GetRecipe <T>(this T product, DepartmentFlag flag) where T : Product
 {
     foreach (RawItem Item in ReciptCollector.SelectRawItems(product, flag))
     {
         yield return(Item);
     }
     yield break;
 }
Пример #4
0
 public static IEnumerable <Product> GetProducts <T>(this T cheque, DepartmentFlag flag) where T : Structure.Cheque
 {
     foreach (Product Item in ReciptCollector.SelectProducts(cheque, flag))
     {
         yield return(Item);
     }
     yield break;
 }
Пример #5
0
        public void EndOrder(DepartmentFlag flag, int id, int index, long time)
        {
            Department department = null;

            if (TryGetDrawer(flag, id, out department))
            {
                department.EndOrder(index, time);
            }
        }
Пример #6
0
        public void Process(DepartmentFlag flag, int id, Cheque cheque, out List <Exception> thrownexception)
        {
            Department department = null;

            thrownexception = null;
            if (TryGetDrawer(flag, id, out department))
            {
                department.Process(cheque, out thrownexception);
            }
        }
Пример #7
0
        public bool TryGetDrawer(DepartmentFlag flag, int id, out Department department)
        {
            Dictionary <int, Department> values = null;

            department = null;
            if (this.items.TryGetValue(flag, out values))
            {
                return(values.TryGetValue(id, out department));
            }
            return(false);
        }
Пример #8
0
        public void ProcessDepartments(DepartmentFlag flag, int id, Cheque cheque, out List <Exception> thrownexception)
        {
            List <Department> departments = null;

            thrownexception = null;
            if (TryGetDrawers(out departments, flag, id))
            {
                List <Exception> exceptions = null;
                foreach (Department department in departments)
                {
                    department.Process(cheque, out exceptions);
                    if (exceptions != null)
                    {
                        if (thrownexception == null)
                        {
                            thrownexception = new List <Exception>();
                        }
                        thrownexception.AddRange(exceptions.AsEnumerable());
                    }
                }
            }
        }
Пример #9
0
 public static IEnumerable <Structure.Product> SelectProducts(Cheque cheque, DepartmentFlag flag = DepartmentFlag.None)
 {
     if (flag != DepartmentFlag.None)
     {
         if (Receipts.ContainsKey(flag))
         {
             foreach (var product in Receipts[flag].Select(x => x.Key).Where(p => cheque.Contains(p)))
             {
                 yield return(product);
             }
         }
         yield break;
     }
     else
     {
         foreach (var product in Receipts.Values.SelectMany(x => x.Keys).Where(p => cheque.Contains(p)))
         {
             yield return(product);
         }
         yield break;
     }
 }
Пример #10
0
 public bool TryGetDrawers(out List <Department> departments, DepartmentFlag flag = DepartmentFlag.None, int id = 0)
 {
     departments = null;
     if (flag == DepartmentFlag.None && id == 0)
     {
         departments = this.Departments;
         return(departments != null);
     }
     else if (flag != DepartmentFlag.None && id == 0)
     {
         departments = this.Departments.Where(p => p.Flag == flag).ToList();
         return(departments != null);
     }
     else if (flag == DepartmentFlag.None && id != 0)
     {
         departments = this.Departments.Where(p => p.ID == id).ToList();
         return(departments != null);
     }
     else
     {
         departments = this.Departments.Where(p => p.Flag == flag && p.ID == id).ToList();
         return(departments != null);
     }
 }
Пример #11
0
 public static IEnumerable <Structure.RawItem> SelectRawItems(Product Product, DepartmentFlag flag = DepartmentFlag.None)
 {
     if (flag != DepartmentFlag.None)
     {
         foreach (var rawitem in Receipts.Values.Where(p => p.Select(x => x.Key).Contains(Product)).SelectMany(x => x.Values)
                  .Where(p => p.Select(x => x.Key).Contains(flag)).SelectMany(x => x.Values).SelectMany(x => x))
         {
             yield return(rawitem);
         }
         yield break;
     }
     else
     {
         foreach (var rawitem in Receipts.Values.Where(p => p.Select(x => x.Key).Contains(Product)).SelectMany(x => x.Values)
                  .SelectMany(x => x.Values).SelectMany(x => x))
         {
             yield return(rawitem);
         }
         yield break;
     }
 }