public virtual async Task <IEnumerable <string> > PushAsync(IPropertyChangeTracker tracker, IDataAccessLayer dal, int action, int commentId) { InvokeBeforePushActions(); long utcTimestamp = DateTime.UtcNow.Ticks; IsPushing = true; RaisePushing(); IEnumerable <string> changes = DbEntityChanges(tracker, utcTimestamp); try { int editDuration = (int)Math.Round(EditDuration); IDictionary <string, Tuple <string, object>[]> newEntitiesPrimaryKeys = await dal.UpdateEntity(GetType(), ChangesAsJson(tracker, utcTimestamp), changes, action, editDuration, commentId); tracker.Untracked((e) => { DbEntityUtilities.UpdatePrimaryKeys(newEntitiesPrimaryKeys, this); }); // TODO: Only clear the changes if the push has been successful PurgeChanges(tracker, utcTimestamp); RaisePushed(changes); } catch (Exception) { changes = Enumerable.Empty <string>(); } finally { IsPushing = false; } return(changes); }
public static string GetLoggingDetails(IPropertyChangeTracker <PropertyDefinition> entity) { DataContractSerializer dataContractSerializer = new DataContractSerializer(entity.GetType(), EntityLogger.LoggingSerializerSettings); string result; using (StringWriter stringWriter = new StringWriter()) { using (EntityXmlTextWriter entityXmlTextWriter = new EntityXmlTextWriter(stringWriter)) { dataContractSerializer.WriteObject(entityXmlTextWriter, entity); result = stringWriter.ToString(); } } return(result); }
protected virtual void SetCustomLoggingData(string key, object obj) { if (obj != null) { IPropertyChangeTracker <PropertyDefinition> propertyChangeTracker = obj as IPropertyChangeTracker <PropertyDefinition>; try { string value = (propertyChangeTracker == null) ? obj.ToString() : EntityLogger.GetLoggingDetails(propertyChangeTracker); this.SetCustomLoggingData(key, value); } catch (Exception exception) { ExWatson.SendReport(exception, ReportOptions.DoNotCollectDumps | ReportOptions.DoNotLogProcessAndThreadIds | ReportOptions.DoNotFreezeThreads, string.Empty); } } }
public virtual void PurgeChanges(IPropertyChangeTracker tracker, long utcTimestamp = long.MaxValue) { tracker.PurgeChanges(this, utcTimestamp); }
public virtual IEnumerable <PropertyChange> PropertyChanges(IPropertyChangeTracker tracker) { return(tracker.Changes(this)); }
public virtual IEnumerable <string> DbEntityChanges(IPropertyChangeTracker tracker, long utcTimestamp = long.MaxValue) { return(tracker.DbEntityChanges(true, this, utcTimestamp)); }
public virtual string ChangesAsJson(IPropertyChangeTracker tracker, long utcTimestamp = long.MaxValue) { return(tracker.DbEntityAsJson(this, utcTimestamp)); }