Esempio n. 1
0
        void OnGroupSubscriptionReceived(IGroupEntity group)
        {
            //var groupLogger = BatchLoggerFactory.GetGroupLogger(group.Id);
            //IGroupStartContext context=new GroupStartContext(group, groupLogger);

            //foreach (var groupSubscriber in _groupSubscribers)
            //{
            //    Robustness.Instance.SafeCall(() => { groupSubscriber.OnGroupStarting(context); });
            //}
        }
Esempio n. 2
0
        private void SubmitProcesses(List <IProcessState> groupProcesses, IGroupEntity groupEntity)
        {
            //groupProcesses.ForEach(p =>
            //{
            //    p.GroupId = groupEntity.Id; // todo
            //    p.Criteria = groupEntity.Criteria;
            //});


            //todo
            using (var trans = _stateManager.BeginTransaction())
            {
                foreach (var process in groupProcesses)
                {
                    _stateManager.Insert(process);
                }

                trans.Commit();
            }


            var subscribers = _batchEngineSubscribers.GetProcessSubscribers().ToList();

            if (subscribers.Count > 0)
            {
                groupProcesses.ForEach(p =>
                {
                    var processSubscribers = subscribers.Where(s => s.ProcessKey == p.ProcessKey).ToList();
                    if (processSubscribers.Count > 0)
                    {
                        ProcessSubmittedContext pContext = new ProcessSubmittedContext(p.Id, p.ProcessKey, groupEntity.IsResubmission, groupEntity.SubmittedBy, LoggerFactory.GetProcessLogger(p.Id, p.ProcessKey));
                        foreach (var subscriber in subscribers)
                        {
                            Robustness.Instance.SafeCall(() => subscriber.OnProcessSubmitted(pContext));
                        }
                    }
                });
            }
        }
Esempio n. 3
0
        private void StartGroup(IGroupEntity group)
        {
            var groupLogger = LoggerFactory.GetGroupLogger(group.Id, group.GroupKey);

            groupLogger.Trace("Starting group");

            GroupStartContext context = new GroupStartContext(group, groupLogger);

            var groupSubscribers = _batchEngineSubscribers.GetGroupSubscribers().ToList();

            foreach (var groupSubscriber in groupSubscribers)
            {
                if (groupSubscriber.GroupKey != group.GroupKey)
                {
                    continue;
                }
                context.CurrentSubscriber = groupSubscriber;
                Robustness.Instance.SafeCall(() => { groupSubscriber.OnGroupStarting(context); }, groupLogger);
                context.CurrentSubscriber = null;
            }

            if (context.StopFlag)
            {
                groupLogger.Info("Group stopped by subscriber");
                StopGroup(group, "Group stopped by subscriber");
                return;
            }

            //todo get group processes and add to queue
            var groupProcesses = GetGroupProcesses(group.GroupKey);

            if (groupProcesses.Count == 0)
            {
                _logger.Error("No process found for group");
                StopGroup(group, "No process found for group");
                return;
            }

            _logger.Trace($"Submitting processes {groupProcesses.Count}");
            SubmitProcesses(groupProcesses, group);
            _logger.Trace($"Submission complete of {groupProcesses.Count} processes");

            foreach (var groupSubscriber in groupSubscribers)
            {
                if (groupSubscriber.GroupKey != group.GroupKey)
                {
                    continue;
                }
                context.CurrentSubscriber = groupSubscriber;
                Robustness.Instance.SafeCall(() => { groupSubscriber.OnGroupSubmitted(context); }, groupLogger);
                context.CurrentSubscriber = null;
            }

            if (context.StopFlag)
            {
                groupLogger.Info("Group stopped by subscriber");
                StopGroup(group, "Group stopped by subscriber");
                return;
            }

            var nextProcesses = GetNextProcesses(null);

            nextProcesses.ForEach(p =>
            {
                var volumeMessage = new ProcessExecutionContext(LoggerFactory.GetProcessLogger(p.Id, p.ProcessKey), p);
                Bus.Instance.HandleVolumeRequest(volumeMessage);
            });
        }
Esempio n. 4
0
 private void StopGroup(IGroupEntity group, string message)
 {
     //todo mark all pending tasks/processes as stopped
     group.MarkGroupStatus(TaskCompletionStatus.Stopped, ResultStatus.Empty, message);
     //publish group stop message
 }
 public void MarkGroupStopped(IGroupEntity group)
 {
     throw new NotImplementedException();
 }
 public void AddGroupProcess(List <IReadWritableProcessState> groupProcesses, IGroupEntity groupEntity)
 {
     throw new NotImplementedException();
 }
Esempio n. 7
0
        /// <summary>
        /// Gathers all of user's permissions on a given <c>IGroupEntity</c> and returns them as a collection.
        /// </summary>
        /// <param name="user"></param>
        /// <param name="entity"></param>
        /// <returns></returns>
        private static IEnumerable <PermissionTypes> GetUserPermissionsOnEntity(ChatUser user, IGroupEntity entity)
        {
            var userGroupsOnServer = entity.Groups.Where(x => x.Users.Contains(user));
            var userPermissions    = new List <PermissionTypes>();

            foreach (var group in userGroupsOnServer)
            {
                userPermissions.Add(group.GroupPermissions);
            }

            return(userPermissions);
        }
 public GroupService(IGroupEntity entity)
 {
     this.entity = entity;
 }
Esempio n. 9
0
 public void MarkGroupStopped(IGroupEntity @group)
 {
     Execute(() => _stateManagerImplementation.MarkGroupStopped(@group));
 }
Esempio n. 10
0
 public void AddGroupProcess(List <IReadWritableProcessState> groupProcesses, IGroupEntity groupEntity)
 {
     Execute(() => _stateManagerImplementation.AddGroupProcess(groupProcesses, groupEntity));
 }