Exemplo n.º 1
0
        public ActionResult Leave(LeaveViewModel model)
        {
            string result = "no";
            //Guid instanceGuid = WorkFlowHelper.Run(new Leave(), new Dictionary<string, object>()
            //{
            //    {"R2",model.Reason},
            //    {"D2",model.Days}
            //});
            string     title    = model.LeaveTitle == "1" ? "事假" : model.LeaveTitle == "2" ? "病假" : "休假";
            WFInstance instance = new WFInstance()
            {
                InstanceTitle = "请假--" + title,
                Details       = string.Format("事由:{0},天数:{1}天。", model.Reason, model.Days),
                InstanceGuid  = "",
                InstanceState = (short)InstanceState.Approving,
                Remark        = string.IsNullOrWhiteSpace(model.Remark) ? string.Format("{0}至{1}", DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.AddDays(model.Days).ToString("yyyy-MM-dd")) : model.Remark,
                SubBy         = UserLogin.UserId,
                SubTime       = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
            };

            instance.WFStep.Add(new WFStep()
            {
                NextId  = model.NextId,
                SubBy   = UserLogin.UserId,
                SubTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
            });
            if (WFInstanceBll.Add(instance))
            {
                result = "ok";
            }
            return(Content(result));
        }
Exemplo n.º 2
0
        public ActionResult Expense(ExpenseViewModel model)
        {
            string result = "no";
            //Guid instanceGuid = WorkFlowHelper.Run(new Expense(), new Dictionary<string, object>()
            //{
            //    {"R2",model.Reason},
            //    {"M2",model.Money}
            //});
            WFInstance instance = new WFInstance()
            {
                InstanceTitle = "报销--" + model.ExpenseTitle,
                Details       = string.Format("事由:{0},金额:{1}元。", model.Reason, model.Money),
                InstanceGuid  = "",
                InstanceState = (short)InstanceState.Approving,
                Remark        = model.Remark,
                SubBy         = UserLogin.UserId,
                SubTime       = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
            };

            instance.WFStep.Add(new WFStep()
            {
                NextId  = model.NextId,
                SubBy   = UserLogin.UserId,
                SubTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
            });
            if (WFInstanceBll.Add(instance))
            {
                result = "ok";
            }
            return(Content(result));
        }
Exemplo n.º 3
0
        // If your activity returns a value, derive from CodeActivity<TResult>
        // and return the value from the Execute method.
        protected override void Execute(CodeActivityContext context)
        {
            // Obtain the runtime value of the Text input argument
            short  stepStatus    = context.GetValue(this.StepStatus);
            string stepName      = context.GetValue(this.StepName);
            short  isEnd         = context.GetValue(this.IsEnd);
            int    nextProcessBy = context.GetValue(this.NextProcessBy);
            int    inputValue    = context.GetValue(this.InPutValue);
            int    tempId        = context.GetValue(this.TempId);
            int    startBy       = context.GetValue(this.StartBy);
            int    stepId        = context.GetValue(this.StepId);

            Guid insId = context.WorkflowInstanceId;

            //string insIdStr = insId.ToString();
            IWFInstanceBll commonWFInstanceBll = new WFInstanceBll();
            IWFStepBll     commonWFStepBll     = new WFStepBll();

            CommonWFInstance inst = commonWFInstanceBll.GetEntities(F => F.WFInstanceId == insId).FirstOrDefault();

            if (inst == null)
            {
                inst = new CommonWFInstance();
                inst.WFInstanceId = insId;
                inst.MaxValue     = inputValue;
                inst.SubTime      = DateTime.Now;
                inst.status       = isEnd;
                inst.TempId       = tempId;
                inst.UserId       = startBy;
                commonWFInstanceBll.Add(inst);
            }

            //CommonWFStep step = commonWFStepBll.GetEntities(s => s.CommonWFInstanceId == inst.Id && s.ProcessBy == nextProcessBy && s.StepName == stepName).FirstOrDefault();
            //if (step==null)
            //{
            //    step = new CommonWFStep();
            //    step.StepName=stepName;
            //    step.ProcessBy=nextProcessBy;
            //    step.SubTime = DateTime.Now;
            //    step.StepStatus=stepStatus;
            //    step.CommonWFInstanceId = inst.Id;
            //    commonWFStepBll.Add(step);
            //}
            //else
            //{
            //    step.SubTime = DateTime.Now;
            //    step.StepStatus = stepStatus;
            //    commonWFStepBll.Update(step);
            //}

            if (stepId == 0)
            {
                CommonWFStep step = new CommonWFStep();
                step.StepName           = stepName;
                step.ProcessBy          = nextProcessBy;
                step.SubTime            = DateTime.Now;
                step.StepStatus         = stepStatus;
                step.CommonWFInstanceId = inst.Id;
                commonWFStepBll.Add(step);
                context.SetValue(StepId, step.Id);
            }
            else
            {
                CommonWFStep step = commonWFStepBll.GetEntities(s => s.Id == stepId).FirstOrDefault();
                step.SubTime    = DateTime.Now;
                step.StepStatus = stepStatus;
                commonWFStepBll.Update(step);
            }
            if (isEnd == (short)SimpleOA.Enum.WF_InstanceEnum.Processed)
            {
                inst.status = isEnd;
                commonWFInstanceBll.Update(inst);
            }
            //var step = commonWFStepBll.GetEntities(s => s.CommonWFInstance.Id == inst.Id).FirstOrDefault();
            ////Common.LogHelper.WriteLog("SetSetpActivity:" + text);
            //step.StepName = stepName;
            //step.StepStatus = stepStatus;
            //step.ProcessBy = nextProcessBy;
            //step.IsEndStep = end;
            //if (end)
            //{
            //    step.ProcessResult = "审批结束";
            //    step.StepStatus = (short)SimpleOA.Enum.WFStepEnum.Processed;
            //    inst.status = (short)SimpleOA.Enum.WF_InstanceEnum.Processed;
            //    commonWFInstanceBll.Update(inst);
            //}
            //commonWFStepBll.Update(step);
        }