internal RestMemberRolesUpdatedAuditLog(RestDiscordClient client, AuditLogModel log, AuditLogEntryModel entry) : base(client, log, entry) { for (var i = 0; i < entry.Changes.Length; i++) { var change = entry.Changes[i]; switch (change.Key) { case "$add": { RolesAdded = AuditLogChange <IReadOnlyList <Role> > .Convert <RoleModel[]>(change, x => x.ToReadOnlyList(y => new Role(y))).NewValue; break; } case "$remove": { RolesRemoved = AuditLogChange <IReadOnlyList <Role> > .Convert <RoleModel[]>(change, x => x.ToReadOnlyList(y => new Role(y))).NewValue; break; } default: { client.Log(LogSeverity.Error, $"Unknown change key for {nameof(RestMemberRolesUpdatedAuditLog)}: '{change.Key}'."); break; } } } }
public void BuildAddAuditLogCommand_GivenValidAuditLogViewModel_AddAuditLogCommand() { var auditLogId = Guid.NewGuid(); const string action = "Index"; const string auditData = "1"; var eventDateTime = new DateTime(2015, 05, 05); const string controller = "Person"; const string user = "******"; var auditLog = new AuditLogModel() { AuditLogId = auditLogId, Action = action, AuditData = auditData, EventDateTime = eventDateTime, Controller = controller, User = user }; var result = _builder.BuildAddAuditLogCommand(auditLog); result.AuditLogId.Should().NotBeEmpty(); result.Action.ShouldBeEquivalentTo(action); result.AuditData.ShouldAllBeEquivalentTo(auditData); result.Controller.ShouldBeEquivalentTo(controller); result.EventDateTime.ShouldBeEquivalentTo(eventDateTime); result.User.ShouldBeEquivalentTo(user); }
public ActionResult verify(string access_token, string comment, int info_id, int verified) { var user = UserBussiness.GetUserModel(m => m.OpenID == access_token); var si = SignInRecordBussiness.GetSignInRecordModel(info_id); si.Status = verified; si.AuditDesc = comment; bool flag = SignInRecordBussiness.UpdateSignInRecordModel(si); if (flag) { Task.Factory.StartNew(() => { AuditLogModel auditLogModel = new AuditLogModel(); auditLogModel.CreateTime = DateTime.Now; auditLogModel.CreateUserID = user.ID; auditLogModel.remark = comment; auditLogModel.Status = verified; auditLogModel.SignInRecordID = info_id; AuditLogBussiness.InsertActiveModel(auditLogModel); }); return(Success("操作成功")); } else { return(Fail("请重试")); } }
public async Task <ResponseModel <IEnumerable <AuditLogModel> > > GetByCriteriaAsync(string action, DateTime?endDate, DateTime?startDate, int?tableId, string tableName) { var auditLogEntities = await _auditLogRepository.GetByCriteriaAsync(action, endDate, startDate, tableId, tableName); return(new ResponseModel <IEnumerable <AuditLogModel> > { Data = AuditLogModel.MakeMany(auditLogEntities), Count = auditLogEntities.Count() }); }
public AddAuditLogCommand BuildAddAuditLogCommand(AuditLogModel auditVm) { if (auditVm == null) { throw new ArgumentNullException("auditVm"); } var command = Mapper.DynamicMap <AuditLogModel, AddAuditLogCommand>(auditVm); command.AuditLogId = Guid.NewGuid(); return(command); }
private AuditLogModel GetAuditLogModel(ActionExecutedContext filterContext, string auditedData) { var auditVm = new AuditLogModel() { Action = filterContext.ActionDescriptor.ActionName, Controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName, EventDateTime = _dateTimeProvider.Now, AuditData = auditedData, User = _userPrincipalProvider.CurrentUserName }; return(auditVm); }
internal RestAuditLog(RestDiscordClient client, AuditLogModel log, AuditLogEntryModel entry) : base(client, entry.Id) { ResponsibleUserId = entry.UserId; ResponsibleUser = new RestDownloadable <RestUser>(options => client.GetUserAsync(ResponsibleUserId, options)); var userModel = Array.Find(log.Users, x => x.Id == entry.UserId); if (userModel != null) { ResponsibleUser.SetValue(new RestUser(client, userModel)); } Reason = entry.Reason; }
internal RestAuditLog(RestDiscordClient client, AuditLogModel log, AuditLogEntryModel entry) : base(client, entry.Id) { TargetId = entry.TargetId; ResponsibleUserId = entry.UserId; ResponsibleUser = RestFetchable.Create(this, (@this, options) => @this.Client.GetUserAsync(@this.ResponsibleUserId, options)); var userModel = Array.Find(log.Users, x => x.Id == entry.UserId); if (userModel != null) { ResponsibleUser.Value = new RestUser(client, userModel); } Reason = entry.Reason; }
public void InsertElastic <T2>(T2 updateEntity, string operatioName, string elasticIndex) { if (updateEntity is IAuditable) { //Insert ElasticSearch for AuditLog string jsonString; jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(updateEntity); AuditLogModel logModel = new AuditLogModel(); logModel.PostDate = DateTime.Now; logModel.UserID = 1; logModel.JsonModel = jsonString; logModel.Operation = operatioName; logModel.ClassName = updateEntity.GetType().Name; _elasticAuditLogService.CheckExistsAndInsertLog(logModel, elasticIndex); } }
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) { // do something before the action executes Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); ActionExecutedContext resultContext = await next();//执行Action // do something after the action executes; resultContext.Result will be set stopwatch.Stop(); if (!Ignore) { try { AuditLogModel model = new AuditLogModel { CurrentUserId = context.HttpContext.User.Identity.IsAuthenticated ? context.HttpContext.User.FindFirst("sub").Value : string.Empty, Action = context.ActionDescriptor.DisplayName.ToSubstring(127), HttpMethod = context.HttpContext.Request.Method, IP = HttpHelper.GetIP(context.HttpContext), ExecuteDuration = (int)stopwatch.ElapsedMilliseconds, ExecuteTime = DateTime.Now, Arguments = context.ActionArguments.Count > 0 ? context.ActionArguments.ToJson().ToSubstring(1023) : string.Empty, Exception = resultContext.Exception?.Message.ToSubstring(127), Result = (resultContext.Result is JsonResult) ? (resultContext.Result as JsonResult).Value?.ToJson().ToSubstring(2047) : string.Empty }; IAuditLogStore store = context.HttpContext.RequestServices.GetService <IAuditLogStore>(); await store.SaveAsync(model); } catch (Exception ex) { throw ex; } } }
/// <summary> /// 保存审计日志对象 /// </summary> /// <param name="model">审计日志</param> public virtual void Save(AuditLogModel model) { _logger.LogInformation(model.ToJson()); }
internal RestOverwriteUpdatedAuditLog(RestDiscordClient client, AuditLogModel log, AuditLogEntryModel entry) : base(client, log, entry) { Changes = new OverwriteChanges(client, entry); }
internal RestOverwriteCreatedAuditLog(RestDiscordClient client, AuditLogModel log, AuditLogEntryModel entry) : base(client, log, entry) { Data = new OverwriteData(client, entry, true); }
//public RoleData Data { get; } internal RestInviteCreatedAuditLog(RestDiscordClient client, AuditLogModel log, AuditLogEntryModel entry) : base(client, log, entry) { //Data = new RoleData(client, entry, true); }
internal RestChannelDeletedAuditLog(RestDiscordClient client, AuditLogModel log, AuditLogEntryModel entry) : base(client, log, entry) { Data = new ChannelData(client, entry, false); }
internal RestChannelCreatedAuditLog(RestDiscordClient client, AuditLogModel auditLogModel, AuditLogEntryModel model) : base(client, auditLogModel, model) { Metadata = new RestAuditLogChannelMetadata(client, auditLogModel, model); }
internal static RestAuditLog Create(RestDiscordClient client, AuditLogModel log, AuditLogEntryModel entry) => entry.ActionType switch {
private void AddToListItems(IOrganizationService service, string entityName, int langCode, AuditDetail detail, List <DataModel.AuditLogModel> items, AuditLogModelBase auditLogModelBase) { var crmAttrbites = _schema.GetEntityFields(service, _log, entityName, langCode); AuditLogModel auditLogModel; IFieldDesc fieldDesc = null; CrmAttrbite attr = null; CrmValueAttrbite crmValueAttrbite = null; Entity record = (Entity)detail.AuditRecord; // Show additional details for certain AuditDetail sub-types. var detailType = detail.GetType(); if (detailType == typeof(AttributeAuditDetail)) { var attributeDetail = (AttributeAuditDetail)detail; if (attributeDetail.NewValue != null && attributeDetail.NewValue.Attributes.Any()) { // Display the old and new attribute values. foreach (KeyValuePair <String, object> attribute in attributeDetail.NewValue.Attributes) { fieldDesc = null; crmValueAttrbite = null; attr = crmAttrbites.Where(a => a.FieldName == attribute.Key).FirstOrDefault(); if (attr == null) { continue; } auditLogModel = new AuditLogModel(); auditLogModel.AuditLogId = Guid.NewGuid(); auditLogModelBase.CopyTo(auditLogModel); auditLogModel.FieldDesc = attr.DisplayName; auditLogModel.FieldSchemaName = attr.FieldName; if (attributeDetail.OldValue.Contains(attribute.Key)) { fieldDesc = _factoryFieldsValue.GetFieldDesc(attribute.Key, attr, attributeDetail.OldValue); if (fieldDesc != null) { crmValueAttrbite = fieldDesc.GetValue(attribute.Key.ToString(), attributeDetail.OldValue); auditLogModel.OldValue = crmValueAttrbite.FieldValue; } } fieldDesc = _factoryFieldsValue.GetFieldDesc(attribute.Key, attr, attributeDetail.NewValue); if (fieldDesc != null) { crmValueAttrbite = fieldDesc.GetValue(attribute.Key.ToString(), attributeDetail.NewValue); auditLogModel.NewValue = crmValueAttrbite.FieldValue; } items.Add(auditLogModel); } } // for data who clear (the old value was data and new value was empty) if (attributeDetail.OldValue != null && attributeDetail.OldValue.Attributes.Any()) { foreach (KeyValuePair <String, object> attribute in attributeDetail.OldValue.Attributes) { if (attributeDetail.NewValue != null && !attributeDetail.NewValue.Contains(attribute.Key)) { fieldDesc = null; crmValueAttrbite = null; attr = crmAttrbites.Where(a => a.FieldName == attribute.Key).FirstOrDefault(); auditLogModel = new AuditLogModel(); auditLogModel.AuditLogId = Guid.NewGuid(); auditLogModelBase.CopyTo(auditLogModel); auditLogModel.FieldDesc = attr.DisplayName; auditLogModel.FieldSchemaName = attr.FieldName; fieldDesc = _factoryFieldsValue.GetFieldDesc(attribute.Key, attr, attributeDetail.OldValue); if (fieldDesc != null) { crmValueAttrbite = fieldDesc.GetValue(attribute.Key.ToString(), attributeDetail.OldValue); auditLogModel.OldValue = crmValueAttrbite.FieldValue; auditLogModel.NewValue = ""; } items.Add(auditLogModel); } } } } }
//public OverwriteData Data { get; } internal RestIntegrationDeletedAuditLog(RestDiscordClient client, AuditLogModel log, AuditLogEntryModel entry) : base(client, log, entry) { //Data = new OverwriteData(client, entry, false); }
internal RestWebhookUpdatedAuditLog(RestDiscordClient client, AuditLogModel log, AuditLogEntryModel entry) : base(client, log, entry) { Changes = new WebhookChanges(client, entry); }
internal RestMessagesDeletedAuditLog(RestDiscordClient client, AuditLogModel log, AuditLogEntryModel entry) : base(client, log, entry) { ChannelId = entry.Options.ChannelId; Count = entry.Options.Count; }
/// <summary> /// 保存审计日志对象 /// </summary> /// <param name="model">审计日志</param> public virtual Task SaveAsync(AuditLogModel model) { _logger.LogInformation(model.ToJson()); return(Task.CompletedTask); }
internal RestMessageUnpinnedAuditLog(RestDiscordClient client, AuditLogModel log, AuditLogEntryModel entry) : base(client, log, entry) { ChannelId = entry.Options.ChannelId; MessageId = entry.Options.MessageId; }
public RepositoryResponse AddOrEditStarOfMonth(StarOfMonthModel model, string loggedInuserID) { _nominationRepo = new NominationRepo(); baseModel = new RepositoryResponse(); try { string nomID = string.Empty; //string IPValue = string.Empty; Nomination dbNomModel = new Nomination(); using (objSOMEntities = new SOMEntities()) { //var config = objSOMEntities.Configurations.Where(r => r.Module == "SOM" && r.Type == "UPDATEIP" && r.IsActive == true).FirstOrDefault(); //IPValue = config.Value; var dbModel = objSOMEntities.StarOfTheMonths.Where(r => r.TransID == model.TransID).FirstOrDefault(); if (string.IsNullOrEmpty(model.SelectedNominationID)) { dbNomModel = objSOMEntities.Nominations.Where(r => r.NominationId == dbModel.NominationID).FirstOrDefault(); } else { dbNomModel = objSOMEntities.Nominations.Where(r => r.NominationId == model.SelectedNominationID.Replace("\r\n", "")).FirstOrDefault(); } if (dbModel == null) { nomID = dbNomModel.NominationId; dbModel = new StarOfTheMonth.DataBase.StarOfTheMonth(); dbModel.EmpId = int.Parse(dbNomModel.EmployeeNumber); dbModel.IsApproved = true; dbModel.IsDisplay = true; if (string.IsNullOrEmpty(model.Month)) { dbModel.Month = model.MonthFilter; } else { dbModel.Month = model.Month; } if (string.IsNullOrEmpty(model.Year)) { dbModel.Year = model.YearFilter; } else { dbModel.Year = model.Year; } dbModel.NominationID = dbNomModel.NominationId; dbModel.Description = dbNomModel.Idea; dbModel.ApprovedBy = int.Parse(loggedInuserID); dbModel.CreatedBy = int.Parse(loggedInuserID); //dbModel.CreatedDate = toISTDate(DateTime.Now); dbModel.ModifiedBy = int.Parse(loggedInuserID); // dbModel.ModifiedDate = toISTDate(DateTime.Now); objSOMEntities.StarOfTheMonths.Add(dbModel); objSOMEntities.SaveChanges(); baseModel = new RepositoryResponse { success = true, message = "Star of Month Declared Successfully", Data = "" }; } else { nomID = dbModel.NominationID; //dbModel.EmpId = int.Parse(model.EmpId); //dbModel.IsApproved = true; //dbModel.IsDisplay = true; //dbModel.Description = model.Description; dbModel.Month = model.MonthFilter; dbModel.Year = model.YearFilter; //dbModel.NominationID = model.NominationID; dbModel.CreatedBy = int.Parse(loggedInuserID); //dbModel.CreatedDate = DateTime.UtcNow; dbModel.ModifiedBy = int.Parse(loggedInuserID); //dbModel.ModifiedDate = DateTime.UtcNow; objSOMEntities.SaveChanges(); baseModel = new RepositoryResponse { success = true, message = "Star of Month Declared updated Successfully", Data = "" }; } if (dbNomModel != null) { dbNomModel.SOMComments = model.SOMComments; dbNomModel.SOMSubmittedDate = DateTime.Now.ToString("ddMMyyyy"); dbNomModel.SOMSignature = loggedInuserID; dbNomModel.Status = (int)NominationStatus.TQC_Declare_SOM; dbNomModel.ModifiedBy = loggedInuserID; objSOMEntities.SaveChanges(); } Evaluation evalDbModel = objSOMEntities.Evaluations.Where(r => r.NominationID == nomID && r.EvaluatorID != "").FirstOrDefault(); long HODId = _nominationRepo.GetReportingIDByEmpID(dbNomModel.EmployeeNumber); AuditLogModel objAuditLog = new AuditLogModel(); objAuditLog.CurrentStatus = NominationStatus.TQC_Declare_SOM; objAuditLog.EmployeeNumber = dbNomModel.EmployeeNumber; objAuditLog.IsNewAlert = true; objAuditLog.IsNotification = true; objAuditLog.DepartmentHeadID = HODId.ToString(); objAuditLog.TQCHeadID = loggedInuserID; objAuditLog.EvaluatorID = evalDbModel.EvaluatorID; objAuditLog.NominationID = nomID; objAuditLog.CreatedBy = loggedInuserID; _nominationRepo.AddEntryIntoAuditLog(objAuditLog); } //if (string.IsNullOrEmpty(IPValue) && IPValue == "true") //{ // AddOrEditStarOfMonth_IntranetPortal(model, loggedInuserID); //} } catch (Exception ex) { baseModel = new RepositoryResponse { success = false, message = ex.ToString() }; } return(baseModel); }
internal RestMemberKickedAuditLog(RestDiscordClient client, AuditLogModel log, AuditLogEntryModel entry) : base(client, log, entry) { }
internal RestAuditLogGuildMetadata(RestDiscordClient client, AuditLogModel auditLogModel, AuditLogEntryModel model) : base(client) { for (var i = 0; i < model.Changes.Length; i++) { var change = model.Changes[i]; switch (change.Key) { case "name": { Name = new AuditLogValue <string>(change); break; } case "icon_hash": { IconHash = new AuditLogValue <string>(change); break; } case "splash_hash": { SplashHash = new AuditLogValue <string>(change); break; } case "owner_id": { OwnerId = new AuditLogValue <ulong>(change); var ownerBeforeModel = Array.Find(auditLogModel.Users, x => x.Id == OwnerId.OldValue); var ownerAfterModel = Array.Find(auditLogModel.Users, x => x.Id == OwnerId.NewValue); Owner = new AuditLogValue <RestUser>( ownerBeforeModel != null ? new RestUser(client, ownerBeforeModel) : Optional <RestUser> .Empty, ownerAfterModel != null ? new RestUser(client, ownerAfterModel) : Optional <RestUser> .Empty); break; } case "region": { VoiceRegionId = new AuditLogValue <string>(change); break; } case "afk_channel_id": { AfkChannelId = new AuditLogValue <ulong?>(change); break; } case "afk_timeout": { AfkTimeout = new AuditLogValue <int>(change); break; } case "mfa_level": { MfaLevel = new AuditLogValue <MfaLevel>(change); break; } case "verification_level": { VerificationLevel = new AuditLogValue <VerificationLevel>(change); break; } case "explicit_content_filter": { ContentFilterLevel = new AuditLogValue <ContentFilterLevel>(change); break; } case "default_message_notifications": { DefaultNotificationLevel = new AuditLogValue <DefaultNotificationLevel>(change); break; } case "vanity_url_code": { VanityUrlCode = new AuditLogValue <string>(change); break; } case "widget_enabled": { IsWidgetEnabled = new AuditLogValue <bool>(change); break; } case "widget_channel_id": { WidgetChannelId = new AuditLogValue <ulong?>(change); break; } case "system_channel_id": { SystemChannelId = new AuditLogValue <ulong?>(change); break; } } } }
internal RestEmojiCreatedAuditLog(RestDiscordClient client, AuditLogModel log, AuditLogEntryModel entry) : base(client, log, entry) { Data = new EmojiData(client, entry, true); }
internal RestUnknownAuditLog(RestDiscordClient client, AuditLogModel model, AuditLogEntryModel entryModel) : base(client, model, entryModel) { Type = (int)entryModel.ActionType; }
internal RestGuildUpdatedAuditLog(RestDiscordClient client, AuditLogModel auditLogModel, AuditLogEntryModel model) : base(client, auditLogModel, model) { Metadata = new RestAuditLogGuildMetadata(client, auditLogModel, model); }
internal RestEmojiUpdatedAuditLog(RestDiscordClient client, AuditLogModel log, AuditLogEntryModel entry) : base(client, log, entry) { Changes = new EmojiChanges(client, entry); }