Clean up training assignments through report
This commit is contained in:
parent
c97ce37238
commit
603052d7e5
@ -23,7 +23,6 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public AccountController(UserManager<ApplicationUser> userManager)
|
||||
{
|
||||
UserManager = userManager;
|
||||
@ -78,7 +77,6 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
isLoginValid = Functions.IFX_ADAuthenticate(model.LoginID, model.Password);
|
||||
isIFX = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -102,7 +100,6 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
{
|
||||
ModelState.AddModelError("", "The user name does not exist in the DB. Please contact the System Admin");
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -202,7 +199,9 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
|
||||
//
|
||||
// GET: /Account/Manage
|
||||
#pragma warning disable IDE0060 // Remove unused parameter
|
||||
public ActionResult Manage(ManageMessageId? message)
|
||||
#pragma warning restore IDE0060 // Remove unused parameter
|
||||
{
|
||||
//ViewBag.StatusMessage =
|
||||
// message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
|
||||
|
@ -15,8 +15,6 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Fab2ApprovalSystem.Controllers
|
||||
{
|
||||
|
||||
|
||||
[Authorize]
|
||||
[SessionExpireFilter]
|
||||
public class TrainingController : Controller
|
||||
@ -44,7 +42,6 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
trainingDMO.DeleteTraining(oldTrainingId);
|
||||
}
|
||||
|
||||
|
||||
int trainingId = trainingDMO.Create(ecnId);
|
||||
List<int> TrainingGroups = new List<int>();
|
||||
TrainingGroups = trainingDMO.GetECNAssignedTrainingGroups(ecnId);
|
||||
@ -61,8 +58,6 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
int assignmentId = trainingDMO.CreateAssignment(trainingId, trainee);
|
||||
NotifyTrainee(trainee, assignmentId, ecnId, ECNTitle);
|
||||
}
|
||||
|
||||
|
||||
return trainingId;
|
||||
}
|
||||
public ActionResult AddUserToTrainingAdHoc(int trainingId, int traineeId, int ecnId)
|
||||
@ -114,7 +109,6 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
{
|
||||
return Content("User already has an open or completed assignment for this training.");
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -135,9 +129,8 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
{
|
||||
return Content("Not Authorized");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ActionResult AddGroupToTrainingAdHoc(int trainingId, int groupId, int ecnId)
|
||||
{
|
||||
if ((bool)Session[GlobalVars.IS_ADMIN])
|
||||
@ -166,13 +159,11 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
int assignmentId = trainingDMO.CreateAssignment(trainingId, id);
|
||||
NotifyTrainee(id, assignmentId, ecnId, ecn.Title);
|
||||
}
|
||||
|
||||
}
|
||||
if (usersAdded > 0)
|
||||
{
|
||||
trainingDMO.reOpenTraining(trainingId);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -188,13 +179,13 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
}
|
||||
}
|
||||
}
|
||||
if(usersAdded > 0)
|
||||
if (usersAdded > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
trainingDMO.AddTrainingGroupToECN(ecnId, groupId);
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
return Content(e.ToString());
|
||||
}
|
||||
@ -220,8 +211,6 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
{
|
||||
return Content("Not Authorized");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public ActionResult DeleteTrainingByECN(int ECNNumber)
|
||||
{
|
||||
@ -258,20 +247,20 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
|
||||
subject = "ECN# " + ecnId + " - Training Assignment Notice - " + title;
|
||||
|
||||
EmailNotification en = new EmailNotification(subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
|
||||
//string emailparams = "";
|
||||
userEmail = recipient;
|
||||
string[] emailparams = new string[4];
|
||||
emailparams[0] = assignmentId.ToString();
|
||||
emailparams[1] = ecnId.ToString();
|
||||
emailparams[2] = GlobalVars.hostURL;
|
||||
EmailNotification en = new EmailNotification(subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
|
||||
//string emailparams = "";
|
||||
userEmail = recipient;
|
||||
string[] emailparams = new string[4];
|
||||
emailparams[0] = assignmentId.ToString();
|
||||
emailparams[1] = ecnId.ToString();
|
||||
emailparams[2] = GlobalVars.hostURL;
|
||||
//#if(DEBUG)
|
||||
//string SenderEmail = "MesaFabApproval@infineon.com";
|
||||
//userEmail = "jonathan.ouellette@infineon.com";
|
||||
//#endif
|
||||
|
||||
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, null, subject, emailparams);
|
||||
//en.SendNotificationEmail(emailTemplate, SenderEmail, senderName, userEmail, null, subject, emailparams);
|
||||
//en.SendNotificationEmail(emailTemplate, SenderEmail, senderName, userEmail, null, subject, emailparams);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -285,9 +274,8 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
detailedException = e.Message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ActionResult ViewTrainingPartial(int trainingID, int userID)
|
||||
{
|
||||
List<TrainingAssignment> TrainingData = trainingDMO.GetTrainingAssignmentsByUser(trainingID, userID);
|
||||
@ -329,9 +317,6 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
string exception = e.ToString();
|
||||
return Content(exception);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,9 +403,6 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
{
|
||||
return PartialView(trainingList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
public ActionResult ViewTrainingAssignmentsReportView(int trainingID, string statusFilter, string groupFilter)
|
||||
{
|
||||
@ -445,9 +427,11 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
totalCompleted++;
|
||||
}
|
||||
}
|
||||
#pragma warning disable IDE0047 // Remove unnecessary parentheses
|
||||
percentComplete = (totalCompleted / assignmentCount) * 100;
|
||||
#pragma warning restore IDE0047 // Remove unnecessary parentheses
|
||||
ViewBag.PercentComplete = percentComplete.ToString("0.00") + "%";
|
||||
|
||||
|
||||
if (groupFilter != "" && groupFilter != null)
|
||||
{
|
||||
ViewBag.GroupFilter = groupFilter;
|
||||
@ -455,7 +439,7 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
List<int> groupMemberIds = trainingDMO.GetTrainees(Convert.ToInt32(groupFilter));
|
||||
foreach (var assignment in trainingAssignments)
|
||||
{
|
||||
if(trainingDMO.isUserTrainingMember(Convert.ToInt32(groupFilter), assignment.UserID))
|
||||
if (trainingDMO.isUserTrainingMember(Convert.ToInt32(groupFilter), assignment.UserID))
|
||||
{
|
||||
groupFilteredTraining.Add(assignment);
|
||||
}
|
||||
@ -468,7 +452,7 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
List<TrainingAssignment> filteredTraining = new List<TrainingAssignment>();
|
||||
switch (statusFilter)
|
||||
{
|
||||
|
||||
|
||||
case "1":
|
||||
//Completed
|
||||
filteredTraining = (from a in trainingAssignments where a.status == true && a.Deleted != true select a).ToList();
|
||||
@ -503,7 +487,7 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
ViewBag.AllUsers = userDMO.GetAllActiveUsers();
|
||||
ViewBag.AllGroups = trainingDMO.GetTrainingGroups();
|
||||
IEnumerable<TrainingAssignment> trainingAssignments = trainingDMO.GetTrainingAssignments(trainingID);
|
||||
|
||||
|
||||
return View(trainingAssignments);
|
||||
}
|
||||
/// <summary>
|
||||
@ -530,11 +514,8 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
DateAssigned = assignment.DateAssigned,
|
||||
DateCompleted = assignment.DateCompleted,
|
||||
Status = assignment.status
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return View(ViewData);
|
||||
@ -580,8 +561,8 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
ViewBag.AllGroups = trainingDMO.GetTrainingGroups();
|
||||
return View(AllTrainings);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
public ActionResult ViewAllTrainings()
|
||||
{
|
||||
@ -630,7 +611,7 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
ECN ecn = ecnDMO.GetECN(ecnId);
|
||||
if (ecn != null)
|
||||
{
|
||||
if(ecn.CloseDate != null)
|
||||
if (ecn.CloseDate != null)
|
||||
{
|
||||
if (newTrainingGroupIds.Count > 0)
|
||||
{
|
||||
@ -643,12 +624,12 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
{
|
||||
trainingDMO.AddTrainingGroupToECN(ecnId, trainingId);
|
||||
}
|
||||
|
||||
|
||||
trainingDMO.SetTrainingFlag(ecnId);
|
||||
Create(ecnId);
|
||||
return Content("Success");
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
return Content("Failed: " + e.Message.ToString());
|
||||
}
|
||||
@ -677,9 +658,9 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
public ActionResult CheckECN(int ecnId)
|
||||
{
|
||||
ECN ecn = ecnDMO.GetECN(ecnId);
|
||||
if(ecn != null)
|
||||
if (ecn != null)
|
||||
{
|
||||
if(ecn.CloseDate != null)
|
||||
if (ecn.CloseDate != null)
|
||||
{
|
||||
List<int> trainingGroupIds = trainingDMO.GetECNAssignedTrainingGroups(ecnId);
|
||||
List<TrainingGroup> assignedGroups = new List<TrainingGroup>();
|
||||
@ -772,5 +753,5 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
return isSuccess;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -154,6 +154,21 @@ namespace Fab2ApprovalSystem.DMO
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
var TrainingData = from a in db.TrainingAssignments where a.TrainingID == TrainingID select a;
|
||||
|
||||
bool assignmentIsIncomplete = false;
|
||||
UserAccountDMO userAccountDMO = new UserAccountDMO();
|
||||
foreach (TrainingAssignment assignment in TrainingData)
|
||||
{
|
||||
LoginModel userModel = userAccountDMO.GetUserByID(assignment.UserID);
|
||||
if (!userModel.IsActive) UpdateAssignmentStatus(assignment.ID);
|
||||
if (assignment.Deleted != true && (assignment.DateCompleted is null || assignment.DateCompleted > DateTime.Now))
|
||||
assignmentIsIncomplete = true;
|
||||
}
|
||||
|
||||
if (!assignmentIsIncomplete)
|
||||
UpdateTrainingStatus(TrainingID);
|
||||
|
||||
TrainingData = from a in db.TrainingAssignments where a.TrainingID == TrainingID select a;
|
||||
|
||||
return TrainingData.ToList();
|
||||
}
|
||||
public List<TrainingAssignment> GetTrainingAssignments(int TrainingID)
|
||||
@ -161,6 +176,21 @@ namespace Fab2ApprovalSystem.DMO
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
var TrainingData = from a in db.TrainingAssignments where a.TrainingID == TrainingID && a.Deleted != true select a;
|
||||
|
||||
bool assignmentIsIncomplete = false;
|
||||
UserAccountDMO userAccountDMO = new UserAccountDMO();
|
||||
foreach (TrainingAssignment assignment in TrainingData)
|
||||
{
|
||||
LoginModel userModel = userAccountDMO.GetUserByID(assignment.UserID);
|
||||
if (!userModel.IsActive) UpdateAssignmentStatus(assignment.ID);
|
||||
if (assignment.Deleted != true && (assignment.DateCompleted is null || assignment.DateCompleted > DateTime.Now))
|
||||
assignmentIsIncomplete = true;
|
||||
}
|
||||
|
||||
if (!assignmentIsIncomplete)
|
||||
UpdateTrainingStatus(TrainingID);
|
||||
|
||||
TrainingData = from a in db.TrainingAssignments where a.TrainingID == TrainingID select a;
|
||||
|
||||
return TrainingData.ToList();
|
||||
}
|
||||
public List<TrainingAssignment> GetTrainingAssignmentsByUser(int TrainingID, int userID)
|
||||
|
@ -20,10 +20,14 @@
|
||||
<IISExpressAnonymousAuthentication />
|
||||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
<SccProjectName>
|
||||
</SccProjectName>
|
||||
<SccLocalPath>
|
||||
</SccLocalPath>
|
||||
<SccAuxPath>
|
||||
</SccAuxPath>
|
||||
<SccProvider>
|
||||
</SccProvider>
|
||||
<UseGlobalApplicationHostFile />
|
||||
<Use64BitIISExpress>true</Use64BitIISExpress>
|
||||
<TargetFrameworkProfile />
|
||||
|
Loading…
x
Reference in New Issue
Block a user