/// <summary> /// 到中文名称 /// </summary> /// <param name="state">审核状态类型</param> /// <returns>中文名称</returns> public static string ToChiness(this AuditStateType state) { switch (state) { case AuditStateType.Submit: return("提交审核"); case AuditStateType.Deny: return("已否决"); case AuditStateType.Pass: return("已通过"); case AuditStateType.Again: return("反审核"); case AuditStateType.End: return("结束"); case AuditStateType.None: return("草稿"); default: return("错误"); } }
/// <summary> /// 设置审核状态 /// </summary> /// <param name="data"></param> /// <param name="audit"></param> /// <param name="state"></param> private void SetAuditState(TData data, AuditStateType audit, DataStateType state) { data.AuditState = audit; switch (audit) { case AuditStateType.Pass: state = DataStateType.Enable; data.AuditDate = DateTime.Now; data.Auditor = GlobalContext.Current.User.NickName; data.AuditorId = GlobalContext.Current.User.UserId; break; case AuditStateType.Deny: state = DataStateType.Discard; data.AuditDate = DateTime.Now; data.Auditor = GlobalContext.Current.User.NickName; data.AuditorId = GlobalContext.Current.User.UserId; break; case AuditStateType.End: data.IsFreeze = true; break; } data.DataState = state; OnAuditStateChanged(data); }
/// <summary> /// Transforms the given model to its endpoints acceptable structure and sends it to the endpoint /// </summary> public void SetDatabaseThreatDetectionPolicy(DatabaseThreatDetectionPolicyModel model, String clientId) { if (model.ThreatDetectionState == ThreatDetectionStateType.Enabled) { if (!IsRightServerVersionForThreatDetection(model.ResourceGroupName, model.ServerName, clientId)) { throw new Exception(Properties.Resources.ServerNotApplicableForThreatDetection); } // Check that auditing is turned on: DatabaseAuditingPolicyModel databaseAuditingPolicyModel; AuditingAdapter.GetDatabaseAuditingPolicy(model.ResourceGroupName, model.ServerName, model.DatabaseName, clientId, out databaseAuditingPolicyModel); AuditStateType auditingState = databaseAuditingPolicyModel.AuditState; if (databaseAuditingPolicyModel.UseServerDefault == UseServerDefaultOptions.Enabled) { ServerAuditingPolicyModel serverAuditingPolicyModel; AuditingAdapter.GetServerAuditingPolicy(model.ResourceGroupName, model.ServerName, clientId, out serverAuditingPolicyModel); auditingState = serverAuditingPolicyModel.AuditState; } if (auditingState != AuditStateType.Enabled) { throw new Exception(Properties.Resources.AuditingIsTurnedOff); } } var databaseSecurityAlertPolicyParameters = PolicizeDatabaseSecurityAlertModel(model); ThreatDetectionCommunicator.SetDatabaseSecurityAlertPolicy(model.ResourceGroupName, model.ServerName, model.DatabaseName, clientId, databaseSecurityAlertPolicyParameters); }
/// <summary> /// 复制值 /// </summary> /// <param name="source">复制的源字段</param> protected override void CopyValueInner(DataObjectBase source) { var sourceEntity = source as PositionData; if (sourceEntity == null) { return; } this._id = sourceEntity._id; this._fullname = sourceEntity._fullname; this._shortname = sourceEntity._shortname; this._positionlevel = sourceEntity._positionlevel; this._memo = sourceEntity._memo; this._datastate = sourceEntity._datastate; this._isfreeze = sourceEntity._isfreeze; this._authorid = sourceEntity._authorid; this._adddate = sourceEntity._adddate; this._lastreviserid = sourceEntity._lastreviserid; this._lastmodifydate = sourceEntity._lastmodifydate; this._auditstate = sourceEntity._auditstate; this._auditorid = sourceEntity._auditorid; this._auditdate = sourceEntity._auditdate; CopyExtendValue(sourceEntity); this.__EntityStatus.SetModified(); }
/// <summary> /// Transforms the given policy state into a string representation /// </summary> private string PolicizeAuditState(AuditStateType auditState) { switch (auditState) { case AuditStateType.Enabled: return SecurityConstants.AuditingEndpoint.Enabled; case AuditStateType.New: return SecurityConstants.AuditingEndpoint.New; case AuditStateType.Disabled: default: return SecurityConstants.AuditingEndpoint.Disabled; } }
/// <summary> /// Transforms the given policy state into a string representation /// </summary> private string PolicizeAuditState(AuditStateType AuditState) { switch (AuditState) { case AuditStateType.Enabled: return(Constants.AuditingEndpoint.Enabled); case AuditStateType.New: return(Constants.AuditingEndpoint.New); case AuditStateType.Disabled: default: return(Constants.AuditingEndpoint.Disabled); } }
/// <summary> /// Updates the given model element with the cmdlet specific operation /// </summary> /// <param name="model">A model object</param> protected override DatabaseAuditingPolicyModel ApplyUserInputToModel(DatabaseAuditingPolicyModel model) { base.ApplyUserInputToModel(model); AuditStateType orgAuditStateType = model.AuditState; model.AuditState = AuditStateType.Enabled; model.UseServerDefault = UseServerDefaultOptions.Disabled; if (StorageAccountName != null) { model.StorageAccountName = StorageAccountName; } if (!string.IsNullOrEmpty(StorageKeyType)) // the user enter a key type - we use it (and running over the previously defined key type) { model.StorageKeyType = (StorageKeyType == SecurityConstants.Primary) ? StorageKeyKind.Primary : StorageKeyKind.Secondary; } EventType = Util.ProcessAuditEvents(EventType); if (EventType != null) // the user provided event types to audit { model.EventType = EventType.Select(s => SecurityConstants.AuditEventsToAuditEventType[s]).ToArray(); } if (RetentionInDays != null) { model.RetentionInDays = RetentionInDays; } if (TableIdentifier == null) { if ((orgAuditStateType == AuditStateType.New) && (model.RetentionInDays > 0)) { // If retention days is greater than 0 and no audit table identifier is supplied , we throw exception giving the user hint on the recommended TableIdentifier we got from the CSM throw new Exception(string.Format(Resources.InvalidRetentionTypeSet, model.TableIdentifier)); } } else { model.TableIdentifier = TableIdentifier; } if (Util.DeprecatedEventTypeFound(EventType)) { WriteWarning(string.Format(Resources.DeprecatedEventTypeUsed)); } return(model); }
/// <summary> /// 复制值 /// </summary> /// <param name="source">复制的源字段</param> protected override void CopyValueInner(DataObjectBase source) { var sourceEntity = source as RoleData; if (sourceEntity == null) { return; } this._id = sourceEntity._id; this._role = sourceEntity._role; this._caption = sourceEntity._caption; this._memo = sourceEntity._memo; this._datastate = sourceEntity._datastate; this._isfreeze = sourceEntity._isfreeze; this._authorid = sourceEntity._authorid; this._adddate = sourceEntity._adddate; this._lastreviserid = sourceEntity._lastreviserid; this._lastmodifydate = sourceEntity._lastmodifydate; this._auditstate = sourceEntity._auditstate; this._auditorid = sourceEntity._auditorid; this._auditdate = sourceEntity._auditdate; CopyExtendValue(sourceEntity); this.__EntityStatus.SetModified(); }
/// <summary> /// Transforms the given policy state into a string representation /// </summary> private string PolicizeAuditState(AuditStateType auditState) { switch(auditState) { case AuditStateType.Enabled: return SecurityConstants.AuditingEndpoint.Enabled; case AuditStateType.New: return SecurityConstants.AuditingEndpoint.New; case AuditStateType.Disabled: default: return SecurityConstants.AuditingEndpoint.Disabled; } }
/// <summary> /// 设置属性值 /// </summary> /// <param name="property"></param> /// <param name="value"></param> protected override void SetValueInner(string property, object value) { switch (property.Trim().ToLower()) { case "id": this.Id = (int)Convert.ToDecimal(value); return; case "role": this.Role = value == null ? null : value.ToString(); return; case "caption": this.Caption = value == null ? null : value.ToString(); return; case "memo": this.Memo = value == null ? null : value.ToString(); return; case "datastate": if (value != null) { if (value is int) { this.DataState = (DataStateType)(int)value; } else if (value is DataStateType) { this.DataState = (DataStateType)value; } else { var str = value.ToString(); DataStateType val; if (DataStateType.TryParse(str, out val)) { this.DataState = val; } else { int vl; if (int.TryParse(str, out vl)) { this.DataState = (DataStateType)vl; } } } } return; case "isfreeze": if (value != null) { int vl; if (int.TryParse(value.ToString(), out vl)) { this.IsFreeze = vl != 0; } else { this.IsFreeze = Convert.ToBoolean(value); } } return; case "authorid": this.AuthorID = (int)Convert.ToDecimal(value); return; case "adddate": this.AddDate = Convert.ToDateTime(value); return; case "lastreviserid": this.LastReviserID = (int)Convert.ToDecimal(value); return; case "lastmodifydate": this.LastModifyDate = Convert.ToDateTime(value); return; case "auditstate": if (value != null) { if (value is int) { this.AuditState = (AuditStateType)(int)value; } else if (value is AuditStateType) { this.AuditState = (AuditStateType)value; } else { var str = value.ToString(); AuditStateType val; if (AuditStateType.TryParse(str, out val)) { this.AuditState = val; } else { int vl; if (int.TryParse(str, out vl)) { this.AuditState = (AuditStateType)vl; } } } } return; case "auditorid": this.AuditorId = (int)Convert.ToDecimal(value); return; case "auditdate": this.AuditDate = Convert.ToDateTime(value); return; } //System.Diagnostics.Trace.WriteLine(property + @"=>" + value); }
partial void OnAuditStateSet(ref AuditStateType value);