private static AuditOperation BuildOperation(AuditOperationEntry operationEntry) { AuditOperation operation = operationEntry.MapTo <AuditOperation>(); if (operationEntry.UserAgent != null) { UserAgent userAgent = new UserAgent(operationEntry.UserAgent); operation.OperationSystem = userAgent.GetSystem(); operation.Browser = userAgent.GetBrowser(); } operation.Elapsed = (int)operationEntry.EndedTime.Subtract(operationEntry.CreatedTime).TotalMilliseconds; if (operation.ResultType == AjaxResultType.Success) { foreach (AuditEntityEntry entityEntry in operationEntry.EntityEntries) { AuditEntity entity = entityEntry.MapTo <AuditEntity>(); operation.AuditEntities.Add(entity); foreach (AuditPropertyEntry propertyEntry in entityEntry.PropertyEntries) { AuditProperty property = propertyEntry.MapTo <AuditProperty>(); entity.Properties.Add(property); } } } return(operation); }
private void AuditWorkflow(AuditOperation op) { if (!string.IsNullOrEmpty(txtAuditDescription.Text)) { var audit = new FlowAuditRecord { Id = 0, FlowId = ArchiveFlow.FlowId, AuditUserId = AuthenticateStatus.CurrentUser.UserId, AuditTime = DateTime.Now, Operation = op, AuditDescription = txtAuditDescription.Text }; flowContext.AuditArchiveWorkflow(audit, obj => { if (Utility.Utility.CheckInvokeOperation(obj)) { if (obj.Value > 0) { MessageBox.Show("操作成功!"); } else { MessageBox.Show("审核操作失败!错误码:" + obj.Value); } } }, null); } else { CustomMessageBox.Show("请输入审核意见"); txtAuditDescription.Focus(); } }
protected void btnEduConfirm_Click(object sender, EventArgs e) { DataClassesDataContext dc = new DataClassesDataContext(); ExecuteStatus es = dc.ExecuteStatus.SingleOrDefault(ess => ess.F_projectID.Equals(projectID)); if (radEdu.SelectedValue.Equals("审核不通过")) { es.F_status = ProjectStatus.Deny; } else { es.F_status = ProjectStatus.PassEduCheck; } es.F_completeStatus = txtCompleteStatus.Text; es.F_problem = txtProblem.Text; es.F_conclusion = txtConclustion.Text; es.F_suggestion = txtSuggestion.Text; if (string.IsNullOrEmpty(txtCheckDate.Text) == false) { es.F_checkDate = DateTime.Parse(txtCheckDate.Text); } es.F_checkPerson = txtCheckPerson.Text; if (String.IsNullOrEmpty(txtEduConfirmDate.Text) == false) { es.F_eduConfirmDate = DateTime.Parse(txtEduConfirmDate.Text); } AuditOperation.SetAudit(projectID, RoleType.EduAdmin, radEdu.SelectedValue, es.F_eduConfirmDate.Value); dc.SubmitChanges(); Response.Redirect("frmExecute.aspx?tabNum=4"); }
private void DoStore(IStorable storable, IAuditMetadata auditMeta) { AuditOperation operation = AuditOperation.UPDATE; // ensure db id StorableDocument doc = (StorableDocument)storable; long dbId = doc.DbId is long?(long)doc.DbId : -1; if (dbId == -1) { dbId = ++lastDbId; storable.SetData("dbId", dbId); } IDictionary <string, object> document = new Dictionary <string, object>(); if (documents.ContainsKey(dbId)) { documents[dbId].Document.ToList().ForEach(kvp => document[kvp.Key] = kvp.Value); } else { operation = AuditOperation.INSERT; } doc.Document.ToList().ForEach(kvp => document[kvp.Key] = kvp.Value); doc = new StorableDocument(doc.Categories, null); doc.Document = document; documents[dbId] = doc; AuditRecord audit = NewAuditRecord(auditMeta); audit.InstanceDbId = dbId; audit.Operation = operation; audit.Instance = doc; auditRecords[audit.DbId] = audit; }
private void Initial() { DataClassesDataContext dc = new DataClassesDataContext(); ExecuteStatus es = dc.ExecuteStatus.SingleOrDefault(ess => ess.F_projectID.Equals(projectID)); txtUnitComment.Text = es.F_unitComment; if (es.F_unitCheckDate != null) { txtUnitCheckDate.Text = es.F_unitCheckDate.Value.ToShortDateString(); } AuditOpinion ao = AuditOperation.GetAudit(projectID, RoleType.SchoolAdmin); if (ao != null) { radScho.SelectedValue = ao.F_result; } txtCompleteStatus.Text = es.F_completeStatus; txtProblem.Text = es.F_problem; if (es.F_checkDate != null) { txtCheckDate.Text = es.F_checkDate.Value.ToShortDateString(); } txtCheckPerson.Text = es.F_checkPerson; if (es.F_eduConfirmDate != null) { txtEduConfirmDate.Text = es.F_eduConfirmDate.Value.ToShortDateString(); } ao = AuditOperation.GetAudit(projectID, RoleType.EduAdmin); if (ao != null) { radEdu.SelectedValue = ao.F_result; } txtPlan.Text = es.F_plan; ddlEvaluation.SelectedValue = es.F_selfEvaluation; }
public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) { IAuditStore auditStore = null; AuditOperation auditedOperation = null; // 必须保证审计和业务用的是不同的 DbContext 不然,会导致数据异常入库 using var scope = context.HttpContext.RequestServices.CreateScope(); if (Conts.MethodDict.ContainsKey(context.HttpContext.Request.Method)) { auditStore = scope.ServiceProvider.GetService <IAuditStore>(); if (auditStore == null) { throw new MicroserviceFrameworkException("AuditStore is not registered"); } var ua = context.HttpContext.Request.Headers["User-Agent"].ToString(); var ip = context.GetRemoteIpAddress(); var url = context.HttpContext.Request.GetDisplayUrl(); var deviceId = context.HttpContext.Request.Query["deviceId"].ToString(); var deviceModel = context.HttpContext.Request.Query["deviceId"].ToString(); var lat = context.HttpContext.Request.Query["lat"].ToString(); var lng = context.HttpContext.Request.Query["lng"].ToString(); auditedOperation = new AuditOperation( $"{context.HttpContext.Request.Method} {url}", ua, ip, string.IsNullOrEmpty(deviceModel) ? null : deviceModel, string.IsNullOrEmpty(deviceId) ? null : deviceId, double.TryParse(lat, out var a) ? a : null, double.TryParse(lng, out var n) ? n : null); auditedOperation.SetCreation( context.HttpContext.User.Identity is { IsAuthenticated: true } and ClaimsIdentity identity ? identity.GetUserId() : string.Empty); context.HttpContext.Items.Add("___AuditOperation", auditedOperation); } await base.OnActionExecutionAsync(context, next); // comment: 必须使用 HTTP request scope 的 uow manager 才能获取到审计对象 // comment: 只有有变化的数据才会尝试获取变更对象 if (auditStore != null && Conts.MethodDict.ContainsKey(context.HttpContext.Request.Method)) { var unitOfWork = context.HttpContext.RequestServices.GetService <IUnitOfWork>(); if (unitOfWork != null) { auditedOperation.AddEntities(unitOfWork.GetAuditEntities()); } auditedOperation.End(); await auditStore.AddAsync(auditedOperation); await auditStore.FlushAsync(); } }
public async Task AddTrailsAsync <T>(AuditOperation auditOperation, string user, AuditableObjects <T> auditableObjects, IEnumerable <string> namesOfPropertiesToIgnore) where T : class { if (!auditConfigurationSqlServer.Enable.Value) { return; } var trails = auditableObjects.Select(o => new AuditTrail( auditableObjects.TransactionId, auditableObjects.Timestamp, auditConfigurationSqlServer.ApplicationId, auditOperation, user, httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(), o.Key, o.Value, namesOfPropertiesToIgnore)); var transactionBuilder = new StringBuilder(); foreach (var trail in trails) { transactionBuilder.Append($@" insert into [{auditConfigurationSqlServer.SqlServer.DatabaseName}]. [{auditConfigurationSqlServer.SqlServer.SchemaName}]. [{auditConfigurationSqlServer.SqlServer.TableName}] ( [{nameof(AuditTrail.Id)}], [{nameof(AuditTrail.TransactionId)}], [{nameof(AuditTrail.Timestamp)}], [{nameof(AuditTrail.ApplicationId)}], [{nameof(AuditTrail.Operation)}], [{nameof(AuditTrail.User)}], [{nameof(AuditTrail.Origin)}], [{nameof(AuditTrail.ObjectAssembly)}], [{nameof(AuditTrail.ObjectId)}], [{nameof(AuditTrail.ObjectSerial)}] ) values ( '{trail.Id}', '{trail.TransactionId}', '{trail.Timestamp.ToString("yyyy-MM-dd HH:mm:ss.fff") }', '{trail.ApplicationId}', '{trail.Operation}', '{trail.User}', {(!string.IsNullOrWhiteSpace(trail.Origin) ? $"'{trail.Origin}'" : "NULL")}, '{trail.ObjectAssembly}', '{trail.ObjectId}', {(!string.IsNullOrWhiteSpace(trail.ObjectSerial) ? $"'{trail.ObjectSerial}'" : "NULL")} );"); } await auditContext.ExecuteWithTransactionAsync(transactionBuilder.ToString()); }
private string GetOperationString(AuditOperation auditOperation) { switch (auditOperation) { case AuditOperation.Add: return("Criação"); case AuditOperation.Remove: return("Exclusão"); case AuditOperation.Update: return("Alteração"); default: return(""); } }
public async Task WriteAsync <TEntity>(TEntity target, AuditOperation operation, IIdentityUser user, Dictionary <string, object> parameters = null) where TEntity : class, IBaseEntityObject { try { if (_context == null) { return; } if (target.IsDeleted) { operation = AuditOperation.Deleted; } if (target.SmartCoreObjectType.ItemId == -1) { if (parameters == null) { parameters = new Dictionary <string, object>(); } parameters.Add("ObjectType", typeof(TEntity).UnderlyingSystemType.Name); } await _context.AuditCollection.InsertOneAsync(new AuditEntity { //Action = $"{objectName}{operation}", Action = $"{operation}", Date = DateTime.UtcNow, ObjectId = (int)target?.ItemId, ObjectTypeId = (int)target?.SmartCoreObjectType.ItemId, UserId = user.ItemId, AdditionalParameters = parameters, OperatorId = user.OperatorId }); } catch (Exception ex) { } }
protected void btnUnitConfirm_Click(object sender, EventArgs e) { DataClassesDataContext dc = new DataClassesDataContext(); ExecuteStatus es = dc.ExecuteStatus.SingleOrDefault(ess => ess.F_projectID.Equals(projectID)); if (radScho.SelectedValue.Equals("审核不通过")) { es.F_status = ProjectStatus.Deny; } else { es.F_status = ProjectStatus.UnderEducationAudit; } es.F_unitComment = txtUnitComment.Text; if (String.IsNullOrEmpty(txtUnitCheckDate.Text) == false) { es.F_unitCheckDate = DateTime.Parse(txtUnitCheckDate.Text); } AuditOperation.SetAudit(projectID, RoleType.SchoolAdmin, radScho.SelectedValue, es.F_unitCheckDate.Value); dc.SubmitChanges(); Response.Redirect("frmExecute.aspx?tabNum=4"); }
public override void OnActionExecuting(ActionExecutingContext context) { var scope = context.HttpContext.RequestServices.CreateScope(); _logger = scope.ServiceProvider.GetRequiredService <ILogger <Audit> >(); _logger.LogDebug("Executing audit filter"); _auditService = scope.ServiceProvider.GetRequiredService <IAuditService>(); if (_auditService == null) { throw new MSFrameworkException("AuditService is not registered"); } _auditUnitOfWorkManager = scope.ServiceProvider.GetService <IUnitOfWorkManager>(); var configuration = scope.ServiceProvider.GetRequiredService <IConfiguration>(); var applicationName = configuration["ApplicationName"]; applicationName = string.IsNullOrWhiteSpace(applicationName) ? Assembly.GetEntryAssembly()?.FullName : applicationName; var path = context.ActionDescriptor.GetActionPath(); var ua = context.HttpContext.Request.Headers["User-Agent"].ToString(); var ip = context.GetRemoteIpAddress(); _auditedOperation = new AuditOperation(applicationName, path, ip, ua); if (context.HttpContext.User?.Identity != null && context.HttpContext.User.Identity.IsAuthenticated && context.HttpContext.User.Identity is ClaimsIdentity identity) { _auditedOperation.SetCreation(identity.GetUserId(), identity.GetUserName()); } else { _auditedOperation.SetCreation("Anonymous", "Anonymous"); } }
public async Task AddTrailsAsync <T>(AuditOperation auditOperation, string user, AuditableObjects <T> auditableObjects) where T : class => await AddTrailsAsync(auditOperation, user, auditableObjects, null);
/// <summary> /// 异步保存实体审计数据 /// </summary> /// <param name="operationEntry">操作审计数据</param> /// <param name="cancelToken">异步取消标识</param> /// <returns></returns> public async Task SaveAsync(AuditOperationEntry operationEntry, CancellationToken cancelToken = default(CancellationToken)) { AuditOperation operation = BuildOperation(operationEntry); await _operationRepository.InsertAsync(operation); }
protected void HandIn(AuditOperation auditOperation, AuditAction action) { try { CanAudit(false); #region 参数信息 /* FormID string 业务表单ID 必填 FlowGUID string 待审批流程GUID Status为Add时不填, Status为Update时必填 ModelCode string 模块代码 必填 CompanyID string 公司代码 必填 PostID string 岗位ID 必填 CreateUserID string 创建用户ID 必填 CreateUserName string 创建用户名称 必填 NextStateCode string 自定义流程代码 可选 AppUserId string 下一步骤人ID 必填 AppUserName string 下一步骤人名称 必填 Content string 审批意见内容 Status为Add时不填 Status为Update时必填 AppOpt string 审批意见(0-不同意,1-同意) Status为Add时不填 Status为Update时必填 Status string 操作标志:Add-增加,Update-审批] 必填 */ #endregion currAuditOperation = auditOperation; curAuditAction = action; currentAction = action; AuditRemark = this.txRemark.Text; string op = auditOperation.ToString(); if (string.IsNullOrEmpty(AuditRemark)) { if (auditOperation == AuditOperation.Update) { AuditRemark = action == AuditAction.Fail ? Utility.GetResourceStr("AUDITNOPASS") : Utility.GetResourceStr("AUDITPASS"); } else { AuditRemark = Utility.GetResourceStr("SUBMITAUDIT"); } } // 审核前的事件 if (!OnAuditing(auditOperation, action)) { return; } if (!AuditCheck()) { return; } this.AuditEntity.StartDate = System.DateTime.Now; InnerHandIn(auditOperation, action); // ShowKPI(auditOperation, action); } catch { CanAudit(true); } }
public Task AddAsync(AuditOperation auditOperation) { _logger.LogInformation(System.Text.Json.JsonSerializer.Serialize(auditOperation)); return(Task.CompletedTask); }
public AuditTrail(Guid transactionId, DateTime timestamp, string applicationId, AuditOperation operation, string user, string origin, string objectId, object @object, IEnumerable <string> namesOfPropertiesToIgnore = null) { Id = Guid.NewGuid(); TransactionId = transactionId; Timestamp = timestamp; ApplicationId = !string.IsNullOrWhiteSpace(applicationId) ? applicationId : throw new ArgumentNullException(nameof(applicationId)); Operation = operation.ToString(); User = !string.IsNullOrWhiteSpace(user) ? user : throw new ArgumentNullException(nameof(user)); Origin = origin; ObjectAssembly = @object?.GetType().FullName ?? throw new ArgumentNullException(nameof(@object)); ObjectId = !string.IsNullOrWhiteSpace(objectId) ? objectId : throw new ArgumentNullException(nameof(objectId)); ObjectSerial = operation == AuditOperation.Create || operation == AuditOperation.Update ? JsonConvert.SerializeObject(@object, @object.GetType(), new GeneralJsonSerializerSettings().IgnoreProperties(@object.GetType(), namesOfPropertiesToIgnore)) : string.Empty; }
private void InitAudit(AuditOperation op) { EmployeerData auditor = null; if (op == AuditOperation.Add) { auditor = this.OrderEntity.GetOwnerInfo(); string userID = Convert.ToString(auditor.Value); if (string.IsNullOrEmpty(userID) || userID == DataCore.SuperUser.Value.ToString()) { auditor = this.OrderEntity.LoginUser; } } else { auditor = this.OrderEntity.LoginUser; } // 提交前,需要对AuditEntity赋值 ,以下属性必填 AuditEntity.CreateCompanyID = auditor.Company.Value.ToString(); AuditEntity.CreateDepartmentID = auditor.Department.Value.ToString(); AuditEntity.CreatePostID = auditor.Post.Value.ToString(); AuditEntity.CreateUserID = auditor.Value.ToString(); AuditEntity.CreateUserName = auditor.Text; AuditEntity.EditUserID = auditor.Value.ToString(); AuditEntity.EditUserName = auditor.Text; AuditEntity.ModelCode = this.OrderEntity.OrderInfo.Type; AuditEntity.FormID = this.OrderEntity.OrderID; // 如果这个单据是报销单,或借款单,且有外部扩展单据关联。重新赋FormID和ModelCode 和EditUserID= "" if (this.OrderEntity.OrderType != typeof(T_FB_CHARGEAPPLYMASTER) && this.OrderEntity.OrderType != typeof(T_FB_BORROWAPPLYMASTER)) { return; } if (this.OrderEntity.OrderType == typeof(T_FB_CHARGEAPPLYMASTER)) { T_FB_CHARGEAPPLYMASTER entView = orderEntity.Entity as T_FB_CHARGEAPPLYMASTER; if (entView.T_FB_EXTENSIONALORDER == null) { return; } if (entView.T_FB_EXTENSIONALORDER.T_FB_EXTENSIONALTYPE != null) { AuditEntity.ModelCode = entView.T_FB_EXTENSIONALORDER.T_FB_EXTENSIONALTYPE.MODELCODE; AuditEntity.FormID = entView.T_FB_EXTENSIONALORDER.ORDERID; } } else if (this.OrderEntity.OrderType == typeof(T_FB_BORROWAPPLYMASTER)) { T_FB_BORROWAPPLYMASTER entView = orderEntity.Entity as T_FB_BORROWAPPLYMASTER; if (entView.T_FB_EXTENSIONALORDER == null) { return; } if (entView.T_FB_EXTENSIONALORDER.T_FB_EXTENSIONALTYPE != null) { AuditEntity.ModelCode = entView.T_FB_EXTENSIONALORDER.T_FB_EXTENSIONALTYPE.MODELCODE; AuditEntity.FormID = entView.T_FB_EXTENSIONALORDER.ORDERID; } } }
protected virtual void InnerHandIn(AuditOperation auditOperation, AuditAction action) { string op = auditOperation.ToString(); string tmpnextStateCode = IsEndAudit ? "EndFlow" : NextStateCode; //EndFlow SubmitFlag AuditSubmitFlag = op.ToUpper() == "ADD" ? SubmitFlag.New : SubmitFlag.Approval; #region beyond switch (auditOperation) { case AuditOperation.Add: AuditSubmitFlag = SubmitFlag.New; break; case AuditOperation.Update: AuditSubmitFlag = SubmitFlag.Approval; break; case AuditOperation.Cancel: AuditSubmitFlag = SubmitFlag.Cancel; break; default: break; } AuditSubmitData.DictCounterUser = this.DictCounterUser; if (AuditSubmitFlag == SubmitFlag.New) { AuditSubmitData.XML = XmlObject; } #endregion AuditSubmitData.FormID = AuditEntity.FormID; AuditSubmitData.ModelCode = AuditEntity.ModelCode; AuditSubmitData.ApprovalUser = new UserInfo(); AuditSubmitData.ApprovalUser.CompanyID = AuditEntity.CreateCompanyID; AuditSubmitData.ApprovalUser.DepartmentID = AuditEntity.CreateDepartmentID; AuditSubmitData.ApprovalUser.PostID = AuditEntity.CreatePostID; AuditSubmitData.ApprovalUser.UserID = AuditEntity.CreateUserID; AuditSubmitData.ApprovalUser.UserName = AuditEntity.CreateUserName; AuditSubmitData.ApprovalContent = AuditRemark; AuditSubmitData.NextStateCode = tmpnextStateCode; AuditSubmitData.NextApprovalUser = new UserInfo(); AuditSubmitData.NextApprovalUser.CompanyID = NextCompanyID; AuditSubmitData.NextApprovalUser.DepartmentID = NextDepartmentID; AuditSubmitData.NextApprovalUser.PostID = NextPostID; AuditSubmitData.NextApprovalUser.UserID = NextUserID; AuditSubmitData.NextApprovalUser.UserName = NextUserName; AuditSubmitData.SubmitFlag = AuditSubmitFlag; //AuditSubmitData.XML = XmlObject; AuditSubmitData.FlowSelectType = IsFixedFlow ? FlowSelectType.FixedFlow : FlowSelectType.FreeFlow; if (!IsFixedFlow && ckbIsEndAudit.IsChecked.Value != true && action != AuditAction.Fail) { if (string.IsNullOrEmpty(this.txtAuditId.Text)) { //ComfirmWindow.ConfirmationBox("","请选择下一审核人" , Utility.GetResourceStr("CONFIRMBUTTON")); DataResult dataResult = new DataResult(); dataResult.FlowResult = FlowResult.FAIL; dataResult.Err = "请选择下一审核人"; //AuditEventArgs args = new AuditEventArgs(AuditEventArgs.AuditResult.Error, dataResult); //args.StartDate = this.AuditEntity.StartDate; //args.EndDate = System.DateTime.Now; this.DoAuditResult(dataResult); //this.CloseProcess(); return; } else if (this.txtAuditId.Text == SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID) { DataResult dataResult = new DataResult(); dataResult.FlowResult = FlowResult.FAIL; dataResult.Err = "不能提交给自己"; //AuditEventArgs args = new AuditEventArgs(AuditEventArgs.AuditResult.Error, dataResult); //args.StartDate = this.AuditEntity.StartDate; //args.EndDate = System.DateTime.Now; this.DoAuditResult(dataResult); //this.CloseProcess(); return; } } if (AuditSubmitData.FlowType == null) AuditSubmitData.FlowType = FlowType.Approval; if (AuditSubmitFlag == SubmitFlag.Approval) { AuditSubmitData.ApprovalUser.CompanyID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].CompanyID; AuditSubmitData.ApprovalUser.DepartmentID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID; AuditSubmitData.ApprovalUser.PostID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].PostID; AuditSubmitData.ApprovalUser.UserID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID; AuditSubmitData.ApprovalUser.UserName = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeName; } //提交人(只帮别人提单的时候起作用,区分单据所属人) AuditSubmitData.SumbitCompanyID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].CompanyID; AuditSubmitData.SumbitDeparmentID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID; AuditSubmitData.SumbitPostID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].PostID; AuditSubmitData.SumbitUserID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID; AuditSubmitData.SumbitUserName = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeName; //end /提交人(只帮别人提单的时候起作用,区分单据所属人) AuditSubmitData.ApprovalResult = (ApprovalResult)((int)action);// SMTWFTest.WcfFlowService.ApprovalResult.Pass; AuditService.SubimtFlowAsync(AuditSubmitData); RetSubmit = false; // beyond 记录日志 //submitStartTime = DateTime.Now; }
private bool OnAuditing(AuditOperation auditOperation, AuditAction action) { if (Auditing != null) { AuditEventArgs.AuditResult result = AuditEventArgs.AuditResult.Auditing; if (auditOperation == AuditOperation.Update) { result = action == AuditAction.Fail ? AuditEventArgs.AuditResult.Fail : AuditEventArgs.AuditResult.Successful; } AuditEventArgs args = new AuditEventArgs(result, null); Auditing(this, args); return args.Result != AuditEventArgs.AuditResult.Cancel; } return true; }
public async Task AddAsync(AuditOperation auditOperation) { await _dbContext.AddAsync(auditOperation); }
protected virtual void InnerHandInOld(AuditOperation auditOperation, AuditAction action) { string op = auditOperation.ToString(); string tmpnextStateCode = IsEndAudit ? "EndFlow" : NextStateCode; //EndFlow SubmitFlag AuditSubmitFlag = op.ToUpper() == "ADD" ? SubmitFlag.New : SubmitFlag.Approval; AuditSubmitData.FormID = AuditEntity.FormID; AuditSubmitData.ModelCode = AuditEntity.ModelCode; AuditSubmitData.ApprovalUser = new UserInfo(); AuditSubmitData.ApprovalUser.CompanyID = AuditEntity.CreateCompanyID; AuditSubmitData.ApprovalUser.DepartmentID = AuditEntity.CreateDepartmentID; AuditSubmitData.ApprovalUser.PostID = AuditEntity.CreatePostID; AuditSubmitData.ApprovalUser.UserID = AuditEntity.CreateUserID; AuditSubmitData.ApprovalUser.UserName = AuditEntity.CreateUserName; AuditSubmitData.ApprovalContent = AuditRemark; AuditSubmitData.NextStateCode = tmpnextStateCode; AuditSubmitData.NextApprovalUser = new UserInfo(); AuditSubmitData.NextApprovalUser.CompanyID = NextCompanyID; AuditSubmitData.NextApprovalUser.DepartmentID = NextDepartmentID; AuditSubmitData.NextApprovalUser.PostID = NextPostID; AuditSubmitData.NextApprovalUser.UserID = NextUserID; AuditSubmitData.NextApprovalUser.UserName = NextUserName; AuditSubmitData.SubmitFlag = AuditSubmitFlag; AuditSubmitData.XML = XmlObject; AuditSubmitData.FlowSelectType = IsFixedFlow ? FlowSelectType.FixedFlow : FlowSelectType.FreeFlow; if (AuditSubmitData.FlowType == null) AuditSubmitData.FlowType = FlowType.Approval; if (AuditSubmitFlag == SubmitFlag.Approval) { AuditSubmitData.ApprovalUser.CompanyID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].CompanyID; AuditSubmitData.ApprovalUser.DepartmentID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID; AuditSubmitData.ApprovalUser.PostID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].PostID; AuditSubmitData.ApprovalUser.UserID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID; AuditSubmitData.ApprovalUser.UserName = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeName; } //提交人(只帮别人提单的时候起作用,区分单据所属人) AuditSubmitData.SumbitCompanyID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].CompanyID; AuditSubmitData.SumbitDeparmentID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID; AuditSubmitData.SumbitPostID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].PostID; AuditSubmitData.SumbitUserID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID; AuditSubmitData.SumbitUserName = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeName; //end /提交人(只帮别人提单的时候起作用,区分单据所属人) AuditSubmitData.ApprovalResult = (ApprovalResult)((int)action);// SMTWFTest.WcfFlowService.ApprovalResult.Pass; AuditService.SubimtFlowAsync(AuditSubmitData); }
public void Retry() { if (savedEndpointOperation != null) { switch (Operation) { case PNOperationType.PNAccessManagerAudit: if (savedEndpointOperation is AuditOperation) { AuditOperation endpoint = savedEndpointOperation as AuditOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNAccessManagerGrant: if (savedEndpointOperation is GrantOperation) { GrantOperation endpoint = savedEndpointOperation as GrantOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNAddChannelsToGroupOperation: if (savedEndpointOperation is AddChannelsToChannelGroupOperation) { AddChannelsToChannelGroupOperation endpoint = savedEndpointOperation as AddChannelsToChannelGroupOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNRemoveGroupOperation: if (savedEndpointOperation is DeleteChannelGroupOperation) { DeleteChannelGroupOperation endpoint = savedEndpointOperation as DeleteChannelGroupOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.ChannelGroupAllGet: if (savedEndpointOperation is ListAllChannelGroupOperation) { ListAllChannelGroupOperation endpoint = savedEndpointOperation as ListAllChannelGroupOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.ChannelGroupGet: if (savedEndpointOperation is ListChannelsForChannelGroupOperation) { ListChannelsForChannelGroupOperation endpoint = savedEndpointOperation as ListChannelsForChannelGroupOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNRemoveChannelsFromGroupOperation: if (savedEndpointOperation is RemoveChannelsFromChannelGroupOperation) { RemoveChannelsFromChannelGroupOperation endpoint = savedEndpointOperation as RemoveChannelsFromChannelGroupOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNGetStateOperation: if (savedEndpointOperation is GetStateOperation) { GetStateOperation endpoint = savedEndpointOperation as GetStateOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNHereNowOperation: if (savedEndpointOperation is HereNowOperation) { HereNowOperation endpoint = savedEndpointOperation as HereNowOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNSetStateOperation: if (savedEndpointOperation is SetStateOperation) { SetStateOperation endpoint = savedEndpointOperation as SetStateOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNWhereNowOperation: if (savedEndpointOperation is WhereNowOperation) { WhereNowOperation endpoint = savedEndpointOperation as WhereNowOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNFireOperation: if (savedEndpointOperation is FireOperation) { FireOperation endpoint = savedEndpointOperation as FireOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNPublishOperation: if (savedEndpointOperation is PublishOperation) { PublishOperation endpoint = savedEndpointOperation as PublishOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PushRegister: if (savedEndpointOperation is AddPushChannelOperation) { AddPushChannelOperation endpoint = savedEndpointOperation as AddPushChannelOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PushGet: if (savedEndpointOperation is AuditPushChannelOperation) { AuditPushChannelOperation endpoint = savedEndpointOperation as AuditPushChannelOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PushUnregister: if (savedEndpointOperation is RemovePushChannelOperation) { RemovePushChannelOperation endpoint = savedEndpointOperation as RemovePushChannelOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNHistoryOperation: if (savedEndpointOperation is HistoryOperation) { HistoryOperation endpoint = savedEndpointOperation as HistoryOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNFetchHistoryOperation: if (savedEndpointOperation is FetchHistoryOperation) { FetchHistoryOperation endpoint = savedEndpointOperation as FetchHistoryOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNMessageCountsOperation: if (savedEndpointOperation is MessageCountsOperation) { MessageCountsOperation endpoint = savedEndpointOperation as MessageCountsOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNTimeOperation: if (savedEndpointOperation is TimeOperation) { TimeOperation endpoint = savedEndpointOperation as TimeOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNSetUuidMetadataOperation: if (savedEndpointOperation is SetUuidMetadataOperation) { SetUuidMetadataOperation endpoint = savedEndpointOperation as SetUuidMetadataOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNSetChannelMetadataOperation: if (savedEndpointOperation is SetChannelMetadataOperation) { SetChannelMetadataOperation endpoint = savedEndpointOperation as SetChannelMetadataOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNDeleteUuidMetadataOperation: if (savedEndpointOperation is RemoveUuidMetadataOperation) { RemoveUuidMetadataOperation endpoint = savedEndpointOperation as RemoveUuidMetadataOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNDeleteChannelMetadataOperation: if (savedEndpointOperation is RemoveChannelMetadataOperation) { RemoveChannelMetadataOperation endpoint = savedEndpointOperation as RemoveChannelMetadataOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNGetUuidMetadataOperation: if (savedEndpointOperation is GetUuidMetadataOperation) { GetUuidMetadataOperation endpoint = savedEndpointOperation as GetUuidMetadataOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNGetChannelMetadataOperation: if (savedEndpointOperation is GetChannelMetadataOperation) { GetChannelMetadataOperation endpoint = savedEndpointOperation as GetChannelMetadataOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNGetAllUuidMetadataOperation: if (savedEndpointOperation is GetAllUuidMetadataOperation) { GetAllUuidMetadataOperation endpoint = savedEndpointOperation as GetAllUuidMetadataOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNGetAllChannelMetadataOperation: if (savedEndpointOperation is GetAllChannelMetadataOperation) { GetAllChannelMetadataOperation endpoint = savedEndpointOperation as GetAllChannelMetadataOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNManageMembershipsOperation: if (savedEndpointOperation is ManageMembershipsOperation) { ManageMembershipsOperation endpoint = savedEndpointOperation as ManageMembershipsOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNSetMembershipsOperation: if (savedEndpointOperation is SetMembershipsOperation) { SetMembershipsOperation endpoint = savedEndpointOperation as SetMembershipsOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNRemoveMembershipsOperation: if (savedEndpointOperation is RemoveMembershipsOperation) { RemoveMembershipsOperation endpoint = savedEndpointOperation as RemoveMembershipsOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNManageChannelMembersOperation: if (savedEndpointOperation is ManageChannelMembersOperation) { ManageChannelMembersOperation endpoint = savedEndpointOperation as ManageChannelMembersOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNSetChannelMembersOperation: if (savedEndpointOperation is SetChannelMembersOperation) { SetChannelMembersOperation endpoint = savedEndpointOperation as SetChannelMembersOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNRemoveChannelMembersOperation: if (savedEndpointOperation is RemoveChannelMembersOperation) { RemoveChannelMembersOperation endpoint = savedEndpointOperation as RemoveChannelMembersOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNGetMembershipsOperation: if (savedEndpointOperation is GetMembershipsOperation) { GetMembershipsOperation endpoint = savedEndpointOperation as GetMembershipsOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNGetChannelMembersOperation: if (savedEndpointOperation is GetChannelMembersOperation) { GetChannelMembersOperation endpoint = savedEndpointOperation as GetChannelMembersOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNAddMessageActionOperation: if (savedEndpointOperation is AddMessageActionOperation) { AddMessageActionOperation endpoint = savedEndpointOperation as AddMessageActionOperation; if (endpoint != null) { endpoint.Retry(); } } break; case PNOperationType.PNRemoveMessageActionOperation: if (savedEndpointOperation is RemoveMessageActionOperation) { RemoveMessageActionOperation endpoint = savedEndpointOperation as RemoveMessageActionOperation; if (endpoint != null) { endpoint.Retry(); } } break; default: break; } } }
/// <summary> /// 设置保存审计数据 /// </summary> /// <param name="operationEntry">操作审计数据</param> public void Save(AuditOperationEntry operationEntry) { AuditOperation operation = BuildOperation(operationEntry); _operationRepository.Insert(operation); }