Beispiel #1
0
        // если в config-е режим не задан или задан неверно, то по умолчанию - Cook
        private static void initFromCfgFile()
        {
            KDSModeEnum mode;
            string      cfgValue = CfgFileHelper.GetAppSetting("KDSMode");

            if (cfgValue.IsNull())
            {
                mode = KDSModeEnum.Cook;  // нет такого элемента
            }
            else if (Enum.TryParse <KDSModeEnum>(cfgValue, out mode) == false)
            {
                mode = KDSModeEnum.Cook;  // не смогли распарсить
            }
            // сохранить в свойствах класса
            KDSModeHelper.CurrentKDSMode = mode;

            // особая роль, читаем доп.элементы в config и заполняем четвертый элемент в _definedKDSModes
            if (mode == KDSModeEnum.Special)
            {
                KDSModeStates modeStates = _definedKDSModes[KDSModeEnum.Special];

                string cfgVal = CfgFileHelper.GetAppSetting("KDSModeSpecialStates");
                modeStates.StringToAllowedStates(cfgVal);

                cfgVal = CfgFileHelper.GetAppSetting("KDSModeSpecialActions");
                modeStates.StringToAllowedActions(cfgVal);

                modeStates.CreateUserStateSets();
            }
        }  // method
Beispiel #2
0
        private static void initDefinedKDSModes()
        {
            // повар
            #region Повар
            KDSModeStates modeCook = new KDSModeStates()
            {
                KDSMode = KDSModeEnum.Cook
            };
            modeCook.AllowedStates.AddRange(new OrderStatusEnum[]
            {
                OrderStatusEnum.WaitingCook, OrderStatusEnum.Cooking, OrderStatusEnum.Cancelled
            });
            modeCook.AllowedActions.AddRange(new KeyValuePair <OrderStatusEnum, OrderStatusEnum>[]
            {
                new KeyValuePair <OrderStatusEnum, OrderStatusEnum>(OrderStatusEnum.WaitingCook, OrderStatusEnum.Cooking),
                new KeyValuePair <OrderStatusEnum, OrderStatusEnum>(OrderStatusEnum.Cooking, OrderStatusEnum.Ready),
                new KeyValuePair <OrderStatusEnum, OrderStatusEnum>(OrderStatusEnum.Cancelled, OrderStatusEnum.CancelConfirmed)
            });
            modeCook.CreateUserStateSets();
            #endregion

            // шеф-повар
            #region Шеф-повар
            KDSModeStates modeChef = new KDSModeStates()
            {
                KDSMode = KDSModeEnum.Chef
            };
            // состояния
            modeChef.AllowedStates.AddRange(new[]
                                            { OrderStatusEnum.WaitingCook, OrderStatusEnum.Cooking,
                                              OrderStatusEnum.Ready, OrderStatusEnum.Cancelled });
            if (_useReadyConfirmedState)
            {
                modeChef.AllowedStates.Add(OrderStatusEnum.ReadyConfirmed);
            }
            if (_isReadTakenDishes)
            {
                modeChef.AllowedStates.Add(OrderStatusEnum.Took);
            }

            // действия
            if (_useReadyConfirmedState)
            {
                modeChef.AllowedActions.AddRange(new KeyValuePair <OrderStatusEnum, OrderStatusEnum>[]
                {
                    new KeyValuePair <OrderStatusEnum, OrderStatusEnum>(OrderStatusEnum.WaitingCook, OrderStatusEnum.Cooking),
                    new KeyValuePair <OrderStatusEnum, OrderStatusEnum>(OrderStatusEnum.Cooking, OrderStatusEnum.ReadyConfirmed),
                    new KeyValuePair <OrderStatusEnum, OrderStatusEnum>(OrderStatusEnum.Ready, OrderStatusEnum.Cooking),
                    new KeyValuePair <OrderStatusEnum, OrderStatusEnum>(OrderStatusEnum.Ready, OrderStatusEnum.ReadyConfirmed),
                    new KeyValuePair <OrderStatusEnum, OrderStatusEnum>(OrderStatusEnum.ReadyConfirmed, OrderStatusEnum.Cooking),
                    new KeyValuePair <OrderStatusEnum, OrderStatusEnum>(OrderStatusEnum.Cancelled, OrderStatusEnum.CancelConfirmed),
                    new KeyValuePair <OrderStatusEnum, OrderStatusEnum>(OrderStatusEnum.ReadyConfirmed, OrderStatusEnum.Took)
                });
            }
            else
            {
                modeChef.AllowedActions.AddRange(new KeyValuePair <OrderStatusEnum, OrderStatusEnum>[]
                {
                    new KeyValuePair <OrderStatusEnum, OrderStatusEnum>(OrderStatusEnum.WaitingCook, OrderStatusEnum.Cooking),
                    new KeyValuePair <OrderStatusEnum, OrderStatusEnum>(OrderStatusEnum.Cooking, OrderStatusEnum.Ready),
                    new KeyValuePair <OrderStatusEnum, OrderStatusEnum>(OrderStatusEnum.Ready, OrderStatusEnum.Cooking),
                    new KeyValuePair <OrderStatusEnum, OrderStatusEnum>(OrderStatusEnum.Cancelled, OrderStatusEnum.CancelConfirmed),
                    new KeyValuePair <OrderStatusEnum, OrderStatusEnum>(OrderStatusEnum.Ready, OrderStatusEnum.Took)
                });
            }
            modeChef.CreateUserStateSets();
            #endregion

            // официант
            #region Официант
            KDSModeStates modeWaiter = new KDSModeStates()
            {
                KDSMode = KDSModeEnum.Waiter
            };
            modeWaiter.AllowedStates.AddRange(new OrderStatusEnum[]
            {
                OrderStatusEnum.WaitingCook, OrderStatusEnum.Cooking,
                OrderStatusEnum.Ready, OrderStatusEnum.Cancelled
            });
            if (_useReadyConfirmedState)
            {
                modeWaiter.AllowedStates.Add(OrderStatusEnum.ReadyConfirmed);
                modeWaiter.AllowedActions.AddRange(new KeyValuePair <OrderStatusEnum, OrderStatusEnum>[]
                {
                    new KeyValuePair <OrderStatusEnum, OrderStatusEnum>(OrderStatusEnum.ReadyConfirmed, OrderStatusEnum.Took)
                });
            }
            else
            {
                modeWaiter.AllowedActions.AddRange(new KeyValuePair <OrderStatusEnum, OrderStatusEnum>[]
                {
                    new KeyValuePair <OrderStatusEnum, OrderStatusEnum>(OrderStatusEnum.Ready, OrderStatusEnum.Took)
                });
            }
            modeWaiter.CreateUserStateSets();
            #endregion

            // особая роль
            KDSModeStates modeSpecial = new KDSModeStates()
            {
                KDSMode = KDSModeEnum.Special
            };

            _definedKDSModes = new Dictionary <KDSModeEnum, KDSModeStates>()
            {
                { KDSModeEnum.Cook, modeCook },
                { KDSModeEnum.Chef, modeChef },
                { KDSModeEnum.Waiter, modeWaiter },
                { KDSModeEnum.Special, modeSpecial }
            };
        }