public IObjResult <Writers> GetWriter(int id) { AutUserInfo userInfo = _httpContext.HttpContext.Session.GetObject <AutUserInfo>("UserInfo"); string resultmessage = StaticValues.ErrorMessage; int resultcode = StaticValues.ErrorCode; bool resultval = false; Writers resultobj = null; try { if (!_memcache.TryGetValue <Writers>("Writer" + id, out resultobj)) { var result = _writer.GetById(id, userInfo); resultcode = result.ResultCode; resultmessage = result.Message; resultval = result.IsSuccess; resultobj = result.Object; if (resultval) { _memcache.Set <Writers>("Writer" + id, resultobj); } } else { resultcode = StaticValues.SuccessCode; resultmessage = StaticValues.SuccessMessage; resultval = true; } } catch (Exception ex) { _logs.Add(userInfo.SessId, ex.ToString(), "GetWriter", "WriterController", Enum.GetName(typeof(LayerInfo), 1), "", userInfo.ClientIp, userInfo.UsrId); } return(new ObjResult <Writers>(resultval, resultmessage, resultcode, resultobj)); }
public IObjResult <AccessToken> AuthUser([FromBody] UserQuery User) { string clientip = _httpContext.HttpContext.Connection.RemoteIpAddress.ToString(); bool _resultValue = false; string _resultMessage = string.Empty; int _resultCode = 0; string _sessionid = GenerateUniqueId.Create(); AccessToken token = null; try { IDictionary <int, string> keyValuePairs = UserValidation.UserQueryControl(User); if (keyValuePairs.ContainsKey(StaticValues.SuccessCode)) { string password = Encryption.GenerateSHA256String(User?.Password); IObjResult <AutUserInfo> infoes = _user.GetUser(User?.Email, password, clientip, _sessionid); if (infoes.IsSuccess && infoes.Object != null) { var result = _user.CreateToken(infoes.Object); _resultValue = result.IsSuccess; _resultCode = result.ResultCode; _resultMessage = result.Message; token = result.Object; if (result.IsSuccess) { _httpContext.HttpContext.Session.SetObject("UserInfo", infoes.Object); } } else { _resultValue = infoes.IsSuccess; _resultCode = infoes.ResultCode; _resultMessage = infoes.Message; } } else { _resultCode = StaticValues.ErrorNullCode; keyValuePairs.TryGetValue(StaticValues.ErrorNullCode, out _resultMessage); } } catch (Exception ex) { _resultMessage = StaticValues.ErrorMessage; _resultCode = StaticValues.ErrorCode; _logs.Add(_sessionid, "Kullanıcı oturum açma işlemi esnasında bir sorun ile karşılaşıldı. Hata:" + ex.ToString(), "AuthUser", "UserController", Enum.GetName(typeof(LayerInfo), 1), _httpContext.HttpContext.Request.Path, clientip, StaticValues.DefUserId); } return(new ObjResult <AccessToken>(_resultValue, _resultMessage, _resultCode, token)); }
public int GetPayments(Logs logs) { var result = _paymentsService.GetPlateFromPaym(logs.SubPlate); if (result == 2) { var userinfo = _usersService.GetByCarPlate(logs.SubPlate); if (userinfo.UseActive == true) { _logservice.Add(logs); } else { return(0); } } else { return(0); } return(result); }
public IResult RemoveCache([FromQuery] string key) { AutUserInfo userInfo = _httpContext.HttpContext.Session.GetObject <AutUserInfo>("UserInfo"); string resultmessage = StaticValues.ErrorMessage; int resultcode = StaticValues.ErrorCode; bool resultval = false; try { if (_memcache.TryGetValue(key, out object val)) { _memcache.Remove(key); resultmessage = StaticValues.SuccessMessage; resultcode = StaticValues.SuccessCode; resultval = true; } else { resultmessage = StaticValues.ErrorNullObjMessage; resultcode = StaticValues.ErrorNullObjCode; } } catch (Exception ex) { _logs.Add(userInfo.SessId, ex.ToString(), "RemoveCache", "CacheController", Enum.GetName(typeof(LayerInfo), 1), "", userInfo.ClientIp, userInfo.UsrId); } return(new Result(resultval, resultmessage, resultcode)); }
public IObjResult <AccessToken> CreateToken(AutUserInfo userInfo) { string _resultMessage; int _code = StaticValues.InfoCode; bool _resultval = false; AccessToken token = null; try { _log.Add(userInfo.SessId, "Kullanıcı için token oluşturma işlemi başlamıştır", "CreateToken", "UserManager", Enum.GetName(typeof(Layers.LayerInfo), 2), "", userInfo.ClientIp, userInfo.UsrId); token = _tokenHelper.CreateToken(userInfo); if (token != null) { _resultMessage = StaticValues.SuccessMessage; _code = StaticValues.SuccessCode; _resultval = true; } else { _resultMessage = StaticValues.ErrorMessage; _code = StaticValues.ErrorCode; } _log.Add(userInfo.SessId, "Kullanıcı için token oluşturma işlemi tamamlanmıştır.Sonuç=" + (_resultval ? "Başarılı" : "Hatalı"), "CreateToken", "UserManager", Enum.GetName(typeof(Layers.LayerInfo), 2), "", userInfo.ClientIp, userInfo.UsrId); } catch (Exception ex) { _resultMessage = StaticValues.ErrorMessage; _code = StaticValues.ErrorCode; _log.Add(userInfo.SessId, "Kullanıcı bilgileri getirme esnasında bir sorun ile karşılaşıldı. Hata içeriği=" + ex.ToString(), "CreateToken", "UserManager", Enum.GetName(typeof(Layers.LayerInfo), 2), "", userInfo.ClientIp, userInfo.UsrId); } return(new ObjResult <AccessToken>(_resultval, _resultMessage, _code, token)); }
public IResult Add(Writers model, AutUserInfo userInfo) { string _resultMessage = string.Empty; int _code = StaticValues.InfoCode; bool _resultval = false; try { _repos.Add(model); _code = StaticValues.SuccessCode; _resultMessage = StaticValues.SuccessMessage; _resultval = true; } catch (Exception ex) { _logs.Add(userInfo.SessId, ex.ToString(), "Add", "WritersManager", Enum.GetName(typeof(LayerInfo), 2), "", userInfo.ClientIp, userInfo.UsrId); _code = StaticValues.ErrorCode; _resultMessage = StaticValues.ErrorMessage; _resultval = false; } return(new Result(_resultval, _resultMessage, _code)); }
public IActionResult Add([FromBody] Logs log) { try { var date = DateTime.Now; _service.Add(log); } catch (Exception ex) { return(BadRequest(ex.Message)); } return(Ok()); }
public IObjResult <Articles> GetArticle(int id) { AutUserInfo userInfo = _httpContext.HttpContext.Session.GetObject <AutUserInfo>("UserInfo"); string resultmessage = StaticValues.ErrorMessage; int resultcode = StaticValues.ErrorCode; bool resultval = false; Articles resultobj = null; try { _memcache.TryGetValue <Articles>("Article" + id, out resultobj); if (resultobj == null) { var result = _article.GetById(id, userInfo); resultcode = result.ResultCode; resultmessage = result.Message; resultval = result.IsSuccess; resultobj = result.Object; if (result.IsSuccess && result.Object != null) { var cacheExpOptions = new MemoryCacheEntryOptions { AbsoluteExpiration = DateTime.Now.AddMinutes(10), Priority = CacheItemPriority.Normal }; _memcache.Set <Articles>("Article" + id, resultobj, cacheExpOptions); } } else { resultobj.Title += "-Mem"; resultcode = StaticValues.SuccessCode; resultmessage = StaticValues.SuccessMessage; resultval = true; } } catch (Exception ex) { _logs.Add(userInfo.SessId, ex.ToString(), "GetArticle", "ArticleController", Enum.GetName(typeof(LayerInfo), 1), "", userInfo.ClientIp, userInfo.UsrId); } return(new ObjResult <Articles>(resultval, resultmessage, resultcode, resultobj)); }
public void POST(Logs logs) { _logservice.Add(logs); }