示例#1
0
文件: Mailbox.cs 项目: itadapter/nfx
 protected virtual void OnReceipt(Subscription subscription, CRUDSubscriptionEvent data, Exception error)
 {
     if (Receipt!=null)
       Receipt(subscription, this, data, error);
 }
示例#2
0
文件: Mailbox.cs 项目: itadapter/nfx
        public bool DeliverError(Subscription subscription, Exception error)
        {
            if (subscription.Store!=this.Store) return false;

            OnReceipt(subscription, default(CRUDSubscriptionEvent), error);

            return true;
        }
示例#3
0
文件: Mailbox.cs 项目: keck/nfx
 protected virtual void OnReceipt(Subscription subscription, RowChange data, Exception error)
 {
   if (Receipt!=null)
     Receipt(subscription, this, data, error);
 }
示例#4
0
文件: Mailbox.cs 项目: itadapter/nfx
        /// <summary>
        /// Delivers data to the mailbox. This method is called by subscription
        /// </summary>
        public bool Deliver(Subscription subscription, CRUDSubscriptionEvent data)
        {
            if (subscription.Store!=this.Store) return false;

            var cap = m_BufferCapacity;
            if (cap>0)
              lock(m_Buffer)
              {
            m_Buffer.AddLast(data);
            if (m_Buffer.Count>cap)
              m_Buffer.RemoveFirst();
              }

            OnReceipt(subscription, data, null);

            return true;
        }
示例#5
0
    private void m_Mailbox_Receipt(Subscription subscription, Mailbox recipient, CRUDSubscriptionEvent data, Exception error)
    {
      if (error!=null)
      {
        OnError(error);
        return;
      }
      
      var schema = data.Schema;
      var table = m_Tables.GetOrRegister(schema.Name, (s) => new table(new Table(s), subscription.Query), schema).Table;
      lock(table)
      {
        var proceed = OnReceipt(SynchronizedReceiptHandlerEventArgs.EventPhase.Before, table, data.Type, data.Row);

        if (!proceed) return;

        switch(data.Type)
        {
          case CRUDSubscriptionEvent.EventType.TableCreate: break;
          case CRUDSubscriptionEvent.EventType.TableClear: table.DeleteAll(); break;
          case CRUDSubscriptionEvent.EventType.TableDrop: m_Tables.Unregister(schema.Name); break;
          
          case CRUDSubscriptionEvent.EventType.RowInsert: table.Insert(data.Row); break;
          case CRUDSubscriptionEvent.EventType.RowUpdate: table.Update(data.Row); break;
          case CRUDSubscriptionEvent.EventType.RowUpsert: table.Upsert(data.Row); break;
          case CRUDSubscriptionEvent.EventType.RowDelete: table.Delete(data.Row); break;
        }

        OnReceipt(SynchronizedReceiptHandlerEventArgs.EventPhase.After, table, data.Type, data.Row);
      }
    }