Ejemplo n.º 1
0
 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}");
     }
 }
Ejemplo n.º 2
0
        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(";");
            }
        }
Ejemplo n.º 3
0
        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(";");
            }
        }