// GET: AutoAcceptance public ActionResult Index(int?page, int?sortby, int?sortorder, int?pagevalue, int?ConfidenceCode = null, string MatchGrade = null, int?CountyGroupId = null, string Tags = null) { if (MatchGrade == "Select Match Grade" || MatchGrade == "0" || string.IsNullOrEmpty(MatchGrade) || MatchGrade == "undefined") { MatchGrade = null; } #region Pagination code int pageNumber = (page ?? 1); if (!(sortby.HasValue && sortby.Value > 0)) { sortby = 22; } if (!(sortorder.HasValue && sortorder.Value > 0)) { sortorder = 1; } int sortParam = int.Parse(sortby.ToString() + sortorder.ToString()); int totalCount = 0; int currentPageIndex = page.HasValue ? page.Value : 1; int pageSize = pagevalue.HasValue ? pagevalue.Value : 30; ViewBag.SortBy = sortby; ViewBag.SortOrder = sortorder; ViewBag.pageno = currentPageIndex; ViewBag.pagevalue = pageSize; TempData["pageno"] = currentPageIndex; TempData["pagevalue"] = pageSize; ViewBag.ConfidenceCode = ConfidenceCode; ViewBag.MatchGrade = MatchGrade; ViewBag.TagList = Tags; ViewBag.CountyGroupId = CountyGroupId; #endregion string finalsortOrder = Convert.ToString(sortby) + Convert.ToString(sortorder); List <AutoAdditionalAcceptanceCriteriaEntity> model = new List <AutoAdditionalAcceptanceCriteriaEntity>(); SettingFacade fac = new SettingFacade(this.CurrentClient.ApplicationDBConnectionString); Tags = Tags == "undefined" ? null : Tags; model = fac.GetAutoAcceptanceDetailsPagedSorted(Convert.ToInt32(finalsortOrder), currentPageIndex, pageSize, out totalCount, ConfidenceCode == null ? 0 : Convert.ToInt32(ConfidenceCode), MatchGrade, CountyGroupId == null ? 0 : Convert.ToInt32(CountyGroupId), Tags); IPagedList <AutoAdditionalAcceptanceCriteriaEntity> pagedAcceptance = new StaticPagedList <AutoAdditionalAcceptanceCriteriaEntity>(model.ToList(), currentPageIndex, pageSize, totalCount); ViewBag.Message = TempData["MessageAAC"]; TempData["MessageAAC"] = ""; TempData.Keep(); if (Request.IsAjaxRequest()) { return(PartialView("_index", pagedAcceptance)); } else { return(View(pagedAcceptance)); } }
public ActionResult ExportToExcel(int?ConfidenceCode = null, string MatchGrade = null, int?CountyGroupId = null, string Tags = null) { // Export data to Excel Sheet . string url = Request.Url.Scheme + "://" + Request.Url.Authority; string[] hostParts = new System.Uri(url).Host.Split('.'); string domain = hostParts[0]; SettingFacade fac = new SettingFacade(this.CurrentClient.ApplicationDBConnectionString); DataTable dtAutoAcceptRules = new DataTable(); int totalCount = 0; List <AutoAdditionalAcceptanceCriteriaEntity> lstAutoAccpetance = new List <AutoAdditionalAcceptanceCriteriaEntity>(); lstAutoAccpetance = fac.GetAutoAcceptanceDetailsPagedSorted(11, 1, 100000, out totalCount, ConfidenceCode == null ? 0 : Convert.ToInt32(ConfidenceCode), string.IsNullOrEmpty(MatchGrade) ? null : MatchGrade, CountyGroupId == null ? 0 : Convert.ToInt32(CountyGroupId), Tags); dtAutoAcceptRules = CommonMethod.ToDataTable(lstAutoAccpetance); //dtAutoAcceptRules = fac.GetAutoAcceptanceDetailsExportToExcel(Helper.LicenseEnableTags, Convert.ToInt32(ConfidenceCode), MatchGrade, CountyGroupId == null ? 0 : Convert.ToInt32(CountyGroupId), Tags); dtAutoAcceptRules.Columns.Remove("Error"); dtAutoAcceptRules.Columns.Remove("lstAutoAcceptanceCriteriaDetail"); dtAutoAcceptRules.Columns.Remove("item"); dtAutoAcceptRules.Columns.Remove("CriteriaGroupId"); dtAutoAcceptRules.Columns.Remove("groupId"); dtAutoAcceptRules.Columns.Remove("UserId"); dtAutoAcceptRules.Columns.Remove("UserName"); dtAutoAcceptRules.Columns.Remove("IsValidSave"); dtAutoAcceptRules.Columns.Remove("GroupId"); dtAutoAcceptRules.Columns.Remove("MatchGrade"); dtAutoAcceptRules.Columns.Remove("MDPCode"); if (dtAutoAcceptRules.Columns.Contains("CountryGroupId")) { dtAutoAcceptRules.Columns.Remove("CountryGroupId"); } string fileName = domain + "_AutoAcceptRules_" + DateTime.Now.Ticks.ToString() + ".xlsx"; // Make Excel sheet and download file using (ExcelPackage package = new ExcelPackage()) { ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Auto Accept Rules"); worksheet.Cells.LoadFromDataTable(dtAutoAcceptRules, true); package.Workbook.Properties.Title = "Auto Accept Rules"; return(File(package.GetAsByteArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName)); } }