ปรับปรุง log
This commit is contained in:
@@ -216,8 +216,8 @@ namespace TTSW.EF
|
|||||||
var log_message = Newtonsoft.Json.JsonConvert.SerializeObject(log);
|
var log_message = Newtonsoft.Json.JsonConvert.SerializeObject(log);
|
||||||
|
|
||||||
var activity_log = new activity_log_evaEntity();
|
var activity_log = new activity_log_evaEntity();
|
||||||
activity_log.log_name = entity.GetType().Name;
|
activity_log.log_name = entity.GetType().Name.Replace("Entity", "");
|
||||||
activity_log.description = "Add " + entity.GetType().Name;
|
activity_log.description = "Add " + entity.GetType().Name.Replace("Entity", "");
|
||||||
activity_log.subject_id = 0;
|
activity_log.subject_id = 0;
|
||||||
activity_log.subject_type = entity.GetType().Name;
|
activity_log.subject_type = entity.GetType().Name;
|
||||||
activity_log.causer_id = Convert.ToInt32(_contextAccessor.HttpContext.Request.Cookies["user_id"]);
|
activity_log.causer_id = Convert.ToInt32(_contextAccessor.HttpContext.Request.Cookies["user_id"]);
|
||||||
@@ -273,8 +273,8 @@ namespace TTSW.EF
|
|||||||
var log_message = Newtonsoft.Json.JsonConvert.SerializeObject(log);
|
var log_message = Newtonsoft.Json.JsonConvert.SerializeObject(log);
|
||||||
|
|
||||||
var activity_log = new activity_log_evaEntity();
|
var activity_log = new activity_log_evaEntity();
|
||||||
activity_log.log_name = existingItem.GetType().Name;
|
activity_log.log_name = existingItem.GetType().Name.Replace("Entity", ""); ;
|
||||||
activity_log.description = "update " + existingItem.GetType().Name;
|
activity_log.description = "Update " + existingItem.GetType().Name.Replace("Entity", ""); ;
|
||||||
activity_log.subject_id = 0;
|
activity_log.subject_id = 0;
|
||||||
activity_log.subject_type = existingItem.GetType().Name;
|
activity_log.subject_type = existingItem.GetType().Name;
|
||||||
activity_log.causer_id = Convert.ToInt32(_contextAccessor.HttpContext.Request.Cookies["user_id"]);
|
activity_log.causer_id = Convert.ToInt32(_contextAccessor.HttpContext.Request.Cookies["user_id"]);
|
||||||
@@ -333,6 +333,25 @@ namespace TTSW.EF
|
|||||||
|
|
||||||
var existingItem = Get(id);
|
var existingItem = Get(id);
|
||||||
|
|
||||||
|
var log = new activity_log();
|
||||||
|
log.attributes = existingItem;
|
||||||
|
log.old = null;
|
||||||
|
var log_message = Newtonsoft.Json.JsonConvert.SerializeObject(log);
|
||||||
|
|
||||||
|
var activity_log = new activity_log_evaEntity();
|
||||||
|
activity_log.log_name = existingItem.GetType().Name.Replace("Entity", ""); ;
|
||||||
|
activity_log.description = "Delete " + existingItem.GetType().Name.Replace("Entity", ""); ;
|
||||||
|
activity_log.subject_id = 0;
|
||||||
|
activity_log.subject_type = existingItem.GetType().Name;
|
||||||
|
activity_log.causer_id = Convert.ToInt32(_contextAccessor.HttpContext.Request.Cookies["user_id"]);
|
||||||
|
activity_log.causer_type = @"App\Models\User";
|
||||||
|
activity_log.properties = log_message;
|
||||||
|
activity_log.ip_address = _contextAccessor.HttpContext.Connection.RemoteIpAddress.ToString();
|
||||||
|
activity_log.mac_address = "N/A";
|
||||||
|
activity_log.created_at = DateTime.Now;
|
||||||
|
activity_log.updated_at = activity_log.created_at;
|
||||||
|
_context.Add(activity_log);
|
||||||
|
|
||||||
if (existingItem == null)
|
if (existingItem == null)
|
||||||
throw new NotificationException($"No item in database.");
|
throw new NotificationException($"No item in database.");
|
||||||
|
|
||||||
|
|||||||
@@ -227,8 +227,8 @@ namespace TTSW.EF
|
|||||||
var log_message = Newtonsoft.Json.JsonConvert.SerializeObject(log);
|
var log_message = Newtonsoft.Json.JsonConvert.SerializeObject(log);
|
||||||
|
|
||||||
var activity_log = new activity_log_evaEntity();
|
var activity_log = new activity_log_evaEntity();
|
||||||
activity_log.log_name = entity.GetType().Name;
|
activity_log.log_name = entity.GetType().Name.Replace("Entity", "");
|
||||||
activity_log.description = "Add " + entity.GetType().Name;
|
activity_log.description = "Add " + entity.GetType().Name.Replace("Entity", "");
|
||||||
activity_log.subject_id = 0;
|
activity_log.subject_id = 0;
|
||||||
activity_log.subject_type = entity.GetType().Name;
|
activity_log.subject_type = entity.GetType().Name;
|
||||||
activity_log.causer_id = Convert.ToInt32(_contextAccessor.HttpContext.Request.Cookies["user_id"]);
|
activity_log.causer_id = Convert.ToInt32(_contextAccessor.HttpContext.Request.Cookies["user_id"]);
|
||||||
@@ -282,8 +282,8 @@ namespace TTSW.EF
|
|||||||
var log_message = Newtonsoft.Json.JsonConvert.SerializeObject(log);
|
var log_message = Newtonsoft.Json.JsonConvert.SerializeObject(log);
|
||||||
|
|
||||||
var activity_log = new activity_log_evaEntity();
|
var activity_log = new activity_log_evaEntity();
|
||||||
activity_log.log_name = existingItem.GetType().Name;
|
activity_log.log_name = existingItem.GetType().Name.Replace("Entity", ""); ;
|
||||||
activity_log.description = "update " + existingItem.GetType().Name;
|
activity_log.description = "Update " + existingItem.GetType().Name.Replace("Entity", ""); ;
|
||||||
activity_log.subject_id = 0;
|
activity_log.subject_id = 0;
|
||||||
activity_log.subject_type = existingItem.GetType().Name;
|
activity_log.subject_type = existingItem.GetType().Name;
|
||||||
activity_log.causer_id = Convert.ToInt32(_contextAccessor.HttpContext.Request.Cookies["user_id"]);
|
activity_log.causer_id = Convert.ToInt32(_contextAccessor.HttpContext.Request.Cookies["user_id"]);
|
||||||
@@ -341,6 +341,24 @@ namespace TTSW.EF
|
|||||||
var userLogin = GetLoginProfile();
|
var userLogin = GetLoginProfile();
|
||||||
|
|
||||||
var existingItem = Get(id);
|
var existingItem = Get(id);
|
||||||
|
var log = new activity_log();
|
||||||
|
log.attributes = existingItem;
|
||||||
|
log.old = null;
|
||||||
|
var log_message = Newtonsoft.Json.JsonConvert.SerializeObject(log);
|
||||||
|
|
||||||
|
var activity_log = new activity_log_evaEntity();
|
||||||
|
activity_log.log_name = existingItem.GetType().Name.Replace("Entity", ""); ;
|
||||||
|
activity_log.description = "Delete " + existingItem.GetType().Name.Replace("Entity", ""); ;
|
||||||
|
activity_log.subject_id = 0;
|
||||||
|
activity_log.subject_type = existingItem.GetType().Name;
|
||||||
|
activity_log.causer_id = Convert.ToInt32(_contextAccessor.HttpContext.Request.Cookies["user_id"]);
|
||||||
|
activity_log.causer_type = @"App\Models\User";
|
||||||
|
activity_log.properties = log_message;
|
||||||
|
activity_log.ip_address = _contextAccessor.HttpContext.Connection.RemoteIpAddress.ToString();
|
||||||
|
activity_log.mac_address = "N/A";
|
||||||
|
activity_log.created_at = DateTime.Now;
|
||||||
|
activity_log.updated_at = activity_log.created_at;
|
||||||
|
_context.Add(activity_log);
|
||||||
|
|
||||||
if (existingItem == null)
|
if (existingItem == null)
|
||||||
throw new NotificationException($"No item in database.");
|
throw new NotificationException($"No item in database.");
|
||||||
|
|||||||
Reference in New Issue
Block a user