예제 #1
0
 public FrmLogin(IHermesDevice device)
     : base(device)
 {
     _device = device;
     PinNameIdOrderman user;
     if (!AllUser.AllUseraList.TryGetValue(_device.SerialNumber, out user))
     {
         Logger.Info("ERROR, new FrmLogin for ORDERMAN: {0}", _device.SerialNumber);
         FormMain.SendMail("ERROR, new FrmLogin for ORDERMAN:" + _device.SerialNumber.ToString(), "ERROR");
         var recordbuild = new BusinessForm(this._device);
         recordbuild.BuildRecordSets(this._device);
         Dg = new DGobject
              {
                  Device = _device, IdOrderman = _device.SerialNumber,
                  FrmLogin = this, SleepForm = RecSets.CurrentForm.FrmLogin,
                  Menu = recordbuild.Menu,
                  CurrentOrder = recordbuild.CurrentOrder,
                  TableReservation = false
              };
         AllUser.AllUseraList.Add(_device.SerialNumber, new PinNameIdOrderman()
                                                        {
                                                            DgObject = this.Dg,
                                                            Id = _device.SerialNumber,
                                                            Sleep = false
                                                        });
     }
     else
         {
             Dg = user.DgObject;
             Dg.FrmLogin = this;
             Dg.SleepForm = RecSets.CurrentForm.FrmLogin;
             Dg.TableReservation = false;
         }
     Theme = "custom";
 }
        public void BuildRecordSets(IHermesDevice device)
        {
            //Загружаем один раз официантов и меню
            ComReader.BufferMembers = ComReader.GetMembers();
            ComReader.BufferMenu = ComReader.GetMenuToBuffer();

            //Новая загрузка меню
            var xmlParser = new MenuXmlParser();
            Menu.Clear();
            foreach (var xElement in xmlParser.GetButtonName(ComReader.BufferMenu))
            {
                Menu.AddComponent(xmlParser.BuildMenu(xElement));
            }
            //Разбираем меню в массив
            var xml = new MenuXml();
            ComReader.ListMenu = xml.MenuXmlToList(ComReader.BufferMenu);
            // Append a dictionary to the device which hold's all application specific data
            if (device.Tag == null)
                device.Tag = new Dictionary<string, object>(2);
            var nextId = 0;
            //Создаем Dictionary для сохранения RecordSet
            IDictionary<string, RecordSet> recSets = new Dictionary<string, RecordSet>();
            #region Строим RecordSet Официанты
            var list = ComReader.BufferMembers; //BufferMembers.xml список официантов
            // Recordset всегда!!! основывается на recorddefinition построеном с помощью Orderman Screen Designed.
            // (Recorddefinition определяют вид и формат записей)
            // В Sol есть Record-Definition USERS - это официанты
            var def = device.Resources.RecordDefinitions["USERS"];
            //Каждой записи Recordset необходим уникальный ID. Мы просто используем счетчик nextId
            var usersSet = new RecordSet(nextId++, def, RSET_USERS); //usersSet - официанты; public const string RSET_USERS = "Users";
            var name = from p in list.Elements("Элемент")
                       select p;
            foreach (var p in name)
            {
                //Каждый официант - свой Record
                var rec = new Record(def) {Tag = p};
                //Заполняем данные для отображения
                rec.Cells[0].Value = device.Resources.Images[0x0009];
                rec.Cells[1].Value = p.Attribute("Наименование").Value;
                rec.Tag = p.Attribute("IdUser").Value;
                usersSet.Add(rec);
            }
            //Добавляем в Dictionary RecordSt официанты
            recSets.Add(usersSet.Name, usersSet); //usersSet.Name - "Users"
            #endregion
            #region Строим RecordSet menu and StringTables
            recSets = BuildOrderRecordSet(recSets, device, ref nextId);
            recSets = BuildMenuRecordSet(recSets, device, ref nextId);
            recSets = BuildTablesRecordSet(recSets, device, ref nextId);
            recSets = BuildBillRecordSet(recSets, device, ref nextId);
            recSets = BuildPrinterTablesRecordSet(recSets, device, ref nextId);
            recSets = BuildModifiersTablesRecordSet(recSets, device, ref nextId);
            #endregion
            GetDeviceData(device)[RSET_NAME] = recSets;
            //Строим StringTables
            var menuModifiersStringTables = new Dictionary<string, RecordSet>();
            menuModifiersStringTables = BuildMenuModifiersStringTables(menuModifiersStringTables, ref nextId);
            GetDeviceData(device)["STRINGTABLE"] = menuModifiersStringTables;
        }
 public PopUpMenu(IHermesDevice target, List<Modifikator> sourceItems)
     : base(target)
 {
     //SelectedItem = null;
     Checks = new List<CheckBox>();
     _source = sourceItems;
     Theme = "custom";
 }
예제 #4
0
 public frmLogin(IHermesDevice device)
     : base(device)
 {
     DG = new DGobject
          {
              Device = device,
              IdOrderman = Device.SerialNumber,
              FrmLogin = this,
              CachingOrders = new Dictionary<KeyOrders, CachingOrder>(new CachingOrdersComparer()),
              CachingDich = new Dictionary<string, List<DishTemp>>(),
              CachingXml = new Dictionary<string, XElement>()
          };
     Theme = "custom";
 }
예제 #5
0
        public PowerOn(IHermesDevice device, HermesManager.ConnectionType connectionType)
            : base(device)
        {
            this._connectionType = connectionType;
            _device = device;

            PinNameIdOrderman user;
            if (AllUser.AllUseraList.TryGetValue(_device.SerialNumber, out user)) _dg = user.DgObject;
            else
            {
                //Logger.Info("Init DgObject for Orderman {0}", _device.SerialNumber);

                _dg = new DGobject {Device = _device, IdOrderman = _device.SerialNumber, TableReservation = false};
                lock (AllUser.AllUseraList)
                {
                    AllUser.AllUseraList.Add(_device.SerialNumber, new PinNameIdOrderman()
                                                               {
                                                                   DgObject = _dg,
                                                                   Id = _device.SerialNumber,
                                                                   Sleep = false
                                                               });
                }
            }
        }
 //Строим Recordset для верхнего окна _lstOrders ORDERS
 //5 наборов черный/зеленый/красный для детей и папок
 //красный один и тот же
 //Пока используются только черные 2 набора
 private static IDictionary<string, RecordSet> BuildOrderRecordSet(IDictionary<string, RecordSet> recSets,
     IHermesDevice device, ref int nextId)
 {
     var def = device.Resources.RecordDefinitions["ORDERS"];
     foreach (var q in (RecSets.MarkerOrder[])Enum.GetValues(typeof(RecSets.MarkerOrder)))
     {
         var id = 0;
         foreach (var p in ComReader.ListMenu.Children)
         {
             //q + p.Id - строим новые ключи
             var itemsSet = new RecordSet(nextId++, def, q + p.Id);
             var itemRec = new Record(def);
             itemRec.Cells[0].Value = "1";
             itemRec.Cells[1].Value = id++;
             itemRec.Tag = q.ToString() + p.Id;
             itemRec.TemplateName = q.ToString();
             itemsSet.Add(itemRec);
             try
             {
                 recSets.Add(itemsSet.Name, itemsSet);
             }
             catch (Exception)
             {
                 var i = "Это дубль";
             }
         }
     }
     return recSets;
 }
 public static IDictionary<string, RecordSet> GetMenuStringTable(IHermesDevice device)
 {
     return (IDictionary<string, RecordSet>)GetDeviceData(device)["STRINGTABLE"];
 }
 public static IDictionary<string, RecordSet> GetRecordSets(IHermesDevice device)
 {
     return (IDictionary<string, RecordSet>)GetDeviceData(device)[RSET_NAME];
 }
 public BusinessForm(IHermesDevice device)
     : base(device)
 {
     OrderXmlParser = new OrderXmlParser(CurrentOrder);
 }
 public static IDictionary<string, object> GetDeviceData(IHermesDevice device)
 {
     return (IDictionary<string, object>)device.Tag;
 }
        private IDictionary<string, RecordSet> BuildPrinterTablesRecordSet(IDictionary<string, RecordSet> recSets, IHermesDevice device, ref int nextId)
        {
            var def = this.Device.Resources.RecordDefinitions["DropDown"];
            var itemsSet = new RecordSet(nextId++, def, "Printers");

            var printers = ComReader.GetPrinters();
            var pp = printers.Descendants("Принтер");
            foreach (var element in pp)
            {
                var r = new Record(def);
                r.Cells[0].Value = Device.Resources.Images[0x002B];
                r.Cells[1].Value = element.Attribute("ИмяПринтера").Value;
                r.Tag = element.Attribute("Идентификатор").Value;
                itemsSet.Add(r);
            }
            recSets.Add(itemsSet.Name, itemsSet);
            Device.Data.Download(itemsSet);
            return recSets;
        }
        //Строим группы столов в залах
        private IDictionary<string, RecordSet> BuildTablesRecordSet(IDictionary<string, RecordSet> recSets, 
            IHermesDevice device, ref int nextId)
        {
            var def = device.Resources.RecordDefinitions["TABLES"];
            var doc = ComReader.GetTablesRecordSet();
            var element = doc.Descendants("Зал");
            var xElements = element as XElement[] ?? element.ToArray();
            foreach (var p in xElements)
            {
                var userSet = new RecordSet(nextId++, def, p.Attribute("Наименование").Value);

                foreach (var q in p.Descendants("Столы").OrderBy(z => z.Attribute("ИмяСтола").Value))
                {
                    var rec = new Record(def);
                    rec.Cells[0].Value = Device.Resources.Images[0x0001];
                    rec.Cells[1].Value = q.Attribute("ИмяСтола").Value;
                    rec.TemplateName = RecSets.Tables.FREE.ToString();
                    rec.Tag = q.Attribute("Num").Value;
                    userSet.Add(rec);
                }
                recSets.Add(userSet.Name, userSet);
            }
            return recSets;
        }
        private IDictionary<string, RecordSet> BuildMenuRecordSet(IDictionary<string, RecordSet> recSets, IHermesDevice device, ref int nextId)
        {
            var def = device.Resources.RecordDefinitions["ITEMS-2"];
                foreach (var p in ComReader.ListMenu.Children)
                {
                    if (!(p.IdFather == "This folder!" || p.IdFather == "This Bigfolder!")) continue;
                    //Получим элемент из Menu
                    var element = (IPublicComposite)Menu.FindId(p.Id);
                    var userSet = p.Price == "This Bigfolder!" ?
                        new RecordSet(nextId++, def, p.Name) : new RecordSet(nextId++, def, p.Id);
                    if (p.Name == "БАР" || p.Name == "КУХНЯ" || p.Name == "ОСНОВНЫЕ")
                    {
                        foreach (var o in Menu.Children())
                        {
                            if (o.Name != p.Name) continue;
                            element = (IPublicComposite)o;
                        }
                    }

                    foreach (var o in element.Children())
                    {
                        var rec = new Record(def);
                        rec.Cells[0].Value = o.Name;
                        //rec.Cells[1].Value = o.Id;
                        rec.Tag = o.Id;
                        if (o.Price == "This folder!" || o.Price == "This Bigfolder!")
                            rec.TemplateName = RecSets.Menu.ITEMNAME.ToString();
                        else
                        {
                            var item = (IModifiers) o;
                            rec.TemplateName = item.GetModifiers().Any() ?
                                RecSets.Menu.POPUP.ToString() : RecSets.Menu.ITEMCHILDREN.ToString();
                        }
                        userSet.Add(rec);
                    }
                    try
                    {
                        recSets.Add(userSet.Name, userSet);
                    }
                    catch (Exception)
                    {
                        var h = "Duble";
                    }
                }
            return recSets;
        }
        //Modifier
        private IDictionary<string, RecordSet> BuildModifiersTablesRecordSet(IDictionary<string, 
            RecordSet> recSets, IHermesDevice device, ref int nextId)
        {
            var def = device.Resources.RecordDefinitions["MODIFIER"];
            foreach (var p in ComReader.ListMenu.Children.Where(p => p.Modifikators.Any()))
            {
                var itemsSet = new RecordSet(nextId++, def, RecSets.Modifier.Modifier.ToString() + p.Id);

                foreach (var q in p.Modifikators.OrderByDescending(z => z.Value.Required))
                {
                    var itemRec = new Record(def);
                    itemRec.Cells[0].Value = Device.Resources.Images[0x0018];
                    itemRec.Cells[1].Value =  q.Value.Name;
                    itemRec.Cells[2].Value = q.Value.Id;
                    itemRec.TemplateName = q.Value.Required == "1" ? "Required" : "NoRequired";
                    itemsSet.Add(itemRec);
                }
                try
                {
                    recSets.Add(itemsSet.Name, itemsSet);
                }
                catch (Exception)
                {
                    var i = "Это дубль";
                }
            }
            return recSets;
        }
        //Создаем стринг таблицы верхних папок
        private static IDictionary<string, RecordSet> BuildMenuStringTablesFolder(IDictionary<string, RecordSet> recSets,
            IHermesDevice device, ref int nextId)
        {
            var manuName = new string[3] { "ПИЦЦА", "КУХНЯ", "БАР" };
            //def Описывает структуру заданную в редакторе
            var def = device.Resources.RecordDefinitions["ITEMS-2"];
            for (var tab = 0; tab < 3; tab++)
            {
                //Создаем запись: nextId - номер записи, guidId - имя присваемое нами
                var userSet = new RecordSet(nextId++, def, manuName[tab]);
                var menu = GetXElements(manuName[tab]);

                foreach (var p in menu)
                {
                    var rec = new Record(def);
                    var element = p.Element("Наименование");
                    if (element != null) rec.Cells[0].Value = element.Value;
                    element = p.Element("IdItemName");
                    if (element != null) rec.Cells[1].Value = element.Value;
                    rec.Cells[2].Value = "This folder!";
                    rec.TemplateName = "ITEMNAME";
                    userSet.Add(rec);
                }
                //IDictionary<string, RecordSet> - добавляем ее в словарь
                //itemsSet.Name - это наш guidId
                recSets.Add(userSet.Name, userSet);
            }
            return recSets;
        }
        //Создаем стринг таблицы детей папок / строим на основе разобранного меню
        private static IDictionary<string, RecordSet> BuildMenuStringTablesChildren(IDictionary<string, RecordSet> recSets, IHermesDevice device, ref int nextId)
        {
            var def = device.Resources.RecordDefinitions["ITEMS-2"];
            foreach (var o in ComReader.ListMenu.Children.Where(z => z.IdFather == "This folder!"))
            {
                var userSet = new RecordSet(nextId++, def, o.Id);
                try
                {
                    //Папки уже создали, они не полезут
                    recSets.Add(userSet.Name, userSet);
                    var items = from q in ComReader.ListMenu.Children
                                where q.IdFather == o.Id
                                select q;

                    foreach (var p in items)
                    {
                        var itemRec = new Record(def);
                        itemRec.Cells[0].Value = p.Name;
                        itemRec.Cells[1].Value = p.Id;
                        itemRec.Cells[2].Value = p.Price;
                        itemRec.Tag = p.Id;
                        if (p.Marker == null) p.Marker = "ITEMNAME";
                        itemRec.TemplateName = p.Modifikators.Any() ? "POPUP" : p.Marker;
                        userSet.Add(itemRec);
                    }
                    //IDictionary<string, RecordSet> - добавляем ее в словарь
                    //itemsSet.Name - это наш guidId
                    recSets.Add(userSet.Name, userSet);
                }
                catch (Exception)
                {
                }
            }
            return recSets;
        }
 public BusinessForm(IHermesDevice device)
     : base(device)
 {
 }
 public ListTestForm(IHermesDevice device)
     : base(device)
 {
 }
예제 #19
0
 public PowerOn(IHermesDevice device)
     : base(device)
 {
 }
예제 #20
0
 protected MainForm(IHermesDevice device)
     : base(device)
 {
     OrderXmlParser = new OrderXmlParser(CurrentOrder);
 }
예제 #21
0
 public PowerOn(IHermesDevice device, HermesManager.ConnectionType connectionType)
     : base(device)
 {
     this._connectionType = connectionType;
     //Theme = "custom";
 }
예제 #22
0
 public frmLogin(IHermesDevice device)
     : base(device)
 {
 }
 //Строим построчно блюда для Bill
 private IDictionary<string, RecordSet> BuildBillRecordSet(IDictionary<string, RecordSet> recSets, IHermesDevice device, ref int nextId)
 {
     var def = device.Resources.RecordDefinitions["BILL"];
     foreach (var q in (RecSets.Bill[])Enum.GetValues(typeof(RecSets.Bill)))
     {
         var id = 0;
         foreach (var p in ComReader.ListMenu.Children)
         {
             //todo "BILL" имена совпадают с ORDERS
             var itemsSet = new RecordSet(nextId++, def, "BILL" + q + p.Id);
             var itemRec = new Record(def);
             itemRec.Cells[0].Value = "1";
             itemRec.Cells[1].Value = id++; //p.Name;
             //itemRec.Tag = p.Id;
             itemRec.TemplateName = q.ToString();
             itemsSet.Add(itemRec);
             try
             {
                 recSets.Add(itemsSet.Name, itemsSet);
             }
             catch (Exception)
             {
                 var i = "Это дубль";
             }
         }
     }
     return recSets;
 }