public async Task <ModelResponseMessageLogin> LogOut(EntityLogSystem entity_model) { ModelResponseMessageLogin resp = new ModelResponseMessageLogin(); using (SqlConnection conn = new SqlConnection(ConnectionString)) { conn.Open(); using (SqlCommand cmd = new SqlCommand("sp_logout_system", conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@RegisterId", SqlDbType.VarChar, 50).Value = entity_model.register_id; cmd.Parameters.Add("@UserId", SqlDbType.VarChar, 50).Value = entity_model.userid; cmd.Parameters.Add("@LogEvent", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(entity_model.log_event); cmd.Parameters.Add("@LogDate", SqlDbType.DateTime).Value = entity_model.log_date; SqlParameter rStatus = cmd.Parameters.Add("@rStatus", SqlDbType.Int); rStatus.Direction = ParameterDirection.Output; SqlParameter rMessage = cmd.Parameters.Add("@rMessage", SqlDbType.NVarChar, 500); rMessage.Direction = ParameterDirection.Output; await cmd.ExecuteNonQueryAsync(); if ((int)cmd.Parameters["@rStatus"].Value > 0) { resp.Status = true; } else { resp.Message = (string)cmd.Parameters["@rMessage"].Value; } } conn.Close(); } return(resp); }
public async Task <ModelResponseMessageLogin> LogInAsync(ModelUserLogin model) { ModelResponseMessageLogin resp = new ModelResponseMessageLogin(); if (string.IsNullOrWhiteSpace(model.userid)) { resp.Message = "UserId is require."; } if (string.IsNullOrWhiteSpace(model.passw)) { resp.Message = "Password is require."; } EntityLogSystem entity_model = new EntityLogSystem(); entity_model.userid = model.userid; entity_model.passw = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(model.passw)); entity_model.log_event = "Login to system."; entity_model.log_date = DateTime.Now; resp = await _ISystemRepository.LogIn(entity_model); if (!string.IsNullOrEmpty(resp.Data.RegisterId)) { Guid guid = Guid.NewGuid(); resp.Data.Guid = guid.ToString(); resp.Data.Token = String.Empty; resp.Data.RegisterId = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(resp.Data.RegisterId)); } return(resp); }
public async Task <IActionResult> LogOut(ModelUserLogin model) { ModelResponseMessageLogin e = await _ISystemService.LogOutAsync(model); if (e != null && e.Status) { return(Ok(e)); } return(BadRequest()); }
public async Task <ModelMenuE1_InterfaceData> MenuE1InterfaceDataAsync(string RegisterId, string Passw) { ModelMenuE1_InterfaceData resp = new ModelMenuE1_InterfaceData(); var cultureInfo = new CultureInfo("en-GB"); CultureInfo.DefaultThreadCurrentCulture = cultureInfo; CultureInfo.DefaultThreadCurrentUICulture = cultureInfo; EntityLogSystem user_login = new EntityLogSystem(); user_login.register_id = RegisterId; user_login.userid = "customer"; user_login.passw = Passw; user_login.log_event = "Get Link Login"; user_login.log_date = DateTime.Now; ModelResponseMessageLogin get_login = await _ISystemRepository.LogIn(user_login); // Default resp.Status = false; resp.Message = "ไม่พบสิทธิ์การใช้งานในระบบ!"; resp.docDate = DateTime.Now; resp.docNumber = ""; if (get_login != null && get_login.Status == true) { resp.UserPermission = await _IRegisterUserRepository.GetPermissionPageAsync(RegisterId, "M022"); if (resp.UserPermission != null) { resp.Status = true; resp.Message = "ยินดีต้อนรับเข้าสู่ระบบ."; resp.docDate = DateTime.Now; resp.docNumber = DateTime.Now.ToString("yyMM-XXX"); } } resp.listfaculty = await GetAllFacultyAsync(); return(resp); }
public async Task <ModelResponseMessageLogin> LogOutAsync(ModelUserLogin model) { ModelResponseMessageLogin resp = new ModelResponseMessageLogin(); if (string.IsNullOrWhiteSpace(model.userid)) { resp.Message = "UserId is require."; } if (string.IsNullOrWhiteSpace(model.passw)) { resp.Message = "Password is require."; } EntityLogSystem entity_model = new EntityLogSystem(); entity_model.register_id = Encoding.UTF8.GetString(Convert.FromBase64String(model.registerid)); entity_model.userid = model.userid; entity_model.log_event = "Logout to system."; entity_model.log_date = DateTime.Now; resp = await _ISystemRepository.LogIn(entity_model); return(resp); }