void IDataUpdateTrigger.ContitionSqlCode <TEntity>(List <string> conditions) { if (GlobalContext.Current.IsSystemMode || GlobalContext.Current.User.UserId == LoginUserInfo.SystemUserId) { return; } if (DefaultDataUpdateTrigger.IsType <TEntity>(DefaultDataUpdateTrigger.TypeofIOrganizationData)) { conditions.Add($"`organization_id` = {GlobalContext.Current.User.OrganizationId}"); } }
void IDataUpdateTrigger.AfterUpdateSql <TEntity>(IDataTable <TEntity> table, string condition, StringBuilder code) { if (DefaultDataUpdateTrigger.IsType <TEntity>(DefaultDataUpdateTrigger.TypeofIHistoryData)) { code.Append($@" UPDATE `{table.WriteTableName}` SET `{table.FieldDictionary[nameof(IHistoryData.LastReviserId)]}` = {GlobalContext.Current.LoginUserId}, `{table.FieldDictionary[nameof(IHistoryData.LastModifyDate)]}` = Now()"); if (!string.IsNullOrEmpty(condition)) { code.Append($@" WHERE {condition}"); } code.AppendLine(";"); } }
void IDataUpdateTrigger.AfterUpdateSql <TEntity>(IDataTable <TEntity> table, string condition, StringBuilder code) { if (DefaultDataUpdateTrigger.IsType <TEntity>(DefaultDataUpdateTrigger.TypeofIVersionData)) { long ver; using (RedisProxy proxy = new RedisProxy(RedisProxy.DbSystem)) { ver = proxy.Redis.Incr($"ent:ver:{table.Name}"); } code.Append($@" UPDATE `{table.WriteTableName}` SET `{table.FieldDictionary[nameof(IVersionData.DataVersion)]}` = {ver}"); if (!string.IsNullOrEmpty(condition)) { code.Append($@" WHERE {condition}"); } code.AppendLine(";"); } }