public ActionResult add(int id, sysMenusView model) { try { //1.0 实体模型属性合法性验证 if (ModelState.IsValid == false) { SetStatus(); return(View()); } //2.0 保存数据 //2.0.1 先补齐页面没有传入的,但是DB要求不为null的数据字段值 model.mParentID = id; model.mCreateTime = DateTime.Now; model.mCreatorID = UserMgr.GetCurrentUserInfo().uID; model.mUpdateTime = DateTime.Now; //2.0.2 保存 menuSer.Add(model.EntityMap()); menuSer.SaveChanges(); return(base.WriteSuccess("数据保存成功")); } catch (Exception ex) { return(WriteError(ex.Message)); } }
public ActionResult add(UserInfoAdd model) { if (ModelState.IsValid == false) { return(WriteError("验证失败")); } try { sysUserInfo user = new sysUserInfo() { uLoginName = model.uLoginName, uStatus = model.uStatus, uGender = model.uGender, uEmail = model.uEmail, uRealName = model.uRealName, uMobile = model.uMobile, uLoginPWD = Kits.MD5Entry("123456"), uUpdateTime = DateTime.Now, uCreateID = UserMgr.GetCurrentUserInfo().uID, uCreateTime = DateTime.Now, uCompanyID = model.uCompanyID, uDepID = model.uDepID, uWorkGroupID = model.uWorkGroupID }; _userinfoSer.Add(user); _userinfoSer.SaveChanges(); return(WriteSuccess("新增成功")); } catch (Exception ex) { return(WriteError(ex)); } }
public ActionResult getFunctions() { //1.0获取用户id int uid = UserMgr.GetCurrentUserInfo().uID; //2.0获取从前台传入的当前页面url string url = Request.Form["murl"]; //3.0根据url从单钱用户的权限按钮缓存数据中获取指定的按钮 var allFunctionsFromCache = _permissSer.GetFunctionsForUserByCache(uid); //3.0.1从allFunctionsFromCache集合中获取指定的url对应的按钮数据 var functions = allFunctionsFromCache.Where(c => c.mUrl.ToLower() == url.ToLower()); //4.0遍历functions拼接成ligerUIGrid中toolbar要求的json格式字符串 System.Text.StringBuilder resJson = new System.Text.StringBuilder("[", 200); if (functions.Any()) { foreach (var item in functions) { // { text: '增加', click: add, icon: 'add' }, resJson.Append("{ \"text\": \"" + item.fName + "\", \"click\": \"" + item.fFunction + "\", \"icon\": \"" + item.fPicName + "\" }, { \"line\": \"true\" },"); } //将最后一个逗号移除 if (resJson.Length > 1) { resJson.Remove(resJson.Length - 1, 1); } } resJson.Append("]"); var str = resJson.ToString(); return(Content(str)); }
public ActionResult addNode(int id, wfWorkNodesView model) { try { if (ModelState.IsValid == false) { return(WriteError("实体验证失败")); } //1.0 获取id工作流下面的最后一个节点 var lastNode = worknodesSer.QueryOrderBy(c => c.wfID == id, c => c.wfnOrderNo).LastOrDefault(); //1.0 将id赋值给wfID表示为当前节点是添加到id指定的工作流下 model.wfID = id; model.fCreateTime = DateTime.Now; model.fCreatorID = UserMgr.GetCurrentUserInfo().uID; model.fUpdateTime = DateTime.Now; model.wfnOrderNo = lastNode != null ? lastNode.wfnOrderNo + 1 : 1; worknodesSer.Add(model.EntityMap()); worknodesSer.SaveChanges(); return(WriteSuccess("节点添加成功")); } catch (Exception ex) { return(WriteError(ex)); } }
public ActionResult reject(int id) { int wfpid = id; //2.0 修改id对应的数据 中的 处理状态为 拒绝 处理理由,ext1字段为当前登录用户的uid string msg = Request.Form["msg"]; if (msg.IsEmpty()) { return(WriteError("处理理由非空")); } var process = processSer.QueryWhere(c => c.wfPID == wfpid).FirstOrDefault(); if (process.wfRFStatus != (int)Enums.ERequestFormStatus.Processing) { return(WriteError("此单已经被您处理,请勿重复处理")); } //2.0 对实体进行更新操作 process.wfRFStatus = (int)Enums.ERequestFormStatus.Reject; process.wfPDescription = msg; process.wfPExt1 = UserMgr.GetCurrentUserInfo().uID.ToString(); var endNode = process.wfWorkNodes.wfWork.wfWorkNodes.OrderBy(c => c.wfnOrderNo).LastOrDefault(); //3.0 增加一条结束数据 wfProcess endProcess = new wfProcess() { fUpdateTime = DateTime.Now, fCreateTime = DateTime.Now, fCreatorID = UserMgr.GetCurrentUserInfo().uID, wfPExt1 = UserMgr.GetCurrentUserInfo().uID.ToString(), wfPDescription = "申请单已经结束", wfRFStatus = (int)Enums.ERequestFormStatus.Pass, wfRFID = process.wfRFID, wfnID = endNode.wfnID }; //新增一条结束明细数据 processSer.Add(endProcess); //4.0 将当前提交单的状态修改拒绝状态 wfRequestForm rfmodel = new wfRequestForm() { wfRFID = process.wfRFID, wfRFStatus = (int)Enums.ERequestFormStatus.Reject }; requestformSer.Edit(rfmodel, new string[] { "wfRFStatus" }); using (System.Transactions.TransactionScope scop = new System.Transactions.TransactionScope()) { processSer.SaveChanges(); scop.Complete(); } return(WriteSuccess("申请单已经拒绝")); }
public ActionResult SetMessage() { //1.0 接收ajax发送过来的数据 string touserid = Request.Params["touserid"]; string torealname = Request.Params["torealname"]; string msgbody = Request.Params["msgbody"]; //2.0 参数合法性验证 ChatMsg msg = new ChatMsg() { ToUserId = int.Parse(touserid), ToRealName = torealname, FromRealName = UserMgr.GetCurrentUserInfo().uRealName , FromUserId = UserMgr.GetCurrentUserInfo().uID, SendTime = DateTime.Now, MessageBody = msgbody }; //3.0包装成chatmsg对象发送给WCF聊天服务 ChatMgrClient c = new ChatMgrClient(); c.SetMessage(msg); return(WriteSuccess("消息发送成功")); }
public ActionResult getlist() { int page = Request.Form["page"].AsInt(); int pagesize = Request.Form["pagesize"].AsInt(); int rowcount = 0; //1.0 获取当前用户所在的角色id的合集 int uid = UserMgr.GetCurrentUserInfo().uID; var roleids = userinfoRoleSer.QueryWhere(c => c.uID == uid).Select(c => c.rID).ToList(); //1.0 获取视图要求的字段数据集合 var list = processSer.QueryByPage(page, pagesize, out rowcount, c => c.wfPID, c => roleids.Contains(c.wfProcessor)) .Select(c => new { c.wfPID, RealName = UserMgr.GetUserByID(c.wfRequestForm.fCreatorID).uRealName, c.wfRequestForm.wfRFTitle, c.wfRequestForm.wfRFRemark, c.wfRequestForm.wfRFNum, c.wfRFStatus, StatusName = c.sysKeyValue.KName }); //返回 return(Json(new { Rows = list, Total = rowcount })); }
public ActionResult add(int id, sysFunctionView model) { try { //1.0 判断视图的合法性 if (ModelState.IsValid == false) { return(WriteError("实体验证失败")); } //2.0 将model中的Mid补全 model.mID = id; model.fCreateTime = DateTime.Now; model.fUpdateTime = DateTime.Now; model.fCreatorID = UserMgr.GetCurrentUserInfo().uID; //3.0 实体转换和保存 var entity = model.EntityMap(); funSer.Add(entity); funSer.SaveChanges(); return(WriteSuccess("新增成功")); } catch (Exception ex) { return(WriteError(ex)); } }
public ActionResult Index() { // 1.0 获取菜单表的有效数据 , 并且按照排序号进行排列 // var list = menuSer.QueryOrderBy(c => c.mStatus == (int)Enums.Estate.Nomal, c => c.mSortid); var list = menuSer.RunProc <sysMenus>("GetPerissMenusByUser @uid=" + UserMgr.GetCurrentUserInfo().uID); // 2.0 将数据以ViewBag.list的形式传回 ViewBag.mlist = list; return(View()); }
public ActionResult addBranch(int id, wfWorkBranchView model) { model.wfnID = id; model.fCreateTime = DateTime.Now; model.fUpdateTime = DateTime.Now; model.fCreatorID = UserMgr.GetCurrentUserInfo().uID; workbranchSer.Add(model.EntityMap()); workbranchSer.SaveChanges(); return(WriteSuccess("添加成功")); }
// GET: Admin/Home public ActionResult Index() { ////1.0获取菜单表的所有有效数据,并且按照排序号进行排列 //var list = _menuSer.QueryOrderBy(c => c.mStatus == (int)Enums.EState.Nomal, c => c.mSortID); ////2.0将数据viewbag传入视图 //ViewBag.mlist = list; //Usp_GetPermissMenusForUser var list = _menuSer.RunProc <sysMenus>("Usp_GetPermissMenusForUser " + UserMgr.GetCurrentUserInfo().uID); ViewBag.mlist = list; return(View()); }
public ActionResult setPermiss() { try { string id = Request.Form["p"]; //1.0 分解id的值 string[] arr = id.Split('-'); int rid = arr[0].AsInt(); string[] permissListRow = arr[1].Replace("m", "").Replace("f", "").Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries); //2.0 先将syspermisslist中删除rid的权限数据 permissSer.QueryWhere(c => c.rID == rid).ForEach(c => permissSer.Delete(c, true)); //3.0 批量将最新的数据插入 string[] midfids; sysPermissList model; foreach (var midfid in permissListRow) { midfids = midfid.Split(','); //2.0 new sysPermissList的实体 model = new sysPermissList() { rID = rid, mID = midfids[0].AsInt(), fID = midfids[1].AsInt(), plCreateTime = DateTime.Now, plCreatorID = UserMgr.GetCurrentUserInfo().uID }; //3.0 将model追加到EF容器 permissSer.Add(model); } //4.0 开启分布式事务 using (System.Transactions.TransactionScope scop = new System.Transactions.TransactionScope()) { permissSer.SaveChanges(); //提交事务 scop.Complete(); } //5.0 成功响应 return(WriteSuccess("权限已经设置成功")); } catch (Exception ex) { return(WriteError(ex)); } }
public ActionResult add(int id, sysMenusView model) { try { //1.0实体属性合法性验证 if (ModelState.IsValid == false) { SetStatus(); return(View()); } //2.0保存数据 model.mParentID = id; model.mCreateTime = DateTime.Now; model.mCreatorID = UserMgr.GetCurrentUserInfo().uID; model.mUpdateTime = DateTime.Now; model.mUpdateID = UserMgr.GetCurrentUserInfo().uID; model.mExp1 = null; model.mExp2 = null; sysMenus entity = model.EntityMap(); //2.0.2 保存 _menuSer.Add(entity); _menuSer.SaveChanges(); return(base.WriteSuccess("数据保存成功")); } //catch (DbEntityValidationException dbEx) //{ // string s = null; // foreach (var validationErrors in dbEx.EntityValidationErrors) // { // foreach (var validationError in validationErrors.ValidationErrors) // { // s += string.Format("Class: {0}, Property: {1}, Error: {2}", // validationErrors.Entry.Entity.GetType().FullName, // validationError.PropertyName, // validationError.ErrorMessage); // } // } // return base.WriteError(s); //} catch (Exception ex) { return(WriteError(ex.Message)); } }
public ActionResult back(int id) { //驳回理由 string msg = Request.Form["msg"]; if (msg.IsEmpty()) { return(WriteError("处理理由非空")); } //1.0 将id所在的wfprocess表中的数据状态修改成驳回状态同时将理由更新 var currentProcess = processSer.QueryWhere(c => c.wfPID == id).FirstOrDefault(); currentProcess.wfRFStatus = (int)Enums.ERequestFormStatus.Back; currentProcess.wfPDescription = msg; currentProcess.wfPExt1 = UserMgr.GetCurrentUserInfo().uID.ToString(); //2.0 将审核单提交给我的下级 int preWfpid = currentProcess.wfPExt2.Value; var preProcess = processSer.QueryWhere(c => c.wfPID == preWfpid).FirstOrDefault(); //new新的审核明细实体 wfProcess nextProcess = new wfProcess() { wfRFStatus = (int)Enums.ERequestFormStatus.Processing, wfPDescription = null, fCreateTime = DateTime.Now, fUpdateTime = DateTime.Now, fCreatorID = UserMgr.GetCurrentUserInfo().uID, wfnID = preProcess.wfnID, wfPExt2 = preProcess.wfPID, wfProcessor = preProcess.wfProcessor, wfRFID = preProcess.wfRFID }; processSer.Add(nextProcess); //开启事物操作 using (System.Transactions.TransactionScope scop = new System.Transactions.TransactionScope()) { processSer.SaveChanges(); scop.Complete(); } return(WriteSuccess("驳回操作成功")); }
public ActionResult GetMessage() { //1.0 获取当前登录用户的id int userid = UserMgr.GetCurrentUserInfo().uID; //2.0 调用WCF服务获取当前用户的消息 ChatMgrClient client = new ChatMgrClient(); var msgs = client.GetMessage(userid).Select(c => new { frn = c.FromRealName, st = c.SendTime, fui = c.FromUserId, mb = c.MessageBody }); return(WriteSuccess("ok", msgs)); }
public ActionResult getFunctions() { //1.0 获取用户id int uid = UserMgr.GetCurrentUserInfo().uID; //2.0 获取从前台传入的当前页面的url string url = Request.Form["murl"]; //3.0 根据url从当前用户的权限按钮缓存数据中获取指定的按钮 var allFunctionsFromCache = permissSer.GetFunctionsForUserByCache(uid); //3.0.1 从allFunctionsFromCache 集合中获取指定的url对于的按钮数据 var functions = allFunctionsFromCache.Where(c => c.mUrl.ToLower() == url.ToLower()); //4.0 遍历functions集合拼接成ligerGrid中的Toolbar要求的json格式的字符串 /* * : [ * { text: '增加', click: add, icon: 'add' }, * { line: true }, * { text: '修改', click: edit, icon: 'modify' }, * { line: true }, * { text: '删除', click: del, icon: 'delete' }, * { line: true }, * { text: '刷新', click: getlist, icon: 'refresh' } * ] */ System.Text.StringBuilder resJson = new System.Text.StringBuilder("[", 200); if (functions.Any()) { foreach (var item in functions) { resJson.Append("{ \"text\": \"" + item.fName + "\", \"click\": \"" + item.fFunction + "\", \"icon\": \"" + item.fPicname + "\" }, { \"line\": \"true\" },"); } //将最后一个逗号移除 if (resJson.Length > 1) { resJson.Remove(resJson.Length - 1, 1); } } resJson.Append("]"); //返回 return(Content(resJson.ToString())); }
public ActionResult GetHistoryMessage() { //1.0 获取时间间隔 string begintime = Request.Params["btime"]; string endtime = Request.Params["etime"]; //2.0 进行时间格式的合法性验证 //3.0调用wcf ChatMgrClient client = new ChatMgrClient(); var list = client.GetHistoryMessage(UserMgr.GetCurrentUserInfo().uID, DateTime.Parse(begintime), DateTime.Parse(endtime)); var nlist = list.Select(c => new { frn = c.FromRealName, st = c.SendTime, fui = c.FromUserId, mb = c.MessageBody }); return(WriteSuccess("ok", nlist)); }
public ActionResult getlist() { int page = Request.Form["page"].AsInt(); //页码 int pagesize = Request.Form["pagesize"].AsInt(); //页容量 int rowcount = 0; //根据主键进行倒叙排列,确保最新的提交单在第一条数据 int uid = UserMgr.GetCurrentUserInfo().uID; var list = requestformSer.QueryByPage(page, pagesize, out rowcount, c => c.wfRFID, c => c.fCreatorID == uid) .Select(c => new { c.wfRFID, c.wfWork.wfTitle, c.wfRFPriority, c.wfRFNum, c.wfRFStatus, StatusName = c.sysKeyValue1.KName, c.wfRFTitle }).ToList(); return(Json(new { Rows = list, Total = rowcount })); }
public ActionResult add(wfRequestFormView model) { if (ModelState.IsValid == false) { return(WriteError("实体属性验证失败")); } int uid = UserMgr.GetCurrentUserInfo().uID; //补全数据 model.fCreateTime = DateTime.Now; model.fUpdateTime = DateTime.Now; model.fCreatorID = UserMgr.GetCurrentUserInfo().uID; model.wfRFStatus = (int)Enums.ERequestFormStatus.Processing; //2.0 将实体追加到EF容器 wfRequestForm entity = model.EntityMap(); requestformSer.Add(entity); using (System.Transactions.TransactionScope scop = new System.Transactions.TransactionScope()) { requestformSer.SaveChanges(); //获取当前新增的申请单的最新主键值 int wfRFID = entity.wfRFID; //2.0.1 根据wfid获取工作流下面的第1,2个节点数据 var nodes = workSer.QueryWhere(c => c.wfID == model.wfID).FirstOrDefault().wfWorkNodes .OrderBy(c => c.wfnOrderNo).ToList(); //判断nodes是否有值 if (nodes == null || nodes.Count() < 2) { return(WriteError("您所选的工作流中不存在节点数据,请联系管理")); } //2.0.2 获取当前登录用户所在的角色 var role = userinfoRoleSer.QueryWhere(c => c.uID == uid).FirstOrDefault(); //3.0 向wfProcess表中插入数据 //3.0.1 向wfProcess表中插入数据一条申请成功的数据 wfProcess process = new wfProcess() { fCreateTime = DateTime.Now, fCreatorID = UserMgr.GetCurrentUserInfo().uID, fUpdateTime = DateTime.Now, wfnID = nodes[0].wfnID, wfPDescription = "申请单已经提交", wfProcessor = role.rID, wfRFID = wfRFID, wfPExt1 = UserMgr.GetCurrentUserInfo().uID.ToString(), wfRFStatus = (int)Enums.ERequestFormStatus.Pass //通过 }; //追加到EF容器 processSer.Add(process); //3.0.2 向wfProcess表中插入数据一条审批节点的审批数据 int secWfnid = nodes[1].wfnID; int roleType = nodes[1].wfnRoleType; //次节点的审批角色类型 int eDeptID = UserMgr.GetCurrentUserInfo().uWorkGroupID.Value; //获取当前申请人所在的部门 //获取当前节点的审批角色id int processRoleid = roleSer.QueryWhere(c => c.eDepID == eDeptID && c.RoleType == roleType).FirstOrDefault().rID; wfProcess process1 = new wfProcess() { fCreateTime = DateTime.Now, fCreatorID = UserMgr.GetCurrentUserInfo().uID, fUpdateTime = DateTime.Now, wfnID = secWfnid, wfPDescription = "", wfProcessor = processRoleid, wfRFID = wfRFID, wfRFStatus = (int)Enums.ERequestFormStatus.Processing //处理中 }; //追加到EF容器 processSer.Add(process1); processSer.SaveChanges(); scop.Complete(); } return(WriteSuccess("新增成功")); }
public ActionResult pass(int id) { //通过理由 string msg = Request.Form["msg"]; if (msg.IsEmpty()) { return(WriteError("处理理由非空")); } //1.0 更新数据表wfprocess中的状态数据 var currentProcess = processSer.QueryWhere(c => c.wfPID == id).FirstOrDefault(); currentProcess.wfRFStatus = (int)Enums.ERequestFormStatus.Pass; currentProcess.wfPDescription = msg; currentProcess.wfPExt1 = UserMgr.GetCurrentUserInfo().uID.ToString(); //2.0 往wfprocess表中插入一条下一个节点的处理数据 //2.0.1 判断下一个节点具体是结束节点还是执行节点(逻辑:去当前处理节点数据中获取bizMethod方法利用 //反射动态执行,获取结果true/false 去wfWorkBranch 查找具体的下一个节点id ) //获取当前处理节点的逻辑判断结果 string bizMethod = currentProcess.wfWorkNodes.wfnBizMethod; //Gt decimal maxNum = currentProcess.wfWorkNodes.wfnMaxNum; decimal targetNum = currentProcess.wfRequestForm.wfRFNum; //利用反射动态执行bizMethod方法 //获取在web.config配置的程序集名称:格式 名称1;名称2 string assNamStr = System.Configuration.ConfigurationManager.AppSettings["bizMethodAssembly"]; string[] assNames = assNamStr.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); if (assNames.Length == 0) { return(WriteError("程序集配置文件有误,请联系管理员")); } object boolobj = null; foreach (var assName in assNames) { Assembly ass = Assembly.Load(assName); Type[] types = ass.GetTypes(); foreach (Type type in types) { MethodInfo minfo = type.GetMethod(bizMethod); if (minfo != null) { //根据type创建类的对象实例 object instance = Activator.CreateInstance(type); //开始调用方法 boolobj = minfo.Invoke(instance, new object[] { targetNum, maxNum }); break; } } } string resToken = boolobj == null ? "" : boolobj.ToString(); //true /false //获取当前节点的id int currentNodeId = currentProcess.wfWorkNodes.wfnID; //2.0.2 获取下一个节点的对象 var branModel = workbranchSer.QueryWhere(c => c.wfnToken == resToken && c.wfnID == currentNodeId).FirstOrDefault(); var nextNode = branModel.wfWorkNodes1; wfProcess nextProcess = new wfProcess() { fCreateTime = DateTime.Now, fUpdateTime = DateTime.Now, fCreatorID = UserMgr.GetCurrentUserInfo().uID, //wfPDescription = null //暂时还不能确定 //, //wfRFStatus = 42//暂时还不能确定 //wfnID = 1 ////暂时还不能确定 wfProcessor = 1////暂时还不能确定 , wfRFID = currentProcess.wfRFID // wfPExt1 = null //代表当前审核人的id , wfPExt2 = currentProcess.wfPID //表示此条数据是当前处理明细数据流转过来的,方便做驳回上级操作 }; if (nextNode == null) { return(WriteError("下一个节点获取到,基础数据异常,联系管理员")); } nextProcess.wfnID = nextNode.wfnID; //进行下一个节点判断,如果是结束节点则赋值成通过 if (nextNode.wfNodeType == (int)Enums.ENodeType.EndNode) { nextProcess.wfRFStatus = (int)Enums.ERequestFormStatus.Pass; nextProcess.wfPDescription = "审批已结束"; nextProcess.wfPExt1 = UserMgr.GetCurrentUserInfo().uID.ToString(); //将申请单的状态修改成通过状态 var requestFormModel = currentProcess.wfRequestForm; requestFormModel.wfRFStatus = (int)Enums.ERequestFormStatus.Pass; } else { nextProcess.wfRFStatus = (int)Enums.ERequestFormStatus.Processing; nextProcess.wfPDescription = null; nextProcess.wfPExt1 = null; } //确定下一条明细数据中的审批角色id int wkgID = UserMgr.GetCurrentUserInfo().uWorkGroupID.Value; //可空类型 int rid = roleSer.QueryWhere(c => c.eDepID == wkgID && c.RoleType == nextNode.wfnRoleType).FirstOrDefault().rID; nextProcess.wfProcessor = rid; //将下一个处理明细数据增加到数据库中 processSer.Add(nextProcess); //带事物执行 using (System.Transactions.TransactionScope scop = new System.Transactions.TransactionScope()) { processSer.SaveChanges(); scop.Complete(); } return(WriteSuccess("审核单已经通过")); }