public JsonResult GetByGuid(Guid guid)
        {
            var alertJobEntity = _context.AlertJobsQueueEntity
                                 .Where(x => x.WorkItemID == guid)
                                 .FirstOrDefault();

            if (alertJobEntity == null)
            {
                { return(Json("Undefined Alert Job Entity")); }
            }

            var alertName = _context.AlertNames
                            .Where(x => x.AlertNameID == alertJobEntity.AlertNameID)
                            .FirstOrDefault();

            if (alertName == null)
            {
                { return(Json("Undefined Alert Name for this Entity")); }
            }

            var alertJob = _context.AlertJobs
                           .Where(x => x.AlertJobsID == alertName.AlertJobsID)
                           .FirstOrDefault();

            if (alertJob == null)
            {
                { return(Json("Undefined Alert Job for this Entity")); }
            }

            var locks = _context.RecordLocks
                        .Where(x => x.IDFromWorkUnitsDBTable == alertJobEntity.AlertJobsQueueEntityID)
                        .FirstOrDefault();

            AppUser lockedTo = new AppUser();

            if (locks != null)
            {
                lockedTo = _context.AppUser
                           .Where(x => x.AppUserID == locks.AppUserID)
                           .FirstOrDefault();
            }
            else
            {
                lockedTo = null;
            }

            AlertJobsQueueEntityData alertJobEntityData = new AlertJobsQueueEntityData {
                AlertJobsQueueEntity = alertJobEntity,
                AlertNames           = alertName,
                AlertJobs            = alertJob,
                LockedTo             = lockedTo
            };

            var returnData = Json(alertJobEntityData);

            return(returnData);
        }
Exemplo n.º 2
0
        public AlertJobsQueueEntityData GetByGuid_v1(Guid guid)
        {
            var alertJobEntity = _context.AlertJobsQueueEntity
                                 .Where(x => x.WorkItemID == guid)
                                 .FirstOrDefault();

            if (alertJobEntity == null)
            {
                return(null);
            }

            var alertName = _context.AlertNames
                            .Where(x => x.AlertNameID == alertJobEntity.AlertNameID)
                            .FirstOrDefault();

            if (alertName == null)
            {
                return(null);
            }

            var alertJob = _context.AlertJobs
                           .Where(x => x.AlertJobsID == alertName.AlertJobsID)
                           .FirstOrDefault();

            if (alertJob == null)
            {
                return(null);
            }

            var locks = _context.AlertNamesDisposition
                        .Where(x => x.AlertNamesDispositionID == alertName.AlertNameID)
                        .FirstOrDefault();

            AppUser lockedTo = new AppUser();

            if (locks != null)
            {
                lockedTo = _context.AppUser
                           .Where(x => x.AppUserID == locks.AppUserID)
                           .FirstOrDefault();
            }
            else
            {
                lockedTo = null;
            }

            AlertJobsQueueEntityData alertJobEntityData = new AlertJobsQueueEntityData
            {
                AlertJobsQueueEntity = alertJobEntity,
                AlertNames           = alertName,
                AlertJobs            = alertJob,
                LockedTo             = lockedTo
            };

            return(alertJobEntityData);
        }
Exemplo n.º 3
0
        public void AlertJobsQueueEntity()
        {
            IEnumerable <AlertJobFilterData> AlertJobFilterDataItems = Enumerable.Empty <AlertJobFilterData>();
            object t = new object();
            AlertJobsQueueEntityData data       = new AlertJobsQueueEntityData();
            AlertJobsQueueEntity     dataEntity = new AlertJobsQueueEntity();
            AlertJobFilter           filter     = new AlertJobFilter();
            Mock <IAlertJobsQueueEntityRepository> AlertJobsQueueEntityService = new Mock <IAlertJobsQueueEntityRepository>();
            Guid                         guid        = new Guid();
            IConfiguration               config      = null;
            WorkItemPostData             wrkitemdata = new WorkItemPostData();
            AlertJobsQueueEntityDataSave datasave    = new AlertJobsQueueEntityDataSave();

            object obj = new object();

            try
            {
                AlertJobsQueueEntityService.Setup(x => x.GetAlertBatchItems()).Returns(t);
                AlertJobsQueueEntityService.Setup(x => x.GetFilteredAlertEntities(It.IsAny <AlertJobFilter>())).Returns(AlertJobFilterDataItems);
                AlertJobsQueueEntityService.Setup(x => x.CheckWorkItemIDForEntity(It.IsAny <WorkItemPostData>(), It.IsAny <IConfiguration>()))
                .Returns(t);
                AlertJobsQueueEntityService.Setup(x => x.GetByGuid(It.IsAny <Guid>())).Returns(data);
                AlertJobsQueueEntityService.Setup(x => x.UpdateEntry(It.IsAny <AlertJobsQueueEntityDataSave>(), It.IsAny <IConfiguration>()))
                .Returns(dataEntity);

                var AlertJobsQueueEntityObject = AlertJobsQueueEntityService.Object;
                var p1 = AlertJobsQueueEntityObject.GetAlertBatchItems();
                var p2 = AlertJobsQueueEntityObject.GetFilteredAlertEntities(filter);
                var p3 = AlertJobsQueueEntityObject.GetByGuid(guid);

                var p4 = AlertJobsQueueEntityObject.CheckWorkItemIDForEntity(wrkitemdata, config);
                var p5 = AlertJobsQueueEntityObject.UpdateEntry(datasave, config);


                Assert.IsAssignableFrom <object>(p1);
                Assert.IsAssignableFrom <IEnumerable <AlertJobFilterData> >(p2);
                Assert.IsAssignableFrom <AlertJobsQueueEntityData>(p3);
                Assert.IsAssignableFrom <object>(p4);
                Assert.IsAssignableFrom <AlertJobsQueueEntity>(p5);

                AlertJobsQueueEntityService.VerifyAll();

                AlertJobsQueueEntityObject.Dispose();
            }
            finally
            {
                AlertJobsQueueEntityService = null;
            }
        }