public void UpdateChangeReqstApproval() { //find not signed=2 status code in all activities table //if we do not find it then all are signed as there will be two status 1=signed 2=not signed int ownrnotsgnedactvty = 0; int aprvrnotsgnedactvty = 0; int rvwrnotsgnedactvty = 0; using (var dbctx = new RadiantSOPEntities()) { ownrnotsgnedactvty = dbctx.fileownersactivities.Where(o => o.changerequestid == ChangeRequestID && o.approvalstatuscode == 2).Select(o => o.owneractivityid).FirstOrDefault(); aprvrnotsgnedactvty = dbctx.fileapproversactivities.Where(o => o.changerequestid == ChangeRequestID && o.approvalstatuscode == 2).Select(o => o.approveractivityid).FirstOrDefault(); rvwrnotsgnedactvty = dbctx.filereviewersactivities.Where(o => o.changerequestid == ChangeRequestID && o.approvalstatuscode == 2).Select(o => o.revieweractivityid).FirstOrDefault(); //if all signed the SOP then update then update changeactivity table with signed status //so approver can publish the SOP if (ownrnotsgnedactvty == 0 && aprvrnotsgnedactvty == 0 && rvwrnotsgnedactvty == 0) { var result = dbctx.filechangerequestactivities.SingleOrDefault(b => b.changerequestid == ChangeRequestID); if (result != null) { result.approvalstatuscode = 1; //1=signed result.statusdatetime = DateTime.Today; dbctx.SaveChanges(); } } } }
public bool UpdateSignatures() { bool success = false; SOPClass oSOP = new SOPClass(); oSOP.SiteUrl = Utility.GetSiteUrl(); oSOP.FileID = FileID; oSOP.FileChangeRqstID = ChangeRequestID; // oSOP.GetSOPInfoByFileID(); oSOP.GetSOPInfo(); using (var dbcontext = new RadiantSOPEntities()) { if (LoggedInSignedAsOwner) { var result = dbcontext.fileownersactivities.SingleOrDefault(b => b.owneractivityid == OwnerActivityID); if (result != null) { result.approvalstatuscode = 1; //1=signed result.statusdatetime = DateTime.Today; dbcontext.SaveChanges(); success = true; } if (success) { int ownerid = 0; int ownershipid = 0; string owneremail = ""; bool removecontr = true; ownershipid = Convert.ToInt32(dbcontext.fileownersactivities.Where(o => o.owneractivityid == OwnerActivityID && o.changerequestid == ChangeRequestID).Select(o => o.ownershipid).FirstOrDefault()); ownerid = dbcontext.fileowners.Where(o => o.ownershipid == ownershipid && o.ownerstatuscode == 1).Select(o => o.ownerid).FirstOrDefault(); // fileid = dbcontext.fileowners.Where(o => o.ownershipid == ownershipid && o.ownerstatuscode == 1).Select(o => o.fileid).FirstOrDefault(); owneremail = dbcontext.vwUsers.Where(u => u.userid1 == ownerid).Select(o => o.useremailaddress).FirstOrDefault(); //first check if this owener is approver or reviewer and have signed it or not //if this person signs in all group then remove contribute and give read permission //if this person does not sign in any approver group then don't remove contribute permission if (owneremail.Trim().ToLower() == oSOP.FileApproverEmail.Trim().ToLower()) { if (oSOP.FileApprover.signstatuscode == 2) //has not signed as approver so keep contribute permission { removecontr = false; } } //if signed as approver then check if same person is reviewer and has not signed, if so do not remove contribute foreach (Employee rvwr in oSOP.FileReviewers) { if (owneremail.Trim().ToLower() == rvwr.useremailaddress.Trim().ToLower()) { if (rvwr.signstatuscode == 2) //has not signed as reviewer so keep contribute { removecontr = false; } break; } } if (removecontr) { oSOP.AssignFilePermissionToUsers("contribute", "remove", owneremail.Trim().ToLower()); // System.Threading.Thread.Sleep(3000); oSOP.AssignFilePermissionToUsers("View Only", "add", owneremail.Trim().ToLower()); } } //end checking success of signing } if (LoggedInSignedAsApprover) { oSOP.GetSOPInfo(); var result = dbcontext.fileapproversactivities.SingleOrDefault(b => b.approveractivityid == ApproverActivityID); if (result != null) { result.approvalstatuscode = 1; //1=signed result.statusdatetime = DateTime.Today; dbcontext.SaveChanges(); success = true; } if (success) { int apporverid = 0; int approveid = 0; string approveremail = ""; bool removecontr = true; approveid = Convert.ToInt32(dbcontext.fileapproversactivities.Where(o => o.approveractivityid == ApproverActivityID && o.changerequestid == ChangeRequestID).Select(o => o.approveid).FirstOrDefault()); apporverid = dbcontext.fileapprovers.Where(o => o.approveid == approveid && o.approverstatuscode == 1).Select(o => o.approverid).FirstOrDefault(); // fileid = dbcontext.fileowners.Where(o => o.ownershipid == ownershipid && o.ownerstatuscode == 1).Select(o => o.fileid).FirstOrDefault(); approveremail = dbcontext.vwUsers.Where(u => u.userid1 == apporverid).Select(o => o.useremailaddress).FirstOrDefault(); if (approveremail.Trim().ToLower() == oSOP.FileOwnerEmail.Trim().ToLower()) { if (oSOP.FileOwner.signstatuscode == 2) //has not signed as owner so keep contribute permission { removecontr = false; } } //if signed as approver then check if same person is reviewer and has not signed, if so do not remove contribute foreach (Employee rvwr in oSOP.FileReviewers) { if (approveremail.Trim().ToLower() == rvwr.useremailaddress.Trim().ToLower()) { if (rvwr.signstatuscode == 2) //has not signed as reviewer so keep contribute { removecontr = false; } break; } } if (removecontr) { oSOP.AssignFilePermissionToUsers("contribute", "remove", approveremail.Trim().ToLower()); // System.Threading.Thread.Sleep(3000); oSOP.AssignFilePermissionToUsers("View Only", "add", approveremail.Trim().ToLower()); } } } if (LoggedInSignedAsReviewer) { oSOP.GetSOPInfo(); var result = dbcontext.filereviewersactivities.SingleOrDefault(b => b.revieweractivityid == ReviewerActivityID); if (result != null) { result.approvalstatuscode = 1; //1=signed result.statusdatetime = DateTime.Today; dbcontext.SaveChanges(); success = true; } if (success) { int reviewerid = 0; int reviewid = 0; string revieweremail = ""; bool removecontr = true; reviewid = Convert.ToInt32(dbcontext.filereviewersactivities.Where(o => o.revieweractivityid == ReviewerActivityID && o.changerequestid == ChangeRequestID).Select(o => o.reviewid).FirstOrDefault()); reviewerid = dbcontext.filereviewers.Where(o => o.reviewid == reviewid && o.reviewerstatuscode == 1).Select(o => o.reviewerid).FirstOrDefault(); // fileid = dbcontext.fileowners.Where(o => o.ownershipid == ownershipid && o.ownerstatuscode == 1).Select(o => o.fileid).FirstOrDefault(); revieweremail = dbcontext.vwUsers.Where(u => u.userid1 == reviewerid).Select(o => o.useremailaddress).FirstOrDefault(); if (revieweremail.Trim().ToLower() == oSOP.FileOwnerEmail.Trim().ToLower()) { if (oSOP.FileOwner.signstatuscode == 2) //has not signed as owner so keep contribute permission { removecontr = false; } } if (revieweremail.Trim().ToLower() == oSOP.FileApproverEmail.Trim().ToLower()) { if (oSOP.FileApprover.signstatuscode == 2) //has not signed as approver so keep contribute permission { removecontr = false; } } if (removecontr) { oSOP.AssignFilePermissionToUsers("contribute", "remove", revieweremail.Trim().ToLower()); // System.Threading.Thread.Sleep(3000); oSOP.AssignFilePermissionToUsers("View Only", "add", revieweremail.Trim().ToLower()); } } } } oSOP = null; return(success); }