pUSH CHANGES
This commit is contained in:
@ -28,6 +28,7 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
UserUtilities userDMO = new UserUtilities();
|
||||
UserAccountDMO originalUserDMO = new UserAccountDMO();
|
||||
TrainingDMO trainingDMO = new TrainingDMO();
|
||||
MiscDMO miscDMO = new MiscDMO();
|
||||
|
||||
|
||||
/// <summary>
|
||||
@ -700,6 +701,101 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
}
|
||||
|
||||
}
|
||||
public bool ApprovalsReminderNotifications()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Get list of approvals
|
||||
List<ApproveListModel> approveList = miscDMO.GetApprovalReminderList();
|
||||
|
||||
foreach (var item in approveList)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
NotifyApprover(item.AssignedEmail, item.Title, item.IssueID, item.DocType);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
EventLogDMO.Add(new WinEventLog() { IssueID = item.ApprovalKey, UserID = "SYSTEM", DocumentType = "Approval Reminders", OperationType = "Email", Comments = e.Message });
|
||||
}
|
||||
//We want to update the last notification anyway so we don't continue trying on something that may be failing.
|
||||
miscDMO.UpdateApprovalNotifyDate(item.ApprovalKey);
|
||||
}
|
||||
// List<ApproveListModel> approveList = miscDMO.
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public void NotifyApprover(string toEmail, string title, int issueId, string docType)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
string emailSentList = "";
|
||||
//List<string> emailIst = ldDMO.GetApproverEmailList(@issueID, currentStep).Distinct().ToList();
|
||||
//List<string> emailIst = MiscDMO.GetApproverEmailListByDocument(@ecnNumber, currentStep, documentType).Distinct().ToList();
|
||||
//string ecnCreatedByEmail = MiscDMO.GetEmail(ecnCreatedById);
|
||||
|
||||
string emailTemplate = "ApprovalReminders.txt";
|
||||
string userEmail = string.Empty;
|
||||
string subject = string.Empty;
|
||||
string senderName = docType;
|
||||
|
||||
subject = docType + " Approval Reminder: " + title;
|
||||
|
||||
EmailNotification en = new EmailNotification(subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
|
||||
string[] emailparams = new string[4];
|
||||
emailparams[0] = docType;
|
||||
emailparams[1] = title;
|
||||
emailparams[2] = issueId.ToString();
|
||||
userEmail = toEmail;
|
||||
|
||||
//#if(DEBUG)
|
||||
//string SenderEmail = "MesaFabApproval@infineon.com";
|
||||
//userEmail = "jonathan.ouellette@infineon.com";
|
||||
//#endif
|
||||
|
||||
en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, userEmail, "jonathan.ouellette@infineon.com", subject, emailparams);
|
||||
//en.SendNotificationEmail(emailTemplate, SenderEmail, senderName, userEmail, null, subject, emailparams);
|
||||
//emailSentList = ecnCreatedByEmail;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
EventLogDMO.Add(new WinEventLog() { IssueID = issueId, UserID = @User.Identity.Name, DocumentType = docType, OperationType = "Email", Comments = "Approval reminders" });
|
||||
}
|
||||
catch { }
|
||||
|
||||
//EmailNotification en = new EmailNotification(subject, ConfigurationManager.AppSettings["EmailTemplatesPath"]);
|
||||
//string[] emailparams = new string[4];
|
||||
//emailparams[0] = issueID.ToString();
|
||||
//emailparams[1] = issueID.ToString();
|
||||
//emailparams[2] = GlobalVars.hostURL;
|
||||
//emailparams[3] =Session[GlobalVars.SESSION_USERNAME].ToString();
|
||||
//en.SendNotificationEmail(emailTemplate, GlobalVars.SENDER_EMAIL, senderName, emailIst, null, subject, emailparams);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
string detailedException = "";
|
||||
try
|
||||
{
|
||||
detailedException = e.InnerException.ToString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
detailedException = e.Message;
|
||||
}
|
||||
EventLogDMO.Add(new WinEventLog() { IssueID = issueId, UserID = @User.Identity.Name, DocumentType = docType, OperationType = "Email", Comments = "Approval reminders" });
|
||||
throw e;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -72,6 +72,15 @@ namespace Fab2ApprovalSystem.Controllers
|
||||
{
|
||||
return request.CreateResponse(HttpStatusCode.InternalServerError);
|
||||
}
|
||||
case "ApprovalReminders":
|
||||
if (homeFunctions.ApprovalsReminderNotifications())
|
||||
{
|
||||
return request.CreateResponse(HttpStatusCode.OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
return request.CreateResponse(HttpStatusCode.InternalServerError);
|
||||
}
|
||||
default:
|
||||
return request.CreateResponse(HttpStatusCode.InternalServerError, "Action Not Found");
|
||||
|
||||
|
@ -13,7 +13,7 @@ using Fab2ApprovalSystem.ViewModels;
|
||||
|
||||
namespace Fab2ApprovalSystem.DMO
|
||||
{
|
||||
public static class MiscDMO
|
||||
public class MiscDMO
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
@ -626,7 +626,20 @@ namespace Fab2ApprovalSystem.DMO
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
public List<ApproveListModel> GetApprovalReminderList()
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
var approvals = db.Query<ApproveListModel>("GetApprovalForNotifcation", null, commandType: CommandType.StoredProcedure).ToList();
|
||||
return approvals;
|
||||
}
|
||||
public void UpdateApprovalNotifyDate(int approvalId)
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@ApprovalId", approvalId);
|
||||
db.Query<CredentialsStorage>("UpdateApprovalLastNotifyDate", param: parameters, commandType: CommandType.StoredProcedure).Single();
|
||||
//return data;
|
||||
}
|
||||
//================================================================== End of Class
|
||||
}
|
||||
}
|
||||
|
24
Fab2ApprovalSystem/EmailTemplates/ApprovalReminders.txt
Normal file
24
Fab2ApprovalSystem/EmailTemplates/ApprovalReminders.txt
Normal file
@ -0,0 +1,24 @@
|
||||
<font size="2" face="verdana">
|
||||
*****Please DO NOT reply to this email*****
|
||||
<br/><br/>
|
||||
This is a reminder that you have an Approval waiting for you to review.
|
||||
<br/><br/>
|
||||
|
||||
Please log on to the Mesa Approval website to view the assignment and act accordingly.
|
||||
<br/><br/>
|
||||
|
||||
Document Type: {0}
|
||||
<br/>
|
||||
Title: {1}
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
http://messa016ec.ec.local:8021/{0}/Edit?IssueID={2}
|
||||
<br/><br/>
|
||||
|
||||
If you have any questions or trouble logging on please contact a site administrator.
|
||||
<br/><br/>
|
||||
Thank you!
|
||||
|
||||
|
||||
</font>
|
@ -54,11 +54,11 @@
|
||||
<HintPath>..\..\..\..\Utilities\SSRSHelper\Release\DocumentFormat.OpenXml.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Kendo.Mvc">
|
||||
<HintPath>D:\Fab2ApprovalSystem\Kendo.Mvc.dll</HintPath>
|
||||
<HintPath>..\Kendo\Mvc5\Kendo.Mvc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="SSRSHelper">
|
||||
<HintPath>D:\Fab2ApprovalSystem\SSRSHelper.dll</HintPath>
|
||||
<HintPath>..\references\SSRSHelper.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
@ -146,6 +146,7 @@
|
||||
<Compile Include="Models\AllUserModel.cs" />
|
||||
<Compile Include="Models\ApprovalLog.cs" />
|
||||
<Compile Include="Models\ApprovalLogHistory.cs" />
|
||||
<Compile Include="Models\ApproveListModel.cs" />
|
||||
<Compile Include="Models\ChangeControlModel.cs" />
|
||||
<Compile Include="Models\Common.cs" />
|
||||
<Compile Include="Models\C_8DAuditedStandard.cs">
|
||||
@ -338,6 +339,7 @@
|
||||
<Content Include="Content\kendo\kendo.rtl.min.css" />
|
||||
<Content Include="Content\kendo\kendo.silver.min.css" />
|
||||
<Content Include="Content\kendo\kendo.uniform.min.css" />
|
||||
<Content Include="EmailTemplates\ApprovalReminders.txt" />
|
||||
<Content Include="EmailTemplates\CorrectiveActionAICompleted.txt" />
|
||||
<Content Include="EmailTemplates\CorrectiveActionCompleted.txt" />
|
||||
<Content Include="EmailTemplates\CorrectiveActionSectionApproved.txt" />
|
||||
|
22
Fab2ApprovalSystem/Models/ApproveListModel.cs
Normal file
22
Fab2ApprovalSystem/Models/ApproveListModel.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Fab2ApprovalSystem.Models
|
||||
{
|
||||
public class ApproveListModel
|
||||
{
|
||||
public int ApprovalKey { get; set; }
|
||||
public int IssueID { get; set; }
|
||||
public string AssignedName { get; set; }
|
||||
public string AssignedEmail { get; set; }
|
||||
public string AssignedFullName { get; set; }
|
||||
public DateTime LastNotification { get; set; }
|
||||
public DateTime AssignedDate { get; set; }
|
||||
public DateTime RoleAssignedDate { get; set; }
|
||||
public string DocType { get; set; }
|
||||
public string Title { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -7,12 +7,12 @@ by editing this MSBuild file. In order to learn more about this please visit htt
|
||||
<PropertyGroup>
|
||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||
<PublishProvider>FileSystem</PublishProvider>
|
||||
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
|
||||
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||
<SiteUrlToLaunchAfterPublish />
|
||||
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
|
||||
<ExcludeApp_Data>False</ExcludeApp_Data>
|
||||
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
|
||||
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||
<publishUrl>C:\Users\Ouellette\Desktop\FabApprovalDeployDev</publishUrl>
|
||||
<DeleteExistingFiles>True</DeleteExistingFiles>
|
||||
<DeleteExistingFiles>true</DeleteExistingFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
Reference in New Issue
Block a user