public void OnEvent(object sender, CommitEventArgs args)
 {
     lock (_enclosing._updatesMonitor)
     {
         var trans   = ((IInternalObjectContainer)client).Transaction;
         var updated = args.Updated;
         var infos   = updated.GetEnumerator();
         while (infos.MoveNext())
         {
             var info = (IObjectInfo)infos.Current;
             var obj  = trans.ObjectForIdFromCache((int)info.GetInternalID());
             if (obj == null)
             {
                 continue;
             }
             // DEPTH may need to be 2 for member collections
             // to be updated also.
             client.Refresh(obj, 1);
         }
         if (_enclosing.IsNetworkingCS())
         {
             Runtime.NotifyAll(_enclosing._updatesMonitor);
         }
     }
 }
 public void OnEvent(object sender, CommitEventArgs args)
 {
     if (_firstTime)
     {
         _firstTime = false;
         throw new NotImplementedException();
     }
 }
示例#3
0
            public void OnEvent(object sender, CommitEventArgs args)
            {
                var commitEventArgs             = args;
                var deletedObjectInfoCollection = commitEventArgs.Deleted.GetEnumerator();

                while (deletedObjectInfoCollection.MoveNext())
                {
                    var objectInfo = (IObjectInfo)deletedObjectInfoCollection.Current;
                    Assert.IsNotNull(objectInfo.GetUUID());
                }
            }
示例#4
0
            public void OnEvent(object sender, Db4objects.Db4o.Events.CommitEventArgs args)
            {
                CommitEventArgs commitEventArgs             = (CommitEventArgs)args;
                IEnumerator     deletedObjectInfoCollection = commitEventArgs.Deleted.GetEnumerator();

                while (deletedObjectInfoCollection.MoveNext())
                {
                    IObjectInfo objectInfo = (IObjectInfo)deletedObjectInfoCollection.Current;
                    Assert.IsNotNull(objectInfo.GetUUID());
                }
            }
 public void OnEvent(object sender, CommitEventArgs args)
 {
     if (!shallListen.value)
     {
         return;
     }
     Assert.IsFalse(gotEvent.value);
     gotEvent.value = true;
     ownEvent.value = args.IsOwnCommit();
     lockObject.Run(new _IClosure4_161(lockObject));
 }
示例#6
0
            public void OnEvent(object sender, Db4objects.Db4o.Events.CommitEventArgs args)
            {
                if (!this.IsClassMetadataAvailable())
                {
                    return;
                }
                CommitEventArgs commitEventArgs = (CommitEventArgs)args;
                Transaction     trans           = (Transaction)commitEventArgs.Transaction();

                this.EnsureSingleOccurence(trans, commitEventArgs.Added);
                this.EnsureSingleOccurence(trans, commitEventArgs.Updated);
            }
示例#7
0
            public void OnEvent(object sender, CommitEventArgs args)
            {
                if (!IsClassMetadataAvailable())
                {
                    return;
                }
                var commitEventArgs = args;
                var trans           = (Transaction)commitEventArgs.Transaction();

                EnsureSingleOccurence(trans, commitEventArgs.Added);
                EnsureSingleOccurence(trans, commitEventArgs.Updated);
            }
            public void OnEvent(object sender, CommitEventArgs args)
            {
                if (oc.IsClosed())
                {
                    return;
                }
                var updated = args.Updated;
                var infos   = updated.GetEnumerator();

                while (infos.MoveNext())
                {
                    var info = (IObjectInfo)infos.Current;
                    var obj  = info.GetObject();
                    oc.Refresh(obj, 2);
                }
            }
示例#9
0
            public void OnEvent(object sender, CommitEventArgs args)
            {
                var trans = (LocalTransaction)args.Transaction();
                var transactionTimestamp = trans.Timestamp();
                var commitTimestamp      = (transactionTimestamp > 0)
                    ? transactionTimestamp
                    : _enclosing
                                           ._container.GenerateTimeStampId();
                var sysTrans = trans.SystemTransaction();

                AddTimestamp(sysTrans, args.Added.GetEnumerator(), commitTimestamp
                             );
                AddTimestamp(sysTrans, args.Updated.GetEnumerator(), commitTimestamp
                             );
                AddTimestamp(sysTrans, args.Deleted.GetEnumerator(), 0);
            }
示例#10
0
 // #example: implement your event handling
 private static void HandleCommitting(object sender,
                                      CommitEventArgs commitEventArgs)
 {
     // handle the event
 }
示例#11
0
 public void OnEvent(object sender, CommitEventArgs args)
 {
     _enclosing._committed.Increment();
 }
示例#12
0
文件: Graph.cs 项目: git-thinh/limada
        public virtual void ClientCommit(object sender, CommitEventArgs e)
        {
            if (e.IsOwnCommit())
            {
                return;
            }

            var clientContainer = e.ObjectContainer();
            var items           = new List <Tuple <TItem, GraphEventType> > ();
            var edges           = new List <Tuple <TEdge, GraphEventType> > ();

            Action <IObjectInfoCollection, GraphEventType> selectCommit = (col, eventType) => {
                foreach (var objectInfo in col.OfType <IObjectInfo> ())
                {
                    var obj = objectInfo.GetObject();

                    if (eventType == GraphEventType.Remove)
                    {
                        obj = Session.Ext().GetByID(objectInfo.GetInternalID());
                    }
                    else if (eventType == GraphEventType.Update || eventType == GraphEventType.Add)
                    {
                        clientContainer.Ext().Refresh(obj, 1);
                    }

                    if (obj is TEdge)
                    {
                        edges.Add(Tuple.Create((TEdge)obj, eventType));
                    }
                    else if (obj is TItem)
                    {
                        items.Add(Tuple.Create((TItem)obj, eventType));
                    }
                }
            };

            selectCommit(e.Deleted, GraphEventType.Remove);
            selectCommit(e.Updated, GraphEventType.Update);
            selectCommit(e.Added, GraphEventType.Add);

            if (items.Count == 0 && edges.Count == 0)
            {
                return;
            }

            // commit makes a roundup back to sender, dont do it
            //if (!Gateway.Iori.AccessMode.HasFlag (IoMode.Server))
            //    clientContainer.Commit ();

            Action <Tuple <TEdge, GraphEventType> > forEdge = tuple => {
                var edge      = tuple.Item1;
                var eventType = tuple.Item2;
                var item      = (TItem)(object)edge;
                if (eventType == GraphEventType.Update || eventType == GraphEventType.Add)
                {
                    // this is done by commit:
                    // Add (edge);
                }
                try {
                    this.OnGraphChange(item, eventType);
                } catch (Exception ex) {
                    Trace.TraceError(ex.Message);
                }
                if (eventType == GraphEventType.Remove || eventType == GraphEventType.Add)
                {
                    // this is done by commit:
                    //Remove (edge);
                    RemoveCached(edge);
                }
            };

            Action <Tuple <TItem, GraphEventType> > forItem = tuple => {
                var item      = tuple.Item1;
                var eventType = tuple.Item2;
                if (eventType == GraphEventType.Update || eventType == GraphEventType.Add)
                {
                    // Session.Ext ().Refresh (item, 1);
                    // this is done by commit:
                    //Add (item);
                }
                try {
                    this.OnGraphChange(item, eventType);
                } catch (Exception ex) {
                    Trace.TraceError(ex.Message);
                }

                if (eventType == GraphEventType.Remove)
                {
                    // this is done by commit:
                    // Remove (item);
                    SetCached(item, null);
                }
            };

            var tokenSource = new CancellationTokenSource();
            var token       = tokenSource.Token;

            Action afterCommit = () => {
                token.WaitHandle.WaitOne(500);
                token.ThrowIfCancellationRequested();

                items.Where(t => t.Item2 == GraphEventType.Update || t.Item2 == GraphEventType.Add)
                .ForEach(forItem);
                edges.Where(t => t.Item2 == GraphEventType.Update || t.Item2 == GraphEventType.Add)
                .ForEach(forEdge);

                var removeEdges = edges.Where(t => t.Item2 == GraphEventType.Remove);
                var removeItems = items.Where(t => t.Item2 == GraphEventType.Remove);

                removeEdges.ForEach(forEdge);
                removeItems.ForEach(forItem);


                // commit makes a roundtrip back to sender, so use it only on server
                // annoyance: it triggers back the changes to the client
                // bug: if changes are made on the server/client, client changes are lost
                // so currently only changing in client-only-mode is supported!!!
                if (Gateway.Iori.AccessMode.HasFlag(IoMode.Server))
                {
                    Flush();
                }
            };

            var thread = Task.Factory.StartNew(afterCommit);
            //tokenSource.Cancel ();
        }
示例#13
0
 void _SQLiteConn_Commit(object sender, CommitEventArgs e)
 {
     this._IsRunTrans = false;
 }
示例#14
0
 static void eventRegistry_Committing(object sender, CommitEventArgs args)
 {
     ValidateIteration(args.Added);
     ValidateIteration(args.Deleted);
     ValidateIteration(args.Updated);
 }
示例#15
0
 static void cnn_Commit(object sender, CommitEventArgs e)
 {
 }
示例#16
0
 static void EntriesCommittedEvent(object sender, CommitEventArgs args)
 {
     Console.WriteLine("");
     Console.WriteLine("Entries committed event:" + Environment.NewLine + SerializeJson(args, true));
     Console.WriteLine("");
 }