Ejemplo n.º 1
0
        /// <summary>
        /// Send CRUD notifications for a JarsJob 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(JarsJobsNotification crud)
        {
            //ExecuteFaultHandledMethod(() =>
            //{
            //check that the sender has subscribed to the service
            //SubscriptionInfo subscriber = ServerEvents.GetSubscriptionInfo(crud.From);
            List <SubscriptionInfo> subscriber = ServerEvents.GetSubscriptionInfosByUserId(crud.FromUserName);

            if (subscriber == null)
            {
                throw HttpError.NotFound($"Subscriber {crud.FromUserName} does not exist.");
            }

            //do some job updates here using the info from the the crud
            IJarsJobRepository _repository = _DataRepositoryFactory.GetDataRepository <IJarsJobRepository>();

            //first determine if the Dto objects are full or not, if they are then fill the counterpart objects
            if (crud.Selector == SelectorTypes.store)
            {
                crud.Jobs = _repository.CreateUpdateList(crud.Jobs.ConvertAllTo <JarsJob>().ToList(), crud.FromUserName).ConvertAllTo <JarsJobDto>().ToList();
                ServerEvents.NotifyChannel(typeof(JarsJob).Name, crud.Selector, crud.Jobs);
            }

            if (crud.Selector == SelectorTypes.delete)

            {
                _repository.DeleteList(crud.Jobs.ConvertAllTo <JarsJob>().ToList());
                ServerEvents.NotifyChannel(typeof(JarsJob).Name, crud.Selector, crud.Jobs.Select(j => j.Id));
            }
            //});
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Update or create a single job or a list of jobs, depending on whether the Job or Jobs property has got a value set.
        /// If the Job property is set the Job will be created or updated and the Jobs property will be ignored.
        /// To create or update more than one job, assign a list to the Jobs property and make sure Job is set to nothing/null.
        /// </summary>
        /// <param name="request">The request containing the job or jobs that needs to be created or updated</param>
        /// <returns>depending on the values supplied, the updated job or jobs will be returned.</returns>
        public virtual JarsJobsResponse Any(StoreJobs request)
        {
            //return ExecuteFaultHandledMethod(() =>
            //{
            JarsJobsResponse   response    = new JarsJobsResponse();
            IJarsJobRepository _repository = _DataRepositoryFactory.GetDataRepository <IJarsJobRepository>();

            response.Jobs = _repository.CreateUpdateList(request.Jobs.ConvertAllTo <JarsJob>().ToList(), CurrentSessionUsername).ConvertAllTo <JarsJobDto>().ToList();
            return(response);
            //});
        }