//[ObjectAuth(ObjectId = ModuleObjectId.EMPLEADOS_OBJECT, PermissionType = PermissionTypes.Export)] public ActionResult Print(string format, int pageIndex, int pageSize, string iSortCol, string sSortDir) { var exportFormatType = (ExportFormatType)Enum.Parse( typeof(ExportFormatType), format, true); if (!_tokenManager.GenerateToken()) { return(null); } _IClienteApiConsumer.SetAuthHeader(_tokenManager.Token); NameValueCollection filter = Request.QueryString; var configuration = new GridConfiguration() { OrderByClause = "", WhereClause = "" }; if (filter != null) { configuration = GridQueryHelper.GetDataTableConfiguration(filter, new ClientePropertyMapper()); } if (Session["AdvanceSearch"] != null && pageSize != 0) { var advanceFilter = (ClienteAdvanceSearchModel)Session["AdvanceSearch"]; configuration.WhereClause = configuration.WhereClause == "" ? GetAdvanceFilter(advanceFilter) : configuration.WhereClause + " AND " + GetAdvanceFilter(advanceFilter); } string sortDirection = "asc"; ClientePropertyMapper oClientePropertyMapper = new ClientePropertyMapper(); if (Request.QueryString["sSortDir"] != null) { sortDirection = Request.QueryString["sSortDir"]; } configuration.OrderByClause = oClientePropertyMapper.GetPropertyName(iSortCol) + " " + sortDirection; pageSize = pageSize == 0 ? int.MaxValue : pageSize; var result = _IClienteApiConsumer.ListaSelAll((pageIndex * pageSize) - pageSize + 1, pageSize + ((pageIndex * pageSize) - pageSize), configuration.WhereClause, configuration.OrderByClause ?? "").Resource; if (result.Clientes == null) { result.Clientes = new List <Cliente>(); } var data = result.Clientes.Select(m => new ClienteGridModel { Clave = m.Clave , Nombre_Completo = m.Nombre_Completo }).ToList(); return(PartialView("_Print", data)); }
public void Export(string format, int pageIndex, int pageSize, string iSortCol, string sSortDir) { var exportFormatType = (ExportFormatType)Enum.Parse( typeof(ExportFormatType), format, true); if (!_tokenManager.GenerateToken()) { return; } _IClienteApiConsumer.SetAuthHeader(_tokenManager.Token); NameValueCollection filter = Request.QueryString; var configuration = new GridConfiguration() { OrderByClause = "", WhereClause = "" }; if (filter != null) { configuration = GridQueryHelper.GetDataTableConfiguration(filter, new ClientePropertyMapper()); } //Adding Advance Search if (Session["AdvanceSearch"] != null && pageSize != 0) { var advanceFilter = (ClienteAdvanceSearchModel)Session["AdvanceSearch"]; configuration.WhereClause = configuration.WhereClause == "" ? GetAdvanceFilter(advanceFilter) : configuration.WhereClause + " AND " + GetAdvanceFilter(advanceFilter); } string sortDirection = "asc"; ClientePropertyMapper oClientePropertyMapper = new ClientePropertyMapper(); if (Request.QueryString["sSortDir"] != null) { sortDirection = Request.QueryString["sSortDir"]; } configuration.OrderByClause = oClientePropertyMapper.GetPropertyName(iSortCol) + " " + sortDirection; pageSize = pageSize == 0 ? int.MaxValue : pageSize; var result = _IClienteApiConsumer.ListaSelAll((pageIndex * pageSize) - pageSize + 1, pageSize + ((pageIndex * pageSize) - pageSize), configuration.WhereClause, configuration.OrderByClause ?? "").Resource; if (result.Clientes == null) { result.Clientes = new List <Cliente>(); } var data = result.Clientes.Select(m => new ClienteGridModel { Clave = m.Clave , Nombre_Completo = m.Nombre_Completo }).ToList(); switch (exportFormatType) { case ExportFormatType.PDF: PdfConverter.ExportToPdf(data.ToDataTable(), "ClienteList_" + DateTime.Now.ToString()); break; case ExportFormatType.EXCEL: ExcelConverter.ExportToExcel(data.ToDataTable(), "ClienteList_" + DateTime.Now.ToString()); break; case ExportFormatType.CSV: CsvConverter.ExportToCSV(data.ToDataTable(), "ClienteList_" + DateTime.Now.ToString()); break; } }
/// <summary> /// Get List of Cliente from Web API. /// </summary> /// <param name="draw"></param> /// <param name="start"></param> /// <param name="length"></param> /// <returns>Return List of Cliente Entity</returns> public ActionResult GetClienteList(UrlParametersModel param) { int sEcho = param.sEcho; int iDisplayStart = param.iDisplayStart; int iDisplayLength = param.iDisplayLength; string where = param.where; string order = param.order; where = HttpUtility.UrlEncode(where); int sortColumn = -1; string sortDirection = "asc"; if (iDisplayLength == -1) { //length = TOTAL_ROWS; iDisplayLength = Int32.MaxValue; } // note: we only sort one column at a time if (param.sortColumn != null) { sortColumn = int.Parse(param.sortColumn); } if (param.sortDirection != null) { sortDirection = param.sortDirection; } if (!_tokenManager.GenerateToken()) { return(null); } _IClienteApiConsumer.SetAuthHeader(_tokenManager.Token); NameValueCollection filter = HttpUtility.ParseQueryString(param.filters); var configuration = new GridConfiguration() { OrderByClause = "", WhereClause = "" }; if (filter != null) { configuration = GridQueryHelper.GetDataTableConfigurationNew(param, new ClientePropertyMapper()); } if (!String.IsNullOrEmpty(where)) { configuration.WhereClause = configuration.WhereClause == "" ? where : "(" + configuration.WhereClause + " AND " + where + ")"; } if (!String.IsNullOrEmpty(order)) { configuration.OrderByClause = order; } //Adding Advance Search if (param.AdvanceSearch != null && param.AdvanceSearch == true && Session["AdvanceSearch"] != null) { if (Session["AdvanceSearch"].GetType() == typeof(ClienteAdvanceSearchModel)) { var advanceFilter = (ClienteAdvanceSearchModel)Session["AdvanceSearch"]; configuration.WhereClause = configuration.WhereClause == "" ? GetAdvanceFilter(advanceFilter) : configuration.WhereClause + " AND " + GetAdvanceFilter(advanceFilter); } else { Session.Remove("AdvanceSearch"); } } ClientePropertyMapper oClientePropertyMapper = new ClientePropertyMapper(); if (String.IsNullOrEmpty(order)) { if (sortColumn != -1) { configuration.OrderByClause = oClientePropertyMapper.GetPropertyName(param.columns[sortColumn].name) + " " + sortDirection; } } var pageSize = iDisplayLength; var pageIndex = (iDisplayStart / iDisplayLength) + 1; var result = _IClienteApiConsumer.ListaSelAll((pageIndex * pageSize) - pageSize + 1, pageSize + ((pageIndex * pageSize) - pageSize), configuration.WhereClause, configuration.OrderByClause ?? "").Resource; if (result.Clientes == null) { result.Clientes = new List <Cliente>(); } return(Json(new { aaData = result.Clientes.Select(m => new ClienteGridModel { Clave = m.Clave , Nombre_Completo = m.Nombre_Completo }).ToList(), iTotalRecords = result.RowCount, iTotalDisplayRecords = result.RowCount, sEcho = sEcho }, JsonRequestBehavior.AllowGet)); }