Exemplo n.º 1
0
        /// <summary>
        /// Send CRUD notifications for a ApptLabel Entity or Entities
        /// Note! :
        /// This Method is a special method used by the service when ServerEvents are being used.(serviceStack).
        /// If the service does not implement serverEvents this will throw an error.
        /// This will send a notification to all subscribed clients (including the client the request originated from) where the chanel name is the name of the entity type.
        /// This will only process SelectorTypes.store and SelectorTypes.delete notifications.
        /// The notification sent to subscribers will be a ServerEventMessage (serviceStack) where the data(json) is set as ServerEventMessageData (Jars) object.
        /// </summary>
        /// <param name="crud">The notification request indicating a store or delete event that will be sent to other subscribers.</param>
        public virtual void Any(ApptLabelsNotification crud)
        {
            //ExecuteFaultHandledMethod(() =>
            //{
            //check that the sender has subscribed to the service
            var subscriber = ServerEvents.GetSubscriptionsDetails(typeof(ApptLabel).Name);

            if (subscriber == null)
            {
                return;
            }

            var _repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <ApptLabel, IDataContextNhJars> >();

            if (crud.Selector == SelectorTypes.store)
            {
                List <ApptLabelDto> notifyList = _repository.Where(l => crud.Ids.Contains(l.Id)).ConvertAllTo <ApptLabelDto>().ToList();
                TrySendStoreNotificationToChannel(typeof(ApptLabel).Name, notifyList.ToJson());
            }

            if (crud.Selector == SelectorTypes.delete)
            {
                TrySendDeleteNotificationToChannel(typeof(ApptLabel).Name, crud.Ids.ConvertTo <List <string> >().ToArray());//, true);
            }
            //});
        }