// GET: Approvals public ActionResult History(ApprovalSearch search) { string currentuser = !string.IsNullOrEmpty(User?.Identity?.Name) ? User.Identity.Name.ToUpper() : "Anonymous"; currentuser = currentuser.Substring(currentuser.IndexOf('\\') + 1).Replace("\\", "").ToUpper(); ApprovalIndexDto dto = new ApprovalIndexDto(); IEnumerable <Approval> list = db.Approvals.Where(a => 1 == 1); if (search.sp != null) { list = list.Where(p => p.privacy.IND_SP.Contains(search.sp)); } if (search.hospital != null) { list = list.Where(p => p.privacy.WKP_NAME.Contains(search.hospital)); } if (!MyRoleManager.hasRole(MyRoleManager.RoleType.SYSTEMADMIN) && !MyRoleManager.hasRole(MyRoleManager.RoleType.DCEADMIN)) { list = list.Where(p => p.creater.Equals(currentuser)); } else if (search.owner != null) { list = list.Where(p => p.creater.Equals(search.owner)); } if (search.status != null && !search.status.Equals("total")) { if (search.status.Equals("approved")) { list = list.Where(p => p.status.Equals(ApprovalStatus.Approved)); } else if (search.status.Equals("rejected")) { list = list.Where(p => p.status.Equals(ApprovalStatus.Rejected)); } else if (search.status.Equals("request")) { list = list.Where(p => p.status.Equals(ApprovalStatus.Request)); } } else { list = list.Where(p => p.status != ApprovalStatus.Request); } if (search.requestbegindt != null) { list = list.Where(a => a.createdate >= search.requestbegindt); } if (search.requestenddt != null) { list = list.Where(a => a.createdate <= search.requestenddt); } if (search.approvalbegindt != null) { list = list.Where(a => a.modifieddate >= search.approvalbegindt); } if (search.approvalenddt != null) { list = list.Where(a => a.modifieddate <= search.approvalenddt); } if (!string.IsNullOrEmpty(search.owner)) { list = list.Where(a => a.creater.Contains(search.owner)); } if (!string.IsNullOrEmpty(search.name)) { list = list.Where(a => a.privacy.IND_FULL_NAME.Contains(search.name)); } dto.Approvals = list.ToList(); dto.Search = search; ViewBag.CompaniesList = GetCompanyList.GetCompany(); return(View(dto)); }
// GET: Dashboard public ActionResult Dashboard(string pcmsid = null) { string currentuser = !string.IsNullOrEmpty(User?.Identity?.Name) ? User.Identity.Name.ToUpper() : "Anonymous"; currentuser = currentuser.Substring(currentuser.IndexOf('\\') + 1).Replace("\\", "").ToUpper(); DashboardDto dto = new DashboardDto(); if (!MyRoleManager.hasRole(MyRoleManager.RoleType.SYSTEMADMIN) && !MyRoleManager.hasRole(MyRoleManager.RoleType.MARKETING) && !MyRoleManager.hasRole(MyRoleManager.RoleType.DCEADMIN) && !MyRoleManager.hasRole(MyRoleManager.RoleType.BUMCM)) { dto.approvalrequests = db.Approvals.Where(a => a.status == ApprovalStatus.Request && a.creater == currentuser).ToList().Count(); dto.rejectedrequests = db.Approvals.Where(a => a.status == ApprovalStatus.Rejected && a.creater == currentuser).ToList().Count(); if (pcmsid == null) { dto.logs = db.Privacylogs.Where(p => p.creater == currentuser).OrderByDescending(p => p.createdate).Take(300).ToList(); } else { dto.logs = db.Privacylogs.Where(p => p.creater == currentuser && p.privacy.PCMSID.Contains(pcmsid)).OrderByDescending(p => p.createdate).Take(300).ToList(); } } else if (MyRoleManager.hasRole(MyRoleManager.RoleType.DCEADMIN)) { var query = from u in db.UserRoles join c in db.Companies on u.COMP_CODE equals c.COMP_CODE select c.DCE_TSA; foreach (var q in query) { if (q == "Y") { dto.approvedrequests = db.Approvals.Where(a => a.status == ApprovalStatus.Approved).ToList().Count(); dto.rejectedrequests = db.Approvals.Where(a => a.status == ApprovalStatus.Rejected).ToList().Count(); dto.approvalrequests = db.Approvals.Where(a => a.status == ApprovalStatus.Request).ToList().Count(); dto.mmscount = db.Consents.Where(c => c.CONSENT_SOURCE == @"MMS").Count(); //dto.pforcerxcount = db.Privacylogs.Where(pl => pl.creater == @"PFORCERX").Count(); dto.pforcerxcount = db.Consents.Where(c => c.CONSENT_SOURCE == @"PFORCERX").Count(); dto.hardcount = db.Consents.Where(c => c.CONSENT_SOURCE != @"MMS" && c.CONSENT_SOURCE != @"GRV" && c.CONSENT_SOURCE != @"PFORCERX").Select(c => c.privacy).Distinct().Count(); dto.grvcount = db.Consents.Where(c => c.CONSENT_SOURCE == @"GRV").Count(); if (pcmsid == null) { dto.logs = db.Privacylogs.OrderByDescending(p => p.createdate).Take(300).ToList(); } else { dto.logs = db.Privacylogs.Where(p => p.privacy.PCMSID.Contains(pcmsid)).OrderByDescending(p => p.createdate).Take(300).ToList(); } } } } else { dto.approvedrequests = db.Approvals.Where(a => a.status == ApprovalStatus.Approved).ToList().Count(); dto.rejectedrequests = db.Approvals.Where(a => a.status == ApprovalStatus.Rejected).ToList().Count(); dto.approvalrequests = db.Approvals.Where(a => a.status == ApprovalStatus.Request).ToList().Count(); // 만료 갯수 /* * Setting setting = db.Settings.Where(s => s.type == SettingType.ConsentTerm).First(); * DateTime expired = DateTime.UtcNow.AddYears(-1 * Int32.Parse(setting.value)); * IQueryable<Privacy> privacys = db.Consents.Where(cst => cst.CONSENT_DATE < expired).Select(cst => cst.privacy).Distinct(); * privacys = privacys.Where(p => p.status != PrivacyStatus.DELETED || p.status != PrivacyStatus.DELETED); * var count = privacys.Count(); * * // String sqlQuery = "select count(*) from Privacies where id in (select privacy_ID from Consents where CONSENT_DATE < DATEADD(year ," + -1 * Int32.Parse(setting.value) + ", CURRENT_TIMESTAMP));"; * // var count = db.Database.SqlQuery(sqlQuery); * * dto.expiredconsents = (int)count; */ // dto.mmscount = db.Privacylogs.Where(pl => pl.creater == @"MMS").Count(); dto.mmscount = db.Consents.Where(c => c.CONSENT_SOURCE == @"MMS").Count(); //dto.pforcerxcount = db.Privacylogs.Where(pl => pl.creater == @"PFORCERX").Count(); dto.pforcerxcount = db.Consents.Where(c => c.CONSENT_SOURCE == @"PFORCERX").Count(); dto.hardcount = db.Consents.Where(c => c.CONSENT_SOURCE != @"MMS" && c.CONSENT_SOURCE != @"GRV" && c.CONSENT_SOURCE != @"PFORCERX").Select(c => c.privacy).Distinct().Count(); //dto.codemappingcount = db.Privacylogs.Where(pl => pl.creater == @"ODSM").Count(); //dto.codemappingcount += db.Privacylogs.Where(pl => pl.creater == @"TASK" && (pl.changes.Contains(@"NucleusKey") || pl.changes.Contains(@"OneKey"))).Count(); dto.grvcount = db.Consents.Where(c => c.CONSENT_SOURCE == @"GRV").Count(); if (pcmsid == null) { dto.logs = db.Privacylogs.OrderByDescending(p => p.createdate).Take(300).ToList(); } else { dto.logs = db.Privacylogs.Where(p => p.privacy.PCMSID.Contains(pcmsid)).OrderByDescending(p => p.createdate).Take(300).ToList(); } } ViewBag.pcmsid = pcmsid; return(View(dto)); }