Exemplo n.º 1
0
 private static void AddUpdateTerm(UpdateTermCollection terms, UpdateTerm ut)
 {
     if (terms.Contains(ut.FieldName))
     {
         terms[ut.FieldName] = ut;
     }
     else
     {
         terms.Add(ut);
     }
 }
Exemplo n.º 2
0
 private static string CreateInsertTableSQL(string[] keys, string[] fields, IList<string[]> vals, ITraceDb trace, bool canTraceAdd, DAODataTable ddt)
 {
     string str = null;
     if ((keys != null) || (keys.Length > 0))
     {
         int length = keys.Length;
         int num2 = fields.Length;
         for (int i = 0; i < length; i++)
         {
             InsertQuery query = new InsertQuery(ddt.Name);
             foreach (DAODataColumn column in ddt.DataColumns)
             {
                 object val = null;
                 if (column.IsNeedInitial)
                 {
                     val = GetInitialValue(column.InitialValue);
                     LoggingService.DebugFormatted("初始化字段:{0} 的值为:{1}", new object[] { column.Name, val });
                 }
                 else if (column.Name.ToLower() == "createdate")
                 {
                     val = DateTimeHelper.GetNow();
                 }
                 if (val != null)
                 {
                     try
                     {
                         query.Terms.Add(new UpdateTerm(column.Name, GetSqlExpression(column.DataType, val)));
                         if (canTraceAdd)
                         {
                             trace.TraceOuterAdd(ddt.Name, keys[i], column.Name, val.ToString(), "系统新增字段值记录");
                         }
                     }
                     catch (Exception exception)
                     {
                         LoggingService.ErrorFormatted("在设置表:{0}字段:{1}初始化值:{2}时出错:{3}\r\n{4}", new object[] { ddt.Name, column.Name, val, exception.Message, exception.StackTrace });
                     }
                 }
             }
             string[] strArray = vals[i];
             UpdateTerm ut = new UpdateTerm(ddt.Key, SqlExpression.String(keys[i]));
             AddUpdateTerm(query.Terms, ut);
             if (canTraceAdd)
             {
                 trace.TraceOuterAdd(ddt.Name, keys[i], "系统自动初始化数据新增记录");
             }
             if (fields != null)
             {
                 string str2 = string.Empty;
                 for (int j = 0; j < num2; j++)
                 {
                     str2 = fields[j];
                     if (ddt.Contains(str2))
                     {
                         ut = new UpdateTerm(str2, SqlExpression.String(strArray[j]));
                         AddUpdateTerm(query.Terms, ut);
                         if (canTraceAdd)
                         {
                             trace.TraceOuterAdd(ddt.Name, keys[i], str2, strArray[j], "系统新增字段值记录");
                         }
                     }
                 }
             }
             if (query.Terms.Count > 0)
             {
                 str = SqlOmRenderHelper.Instance.RenderInsert(query);
             }
         }
         return str;
     }
     log.Error("没有找到初始化记录的关键字值,不能正确初始化");
     return str;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Render a single column name in an INSERT statement
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="term"></param>
 protected virtual void InsertColumn(StringBuilder builder, UpdateTerm term)
 {
     Identifier(builder, term.FieldName);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Render a single INSERT value
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="term"></param>
 protected virtual void InsertValue(StringBuilder builder, UpdateTerm term)
 {
     Expression(builder, term.Value);
 }
Exemplo n.º 5
0
 internal Value(string fieldName, Expr val)
 {
     Term = new UpdateTerm(fieldName, val?.Expression);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Render a single update phrase
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="term"></param>
 protected virtual void UpdateTerm(StringBuilder builder, UpdateTerm term)
 {
     Identifier(builder, term.FieldName);
     builder.Append(" = ");
     Expression(builder, term.Value);
 }
 public virtual void AddRange(UpdateTerm[] items)
 {
     foreach (UpdateTerm term in items)
     {
         base.List.Add(term);
     }
 }
 public virtual bool Contains(UpdateTerm value)
 {
     return base.List.Contains(value);
 }
 public virtual void Add(UpdateTerm value)
 {
     base.List.Add(value);
 }
Exemplo n.º 10
0
 public UpdateTermCollection(UpdateTerm[] items)
 {
     this.AddRange(items);
 }
Exemplo n.º 11
0
 public virtual void Remove(UpdateTerm value)
 {
     base.List.Remove(value);
 }
Exemplo n.º 12
0
 public virtual void Insert(int index, UpdateTerm value)
 {
     base.List.Insert(index, value);
 }
Exemplo n.º 13
0
 public virtual int IndexOf(UpdateTerm value)
 {
     return base.List.IndexOf(value);
 }