public override DataSet GetBatchFunctionValue(Context ctx, KDSContext kdsContext, object args)
        {
            DataSet set = new DataSet();
            IDictionary <string, BudgetDataEntities> dictionary = args as IDictionary <string, BudgetDataEntities>;

            if ((dictionary != null) && (dictionary.Count != 0))
            {
                return(set);
            }
            return(set);
        }
        public override object GetFunctionValue(Context ctx, KDSContext kdsContext, string[] args)
        {
            BudgetDataEntities funcArgs = new BugdetDataFunctionArgs().ConvertToFunctionArgs(ctx, args);
            List <string>      values   = BugdetDataFunctionArgs.Validate(funcArgs, ctx);

            if (values.Count > 0)
            {
                return(string.Format("#{0}", string.Join("", values)));
            }
            BugdetDataService service = new BugdetDataService();

            return(service.GetBugdetValue(ctx, funcArgs));
        }
示例#3
0
        private List <Order> getOrders()
        {
            List <Order> retVal = null;

            try
            {
                using (KDSContext db = new KDSContext())
                {
                    db.Database.Connection.Open();
                    if (db.Database.Connection.State == System.Data.ConnectionState.Open)
                    {
                        List <Order> dbOrders = db.Database.SqlQuery <Order>(_readOrdersSQLText).ToList();
                        //List<Order> dbOrders = db.vwOrderQueue.ToList();

                        // пройтись по всем заказам
                        int iCnt;
                        Dictionary <int, IntWrapper> statesCnt = new Dictionary <int, IntWrapper>();
                        List <Order> delOrd = new List <Order>();
                        foreach (Order order in dbOrders)
                        {
                            foreach (int key in statesCnt.Keys)
                            {
                                statesCnt[key].IWValue = 0;
                            }
                            // достать из БД блюда и удалить из них позиции для неиспользуемых цехов
                            var dishes = db.Database.SqlQuery <OrderDish>("SELECT Id, DishStatusId, DepartmentId FROM OrderDish WHERE OrderId = " + order.Id.ToString(), order.Id).ToList();
                            iCnt = dishes.Count;
                            foreach (var dish in dishes)
                            {
                                if (_unUsedDeps.Contains(dish.DepartmentId))
                                {
                                    iCnt--;
                                }
                                else
                                {
                                    if (!statesCnt.ContainsKey(dish.DishStatusId))
                                    {
                                        statesCnt.Add(dish.DishStatusId, new IntWrapper());
                                    }
                                    statesCnt[dish.DishStatusId].IWValue += 1;
                                }
                            }
                            if (iCnt == 0)
                            {
                                delOrd.Add(order);
                            }
                            // узнать общий статус оставшихся блюд
                            //foreach (var key in statesCnt.Keys)
                            //{
                            //    int queueStat = key - 1;
                            //    if ((statesCnt[key].IWValue == iCnt) && (queueStat >= 0) && (order.QueueStatusId != queueStat))
                            //        order.QueueStatusId = queueStat;
                            //}
                        }
                        foreach (Order item in delOrd)
                        {
                            dbOrders.Remove(item);
                        }

                        retVal = dbOrders;
                    }
                }
            }
            catch (Exception ex)
            {
                _dbErrMsg = ex.Message;
                if (ex.InnerException != null)
                {
                    _dbErrMsg += "(inner message: " + ex.InnerException.Message + ")";
                }
            }

            if (retVal == null)
            {
                retVal = new List <Order>();
            }
            return(retVal);
        }