コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: Command.cs プロジェクト: YHZX2013/exchange_diff
 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);
         }
     }
 }
コード例 #4
0
 public virtual void PurgeChanges(IPropertyChangeTracker tracker, long utcTimestamp = long.MaxValue)
 {
     tracker.PurgeChanges(this, utcTimestamp);
 }
コード例 #5
0
 public virtual IEnumerable <PropertyChange> PropertyChanges(IPropertyChangeTracker tracker)
 {
     return(tracker.Changes(this));
 }
コード例 #6
0
 public virtual IEnumerable <string> DbEntityChanges(IPropertyChangeTracker tracker, long utcTimestamp = long.MaxValue)
 {
     return(tracker.DbEntityChanges(true, this, utcTimestamp));
 }
コード例 #7
0
 public virtual string ChangesAsJson(IPropertyChangeTracker tracker, long utcTimestamp = long.MaxValue)
 {
     return(tracker.DbEntityAsJson(this, utcTimestamp));
 }