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)); }
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)); }
//获取分页数据 public ActionResult GetPageList() { long searchId; bool isId = long.TryParse(Request["searchId"], out searchId); string searchName = string.IsNullOrEmpty(Request["searchName"]) ? string.Empty : Request["searchName"]; DateTime from, to; bool fromIsDate = DateTime.TryParse(Request["from"], out from); bool toIsDate = DateTime.TryParse(Request["to"], out to); bool showAll = !string.IsNullOrEmpty(Request["show"]); int pageIndex = Request["page"] != null?int.Parse(Request["page"]) : 1; int pageSize = Request["rows"] != null?int.Parse(Request["rows"]) : 5; int totalCount; WhereHelper <WFInstance> wh = new WhereHelper <WFInstance>(); //wh.Equal("IsDeleted", (byte)0); if (!showAll) { wh.Equal("SubBy", UserLogin.UserId); } if (isId) { wh.Equal("InstanceId", searchId); } if (searchName != string.Empty) { wh.Contains("InstanceTitle", searchName); } if (fromIsDate) { wh.StrGreater("SubTime", from.ToString("yyyy-MM-dd HH:mm:ss")); } if (toIsDate) { wh.StrLess("SubTime", to.ToString("yyyy-MM-dd") + " 23:59:59"); } var InstanceList = WFInstanceBll.GetPageList <long>(wh.GetExpression(), i => i.InstanceId, false, pageIndex, pageSize, out totalCount); var uList = UserInfoBll.GetList <int>(us => true); var result = from i in InstanceList from uu in uList where i.SubBy == uu.UserId select new { UserId = UserLogin.UserId, SubId = i.SubBy, InstanceId = i.InstanceId, InstanceTitle = i.InstanceTitle, InstanceState = i.InstanceState, Details = i.Details, Remark = i.Remark, SubTime = i.SubTime, SubBy = uu.RealName != null && uu.RealName != "" ? uu.RealName : uu.Username, RejectMsg = i.RejectMsg }; return(Json(new { total = totalCount, rows = result }, JsonRequestBehavior.AllowGet)); }
public ActionResult ReApply(ReApplyViewModel model) { string result = "no"; WFInstance instance = WFInstanceBll.GetById(model.InstanceId); if (instance.InstanceTitle.StartsWith("报销")) { //WorkFlowHelper.Resume(new Expense(), Guid.Parse(instance.InstanceGuid), "BackInput", new ExpenseModel() //{ // Reason = model.Reason, // Money = model.Num //}); instance.InstanceTitle = model.InstanceTitle.StartsWith("报销--") ? model.InstanceTitle : "报销--" + model.InstanceTitle; instance.Details = string.Format("事由:{0},金额:{1}元。", model.Reason, model.Num); } else if (instance.InstanceTitle.StartsWith("请假")) { //WorkFlowHelper.Resume(new Leave(), Guid.Parse(instance.InstanceGuid), "ReInput", new LeaveModel() //{ // Reason = model.Reason, // Days = model.Num //}); string title = model.InstanceTitle == "1" ? "事假" : model.InstanceTitle == "2" ? "病假" : "休假"; instance.InstanceTitle = "请假--" + title; instance.Details = string.Format("事由:{0},天数:{1}天。", model.Reason, model.Num); } else { return(Content("no")); } instance.InstanceState = (int)InstanceState.Approving; instance.RejectMsg = ""; instance.Remark = model.Remark; instance.WFStep.Add(new WFStep() { IsEnd = 0, NextId = model.NextId, SubBy = UserLogin.UserId, SubTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }); if (WFInstanceBll.Edit(instance)) { result = "ok"; } return(Content(result)); }
public ActionResult Approve(ApproveViewModel model) { string result = "no"; WFInstance wInstance = WFInstanceBll.GetById(model.InstanceId); //int status = !model.Approve ? -1 : model.Approve && model.NextId == 0 ? 1 : 0; //if (wInstance.InstanceTitle.StartsWith("报销")) //{ // WorkFlowHelper.Resume(new Expense(), Guid.Parse(wInstance.InstanceGuid), "Check", status); //} //else if (wInstance.InstanceTitle.StartsWith("请假")) //{ // WorkFlowHelper.Resume(new Leave(), Guid.Parse(wInstance.InstanceGuid), "LeaveCheck", status); //} //else //{ // return Content("no"); //} wInstance.WFStep.Add(new WFStep { Tips = string.IsNullOrWhiteSpace(model.Tips) ? "" : model.Approve ? "同意,意见为:" + model.Tips : "驳回,意见为:" + model.Tips, NextId = model.NextId, SubBy = UserLogin.UserId, SubTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), IsEnd = model.NextId == 0 ? (byte)1 : (byte)0 }); if (model.Approve && model.NextId == 0) { wInstance.InstanceState = (int)InstanceState.Over; } else if (!model.Approve) { wInstance.InstanceState = (int)InstanceState.Reject; } wInstance.RejectMsg = model.Tips; WFStepBll.GetById(model.StepId).IsEnd = 1; if (WFInstanceBll.Edit(wInstance)) { result = "ok"; } return(Content(result)); }
// 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); }
//首页 public ActionResult Index() { #region 查找待办事项信息并放在ViewData中 List <QuickEntryViewModel> ltEntry = new List <QuickEntryViewModel>(); ViewBag.CurrentUser = UserLogin.UserName; var aSteps = WFStepBll.GetList(s => (s.NextId == UserLogin.UserId) && s.IsEnd == 0, s => s.StepId); var aInstances = from s in aSteps select s.WFInstance; AddEntryViewToList(ltEntry, aInstances); var rInstances = WFInstanceBll.GetList(i => (i.SubBy == UserLogin.UserId) && (i.InstanceState == 1), i => i.InstanceId); AddEntryViewToList(ltEntry, rInstances); ViewData["Entry"] = ltEntry; #endregion #region 主菜单过滤 //准备目标集合 List <MenuViewModel> listMenu = new List <MenuViewModel>(); //获取所有的桌面菜单 List <ActionInfo> aList = ActionInfoBll.GetList(a => a.IsDeleted == 0 && a.IsMenu == 1, a => a.ActionTitle).ToList(); //获取当前登录的用户的对象 UserInfo userInfo = UserInfoBll.GetById(UserLogin.UserId); //遍历所有桌面菜单,逐个判断是否有权限 foreach (var actionInfo in aList) { //根据当前数据,构造一个菜单对象 MenuViewModel menu = new MenuViewModel() { ActionTitle = actionInfo.ActionTitle, ControllerName = actionInfo.ControllerName, ActionName = actionInfo.ActionName, MenuIcon = actionInfo.MenuIcon }; //查找否决中是否允许,如果允许,直接加入目标集合 if (UserActionInfoBll.GetList <int>(ua => (ua.ActionId == actionInfo.ActionId) && (ua.UserId == UserLogin.UserId) && (ua.IsAllow == 1)).Count() > 0) { listMenu.Add(menu); continue; } //如果否决没有允许,则查找角色-权限过程 var raList = from r in userInfo.RoleInfo from a in r.ActionInfo where a.ActionId == actionInfo.ActionId select a; if (raList.Count() > 0) { listMenu.Add(menu); } //排除拒绝的特殊权限 var forbidList = from ua in userInfo.UserActionInfo where ua.ActionId == actionInfo.ActionId && ua.IsAllow == 0 select ua; if (forbidList.Count() > 0) { listMenu.Remove(menu); } } #endregion return(View(listMenu)); }