public override void OnException(ExceptionContext context) { if (!context.ExceptionHandled) { logger.LogError(context.HttpContext.Request.GetDisplayUrl() + " 执行异常..." + context.Exception.Message); logger.LogError(context.Exception.StackTrace); if (_env.IsDevelopment() || _env.IsStaging()) { if (context.Exception.InnerException == null) { context.Result = RetData.ExceptionErr(context.Exception.Message); } else { context.Result = RetData.ExceptionErr(context.Exception.InnerException.GetBaseException().Message); } } else { context.Result = RetData.ExceptionErr("系统繁忙"); } context.ExceptionHandled = true; } }
public async Task <IActionResult> GetAccesss() { try { RetData <IEnumerable <IenetAccesses> > ListData = await ApiClientFactory.Instance.GetIenetAccesses(ApiClientFactory.Instance.Encrypt($"Fun|{HttpContext.Session.GetObjSession<string>("Session.HashId")}")); List <IenetAccessesModel> Records = ListData.Data.Select(O => new IenetAccessesModel() { Id = O.Id, Descr = O.Descr }).ToList(); List <IenetAccessesModel> AllRecords = new List <IenetAccessesModel>(); int Total = 0; if (Records.Count() > 0) { AllRecords = Utility.ExpressionBuilderHelper.W2uiSearchNoSkip <IenetAccessesModel>(Records, Request.Form); Records = Utility.ExpressionBuilderHelper.W2uiSearch <IenetAccessesModel>(Records, Request.Form); Total = Records.Count; } return(Json(new { Total, Records, errorMessage = "", AllRecords })); } catch (Exception e1) { return(Json(new { total = 0, records = "", errorMessage = e1.ToString() })); } }
public IActionResult Change([FromBody] ReqChangeFee req) { var validator = new ReqChangeFeeValidator(); string validInfo = CommonUtil.Validate(req, validator); ResChargeFee_DS data = InterfaceHNUtil.ChangeFee(req); return(RetData.SuccessData(data)); }
public IActionResult GetPersonInfo([FromBody] ReqPersonInfo req) { var validator = new ReqPersonInfoValidator(); string validInfo = CommonUtil.Validate(req, validator); ResPersonInfo_DS data = InterfaceHNUtil.GetPersonInfo(req); return(RetData.SuccessData(data)); }
public IActionResult TestComInfo() { Type t = Type.GetTypeFromCLSID(new Guid("F0E70DF1-66B0-40c2-8210-40CEBBB8A6DA")); object obj = System.Activator.CreateInstance(t); object r = t.InvokeMember("test", System.Reflection.BindingFlags.InvokeMethod, null, obj, null); return(RetData.SuccessData(r)); }
public async Task <IActionResult> GetPedidosExternosPendientesAdmin() { try { RetData <List <PedidosPendientesAdmin> > ListDis = await ApiLongClientFactory.Instance.GetPedidosPendientesAdmin(HttpContext.Session.GetObjSession <int>("Session.ClientId")); return(Json(new { codError = ListDis.Info.CodError, errorMessage = ListDis.Info.Mensaje, data = ListDis.Data })); } catch (Exception e1) { return(Json(new { codError = -1, errorMessage = e1.ToString() })); } }
public async Task <IActionResult> GetClientsOrders() { try { RetData <IEnumerable <ClientesModel> > ListClientOrders = await ApiClientFactory.Instance.GetClientsOrders(); return(Json(new { codError = ListClientOrders.Info.CodError, errorMessage = ListClientOrders.Info.Mensaje, data = ListClientOrders.Data })); } catch (Exception e1) { return(Json(new { codError = -1, errorMessage = e1.ToString() })); } }
public IActionResult GetModelJson(string modelClass) { try { Type type = Type.GetType(modelClass); var obj = System.Activator.CreateInstance(type); return(RetData.SuccessData(obj)); } catch (Exception ex) { return(RetData.ExceptionErr(ex.Message)); } }
public override void OnActionExecuting(ActionExecutingContext context) { DateTime d1 = DateTime.Now; try { var isDefineAllowAnonymous = false; var controllerActionDescriptor = context.ActionDescriptor as ControllerActionDescriptor; context.HttpContext.Request.Body.Position = 0; //string bodyStr = string.Empty; //using (var reader = new StreamReader(context.HttpContext.Request.Body, Encoding.UTF8, true, 1024, true)) using (var reader = new StreamReader(context.HttpContext.Request.Body, Encoding.UTF8)) { var bodyRead = reader.ReadToEndAsync(); bodyStr = bodyRead.Result; //把body赋值给bodyStr } logger.LogInformation($" ApiActionFilter {controllerActionDescriptor.DisplayName} 执行开始..."); logger.LogInformation($"Input: {bodyStr}"); if (controllerActionDescriptor != null) { isDefineAllowAnonymous = controllerActionDescriptor.ControllerTypeInfo.GetCustomAttributes(inherit: true).Any(a => a.GetType().Equals(typeof(AllowAnonymousAttribute))); if (isDefineAllowAnonymous == false) { isDefineAllowAnonymous = controllerActionDescriptor.MethodInfo.GetCustomAttributes(inherit: true).Any(a => a.GetType().Equals(typeof(AllowAnonymousAttribute))); } } base.OnActionExecuting(context); DateTime d2 = DateTime.Now; var ts = d2 - d1; if (ts.TotalSeconds >= 5) { logger.LogWarning(" ApiActionFilter 访问时间过长:" + ts.TotalMilliseconds.ToString()); } } catch (Exception ex) { context.Result = RetData.ExceptionErr(ex.Message); logger.LogError(" ApiActionFilter 访问异常:" + ex.Message); logger.LogInformation(" ApiActionFilter 访问异常:" + ex.Message); } }
public async Task <RetData <string> > GaDelete(int gaId) { DateTime StartTime = DateTime.Now; try { RetData <string> Ret = await ApiClientFactory.Instance.GaDelete(gaId); return(Ret); } catch (Exception e1) { return(new RetData <string>() { Info = new RetInfo() { CodError = -1, Mensaje = e1.ToString(), ResponseTimeSeconds = (DateTime.Now - StartTime).TotalSeconds } }); } }
public async Task <RetData <IEnumerable <ClientesModel> > > GetClientsOrders() { DateTime StartTime = DateTime.Now; try { RetData <IEnumerable <ClientesModel> > ListClientOrders = await ApiClientFactory.Instance.GetClientsOrders(); return(ListClientOrders); } catch (Exception e1) { return(new RetData <IEnumerable <ClientesModel> > { Info = new RetInfo { CodError = -1, Mensaje = e1.ToString(), ResponseTimeSeconds = (DateTime.Now - StartTime).TotalSeconds } }); } }
public async Task <IActionResult> GetGroupsAccesss() { try { RetData <IEnumerable <IenetGroups> > ListGroups = await ApiClientFactory.Instance.GetGroups(ApiClientFactory.Instance.Encrypt($"Fun|{HttpContext.Session.GetObjSession<string>("Session.HashId")}")); RetData <IEnumerable <IenetAccesses> > ListAccess = await ApiClientFactory.Instance.GetIenetAccesses(ApiClientFactory.Instance.Encrypt($"Fun|{HttpContext.Session.GetObjSession<string>("Session.HashId")}")); RetData <IEnumerable <IenetGroupsAccesses> > ListGroupsAccesses = await ApiClientFactory.Instance.GetIEnetGroupsAccesses(ApiClientFactory.Instance.Encrypt($"Fun|{HttpContext.Session.GetObjSession<string>("Session.HashId")}")); List <IenetGroupsAccessesModel> AllRecords = new List <IenetGroupsAccessesModel>(); List <IenetGroupsAccessesModel> Records = ( from Ga in ListGroupsAccesses.Data from G in ListGroups.Data from A in ListAccess.Data where Ga.IdIenetAccess == A.Id && Ga.IdIenetGroup == G.Id select new IenetGroupsAccessesModel() { Id = Ga.Id, IdIenetAccess = A.Id, IdIenetGroup = G.Id, Access = A.Descr, Group = G.Descr }).ToList(); int Total = 0; if (Records.Count() > 0) { AllRecords = Utility.ExpressionBuilderHelper.W2uiSearchNoSkip <IenetGroupsAccessesModel>(Records, Request.Form); Records = Utility.ExpressionBuilderHelper.W2uiSearch <IenetGroupsAccessesModel>(Records, Request.Form); Total = Records.Count; } return(Json(new { Total, Records, errorMessage = "", AllRecords })); } catch (Exception e1) { return(Json(new { total = 0, records = "", errorMessage = e1.ToString() })); } }
//public async Task<IActionResult> GetPeticionesAdmin(int ClienteId, string dtp1 = "", string chkPending = "") //{ // try // { // //var dict = Request.Form.ToDictionary(x => x.Key, x => x.Value.ToString()); // var draw = HttpContext.Request.Form["draw"].Fod(); // // Skiping number of Rows count // var start = Request.Form["start"].Fod(); // // Paging Length 10,20 // var length = Request.Form["length"].Fod(); // // Sort Column Name // var sortColumn = Request.Form["columns[" + Request.Form["order[0][column]"].Fod() + "][name]"].Fod(); // // Sort Column Direction ( asc ,desc) // var sortColumnDirection = Request.Form["order[0][dir]"].Fod(); // // Search Value from (Search box) // var searchValue = Request.Form["search[value]"].Fod(); // //Paging Size (10,20,50,100) // int pageSize = length != null ? Convert.ToInt32(length) : 0; // int skip = start != null ? Convert.ToInt32(start) : 0; // int recordsTotal = 0; // // Getting all Customer data // RetData<Tuple<IEnumerable<PedidosExternos>, IEnumerable<PedidosDetExternos>>> ListPe = await ApiClientFactory.Instance.GetPedidosExternosMDetAdmin(ClienteId); // if (ListPe.Info.CodError != 0) // return Json(new { draw = 0, recordsFiltered = 0, recordsTotal = 0, errorMessage = ListPe.Info.Mensaje, data = "" }); // if (ListPe.Data.Item1.Count() == 0) // { // return Json(new { draw = 0, recordsFiltered = 0, recordsTotal = 0, errorMessage = (ListPe.Info.CodError != 0 ? ListPe.Info.Mensaje : string.Empty), data = "" }); // } // IEnumerable<PedidosExternos> ListPed = ListPe.Data.Item1.Where(Pe => Pe.IdEstado != 1); // if (!string.IsNullOrEmpty(dtp1)) // { // ListPed = ListPe.Data.Item1.Where(Pe => Pe.FechaCreacion.StartsWith(dtp1)); // } // if (!string.IsNullOrEmpty(chkPending)) // { // if (chkPending.ToLower() == "true") // ListPed = ListPe.Data.Item1.Where(Pe => Pe.IdEstado == 2); // } // if (!(string.IsNullOrEmpty(sortColumn) && string.IsNullOrEmpty(sortColumnDirection) && !string.IsNullOrEmpty(sortColumn))) // { // if (sortColumn == "fechaPedido") // { // if (sortColumnDirection == "desc") // ListPed = ListPed.OrderByDescending(O => O.FechaPedido.ToDateFromEspDate()); // else // ListPed = ListPed.OrderBy(O => O.FechaPedido.ToDateFromEspDate()); // } // else // ListPed = ListPed.AsQueryable().OrderBy(sortColumn + " " + sortColumnDirection); // } // //total number of rows count // recordsTotal = ListPed.Count(); // //Paging // ListPed = ListPed.Skip(skip).Take(pageSize); // //Returning Json Data // return Json(new { draw, recordsFiltered = recordsTotal, recordsTotal, data = ListPed, errorMessage = "" }); // } // catch (Exception e1) // { // return Json(new { draw = 0, recordsFiltered = 0, recordsTotal = 0, errorMessage = e1.ToString(), data = "" }); // } //} public async Task <IActionResult> GetPeticionDetAdmin(int PedidoId) { try { //var dict = Request.Form.ToDictionary(x => x.Key, x => x.Value.ToString()); var draw = HttpContext.Request.Form["draw"].Fod(); // Skiping number of Rows count var start = Request.Form["start"].Fod(); // Paging Length 10,20 var length = Request.Form["length"].Fod(); // Sort Column Name var sortColumn = Request.Form["columns[" + Request.Form["order[0][column]"].Fod() + "][name]"].Fod(); // Sort Column Direction ( asc ,desc) var sortColumnDirection = Request.Form["order[0][dir]"].Fod(); // Search Value from (Search box) var searchValue = Request.Form["search[value]"].Fod(); //Paging Size (10,20,50,100) int pageSize = length != null?Convert.ToInt32(length) : 0; int skip = start != null?Convert.ToInt32(start) : 0; int recordsTotal = 0; // Getting all Customer data RetData <Tuple <IEnumerable <PedidosExternos>, IEnumerable <PedidosDetExternos> > > ListPe = await ApiClientFactory.Instance.GetPedidosExternosAdmin(PedidoId); if (ListPe.Info.CodError != 0) { return(Json(new { draw = 0, recordsFiltered = 0, recordsTotal = 0, errorMessage = ListPe.Info.Mensaje, data = "" })); } if (ListPe.Data.Item2.Count() == 0) { return(Json(new { draw = 0, recordsFiltered = 0, recordsTotal = 0, errorMessage = (ListPe.Info.CodError != 0 ? ListPe.Info.Mensaje : string.Empty), data = "" })); } IEnumerable <PedidosDetExternos> ListPed = ListPe.Data.Item2.Where(Pd => Pd.PedidoId == PedidoId); if (!(string.IsNullOrEmpty(sortColumn) && string.IsNullOrEmpty(sortColumnDirection))) { ListPed = ListPed.AsQueryable().OrderBy(sortColumn + " " + sortColumnDirection); } //total number of rows count recordsTotal = ListPed.Count(); //Paging ListPed = ListPed.Skip(skip).Take(pageSize); //Returning Json Data return(Json(new { draw, recordsFiltered = recordsTotal, recordsTotal, data = ListPed, errorMessage = "" })); } catch (Exception e1) { return(Json(new { draw = 0, recordsFiltered = 0, recordsTotal = 0, errorMessage = e1.ToString(), data = "" })); } }
public async Task <IActionResult> LoginIe(string TxtUser, string TxtPassword) { try { if (string.IsNullOrEmpty(TxtPassword)) { return(LocalRedirect("/Account/?error=USER_INCORRECT")); } string UserEncrypted = ApiClientFactory.Instance.Encrypt(TxtUser); string PasswordEncrypted = ApiClientFactory.Instance.Encrypt(TxtPassword); string HashId = await ApiClientFactory.Instance.LoginIe(UserEncrypted, PasswordEncrypted); if (string.IsNullOrEmpty(HashId)) { return(LocalRedirect("/Account/?error=USER_INCORRECT")); } if (HashId.StartsWith("Error:")) { return(View("Index", new Models.ErrorModel() { ErrorMessage = System.Net.WebUtility.HtmlEncode(HashId.Replace(Environment.NewLine, "<br />")) })); } if (string.IsNullOrEmpty(HashId)) { return(LocalRedirect("/Account/?error=USER_INCORRECT")); } string HashIdDecrypted = Encoding.UTF8.GetString(CryptoHelper.DecryptData(Convert.FromBase64String(HashId))); if (HashIdDecrypted.Split("|").Length != 10) { return(View("Index", new Models.ErrorModel() { ErrorMessage = "Error en el sistema de auth." })); } string[] HashIdDecryptedArray = HashIdDecrypted.Split("|"); RetData <Tuple <IEnumerable <IenetGroups>, IEnumerable <IenetAccesses>, IEnumerable <IenetGroupsAccesses>, IEnumerable <IenetGroupsAccesses> > > LoginStruct = await ApiClientFactory.Instance.GetLoginStruct(HashIdDecryptedArray[1]); if (LoginStruct.Data == null) { return(View("Index", new Models.ErrorModel() { ErrorMessage = "Error al obtener datos de login." })); } if (LoginStruct.Info.CodError != 0) { return(View("Index", new Models.ErrorModel() { ErrorMessage = LoginStruct.Info.Mensaje })); } HttpContext.Session.SetObjSession("Session.TiendaId", HashIdDecryptedArray[7]); HttpContext.Session.SetObjSession("Session.ClientId", HashIdDecryptedArray[3]); HttpContext.Session.SetObjSession("Session.HashId", HashIdDecryptedArray[5]); HttpContext.Session.SetObjSession("Session.IdGroup", HashIdDecryptedArray[1]); HttpContext.Session.SetObjSession("Session.CodUsr", TxtUser); HttpContext.Session.SetObjSession("Session.IdUser", HashIdDecryptedArray[9]); HttpContext.Session.SetObjSession("ListGroups", LoginStruct.Data.Item1); HttpContext.Session.SetObjSession("ListAccesses", LoginStruct.Data.Item2); HttpContext.Session.SetObjSession("ListGroupsAccesses", LoginStruct.Data.Item3); if (LoginStruct.Data.Item4.Count() > 0) { return(LocalRedirect("/")); } else { return(View("Index", new Models.ErrorModel() { ErrorMessage = "El usuario no tiene permiso para ingresar al sistema." })); } } catch (Exception e1) { return(View("Index", new Models.ErrorModel() { ErrorMessage = e1.ToString().Replace("'", "") })); } }
public async Task <IActionResult> GetUsers() { try { RetData <IEnumerable <IenetUsers> > ListUsers = await ApiClientFactory.Instance.GetUsers(ApiClientFactory.Instance.Encrypt($"Fun|{HttpContext.Session.GetObjSession<string>("Session.HashId")}")); IEnumerable <IenetGroups> ListGroups = HttpContext.Session.GetObjSession <IEnumerable <IenetGroups> >("ListGroups"); RetData <IEnumerable <Clientes> > ListClients = await ApiClientFactory.Instance.GetAllClients(ApiClientFactory.Instance.Encrypt($"Fun|{HttpContext.Session.GetObjSession<string>("Session.HashId")}")); if (ListClients.Info.CodError != 0) { return(Json(new { total = 0, records = "", errorMessage = ListClients.Info.Mensaje })); } List <IenetUsersModel> Records = new List <IenetUsersModel>(); List <IenetUsersModel> AllRecords = new List <IenetUsersModel>(); if (ListUsers.Data == null) { return(Json(new { total = 0, records = "", errorMessage = "Otra persona está usando el admin, por favor vuelva a logearse." })); } else { foreach (IenetUsers UserO in ListUsers.Data) { Records.Add(new IenetUsersModel() { Id = UserO.Id, CodUsr = UserO.CodUsr, IdIenetGroup = UserO.IdIenetGroup, NomUsr = UserO.NomUsr, ClienteId = UserO.ClienteId, Cliente = (UserO.ClienteId.HasValue && ListClients.Data.Where(C => C.ClienteId == UserO.ClienteId).Count() > 0 ? ListClients.Data.Where(C => C.ClienteId == UserO.ClienteId).Fod().Nombre : ""), IenetGroup = ListGroups.Where(G => G.Id == UserO.IdIenetGroup).Fod().Descr, TiendaId = UserO.TiendaId }); } } int Total = 0; if (Records.Count > 0) { bool HaveForm = true; try { if (Request.Form != null) { IFormCollection GridForm = Request.Form; } } catch { HaveForm = false; } if (HaveForm) { AllRecords = Utility.ExpressionBuilderHelper.W2uiSearchNoSkip <IenetUsersModel>(Records, Request.Form); Records = Utility.ExpressionBuilderHelper.W2uiSearch <IenetUsersModel>(Records, Request.Form); } Total = Records.Count; } return(Json(new { Total, Records, errorMessage = "", AllRecords })); } catch (Exception e1) { return(Json(new { total = 0, records = "", errorMessage = e1.ToString() })); } }
public IActionResult TestInfo() { return(RetData.Success()); }
public async Task <IActionResult> GetPedidosExternosPendientes() { try { RetData <Tuple <IEnumerable <PedidosExternos>, IEnumerable <PedidosDetExternos>, IEnumerable <Clientes> > > ListDis = await ApiClientFactory.Instance.GetPedidosExternosPendientes(); return(Json(new { codError = ListDis.Info.CodError, errorMessage = ListDis.Info.Mensaje, data = ListDis.Data })); } catch (Exception e1) { return(Json(new { codError = -1, errorMessage = e1.ToString() })); } }