Пример #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));
            }
            //});
        }
Пример #2
0
        public void Create_Jobs_Base_and_QL()
        {
            //IJobRepository rep = _repFactory.GetDataRepository<IJobRepository>();
            IJarsJobRepository nhRep = _repFactory.GetDataRepository <IJarsJobRepository>();

            for (int i = 0; i < 100; i++)
            {
                JarsJob baseJob = new JarsJob
                {
                    StartDate   = DateTime.Now.Subtract(new TimeSpan(2, 0, 0)),
                    EndDate     = DateTime.Now,
                    Description = $"IJobBase Job {i}",
                    Location    = $" IJobBase from QL job {i}",
                    //AdditionalJobProperty = $"This {i}"
                };

                JarsJob jobQl = new JarsJob
                {
                    StartDate   = DateTime.Now.Subtract(new TimeSpan(2, 0, 0)),
                    EndDate     = DateTime.Now,
                    Description = $"QL Job {i}",
                    Location    = $"Test QL  {i}"
                };

                nhRep.CreateUpdate(baseJob, "DataCRUDTest");
                Assert.AreNotEqual(baseJob.Id, 0);

                nhRep.CreateUpdate(jobQl, "DataCRUDTest");
                Assert.AreNotEqual(jobQl.Id, 0);
            }
        }
Пример #3
0
        /// <summary>
        /// Returns a single job where the id in the request matches the record ID in the database.
        /// </summary>
        /// <param name="request">The request used for requesting the record from the database.</param>
        /// <returns>If FetchAsDto was set to false, the JarsJob item will be populated, if not then the JobDto record will have it's values set.</returns>
        public virtual JarsJobsResponse Any(GetJarsJob request)
        {
            //return ExecuteFaultHandledMethod(() =>
            //{
            JarsJobsResponse   response    = new JarsJobsResponse();
            IJarsJobRepository _repository = _DataRepositoryFactory.GetDataRepository <IJarsJobRepository>();

            response.Jobs.Add(_repository.GetById(request.Id, request.FetchEagerly).ConvertTo <JarsJobDto>());
            return(response);
            //});
        }
Пример #4
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);
            //});
        }
Пример #5
0
        public void List_Jobs()
        {
            IJarsJobRepository nhRep = _repFactory.GetDataRepository <IJarsJobRepository>();

            var jl = nhRep.GetAll();

            Assert.IsTrue(jl.Count > 0);

            var jobs = nhRep.GetAll();

            Assert.IsTrue(jobs.Count > 0);
        }
Пример #6
0
        public void Create_Resource_Jobs_Attachment_and_Lines()
        {
            IJarsJobRepository nhRep = _repFactory.GetDataRepository <IJarsJobRepository>();

            //create op
            for (int i = 0; i < 5; i++)
            {
                JarsResource res = new JarsResource
                {
                    DisplayName = $"Test{i}",
                    ExtRef1     = $"T00{i}",
                    IsActive    = true,
                    Skills      = new List <JarsResourceSkill> {
                        new JarsResourceSkill {
                            MaxLevel = 10, Description = "Test Skill", DocumentCode = $"SK0{i}T"
                        }
                    },
                    MobileNo = $"0{i}234{i}2312{i}"
                };

                //res = resrep.CreateUpdate(res, "TEST");

                JarsJobAttachment ja = new JarsJobAttachment {
                    Name = "Attach Test"
                };

                JarsJob baseJob = new JarsJob
                {
                    StartDate   = DateTime.Now.Subtract(new TimeSpan(2, 0, 0)),
                    EndDate     = DateTime.Now,
                    Description = $"IJob Job{i}",
                    Location    = $" IJob for Testing job {i}",
                    ExtRefId    = $"0{i}{i}{i}",
                    ResourceId  = res.Id
                };
                baseJob.Attachments.Add(ja);

                JarsJobLine line = new JarsJobLine {
                    Resource = res, LineCode = $"TEST0{i}", OriginalQty = 1, LineNum = 1, ExternalJobRef = baseJob.ExtRefId
                };

                baseJob.JobLines.Add(line);

                nhRep.CreateUpdate(baseJob, "TEST_LOOP");
            }
        }
Пример #7
0
        void use_repository_factory_to_get_non_generic_repositories_and_create_record()
        {
            IJarsJobRepository jarsRep = _repFactory.GetDataRepository <IJarsJobRepository>();


            Assert.IsNotNull(jarsRep);
            //Assert.IsNotNull(qlRep);

            //test create
            JarsJob jj = jarsRep.CreateUpdate(new JarsJob(), "NONGEN_FACT_TEST");

            Assert.IsTrue(jj.Id > 0);


            //test read
            jj = jarsRep.GetById((long)1);
            Assert.IsTrue(jj.Id == 0);
        }