Beispiel #1
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);
            }
        }
        protected void radGridCurrentOrder_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "RowClick" || e.CommandName == "ExpandCollapse")
                {
                    bool lastState = e.Item.Expanded;

                    if (e.CommandName == "ExpandCollapse")
                    {
                        lastState = !lastState;
                    }

                    CollapseAllRows();
                    e.Item.Expanded = !lastState;
                }

                else if (e.CommandName.Equals("ClearFilter"))
                {
                    foreach (GridColumn column in radGridCurrentOrder.MasterTableView.Columns)
                    {
                        column.CurrentFilterFunction = GridKnownFunction.NoFilter;
                        column.CurrentFilterValue    = string.Empty;
                    }
                    radGridCurrentOrder.MasterTableView.FilterExpression = string.Empty;
                    radGridCurrentOrder.MasterTableView.Rebind();
                }
                else if (e.CommandName.Equals("Refresh"))
                {
                    foreach (GridColumn column in radGridCurrentOrder.MasterTableView.Columns)
                    {
                        column.CurrentFilterFunction = GridKnownFunction.NoFilter;
                        column.CurrentFilterValue    = string.Empty;
                    }
                    radGridCurrentOrder.MasterTableView.FilterExpression = string.Empty;
                    radGridCurrentOrder.DataSource = null;
                    BindGridCurrentOrder();
                }
                else if (e.CommandName.Equals("DownloadPrintRun"))
                {
                    Label lblOrderId = (Label)e.Item.FindControl("lblOrderIdV");
                    Int64 orderId    = Convert.ToInt64(lblOrderId.Text);
                    DownloadPrintRun(orderId);
                }
                else if (e.CommandName.Equals("DownloadPrintPDF"))
                {
                    Label lblOrderId = (Label)e.Item.FindControl("lblOrderIdV");
                    Int64 orderId    = Convert.ToInt64(lblOrderId.Text);

                    var liveOrderId = _orderManagement.GetLiveOrderIdFromOrderId(orderId);

                    var cycleId = _orderManagement.GetCycleIdOfLiveOrder(liveOrderId);

                    //all upper class
                    _menuProcessor.GeneratePdfForOrder(cycleId, 1, orderId);
                    //all PE class
                    _menuProcessor.GeneratePdfForOrder(cycleId, 2, orderId);
                    //all Eco class
                    _menuProcessor.GeneratePdfForOrder(cycleId, 3, orderId);


                    //send email
                    int userId = Convert.ToInt32(Session["USERID"]);
                    var user   = _accountManagement.GetUserById(userId);

                    var PDFMessage = EmailHelper.OrderPdfGenerationCompleteEmailTemplate;
                    PDFMessage = EmailHelper.ConvertMail2(PDFMessage, Convert.ToString(orderId), "\\[ORDERID\\]");

                    EmailHelper.SendMail(user.Username, "*****@*****.**", "EMMA- PDF Generation for Order", PDFMessage);

                    string notificationEmails = (System.Configuration.ConfigurationManager.AppSettings["NotificationEmails"]);

                    var emails = notificationEmails.Split(new char[] { ';' });

                    foreach (var email in emails)
                    {
                        if (!string.IsNullOrEmpty(email))
                        {
                            EmailHelper.SendMail(email, "*****@*****.**", "EMMA- PDF Generation for Order", PDFMessage);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //write to Elma
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }