/// <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> /// 数据状态枚举类型 /// </summary> public static string ToCaption(this DataStateType value) { switch (value) { case DataStateType.None: return("草稿"); case DataStateType.Discard: return("废弃"); case DataStateType.State: return("不正确的状态"); case DataStateType.Orther: return("其它人编辑中"); case DataStateType.Lock: return("锁定"); case DataStateType.Delete: return("删除"); case DataStateType.Enable: return("启用"); case DataStateType.Disable: return("禁用"); default: return("未知数据状态"); } }
/// <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> /// 修改状态 /// </summary> public virtual bool SetState <TPrimaryKey>(DataStateType state, bool isFreeze, TPrimaryKey id) { var sql = $@"UPDATE [{ContextWriteTable}] SET {ResetStateFileSqlCode((int)state, isFreeze ? 1 : 0)} WHERE {PrimaryKeyConditionSQL}"; return(DataBase.Execute(sql, CreatePimaryKeyParameter(id)) == 1); }
public void Delete() { if (this.DataState == DataStateType.Add) { this.DataState = DataStateType.UnChanged; } else { this.DataState = DataStateType.Delete; } }
private void RaisePropertyChanged(string propertyName, bool induceChanged) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); if (induceChanged) { if (this.DataState == DataStateType.UnChanged) { this.DataState = DataStateType.Update; } } } }
/// <summary> /// 修改状态 /// </summary> protected bool SetDataState(int id, DataStateType state, Expression <Func <TData, bool> > filter) { using (Access.DataBase.CreateDataBaseScope()) { if (!Access.ExistPrimaryKey(id) || !Access.Any(filter)) { return(false); } Access.SetValue(p => p.DataState, state, id); if (!unityStateChanged) { return(true); } OnStateChanged(Access.LoadByPrimaryKey(id), BusinessCommandType.SetState); return(true); } }
/// <summary> /// 修改状态 /// </summary> protected bool SetDataState(TPrimaryKey id, DataStateType state, bool isFreeze, Expression <Func <TData, bool> > filter) { if (filter != null && !Access.Any(filter)) { return(false); } if (filter == null && !Access.ExistPrimaryKey(id)) { return(false); } Access.SetState(state, isFreeze, id); using var scope = TransactionScope.CreateScope(Access.DataBase); Access.SetValue(p => p.IsFreeze, isFreeze, id); Access.SetValue(p => p.DataState, state, id); OnStateChanged(id, BusinessCommandType.SetState); return(scope.Succeed()); }
/// <summary> /// 修改状态 /// </summary> protected bool SetDataState(long id, DataStateType state, Expression <Func <TData, bool> > filter, bool?setFreeze) { if (filter != null && !Access.Any(filter)) { return(false); } if (filter == null && !Access.ExistPrimaryKey(id)) { return(false); } using (var scope = Access.DataBase.CreateTransactionScope()) { Access.SetValue(p => p.DataState, state, id); if (setFreeze != null) { Access.SetValue(p => p.IsFreeze, setFreeze.Value, id); } OnStateChanged(id, BusinessCommandType.SetState); return(scope.SetState(true)); } }
/// <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(); }
public void ClearDataState() { this.DataState = DataStateType.UnChanged; }
/// <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 OnDataStateSet(ref DataStateType value);