string getPublicOutList() { DateTime today = DateTime.Today; List <FlowMain> fMainList = ctx.FlowMainList.Where( x => x.billDate != null && x.billDate.Value.Year <= today.Year && x.flowStatus == 2 && x.defId == "PublicOut").ToList <FlowMain>(); List <string> billNoList = (from f in fMainList select f.id).ToList <string>(); List <publicOut> publicOutList = ctx.publicOutList.Where(x => billNoList.Contains(x.flowId)).ToList <publicOut>(); List <dynamic> dataList = new List <dynamic>(); int idx = 1; foreach (var f in fMainList) { string urla = HttpContext.Request.Url.Scheme + "://" + HttpContext.Request.Url.Authority + Url.Action("Detils", "Form", new { id = f.id }); string urlb = HttpContext.Request.Url.Scheme + "://" + HttpContext.Request.Url.Authority + Url.Action("Details", "Form", new { id = f.id }); vwEmployee user = ctx.getUserByWorkNo(f.senderNo); publicOut d = publicOutList.Where(x => x.flowId == f.id).FirstOrDefault(); dynamic obj = new ExpandoObject(); obj.billNo = f.billNo; obj.date = f.billDate; obj.user = user.UserCName; obj.start = d.dtBegin; obj.end = d.dtEnd; obj.title = "外-" + d.dtBegin.Value.ToString("HH:mm") + "~" + d.dtEnd.Value.ToString("HH:mm") + "-" + user.UserCName + "-" + d.destination; obj.formId = d.id; obj.url = f.senderNo == User.Identity.Name ? urla : urlb; obj.id = idx; obj.color = "#ff9900"; obj.textColor = "#ffffff"; obj.order = 2; dataList.Add(obj); idx++; } return(JsonConvert.SerializeObject(dataList)); }
public ActionResult Details(string id, string FlowPageType = "", string ReturnAction = "") { var store = new UserStore <ApplicationUser>(ctx); var manager = new UserManager <ApplicationUser>(store); var user = manager.FindByName(User.Identity.Name); var roleStore = new RoleStore <ApplicationRole>(ctx); var roleManager = new RoleManager <ApplicationRole>(roleStore); bool isAdmin = false; FlowMain fmain = ctx.FlowMainList.Where(x => x.id == id).FirstOrDefault(); ViewBag.flowMain = fmain; vwEmployee employee = ctx.getUserByWorkNo(fmain.senderNo); ViewBag.Employee = employee; foreach (var role in roleManager.Roles) { if (user.Roles.Where(x => x.RoleId == role.Id && role.Name.ToUpper() == "ADMIN").Count() > 0) { isAdmin = true; break; } } if (!isAdmin && fmain.defId != "EventSchedule") { if (ctx.FlowSubList.Where(x => x.pid == id && x.workNo == User.Identity.Name).Count() == 0) { return(RedirectToAction("AccessDenied", "Account")); } } if (ctx.FlowSubList.Where(x => x.pid == id && x.workNo == User.Identity.Name && x.signType == 701).Count() > 0) { FlowPageType = "HRCheck"; } if (FlowPageType == "") { FlowPageType = fmain.defId == "EventSchedule" ? "EventSchedule" : ""; } var context = new ApplicationDbContext(); ViewBag.FlowPageType = FlowPageType; ViewBag.ReturnAction = ReturnAction; List <vwFlowSub> list = new List <vwFlowSub>(); List <FlowSub> fsubList = context.FlowSubList.Where(x => x.pid == id).OrderBy(x => x.seq).ToList <FlowSub>(); foreach (FlowSub sitem in fsubList) { var signResultObj = context.signResultList().Where(x => x.id == sitem.signResult).FirstOrDefault(); var signTypeObj = context.signTypeList().Where(x => x.id == sitem.signType).FirstOrDefault(); var signUser = context.Users.Where(x => x.workNo == sitem.workNo).FirstOrDefault(); vwFlowSub item = new vwFlowSub { id = sitem.id, seq = sitem.seq, signDate = sitem.signDate, signResult = signResultObj == null ? "" : signResultObj.nm, signType = signTypeObj == null ? "會簽" : signTypeObj.nm, signer = signUser == null ? "" : signUser.workNo + "-" + signUser.cName, comment = sitem.comment }; list.Add(item); } #region "非工作時間廠務申請單" if (fmain.defId == "OverTime") { fmain.flowName += "(P016A1)"; ReqOverTime reqOverTimeObj = context.reqOverTimeList.Where(x => x.flowId == id).FirstOrDefault(); vwReqOverTime vwReqOverTimeObj = null; if (reqOverTimeObj != null) { vwReqOverTimeObj = new vwReqOverTime { billNo = fmain.billNo, dtBegin = reqOverTimeObj.dtBegin, dtEnd = reqOverTimeObj.dtEnd, hours = reqOverTimeObj.hours, sMemo = reqOverTimeObj.sMemo }; JObject jobjext = null; try { jobjext = JObject.Parse(reqOverTimeObj.jext); vwReqOverTimeObj.sType = jobjext["stype"] == null ? "" : jobjext["stype"].ToString(); vwReqOverTimeObj.place = jobjext["place"] == null ? "" : jobjext["place"].ToString(); vwReqOverTimeObj.otherPlace = jobjext["otherPlace"] == null ? "" : jobjext["otherPlace"].ToString(); vwReqOverTimeObj.prjId = jobjext["prjId"] == null ? "" : jobjext["prjId"].ToString(); vwReqOverTimeObj.sMemo2 = jobjext["sMemo2"] == null ? "" : jobjext["sMemo2"].ToString(); vwReqOverTimeObj.worker = jobjext["worker"] == null ? "" : jobjext["worker"].ToString(); vwReqOverTimeObj.depNo = jobjext["depNo"] == null ? "" : jobjext["depNo"].ToString(); vwReqOverTimeObj.poNo = jobjext["poNo"] == null ? "" : jobjext["poNo"].ToString(); vwReqOverTimeObj.poNm = jobjext["poNo"] == null ? "" : context.jobPos.Where(x => x.poNo.Equals(vwReqOverTimeObj.poNo)).FirstOrDefault().poNm; jobPo poObj = context.jobPos.Where(x => x.poNo == vwReqOverTimeObj.poNo).First(); string depNo = poObj.depNo; string depNm = context.getParentDeps(depNo, context) + " : " + poObj.poNm; vwReqOverTimeObj.depNm = depNm; } catch (Exception ex) { } } ViewBag.SubModel = vwReqOverTimeObj; return(View(list)); } #endregion #region "加班單" if (fmain.defId == "RealOverTime") { fmain.flowName += "(P017A1)"; ReqOverTime reqOverTimeObj = context.reqOverTimeList.Where(x => x.flowId == id).FirstOrDefault(); vwRealOverTime vwReqOverTimeObj = null; if (reqOverTimeObj != null) { vwReqOverTimeObj = new vwRealOverTime { user = ctx.getUserByWorkNo(fmain.senderNo), billNo = fmain.billNo, dtBegin = reqOverTimeObj.dtBegin, dtEnd = reqOverTimeObj.dtEnd, hours = reqOverTimeObj.hours, sMemo = reqOverTimeObj.sMemo }; JObject jobjext = null; try { jobjext = JObject.Parse(reqOverTimeObj.jext); vwReqOverTimeObj.sMemo2 = jobjext["sMemo2"] == null ? "" : jobjext["sMemo2"].ToString(); } catch (Exception ex) { } } ViewBag.SubModel = vwReqOverTimeObj; return(View(list)); } #endregion #region "請假單" if (fmain.defId == "DayOff") { fmain.flowName += "(P018A1)"; vwDayOffForm subModel = new vwDayOffForm(); dayOff dayOffObj = ctx.dayOffList.Where(x => x.flowId == fmain.id).FirstOrDefault(); subModel.dayOffForm = new vwdayOff { id = dayOffObj.id, billNo = fmain.billNo, dtBegin = dayOffObj.dtBegin, dtEnd = dayOffObj.dtEnd, hours = dayOffObj.hours, dType = dayOffObj.dType, sMemo = dayOffObj.sMemo, jobAgent = dayOffObj.jobAgent }; ViewBag.SubModel = subModel; return(View("Details", list)); } #endregion #region "外出申請單" if (fmain.defId == "PublicOut") { fmain.flowName += "(P019A1)"; publicOut publicOutObj = ctx.publicOutList.Where(x => x.flowId == fmain.id).FirstOrDefault(); vwPublicOut subModel = new vwPublicOut { id = publicOutObj.id, billNo = fmain.billNo, user = ctx.getUserByWorkNo(fmain.senderNo), requestDate = publicOutObj.requestDate, dtBegin = publicOutObj.dtBegin, dtEnd = publicOutObj.dtEnd, subject = publicOutObj.subject, destination = publicOutObj.destination, transport = publicOutObj.transport }; ViewBag.SubModel = subModel; return(View("Details", list)); } #endregion #region "訪客申請單" if (fmain.defId == "GuestForm") { fmain.flowName += "(P011A1)"; guestForm formObj = ctx.guestFormList.Where(x => x.flowId == fmain.id).FirstOrDefault(); vwGuestForm subModel = new vwGuestForm { id = formObj.id, user = ctx.getUserByWorkNo(fmain.senderNo), requestDate = formObj.requestDate, dtBegin = formObj.dtBegin, dtEnd = formObj.dtEnd, subject = formObj.subject, to = formObj.to, toDep = formObj.toDep, guestCmp = formObj.guestCmp, guestName = formObj.guestName, guestCnt = formObj.guestCnt, cellPhone = formObj.cellPhone, area1 = formObj.area1, area2 = formObj.area2, area21 = formObj.area21, area3 = formObj.area3, area4 = formObj.area4, area41 = formObj.area41, sMemo = formObj.sMemo }; ViewBag.SubModel = subModel; return(View("Details", list)); } #endregion #region "廠務派工及總務需求申請單" if (fmain.defId == "ReqInHouse") { fmain.flowName += "(P020A1)"; ReqInHouse formObj = ctx.reqInHouseList.Where(x => x.flowId == fmain.id).FirstOrDefault(); vwReqInHouse subModel = new vwReqInHouse { id = formObj.id, user = ctx.getUserByWorkNo(fmain.senderNo), billDate = fmain.billDate, contact = formObj.contact, depNo = formObj.depNo, reqLimit = formObj.reqLimit, reqMemo = formObj.reqMemo, sMemo = formObj.sMemo }; ViewBag.SubModel = subModel; return(View("Details", list)); } #endregion #region "公司行程規劃表" if (fmain.defId == "EventSchedule") { fmain.flowName += "(B001A1)"; EventSchedule formObj = ctx.eventScheduleList.Where(x => x.flowId == fmain.id).FirstOrDefault(); vwEventSchedule subModel = new vwEventSchedule { id = formObj.id, user = ctx.getUserByWorkNo(fmain.senderNo), billDate = fmain.billDate, beginHH = formObj.beginHH, beginMM = formObj.beginMM, subject = formObj.subject, location = formObj.location, eventType = formObj.eventType, sMemo = formObj.sMemo }; ViewBag.SubModel = subModel; return(View("Details", list)); } #endregion return(View(list)); }