first commit
This commit is contained in:
126
Complex.EndPoint/Utility/BaseController.cs
Normal file
126
Complex.EndPoint/Utility/BaseController.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
//using Microsoft.AspNetCore.Mvc;
|
||||
//using Microsoft.AspNetCore.Mvc.Filters;
|
||||
|
||||
//namespace Complex.EndPoint.Utility
|
||||
//{
|
||||
// public class BaseController : Controller
|
||||
// {
|
||||
// public IPortalService _portalService;
|
||||
// private ILogger? Logger;
|
||||
// public BaseController(IPortalService portalService, ILogger? logger = null)
|
||||
// {
|
||||
// _portalService = portalService;
|
||||
// if (logger != null)
|
||||
// Logger = logger;
|
||||
// }
|
||||
// public long PersonId;
|
||||
|
||||
|
||||
// private PersonInfo _PersonInfo { set; get; }
|
||||
// public PersonInfo PersonInfo
|
||||
// {
|
||||
// get { return _PersonInfo; }
|
||||
// }
|
||||
// private bool? _IsAccessAction = null;
|
||||
// public bool? IsAccessAction
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// return _IsAccessAction;
|
||||
// }
|
||||
// }
|
||||
// //public string temp;
|
||||
// public override void OnActionExecuting(ActionExecutingContext context)
|
||||
// {
|
||||
// //FileIO.Writeln("controller.txt","1");
|
||||
// try
|
||||
// {
|
||||
// var attributes = context.ActionDescriptor.EndpointMetadata.OfType<CheckAccess>();
|
||||
// string actionFullName = context.ActionDescriptor.DisplayName.Replace("Controller", "");
|
||||
// string ActionNameExecuting = string.Join(".", actionFullName.Substring(0, actionFullName.IndexOf('(')).Split('.').Reverse().Take(2).Reverse()).Trim();
|
||||
// //FileIO.Writeln("controller.txt", actionFullName);
|
||||
|
||||
// if (attributes.Count() > 0 && attributes.First().Disabled)
|
||||
// {
|
||||
// base.OnActionExecuting(context);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (ActionNameExecuting == "Portal.Login")// || ActionNameExecuting == "PortalController.ViewPersonInfo")
|
||||
// return;
|
||||
|
||||
// var cookie = context.HttpContext.Request.Cookies.TryGetValue("PortalTC", out string key);
|
||||
// /**/
|
||||
// //key = "110110110-110110110-0987654321qwerttyggffds".SimpleCodeString();
|
||||
// /**/
|
||||
|
||||
// if (!string.IsNullOrEmpty(key))
|
||||
// key = key.SimpleDeCodeString();
|
||||
// else
|
||||
// {
|
||||
// // FileIO.Write("ali.txt", "Key:isEmpty");
|
||||
// context.HttpContext.Response.StatusCode = 401;
|
||||
// context.Result = Json(new ResultDto
|
||||
// {
|
||||
// IsSuccess = false,
|
||||
// Message = ActionNameExecuting //"دسترسی غیر مجاز"
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
// //FileIO.Write("ali.txt", "Key:" + key);
|
||||
// {
|
||||
// _PersonInfo = _portalService.Login(key);
|
||||
// if (_PersonInfo != null)
|
||||
// PersonId = _PersonInfo.PersonId;
|
||||
// else
|
||||
// {
|
||||
// context.HttpContext.Response.StatusCode = 401;
|
||||
// context.Result = Json(new ResultDto
|
||||
// {
|
||||
// IsSuccess = false,
|
||||
// Message = "ورود ناموفق" //"دسترسی غیر مجاز"
|
||||
// });
|
||||
|
||||
// }
|
||||
// }
|
||||
// if (attributes.Count() > 0)
|
||||
// {
|
||||
// var at = attributes.First();
|
||||
// if (at.AccessTitle.IsNullOrEmpty())
|
||||
// at.AccessTitle = ActionNameExecuting;
|
||||
// _IsAccessAction = _portalService.IsAccess(PersonId, at.AccessTitle);
|
||||
// if (at.AvailabilityByAccess && _IsAccessAction == false)
|
||||
// {
|
||||
// context.HttpContext.Response.StatusCode = 403;
|
||||
// context.Result = Json(new ResultDto
|
||||
// {
|
||||
// IsSuccess = false,
|
||||
// Message = "[" + ActionNameExecuting + "]دسترسی غیر مجاز"
|
||||
// });//NoContent();
|
||||
// }
|
||||
// //temp = PersonId + ":" + ActionNameExecuting + ":" + _IsAccessAction;
|
||||
// }
|
||||
// //FileIO.Writeln("controller.txt","3");
|
||||
// base.OnActionExecuting(context);
|
||||
// //FileIO.Writeln("controller.txt","4");
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// context.HttpContext.Response.StatusCode = 504;
|
||||
// context.Result = Json(new ResultDto
|
||||
// {
|
||||
// IsSuccess = false,
|
||||
// Message = ex.Message
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// internal List<GridCommand> GetAccessCommand(List<GridCommand> commands)
|
||||
// {
|
||||
// var acCommands = _portalService.GetAccessOfList(4, commands.Where(c => c.AccessTitle.IsNotNullOrEmpty())
|
||||
// .Select(c => c.AccessTitle).ToList());
|
||||
|
||||
|
||||
// return commands.Where(c => acCommands.Contains(c.AccessTitle) || c.AccessTitle.IsNullOrEmpty()).ToList();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
Reference in New Issue
Block a user