/// <summary> /// /// </summary> /// <param name="o"></param> /// <returns></returns> public static OggEntry Parse(OggEntryOriginal o) { var ogg = new OggEntry() { Table = o.table, Type = o.type, TS = DateTime.Parse(o.ts, CultureInfo.CurrentCulture, DateTimeStyles.AssumeUniversal), Op = (DbOperation)Enum.Parse(typeof(DbOperation), o.Properties[OggEntryProperty.GG_OPTYPE]), HermesId = o.Hermes_ID }; //如果update 并且before和after都是一样,不更新,返回null if (ogg.Op == DbOperation.UPDATE) { if (o.cols.Where(c => c.name != "VERSION" && c.name != "LASTMODIFYTIME").All(c => c.before == c.after)) { return(null); } } ogg.After = new Dictionary <string, object>(); ogg.Before = new Dictionary <string, object>(); foreach (var c in o.cols) { if (!string.IsNullOrEmpty(c.before)) { ogg.Before.Add(c.name, c.before); } if (!string.IsNullOrEmpty(c.after)) { ogg.After.Add(c.name, c.after); } } return(ogg); }
/// <summary> /// /// </summary> /// <param name="o"></param> /// <returns></returns> public static OggEntryWithProperty ParseWithProperty(OggEntryOriginal o) { var ogg = ConvertTo <OggEntry, OggEntryWithProperty>(Parse(o)); o.Properties = o.Properties ?? new Dictionary <string, string>(); ogg.PropertyJson = JsonConvert.SerializeObject(o.Properties); return(ogg); }