Ejemplo n.º 1
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public FlowRuntime(FlowInstance instance)
        {
            dynamic schemeContentJson = Newtonsoft.Json.JsonConvert.DeserializeObject(instance.SchemeContent);//获取工作流模板内容的json对象;

            InitLines(schemeContentJson);
            InitNodes(schemeContentJson);

            currentNodeId   = (string.IsNullOrEmpty(instance.ActivityId)  ? startNodeId : instance.ActivityId);
            currentNodeType = GetNodeType(currentNodeId);
            FormData        = instance.FormData;
            title           = schemeContentJson.title;
            initNum         = schemeContentJson.initNum;
            previousId      = instance.PreviousId;
            flowInstanceId  = instance.Id;

            //会签开始节点和流程结束节点没有下一步
            if (currentNodeType == 0 || currentNodeType == 4)
            {
                nextNodeId   = "-1";
                nextNodeType = -1;
            }
            else
            {
                nextNodeId   = GetNextNodeId();//下一个节点
                nextNodeType = GetNodeType(nextNodeId);
            }
        }
Ejemplo n.º 2
0
        public virtual async Task <FlowSheet> CreateSheet(FlowInstance instance, FlowForm flowForm)
        {
            var formData = instance.FormData;
            var formKey  = flowForm.FormKey;
            //生成单据
            var flowSheet = new FlowSheet()
            {
                FlowInstanceId = instance.Id,
                SheetName      = instance.InstanceName,
                FormKey        = formKey,
                SheetNature    = SheetNature.正单
            };
            var sheetId = await FlowSheetManager.InsertAndGetIdAsync(flowSheet);

            return(flowSheet);
        }
Ejemplo n.º 3
0
        public async Task CreateRevertSheet(FlowSheet flowSheet, string revertReason)
        {
            //产生新的流程实例
            var instance    = flowSheet.FlowInstance;
            var newInstance = new FlowInstance()
            {
                InstanceName   = instance.InstanceName,
                FormContent    = instance.FormContent,
                FormData       = instance.FormData,
                FlowFormId     = instance.FlowFormId,
                FormType       = instance.FormType,
                InstanceStatus = instance.InstanceStatus,
                IsActive       = true,
                Code           = Common.Fun.ConvertToTimeStamp(DateTime.Now).ToString()
            };
            var newInstanceId = await FlowInstanceManager.InsertAndGetIdAsync(newInstance);

            //生成新的单据
            var newFlowSheet = new FlowSheet()
            {
                UnitId         = flowSheet.UnitId,
                FlowInstanceId = newInstanceId,
                SheetSN        = FlowSheetManager.GenerateSheetSN(flowSheet.FormKey),
                SheetName      = newInstance.InstanceName,
                FormKey        = flowSheet.FormKey,
                SheetNature    = SheetNature.冲红,
                RelSheetId     = flowSheet.Id,
                RevertReason   = revertReason,
                Property       = flowSheet.Property
            };

            newFlowSheet.SheetDate = flowSheet.SheetDate;
            newFlowSheet.Remarks   = flowSheet.Remarks;
            var newSheetId = await FlowSheetManager.InsertAndGetIdAsync(newFlowSheet);

            //设置旧单据状态
            flowSheet.SheetNature  = SheetNature.被冲红;
            flowSheet.RelSheetId   = newSheetId;
            flowSheet.RevertReason = revertReason;

            await HandleRevert(newFlowSheet);
        }