예제 #1
0
        /// <summary>
        /// 根据活动Code获取对应产品状态
        /// </summary>
        /// <param name="processGUID"></param>
        /// <param name="verison"></param>
        /// <param name="activityGUID"></param>
        /// <returns></returns>
        private short GetProductOrderStatusByActivityCode(string processGUID, string verison, string activityGUID)
        {
            var wfas         = new WfAppInteropService();
            var activityNode = wfas.GetActivity(processGUID, WfAppRunner.Version, activityGUID);

            if (activityNode.ActivityType == ActivityTypeEnum.EndNode)
            {
                return((short)ProductOrderStatusEnum.Completed);
            }
            else
            {
                return((short)EnumHelper.ParseEnum <ProductOrderStatusEnum>(activityNode.ActivityCode));
            }
        }
예제 #2
0
        /// <summary>
        /// 快递发货
        /// </summary>
        /// <param name="entity"></param>
        public WfAppResult Delivery(ProductOrderEntity entity)
        {
            var appResult = WfAppResult.Default();
            var wfas      = new WfAppInteropService();

            using (var session = DbFactory.CreateSession())
            {
                var transaction = session.DbContext.Database.BeginTransaction();
                try
                {
                    //流程运行
                    var actionParameterInternal = new ActionParameterInternal();
                    actionParameterInternal.MethodParameters = new object[] { "alexsenda" };

                    WfAppRunner.ActionMethodParameters = new Dictionary <string, ActionParameterInternal>();
                    WfAppRunner.ActionMethodParameters.Add("CallHello", actionParameterInternal);

                    var result = wfas.RunProcess(session, WfAppRunner, WfAppRunner.Conditions);
                    if (result.Status == WfExecutedStatus.Success)
                    {
                        //写步骤记录表
                        Write(session, WfAppRunner, "发货", entity.ID.ToString(), entity.OrderCode, "完成发货");

                        //业务数据处理部分,此处是简单示例...
                        short status = GetProductOrderStatusByActivityCode(WfAppRunner.ProcessGUID, WfAppRunner.Version,
                                                                           WfAppRunner.NextActivityPerformers.Keys.ElementAt <string>(0));
                        UpdateStatus(entity.ID, status, session);

                        transaction.Commit();
                        appResult = WfAppResult.Success();
                    }
                    else
                    {
                        transaction.Rollback();
                        appResult = WfAppResult.Error(result.Message);
                    }
                }
                catch (System.Exception ex)
                {
                    transaction.Rollback();
                    appResult = WfAppResult.Error(ex.Message);
                }
                finally
                {
                    session.Dispose();
                }
                return(appResult);
            }
        }
예제 #3
0
        /// <summary>
        /// 称重
        /// </summary>
        /// <param name="entity"></param>
        public WfAppResult Weight(ProductOrderEntity entity)
        {
            var appResult = WfAppResult.Default();
            var wfas      = new WfAppInteropService();

            using (var session = DbFactory.CreateSession())
            {
                try
                {
                    //流程运行
                    session.BeginTrans();
                    var result = wfas.RunProcess(session, WfAppRunner, WfAppRunner.Conditions);
                    if (result.Status == WfExecutedStatus.Success)
                    {
                        //写步骤记录表
                        Write(session, WfAppRunner, "称重", entity.ID.ToString(), entity.OrderCode, "完成称重");

                        //业务数据处理部分,此处是简单示例...
                        short status = GetProductOrderStatusByActivityCode(WfAppRunner.ProcessGUID, WfAppRunner.Version,
                                                                           WfAppRunner.NextActivityPerformers.Keys.ElementAt <string>(0));
                        UpdateStatus(entity.ID, status, session);

                        session.Commit();
                        appResult = WfAppResult.Success();
                    }
                    else
                    {
                        session.Rollback();
                        appResult = WfAppResult.Error(result.Message);
                    }
                }
                catch (System.Exception ex)
                {
                    session.Rollback();
                    appResult = WfAppResult.Error(ex.Message);
                }
                finally
                {
                    session.Dispose();
                }
                return(appResult);
            }
        }
예제 #4
0
        /// <summary>
        /// 派单
        /// </summary>
        /// <param name="entity"></param>
        public WfAppResult Dispatch(ProductOrderEntity entity)
        {
            //启动流程
            var appResult = WfAppResult.Default();
            var wfas      = new WfAppInteropService();

            try
            {
                //判断流程有没有已经启动
                var isRunning = wfas.CheckProcessInstanceRunning(WfAppRunner);
                if (isRunning == false)
                {
                    var startedResult = wfas.StartProcess(WfAppRunner);
                    if (startedResult.Status != WfExecutedStatus.Success)
                    {
                        appResult = WfAppResult.Error(startedResult.Message);
                        return(appResult);
                    }
                }
            }
            catch (System.Exception ex)
            {
                appResult = WfAppResult.Error(ex.Message);
                return(appResult);
            }

            //运行流程部分
            //继续下一步运行
            using (var session = DbFactory.CreateSession())
            {
                try
                {
                    //运行流程
                    session.BeginTrans();
                    var runResult = wfas.RunProcess(session, WfAppRunner, WfAppRunner.Conditions);
                    if (runResult.Status == WfExecutedStatus.Success)
                    {
                        //写步骤记录表
                        Write(session, WfAppRunner, "派单", entity.ID.ToString(), entity.OrderCode, "完成派单");

                        //业务数据处理部分,此处是简单示例...
                        short status = GetProductOrderStatusByActivityCode(WfAppRunner.ProcessGUID, WfAppRunner.Version,
                                                                           WfAppRunner.NextActivityPerformers.Keys.ElementAt <string>(0));
                        UpdateStatus(entity.ID, status, session);

                        session.Commit();
                        appResult = WfAppResult.Success();
                    }
                    else
                    {
                        session.Rollback();
                        appResult = WfAppResult.Error(runResult.Message);
                    }
                }
                catch (System.Exception ex)
                {
                    session.Rollback();
                    appResult = WfAppResult.Error(ex.Message);
                }
                finally
                {
                    session.Dispose();
                }
                return(appResult);
            }
        }