private void CloneNowMenuBased(string fromCycle, string menuCodes, string toCycle)
        {
            this.InvokeEx(f => f.lblStatus.Visible = true);
            this.InvokeEx(f => f.lblStatus.Text    = "In Progress, please wait!");
            this.InvokeEx(f => f.btnSubmit.Enabled = false);

            var newClonedMenus = _menuManagement.CloneMenuCodesToNewCycle(fromCycle, menuCodes, toCycle);

            ChiliProcessor chili = new ChiliProcessor();

            foreach (var key in newClonedMenus.Keys)
            {
                var newMenuID = key;
                var oldMenuId = newClonedMenus[key];

                var newMenu = _menuManagement.GetMenuById(newMenuID);

                var menuCode = "MNU" + Helper.Get8Digits();
                menuCode = MenuProcessor.GenerateMenuCode(Convert.ToInt32(newMenu.MenuTypeId), menuCode);

                var newMenuCodeWeek = menuCode;

                //only food guide will not have _1

                if (newMenu.MenuTypeId != 5)
                {
                    newMenuCodeWeek += "_1";
                }

                _menuManagement.UpdateMenuCode(newMenuID, newMenuCodeWeek);

                var newDOc = chili.CloneChiliDocument(oldMenuId);

                var oldMenuTemplate = _menuManagement.GetMenuTemplate(oldMenuId);
                _menuManagement.UpdateMenuTemplate(newMenuID, oldMenuTemplate.TemplateID, newDOc);


                //apply cycle menucode chili variable in chii doc
                _menuProcessor.RebuildFlightNumberLotNumberChiliVariableForMenu(newMenuID);
            }

            this.InvokeEx(f => f.lblStatus.Visible = true);
            this.InvokeEx(f => f.lblStatus.Text    = "Menu cloning has been completed successfully!");
            this.InvokeEx(f => f.btnSubmit.Enabled = true);

            MessageBox.Show("Menu cloning has been completed successfully!");
        }
        protected void GeneratePDF(string menuCode)
        {
            var codes = menuCode.Split(new char[] { ',' });

            ChiliProcessor chili = new ChiliProcessor();

            var tempPath = @"\\192.168.16.208\Digital_Production\Virgin\Emma\MENU PDFS\99999\";

            if (Directory.Exists(tempPath))
            {
                Directory.Delete(tempPath, true);
            }

            Directory.CreateDirectory(tempPath);

            this.InvokeEx(f => f.lblStatus.Text = "In Progress, Please Wait...");

            for (int i = 0; i < codes.Length; i++)
            {
                if (string.IsNullOrEmpty(codes[i]))
                {
                    continue;
                }

                // this.InvokeEx(f => f.lblStatus.Text = "PDFs generation in Progress for: " + codes[i]);


                var menudata = _menuManagement.GetMenuByMenuCode(codes[i].Trim());

                _menuProcessor.RebuildFlightNumberLotNumberChiliVariableForMenu(Convert.ToInt64(menudata.Id));

                var newDOc = chili.CloneChiliDocument(Convert.ToInt64(menudata.Id));

                chili.UpdateChiliDocumentVariablesallowServerRendering(1, Convert.ToInt64(menudata.Id), newDOc);

                _menuProcessor.GeneratePdfForMenu(Convert.ToInt64(menudata.CycleId), Convert.ToInt64(menudata.Id), 99999, newDOc);
            }

            this.InvokeEx(f => f.lblStatus.Text = "PDFs generated successfully!");

            Process.Start(tempPath);
        }
        protected void UpdateMenuCodes(string menuCodes)
        {
            this.InvokeEx(f => f.lblStatus.Text = "In Progress, Please Wait...");

            var codes = menuCodes.Split(new char[] { ',' });

            for (int i = 0; i < codes.Length; i++)
            {
                if (string.IsNullOrEmpty(codes[i]))
                {
                    continue;
                }

                var menudata = _menuManagement.GetMenuByMenuCode(codes[i].Trim());

                _menuProcessor.RebuildFlightNumberLotNumberChiliVariableForMenu(menudata.Id);
            }

            this.InvokeEx(f => f.lblStatus.Text = "Menucode in chili document has been updated successfully");
        }
Exemple #4
0
        /// <summary>
        /// Generate the order PDF - Upper class chili doc is copied and then PDF generation is done on copy
        /// </summary>
        private void GenerateOrderPDF(int menuTypeSelectedIndex)
        {
            try
            {
                MessageBox.Show("Order PDF Generation is in progress, you will be notified once the PDF generation is complete!");

                this.InvokeEx(f => f.lblStatus.Visible           = true);
                this.InvokeEx(f => f.btnGenerateOrderPDF.Enabled = false);

                var order = txtBoxOrderId.Text.Trim();

                long orderId = Convert.ToInt64(order);

                OrderManagement _orderManagement = new OrderManagement();
                MenuProcessor   _menuProcessor   = new MenuProcessor();

                var liveOrderId = _orderManagement.GetLiveOrderIdFromOrderId(orderId);
                var cycleId     = _orderManagement.GetCycleIdOfLiveOrder(liveOrderId);


                //FOOD GUIDE
                if (menuTypeSelectedIndex == 1)
                {
                    _menuProcessor.GeneratePdfForOrder(cycleId, 1, 5, orderId);
                }
                //all PE class

                if (menuTypeSelectedIndex == 4)
                {
                    _menuProcessor.GeneratePdfForOrder(cycleId, 2, orderId);
                }
                //all Eco class
                if (menuTypeSelectedIndex == 5)
                {
                    _menuProcessor.GeneratePdfForOrder(cycleId, 3, orderId);
                }

                //BRK
                if (menuTypeSelectedIndex == 2)
                {
                    _menuProcessor.GeneratePdfForOrder(cycleId, 1, 3, orderId);
                }


                //MAIN MENU
                if (menuTypeSelectedIndex == 3)
                {
                    List <long> UCMainMenuList   = new List <long>();
                    var         liveOrderDetails = _orderManagement.GetOrderDetailsbyOrderId(orderId);

                    foreach (var ordeDetails in liveOrderDetails)
                    {
                        if (ordeDetails.MenuType == "Main Menu" && ordeDetails.ClassName == "Upper")
                        {
                            if (!UCMainMenuList.Contains(ordeDetails.MenuId))
                            {
                                UCMainMenuList.Add(ordeDetails.MenuId);
                            }
                        }
                    }

                    ChiliProcessor chili = new ChiliProcessor();

                    foreach (var menuId in UCMainMenuList)
                    {
                        _menuProcessor.RebuildFlightNumberLotNumberChiliVariableForMenu(menuId);

                        var newDOc = chili.CloneChiliDocument(menuId);

                        chili.UpdateChiliDocumentVariablesallowServerRendering(1, menuId, newDOc);

                        _menuProcessor.GeneratePdfForMenu(cycleId, menuId, orderId, newDOc);
                    }
                }

                if (menuTypeSelectedIndex == 0)
                {
                    //FOOD GUIDE
                    _menuProcessor.GeneratePdfForOrder(cycleId, 1, 5, orderId);

                    //all PE class
                    _menuProcessor.GeneratePdfForOrder(cycleId, 2, orderId);

                    //all Eco class
                    _menuProcessor.GeneratePdfForOrder(cycleId, 3, orderId);

                    //BRK
                    _menuProcessor.GeneratePdfForOrder(cycleId, 1, 3, orderId);



                    //MAIN MENU
                    List <long> UCMainMenuList   = new List <long>();
                    var         liveOrderDetails = _orderManagement.GetOrderDetailsbyOrderId(orderId);

                    foreach (var ordeDetails in liveOrderDetails)
                    {
                        if (ordeDetails.MenuType == "Main Menu" && ordeDetails.ClassName == "Upper")
                        {
                            if (!UCMainMenuList.Contains(ordeDetails.MenuId))
                            {
                                UCMainMenuList.Add(ordeDetails.MenuId);
                            }
                        }
                    }

                    ChiliProcessor chili = new ChiliProcessor();

                    foreach (var menuId in UCMainMenuList)
                    {
                        _menuProcessor.RebuildFlightNumberLotNumberChiliVariableForMenu(menuId);

                        var newDOc = chili.CloneChiliDocument(menuId);

                        chili.UpdateChiliDocumentVariablesallowServerRendering(1, menuId, newDOc);

                        _menuProcessor.GeneratePdfForMenu(cycleId, menuId, orderId, newDOc);
                    }
                }

                MessageBox.Show("OrderPDF Generation completed successfully!");
                this.InvokeEx(f => f.lblStatus.Text = "OrderPDF Generation completed successfully!");

                this.InvokeEx(f => f.btnGenerateOrderPDF.Enabled = true);
                this.InvokeEx(f => f.btnView.Visible             = true);
                this.InvokeEx(f => f.btnView.Text = "View PDFs");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Order PDF Generation falied, please contact development team!");
                this.InvokeEx(f => f.lblStatus.Text = "Order PDF generation Failed!");

                this.InvokeEx(f => f.btnGenerateOrderPDF.Enabled = true);
            }
        }
Exemple #5
0
        private void btnAddToMenu_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtBoxMenuCode.Text))
            {
                MessageBox.Show("Please enter Menu Code");
                return;
            }


            if (string.IsNullOrEmpty(txtBoxDepartureCode.Text))
            {
                MessageBox.Show("Please enter Departure Airport Code");
                return;
            }


            if (string.IsNullOrEmpty(txtBoxArrivalAirportCode.Text))
            {
                MessageBox.Show("Please enter Arrival Airport Code");
                return;
            }

            if (string.IsNullOrEmpty(txtBoxFlightNumber.Text))
            {
                MessageBox.Show("Please enter Flight Number");
                return;
            }

            if (!string.IsNullOrEmpty(txtBoxFlightNumber.Text))
            {
                if (!txtBoxFlightNumber.Text.Contains("VS"))
                {
                    MessageBox.Show("Invalid flight Number, Valid Flight Number format is VSXXX");
                    return;
                }
            }

            var menu = _menuManagement.GetMenuByMenuCode(txtBoxMenuCode.Text);

            if (menu == null)
            {
                MessageBox.Show("No such menu exists in database: " + txtBoxMenuCode.Text);
                return;
            }

            var routeId = _routeManagement.GetRouteId(txtBoxDepartureCode.Text, txtBoxArrivalAirportCode.Text);


            if (cmbOperation.SelectedItem == "ADD FLIGHT")
            {
                if (!menu.MenuName.Contains(txtBoxFlightNumber.Text))
                {
                    //Menu name has been changed
                    var newMenuName = menu.MenuName + "/" + txtBoxFlightNumber.Text.ToUpper();
                    _menuManagement.UpdateMenuName(menu.Id, newMenuName);

                    //now add/update to menuforRoute table

                    _menuManagement.AddRouteForMenu(menu.Id, routeId, txtBoxFlightNumber.Text.ToUpper());

                    //update the chili document for this flight number

                    _menuProcessor.RebuildFlightNumberLotNumberChiliVariableForMenu(menu.Id);

                    MessageBox.Show("Flight Added Successfully!");
                }
                else
                {
                    MessageBox.Show("Flight is already present in Menu!");
                }
            }


            if (cmbOperation.SelectedItem == "REMOVE FLIGHT")
            {
                if (menu.MenuName.Contains(txtBoxFlightNumber.Text))
                {
                    var oldMenuName = menu.MenuName;
                    var newMenuName = "";

                    var menuNamePart = menu.MenuName.Split(new char[] { '/' });

                    var flights = "";
                    for (int icount = 0; icount < menuNamePart.Length; icount++)
                    {
                        if (menuNamePart[icount] != txtBoxFlightNumber.Text.ToUpper())
                        {
                            newMenuName += menuNamePart[icount] + "/";
                        }
                    }

                    if (newMenuName.EndsWith("/"))
                    {
                        newMenuName = newMenuName.Substring(0, newMenuName.Length - 1);
                    }


                    _menuManagement.UpdateMenuName(menu.Id, newMenuName);

                    _menuManagement.RemoveRouteForMenu(menu.Id, routeId, txtBoxFlightNumber.Text.ToUpper());

                    //update the chili document for this flight number
                    _menuProcessor.RebuildFlightNumberLotNumberChiliVariableForMenu(menu.Id);

                    MessageBox.Show("Flight Removed Successfully!");
                }
                else
                {
                    MessageBox.Show("Flight doesn't seem to be present in Menu, please check with Applaud!");
                }
            }
        }