public void ExecExecConfirmData(int urpchSn) { IEnumerable <uRolePowerConfirmHistoryConfirmData> urpchcdie = db.uRolePowerConfirmHistoryConfirmData.Where(n => n.uRolePowerConfirmHistorySn == urpchSn).ToList(); foreach (var urpchcd in urpchcdie) { //Table UserNews if (urpchcd.cTableName == "UserNews") { ConfirmCRUD <UserNews> crudUserNews = new ConfirmCRUD <UserNews>(); if (urpchcd.execAction == SaveExecConfirmDataModelActionEnum.Create.ToString()) { UserNews newUserNews = new UserNews(); crudUserNews.ExecConfirmAction(db, urpchcd, newUserNews); } else if (urpchcd.execAction == SaveExecConfirmDataModelActionEnum.Update.ToString() || urpchcd.execAction == SaveExecConfirmDataModelActionEnum.Remove.ToString()) { int usn = Convert.ToInt32(urpchcd.primaryColumnValue); UserNews newUserNews = db.UserNews.Where(n => n.sn == usn).FirstOrDefault(); crudUserNews.ExecConfirmAction(db, urpchcd, newUserNews); } db.SaveChanges(); } //Table UserNewsUrls if (urpchcd.cTableName == "UserNewsUrls") { ConfirmCRUD <UserNewsUrls> crudUserNewsUrls = new ConfirmCRUD <UserNewsUrls>(); if (urpchcd.execAction == SaveExecConfirmDataModelActionEnum.Create.ToString()) { UserNewsUrls newUserNewsUrls = new UserNewsUrls(); crudUserNewsUrls.ExecConfirmAction(db, urpchcd, newUserNewsUrls); } else if (urpchcd.execAction == SaveExecConfirmDataModelActionEnum.Update.ToString() || urpchcd.execAction == SaveExecConfirmDataModelActionEnum.Remove.ToString()) { int usn = Convert.ToInt32(urpchcd.primaryColumnValue); UserNewsUrls newUserNewsUrls = db.UserNewsUrls.Where(n => n.UserNewsUrlsID == usn).FirstOrDefault(); crudUserNewsUrls.ExecConfirmAction(db, urpchcd, newUserNewsUrls); } db.SaveChanges(); } //Table UserNewsUrls if (urpchcd.cTableName == "AspNetUsers") { ConfirmCRUD <AspNetUsers> crudAspNetUserss = new ConfirmCRUD <AspNetUsers>(); if (urpchcd.execAction == SaveExecConfirmDataModelActionEnum.Create.ToString()) { AspNetUsers newAspNetUsers = new AspNetUsers(); crudAspNetUserss.ExecConfirmAction(db, urpchcd, newAspNetUsers); } else if (urpchcd.execAction == SaveExecConfirmDataModelActionEnum.Update.ToString() || urpchcd.execAction == SaveExecConfirmDataModelActionEnum.Remove.ToString()) { string usn = urpchcd.primaryColumnValue; AspNetUsers newAspNetUsers = db.AspNetUsers.Where(n => n.Id == usn).FirstOrDefault(); crudAspNetUserss.ExecConfirmAction(db, urpchcd, newAspNetUsers); } db.SaveChanges(); } } }
public void ExecConfirmIsEnd(int urpchSn) { uRolePowerConfirmHistory urpchCk = db.uRolePowerConfirmHistory.Where(n => n.urpchSn == urpchSn).First(); IEnumerable <UserNewsConfirmList> unclList = db.UserNewsConfirmList.Where(n => n.uRolePowerConfirmHistorySn == urpchSn).ToList(); //1.通知欲執行權限者結果 //2.將所有已覆核/為覆核通知設定結束 //3.將其通知改為已結束 未讀 附帶defaultAct //完成覆核 int tmpunsSn = unclList.First().UserNewsSn; UserNews getOneNews = db.UserNews.Where(n => n.sn == tmpunsSn).FirstOrDefault(); string strCResult = urpchCk.state == 2 ? "核准" : "否決"; string returnUserConfirmResult = "<b>覆核結果為'" + strCResult + "'</b>"; string returnUser = getOneNews.fromUser; string returnMsgTitle = getOneNews.msgTitle; string returnMsgContent = "<div style='border:1px solid black;margin: 2px'>" + "<p>" + returnUserConfirmResult + "</p>" + "<div style='border:1px solid black;margin: 2px'>" + getOneNews.msgContent + "</div>" + "</div>"; HubServerMethods returnUserHM = new HubServerMethods(); returnUserHM.SendMessageToUser(true, returnUser, returnMsgTitle, returnMsgContent, ""); if (urpchCk.state == 2 || urpchCk.state == -2) { if (urpchCk.state == 2) { ExecExecConfirmData(urpchCk.urpchSn); } foreach (UserNewsConfirmList uncl in unclList) { UserNews un = db.UserNews.Where(n => n.sn == uncl.UserNewsSn).FirstOrDefault(); IEnumerable <UserNewsUrls> unuie = db.UserNewsUrls.Where(n => n.UserNewsSn == uncl.UserNewsSn); //設定通知覆核結果 un.read = false; //string strCResult = urpchCk.state == 2 ? "核准" : "否決"; string confirmResult = "<b>覆核結果為'" + strCResult + "',"; if (unuie.Count() == 1) { confirmResult += "您已參與此次覆核,您的選擇為'" + unuie.First().UserNewsTitle + "'。"; } else { confirmResult += "您未參與此次覆核。"; } confirmResult += "</b>"; un.msgContent = "<div style='border:1px solid black;margin: 2px'>" + "<p>" + confirmResult + "</p>" + "<div style='border:1px solid black;margin: 2px'>" + un.msgContent + "</div>" + "</div>"; un.noDefaultAction = null; foreach (var unu in unuie) { db.UserNewsUrls.Remove(unu); } } db.SaveChanges(); } }