private void BuildAuditForMenuType(tMenuType menutype, ExcelPackage package, Dictionary <string, int> headerColumns, long cycleId, int classId)
        {
            try
            {
                var menuTypeName = menutype.DisplayName;

                var worksheet = package.Workbook.Worksheets.Add(menuTypeName);

                // Write column headers
                foreach (var colKvp in headerColumns)
                {
                    if (colKvp.Value > 0)
                    {
                        worksheet.Cells[1, colKvp.Value].Value           = colKvp.Key;
                        worksheet.Cells[1, colKvp.Value].Style.Font.Bold = true;
                        worksheet.Cells[1, colKvp.Value].AutoFitColumns();
                        worksheet.Cells[1, colKvp.Value].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                        worksheet.Cells[1, colKvp.Value].Style.VerticalAlignment   = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
                        worksheet.Cells[1, colKvp.Value].Style.Border.BorderAround(
                            OfficeOpenXml.Style.ExcelBorderStyle.Thin, System.Drawing.Color.Black);
                    }
                }



                // Write records
                var menus = _menuManagement.GetMenuByCycleClassAndMenutype(cycleId, classId, menutype.ID);

                int y        = 2;
                int rowCount = 0;

                foreach (var menu in menus)
                {
                    var menunameParts = menu.MenuName.Split(new char[] { '/' });

                    var flights = "";

                    for (int i = 1; i < menunameParts.Length; i++)
                    {
                        flights += menunameParts[i];

                        if (i != menunameParts.Length - 1)
                        {
                            flights += ",";
                        }
                    }

                    var menuHistory = _menuManagement.GetMenuHistory(menu.Id);

                    if (menuHistory == null)
                    {
                        continue;
                    }

                    foreach (var history in menuHistory)
                    {
                        worksheet.Cells[y + rowCount, headerColumns["MenuCode"]].Value                     = menu.MenuCode;
                        worksheet.Cells[y + rowCount, headerColumns["MenuCode"]].Style.WrapText            = true;
                        worksheet.Cells[y + rowCount, headerColumns["MenuCode"]].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                        worksheet.Cells[y + rowCount, headerColumns["MenuCode"]].Style.VerticalAlignment   = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
                        worksheet.Cells[y + rowCount, headerColumns["MenuCode"]].Style.Border.BorderAround(
                            OfficeOpenXml.Style.ExcelBorderStyle.Thin, System.Drawing.Color.Black);

                        worksheet.Cells[y + rowCount, headerColumns["MenuName"]].Value                     = menunameParts[0];
                        worksheet.Cells[y + rowCount, headerColumns["MenuName"]].Style.WrapText            = true;
                        worksheet.Cells[y + rowCount, headerColumns["MenuName"]].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                        worksheet.Cells[y + rowCount, headerColumns["MenuName"]].Style.VerticalAlignment   = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
                        worksheet.Cells[y + rowCount, headerColumns["MenuName"]].Style.Border.BorderAround(
                            OfficeOpenXml.Style.ExcelBorderStyle.Thin, System.Drawing.Color.Black);

                        worksheet.Cells[y + rowCount, headerColumns["Flights"]].Value                     = flights;
                        worksheet.Cells[y + rowCount, headerColumns["Flights"]].Style.WrapText            = true;
                        worksheet.Cells[y + rowCount, headerColumns["Flights"]].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                        worksheet.Cells[y + rowCount, headerColumns["Flights"]].Style.VerticalAlignment   = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
                        worksheet.Cells[y + rowCount, headerColumns["Flights"]].Style.Border.BorderAround(
                            OfficeOpenXml.Style.ExcelBorderStyle.Thin, System.Drawing.Color.Black);

                        worksheet.Cells[y + rowCount, headerColumns["ActionTaken"]].Value                     = history.ActionTaken;
                        worksheet.Cells[y + rowCount, headerColumns["ActionTaken"]].Style.WrapText            = true;
                        worksheet.Cells[y + rowCount, headerColumns["ActionTaken"]].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                        worksheet.Cells[y + rowCount, headerColumns["ActionTaken"]].Style.VerticalAlignment   = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
                        worksheet.Cells[y + rowCount, headerColumns["ActionTaken"]].Style.Border.BorderAround(
                            OfficeOpenXml.Style.ExcelBorderStyle.Thin, System.Drawing.Color.Black);

                        worksheet.Cells[y + rowCount, headerColumns["ModifiedAt"]].Value                     = Convert.ToDateTime(history.ModifiedAt).ToShortDateString();
                        worksheet.Cells[y + rowCount, headerColumns["ModifiedAt"]].Style.WrapText            = true;
                        worksheet.Cells[y + rowCount, headerColumns["ModifiedAt"]].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                        worksheet.Cells[y + rowCount, headerColumns["ModifiedAt"]].Style.VerticalAlignment   = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
                        worksheet.Cells[y + rowCount, headerColumns["ModifiedAt"]].Style.Border.BorderAround(
                            OfficeOpenXml.Style.ExcelBorderStyle.Thin, System.Drawing.Color.Black);

                        var user = _accountManagement.GetUserById(Convert.ToInt32(history.ActionByUserID));
                        worksheet.Cells[y + rowCount, headerColumns["ActionByUser"]].Value                     = user.FirstName + " " + user.LastName;
                        worksheet.Cells[y + rowCount, headerColumns["ActionByUser"]].Style.WrapText            = true;
                        worksheet.Cells[y + rowCount, headerColumns["ActionByUser"]].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                        worksheet.Cells[y + rowCount, headerColumns["ActionByUser"]].Style.VerticalAlignment   = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
                        worksheet.Cells[y + rowCount, headerColumns["ActionByUser"]].Style.Border.BorderAround(
                            OfficeOpenXml.Style.ExcelBorderStyle.Thin, System.Drawing.Color.Black);

                        rowCount++;
                    }
                }

                worksheet.Column(1).Width = 15;
                worksheet.Column(2).Width = 40;
                worksheet.Column(3).Width = 70;
                worksheet.Column(4).Width = 25;
                worksheet.Column(5).Width = 35;
                worksheet.Column(6).Width = 25;
            }
            catch (Exception ex)
            {
                //write to Elma
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }
        private void BuildPrintStatusAuditForMenuType(tMenuType menutype, ExcelPackage package, Dictionary <string, int> headerColumns, long cycleId, int classId)
        {
            try
            {
                var menuTypeName = menutype.DisplayName;

                var worksheet = package.Workbook.Worksheets.Add(menuTypeName);

                // Write column headers
                foreach (var colKvp in headerColumns)
                {
                    if (colKvp.Value > 0)
                    {
                        worksheet.Cells[1, colKvp.Value].Value           = colKvp.Key;
                        worksheet.Cells[1, colKvp.Value].Style.Font.Bold = true;
                        worksheet.Cells[1, colKvp.Value].AutoFitColumns();
                        worksheet.Cells[1, colKvp.Value].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                        worksheet.Cells[1, colKvp.Value].Style.VerticalAlignment   = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
                        worksheet.Cells[1, colKvp.Value].Style.Border.BorderAround(
                            OfficeOpenXml.Style.ExcelBorderStyle.Thin, System.Drawing.Color.Black);
                    }
                }

                // Write records
                var menus = _menuManagement.GetMenuByCycleClassAndMenutype(cycleId, classId, menutype.ID);

                int y        = 2;
                int rowCount = 0;

                foreach (var menu in menus)
                {
                    var menuDetails = _menuManagement.GetMenuById(menu.Id);

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

                    var flights = "";

                    for (int i = 1; i < menunameParts.Length; i++)
                    {
                        flights += menunameParts[i];

                        if (i != menunameParts.Length - 1)
                        {
                            flights += ",";
                        }
                    }
                    worksheet.Cells[y + rowCount, headerColumns["MenuCode"]].Value                     = menuDetails.MenuCode;
                    worksheet.Cells[y + rowCount, headerColumns["MenuCode"]].Style.WrapText            = true;
                    worksheet.Cells[y + rowCount, headerColumns["MenuCode"]].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                    worksheet.Cells[y + rowCount, headerColumns["MenuCode"]].Style.VerticalAlignment   = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
                    worksheet.Cells[y + rowCount, headerColumns["MenuCode"]].Style.Border.BorderAround(
                        OfficeOpenXml.Style.ExcelBorderStyle.Thin, System.Drawing.Color.Black);

                    worksheet.Cells[y + rowCount, headerColumns["MenuName"]].Value                     = menunameParts[0];
                    worksheet.Cells[y + rowCount, headerColumns["MenuName"]].Style.WrapText            = true;
                    worksheet.Cells[y + rowCount, headerColumns["MenuName"]].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                    worksheet.Cells[y + rowCount, headerColumns["MenuName"]].Style.VerticalAlignment   = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
                    worksheet.Cells[y + rowCount, headerColumns["MenuName"]].Style.Border.BorderAround(
                        OfficeOpenXml.Style.ExcelBorderStyle.Thin, System.Drawing.Color.Black);

                    worksheet.Cells[y + rowCount, headerColumns["Flights"]].Value                     = flights;
                    worksheet.Cells[y + rowCount, headerColumns["Flights"]].Style.WrapText            = true;
                    worksheet.Cells[y + rowCount, headerColumns["Flights"]].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                    worksheet.Cells[y + rowCount, headerColumns["Flights"]].Style.VerticalAlignment   = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
                    worksheet.Cells[y + rowCount, headerColumns["Flights"]].Style.Border.BorderAround(
                        OfficeOpenXml.Style.ExcelBorderStyle.Thin, System.Drawing.Color.Black);

                    worksheet.Cells[y + rowCount, headerColumns["CurrentStatus"]].Value                     = menuDetails.ApprovalStatusName;
                    worksheet.Cells[y + rowCount, headerColumns["CurrentStatus"]].Style.WrapText            = true;
                    worksheet.Cells[y + rowCount, headerColumns["CurrentStatus"]].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                    worksheet.Cells[y + rowCount, headerColumns["CurrentStatus"]].Style.VerticalAlignment   = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
                    worksheet.Cells[y + rowCount, headerColumns["CurrentStatus"]].Style.Border.BorderAround(
                        OfficeOpenXml.Style.ExcelBorderStyle.Thin, System.Drawing.Color.Black);

                    rowCount++;
                }

                worksheet.Column(1).Width = 15;
                worksheet.Column(2).Width = 40;
                worksheet.Column(3).Width = 70;
                worksheet.Column(4).Width = 25;
            }
            catch (Exception ex)
            {
                //write to Elma
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }