Esempio n. 1
0
        /*
         * [HttpGet]
         * public ActionResult GetTipo_de_AmparoAll()
         * {
         * try
         * {
         * if (!_tokenManager.GenerateToken())
         *  return Json(null, JsonRequestBehavior.AllowGet);
         * _ITipo_de_AmparoApiConsumer.SetAuthHeader(_tokenManager.Token);
         * var result = _ITipo_de_AmparoApiConsumer.SelAll(false).Resource;
         *
         * return Json(result.OrderBy(m => m.).Select(m => new SelectListItem
         * {
         *   Text = CultureHelper.GetTraductionNew(Convert.ToString(m.Clave), "Tipo_de_Amparo", m.),
         *   Value = Convert.ToString(m.Clave)
         * }).ToArray(), JsonRequestBehavior.AllowGet);
         * }
         * catch (ServiceException ex)
         * {
         * return Json(null, JsonRequestBehavior.AllowGet);
         * }
         * }
         */
        /// <summary>
        /// Get List of Tipo_de_Amparo from Web API.
        /// </summary>
        /// <param name="draw"></param>
        /// <param name="start"></param>
        /// <param name="length"></param>
        /// <returns>Return List of Tipo_de_Amparo Entity</returns>
        public ActionResult GetTipo_de_AmparoList(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);
            }
            _ITipo_de_AmparoApiConsumer.SetAuthHeader(_tokenManager.Token);


            NameValueCollection filter = HttpUtility.ParseQueryString(param.filters);

            var configuration = new GridConfiguration()
            {
                OrderByClause = "", WhereClause = ""
            };

            if (filter != null)
            {
                configuration = GridQueryHelper.GetDataTableConfigurationNew(param, new Tipo_de_AmparoPropertyMapper());
            }

            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(Tipo_de_AmparoAdvanceSearchModel))
                {
                    var advanceFilter =
                        (Tipo_de_AmparoAdvanceSearchModel)Session["AdvanceSearch"];
                    configuration.WhereClause = configuration.WhereClause == "" ? GetAdvanceFilter(advanceFilter) : configuration.WhereClause + " AND " + GetAdvanceFilter(advanceFilter);
                }
                else
                {
                    Session.Remove("AdvanceSearch");
                }
            }

            Tipo_de_AmparoPropertyMapper oTipo_de_AmparoPropertyMapper = new Tipo_de_AmparoPropertyMapper();

            if (String.IsNullOrEmpty(order))
            {
                if (sortColumn != -1)
                {
                    configuration.OrderByClause = oTipo_de_AmparoPropertyMapper.GetPropertyName(param.columns[sortColumn].name) + " " + sortDirection;
                }
            }

            var pageSize  = iDisplayLength;
            var pageIndex = (iDisplayStart / iDisplayLength) + 1;
            var result    = _ITipo_de_AmparoApiConsumer.ListaSelAll((pageIndex * pageSize) - pageSize + 1, pageSize + ((pageIndex * pageSize) - pageSize), configuration.WhereClause, configuration.OrderByClause ?? "").Resource;

            if (result.Tipo_de_Amparos == null)
            {
                result.Tipo_de_Amparos = new List <Tipo_de_Amparo>();
            }

            return(Json(new
            {
                aaData = result.Tipo_de_Amparos.Select(m => new Tipo_de_AmparoGridModel
                {
                    Clave = m.Clave
                    , Descripcion = m.Descripcion
                }).ToList(),
                iTotalRecords = result.RowCount,
                iTotalDisplayRecords = result.RowCount,
                sEcho = sEcho
            }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public void Export(string format, int pageIndex, int pageSize, string iSortCol, string sSortDir, string where, string order, dynamic columnsVisible)
        {
            var exportFormatType = (ExportFormatType)Enum.Parse(
                typeof(ExportFormatType), format, true);

            string[] arrayColumnsVisible = ((string[])columnsVisible)[0].ToString().Split(',');

            where = HttpUtility.UrlEncode(where);
            if (!_tokenManager.GenerateToken())
            {
                return;
            }

            _ITipo_de_AmparoApiConsumer.SetAuthHeader(_tokenManager.Token);

            NameValueCollection filter = Request.QueryString;
            var configuration          = new GridConfiguration()
            {
                OrderByClause = "", WhereClause = ""
            };

            if (filter != null)
            {
                configuration = GridQueryHelper.GetDataTableConfiguration(filter, new Tipo_de_AmparoPropertyMapper());
            }

            if (!String.IsNullOrEmpty(where))
            {
                configuration.WhereClause = configuration.WhereClause == "" ? where : "(" + configuration.WhereClause + " AND " + where + ")";
            }
            if (!String.IsNullOrEmpty(order))
            {
                configuration.OrderByClause = order;
            }
            //Adding Advance Search
            if (Session["AdvanceSearch"] != null && pageSize != 0)
            {
                var advanceFilter =
                    (Tipo_de_AmparoAdvanceSearchModel)Session["AdvanceSearch"];
                configuration.WhereClause = configuration.WhereClause == "" ? GetAdvanceFilter(advanceFilter) : configuration.WhereClause + " AND " + GetAdvanceFilter(advanceFilter);
            }
            string sortDirection = "asc";

            Tipo_de_AmparoPropertyMapper oTipo_de_AmparoPropertyMapper = new Tipo_de_AmparoPropertyMapper();

            if (Request.QueryString["sSortDir"] != null)
            {
                sortDirection = Request.QueryString["sSortDir"];
            }
            configuration.OrderByClause = oTipo_de_AmparoPropertyMapper.GetPropertyName(iSortCol) + " " + sortDirection;
            pageSize = pageSize == 0 ? int.MaxValue : pageSize;

            var result = _ITipo_de_AmparoApiConsumer.ListaSelAll((pageIndex * pageSize) - pageSize + 1, pageSize + ((pageIndex * pageSize) - pageSize), configuration.WhereClause, configuration.OrderByClause ?? "").Resource;

            if (result.Tipo_de_Amparos == null)
            {
                result.Tipo_de_Amparos = new List <Tipo_de_Amparo>();
            }

            var data = result.Tipo_de_Amparos.Select(m => new Tipo_de_AmparoGridModel
            {
                Clave         = m.Clave
                , Descripcion = m.Descripcion
            }).ToList();

            switch (exportFormatType)
            {
            case ExportFormatType.PDF:
                PdfConverter.ExportToPdf(data.ToDataTable(45662, arrayColumnsVisible), "Tipo_de_AmparoList_" + DateTime.Now.ToString());
                break;

            case ExportFormatType.EXCEL:
                ExcelConverter.ExportToExcel(data.ToDataTable(45662, arrayColumnsVisible), "Tipo_de_AmparoList_" + DateTime.Now.ToString());
                break;

            case ExportFormatType.CSV:
                CsvConverter.ExportToCSV(data.ToDataTable(45662, arrayColumnsVisible), "Tipo_de_AmparoList_" + DateTime.Now.ToString());
                break;
            }
        }
Esempio n. 3
0
        //[ObjectAuth(ObjectId = ModuleObjectId.EMPLEADOS_OBJECT, PermissionType = PermissionTypes.Export)]
        public ActionResult Print(string format, int pageIndex, int pageSize, string iSortCol, string sSortDir, string where, string order)
        {
            var exportFormatType = (ExportFormatType)Enum.Parse(
                typeof(ExportFormatType), format, true);

            where = HttpUtility.UrlEncode(where);

            if (!_tokenManager.GenerateToken())
            {
                return(null);
            }

            _ITipo_de_AmparoApiConsumer.SetAuthHeader(_tokenManager.Token);

            NameValueCollection filter = Request.QueryString;

            var configuration = new GridConfiguration()
            {
                OrderByClause = "", WhereClause = ""
            };

            if (filter != null)
            {
                configuration = GridQueryHelper.GetDataTableConfiguration(filter, new Tipo_de_AmparoPropertyMapper());
            }


            if (!String.IsNullOrEmpty(where))
            {
                configuration.WhereClause = configuration.WhereClause == "" ? where : "(" + configuration.WhereClause + " AND " + where + ")";
            }
            if (Session["AdvanceSearch"] != null && pageSize != 0)
            {
                var advanceFilter =
                    (Tipo_de_AmparoAdvanceSearchModel)Session["AdvanceSearch"];
                configuration.WhereClause = configuration.WhereClause == "" ? GetAdvanceFilter(advanceFilter) : configuration.WhereClause + " AND " + GetAdvanceFilter(advanceFilter);
            }

            string sortDirection = "asc";

            Tipo_de_AmparoPropertyMapper oTipo_de_AmparoPropertyMapper = new Tipo_de_AmparoPropertyMapper();

            if (Request.QueryString["sSortDir"] != null)
            {
                sortDirection = Request.QueryString["sSortDir"];
            }
            configuration.OrderByClause = oTipo_de_AmparoPropertyMapper.GetPropertyName(iSortCol) + " " + sortDirection;

            if (!String.IsNullOrEmpty(order))
            {
                configuration.OrderByClause = order;
            }
            pageSize = pageSize == 0 ? int.MaxValue : pageSize;

            var result = _ITipo_de_AmparoApiConsumer.ListaSelAll((pageIndex * pageSize) - pageSize + 1, pageSize + ((pageIndex * pageSize) - pageSize), configuration.WhereClause, configuration.OrderByClause ?? "").Resource;

            if (result.Tipo_de_Amparos == null)
            {
                result.Tipo_de_Amparos = new List <Tipo_de_Amparo>();
            }

            var data = result.Tipo_de_Amparos.Select(m => new Tipo_de_AmparoGridModel
            {
                Clave         = m.Clave
                , Descripcion = m.Descripcion
            }).ToList();

            return(PartialView("_Print", data));
        }