Ejemplo n.º 1
0
        /// <summary>
        /// 消息发布方法
        /// </summary>
        /// <param name="processInstance">流程实例</param>
        /// <param name="throwActivity">消息活动</param>
        /// <param name="throwActivityInstance">消息活动实例</param>
        public void PublishMessage(ProcessInstanceEntity processInstance,
                                   ActivityEntity throwActivity,
                                   ActivityInstanceEntity throwActivityInstance)
        {
            var           topic         = throwActivity.ActivityTypeDetail.Expression;
            ProcessEntity catchProcess  = null;
            var           catchActivity = XPDLHelper.GetMessageCatchActivity(processInstance, throwActivity, throwActivityInstance, out catchProcess);

            var appRunner = new WfAppRunner();

            appRunner.MessageTopic    = topic;
            appRunner.AppName         = throwActivityInstance.AppName;
            appRunner.AppInstanceID   = throwActivityInstance.AppInstanceID;
            appRunner.AppInstanceCode = throwActivityInstance.AppInstanceCode;
            appRunner.UserID          = throwActivityInstance.CreatedByUserID;
            appRunner.UserName        = throwActivityInstance.CreatedByUserName;

            var msgRunnerView = new MessageRunnerView();

            msgRunnerView.ProcessEntity  = catchProcess;
            msgRunnerView.ActivityEntity = catchActivity;
            msgRunnerView.WfAppRunner    = appRunner;

            var jsonRunner = JsonConvert.SerializeObject(msgRunnerView);

            var messageService = MessageQueueServiceFactory.Create();

            messageService.Publish(topic, jsonRunner);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 从消息视图中封装运行者对象
        /// </summary>
        /// <param name="msgRunnerView">消息视图</param>
        /// <returns>运行者对象</returns>
        private WfAppRunner GetRunnerFromMessagExchange(MessageRunnerView msgRunnerView)
        {
            var runner = new WfAppRunner();

            runner.ProcessGUID     = msgRunnerView.ProcessEntity.ProcessGUID;
            runner.Version         = msgRunnerView.ProcessEntity.Version;
            runner.ProcessCode     = msgRunnerView.ProcessEntity.ProcessCode;
            runner.AppName         = msgRunnerView.WfAppRunner.AppName;
            runner.AppInstanceID   = msgRunnerView.WfAppRunner.AppInstanceID;
            runner.AppInstanceCode = msgRunnerView.WfAppRunner.AppInstanceCode;
            runner.UserID          = msgRunnerView.WfAppRunner.UserID;
            runner.UserName        = msgRunnerView.WfAppRunner.UserName;

            var query = new TaskQuery {
                ProcessGUID = runner.ProcessGUID, AppInstanceID = runner.AppInstanceID
            };
            var wfService            = new WorkflowService();
            var activityInstanceList = wfService.GetRunningActivityInstance(query);

            if (activityInstanceList.Count == 1)
            {
                var activityInstance = activityInstanceList[0];
                runner.NextActivityPerformers = NextStepUtility.DeserializeNextStepPerformers(activityInstance.NextStepPerformers);
            }
            return(runner);
        }