Ejemplo n.º 1
0
        private static DataDiffItem ResolveItem(DataDiffTable table, int id, string code)
        {
            DataDiffItem existed;

            lock (table.Definitions){
                existed = table.Definitions.FirstOrDefault(
                    _ => (0 != id && _.Id == id) || (!string.IsNullOrWhiteSpace(code) && code == _.Code));
                if (null == existed)
                {
                    existed = new DataDiffItem {
                        Id = id, Code = code
                    };
                    table.Definitions.Add(existed);
                }
                else
                {
                    if (0 == existed.Id)
                    {
                        existed.Id = id;
                    }
                    if (string.IsNullOrWhiteSpace(existed.Code))
                    {
                        existed.Code = code;
                    }
                }
            }
            return(existed);
        }
Ejemplo n.º 2
0
 private void OutUsualField(DataDiffItem def, string allfield)
 {
     if (def.Fields.ContainsKey(allfield))
     {
         var val = def.Fields[allfield].Replace("'", "''").Trim();
         if (val.IndexOf(',') != 0 && val.ToDecimal(safe: true) != 0)
         {
             val = val.Replace(",", ".");
         }
         _output.Write(", '" + val + "'");
     }
     else
     {
         _output.Write(", null");
     }
 }
Ejemplo n.º 3
0
 private void OutParentField(DataDiffItem def)
 {
     if (def.Fields.ContainsKey("set_parent"))
     {
         var val  = def.Fields["set_parent"].Split('-').Last();
         var ival = val.ToInt();
         if (val == "")
         {                 //сброс ссылки
             _output.Write(", 0, null");
         }
         else if (ival != 0)
         {
             _output.Write(", {0}, null", ival);
         }
         else
         {
             _output.Write(", null, '{0}'", val.Replace("'", "''"));
         }
     }
     else if (def.Fields.ContainsKey("parent"))
     {
         var val  = def.Fields["parent"];
         var ival = val.ToInt();
         if (val == "")
         {                 //сброс ссылки
             _output.Write(", 0, null");
         }
         else if (ival != 0)
         {
             _output.Write(", {0}, null", ival);
         }
         else
         {
             _output.Write(", null, '{0}'", val.Replace("'", "''"));
         }
     }
     else
     {
         _output.Write(", null, null");
     }
 }
Ejemplo n.º 4
0
 private void OutMappedField(DataDiffItem def, string allfield)
 {
     if (def.Fields.ContainsKey(allfield))
     {
         var val  = def.Fields[allfield];
         var ival = val.ToInt();
         if (val == "")                  //сброс ссылки
         {
             _output.Write(", 0, null");
         }
         else if (ival != 0)
         {
             _output.Write(", {0}, null", ival);
         }
         else
         {
             _output.Write(", null, '{0}'", val.Replace("'", "''"));
         }
     }
     else
     {
         _output.Write(", null, null");
     }
 }