initial add
This commit is contained in:
310
Fab2ApprovalSystem/DMO/AdminDMO.cs
Normal file
310
Fab2ApprovalSystem/DMO/AdminDMO.cs
Normal file
@ -0,0 +1,310 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Dapper;
|
||||
using Fab2ApprovalSystem.Models;
|
||||
using System.Text;
|
||||
|
||||
namespace Fab2ApprovalSystem.DMO
|
||||
{
|
||||
public class AdminDMO
|
||||
{
|
||||
private IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
private static FabApprovalTrainingEntities FabApprovalDB = new FabApprovalTrainingEntities();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<Role> GetSubRoles()
|
||||
{
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.Append(
|
||||
"SELECT R.RoleID, R.RoleName, SubRoleID, SubRoleCategoryItem, SR.RoleID, SR.Inactive " +
|
||||
"FROM vSubRoles SR " +
|
||||
"INNER JOIN Role R ON R.RoleID = SR.RoleID " +
|
||||
"ORDER BY R.RoleID, SubRoleCategoryItem ");
|
||||
|
||||
db.Open();
|
||||
var lookup = new Dictionary<int, Role>();
|
||||
List<Role> data = this.db.Query<Role, SubRole, Role>(sql.ToString(),
|
||||
(parent, child) =>
|
||||
{
|
||||
Role role;
|
||||
if (!lookup.TryGetValue(parent.RoleID, out role))
|
||||
{
|
||||
lookup.Add(parent.RoleID, role = parent);
|
||||
}
|
||||
//if (role.RoleID == null)
|
||||
// role.SubRoles = new List<SubRole>();
|
||||
role.SubRoles.Add(child);
|
||||
return role;
|
||||
},
|
||||
splitOn: "SubRoleID").Distinct().ToList();
|
||||
|
||||
|
||||
return data;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// /// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public List<UserSubRoles> GetUserSubRoles(int userId)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@UserId", userId);
|
||||
var userSubRoleList = this.db.Query<UserSubRoles>("GetSubRolesByUserId", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return userSubRoleList;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="subRole"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<LoginModel> GetAllUsersBySubRole(int subRole)
|
||||
{
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.Append("SELECT FirstName + ' ' + LastName AS FullName , LoginID, FirstName, LastName, U.UserID, SubRoleID ");
|
||||
sql.Append("FROM UserSubRole UR ");
|
||||
sql.Append("INNER JOIN Users U ON UR.UserID = U.UserID ");
|
||||
sql.Append("WHERE UR.SubRoleID = " + subRole.ToString() + " ");
|
||||
sql.Append("ORDER BY FirstName");
|
||||
|
||||
return this.db.Query<LoginModel>(sql.ToString()).ToList();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="subRole"></param>
|
||||
/// <param name="userids"></param>
|
||||
public void AddUserRoles(int subRole, string userids)
|
||||
{
|
||||
string sql;
|
||||
|
||||
string[] arrayOfUsers = userids.Split(new char[] { '~' });
|
||||
|
||||
for (int i = 0; i < arrayOfUsers.Length; i++)
|
||||
{
|
||||
sql = "INSERT INTO UserSubRole (UserID, SubRoleID) VALUES (" + arrayOfUsers[i] + ", " + subRole + " )";
|
||||
this.db.Execute(sql);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void DeleteUserFromAllTrainingGroups(int userId)
|
||||
{
|
||||
string sql = "DELETE FROM TrainingGroupMembers WHERE UserId = " + userId;
|
||||
|
||||
|
||||
this.db.Open();
|
||||
this.db.Execute(sql);
|
||||
return;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="subRole"></param>
|
||||
/// <param name="userids"></param>
|
||||
public void DeleteUserRoles(int subRole, string userids)
|
||||
{
|
||||
string sql;
|
||||
|
||||
string[] arrayOfUsers = userids.Split(new char[] { '~' });
|
||||
|
||||
for (int i = 0; i < arrayOfUsers.Length; i++)
|
||||
{
|
||||
sql = "DELETE FROM UserSubRole WHERE UserID = " + arrayOfUsers[i] + " AND SubRoleID = " + subRole;
|
||||
this.db.Execute(sql);
|
||||
}
|
||||
|
||||
}
|
||||
public List<TrainingReportUser> GetTrainingReportUsers()
|
||||
{
|
||||
List<TrainingReportUser> CurrentReportUsers = (from a in FabApprovalDB.TrainingReportUsers select a).ToList();
|
||||
return CurrentReportUsers;
|
||||
}
|
||||
public List<TECNNotificationsUser> GetTECNNotificationUsers()
|
||||
{
|
||||
List<TECNNotificationsUser> currentTECNNotificationUsers = (from a in FabApprovalDB.TECNNotificationsUsers select a).ToList();
|
||||
return currentTECNNotificationUsers;
|
||||
}
|
||||
|
||||
public void TrainingReportAddUser(int userId)
|
||||
{
|
||||
string sql = "INSERT INTO TrainingReportUsers (UserId) " + "VALUES ('" + userId + "') ";
|
||||
|
||||
|
||||
this.db.Open();
|
||||
this.db.Execute(sql);
|
||||
return;
|
||||
}
|
||||
public void TECNExpirationAddUser(int userId)
|
||||
{
|
||||
string sql = "INSERT INTO TECNNotificationsUsers (UserId) " + "VALUES ('" + userId + "') ";
|
||||
|
||||
this.db.Open();
|
||||
this.db.Execute(sql);
|
||||
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
public void TrainingReportDeleteUser(int userId)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
|
||||
parameters = new DynamicParameters();
|
||||
parameters.Add("@UserID", userId);
|
||||
|
||||
this.db.Execute("DeleteUserFromTrainingReport", parameters, commandType: CommandType.StoredProcedure);
|
||||
return;
|
||||
}
|
||||
public void TECNExpirationDeleteUser(int userId)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
|
||||
parameters = new DynamicParameters();
|
||||
parameters.Add("@UserID", userId);
|
||||
|
||||
this.db.Execute("DeleteUserFromTECNReport", parameters, commandType: CommandType.StoredProcedure);
|
||||
return;
|
||||
}
|
||||
public List<TrainingGroup> GetTrainingGroups()
|
||||
{
|
||||
//StringBuilder sql = new StringBuilder();
|
||||
//sql.Append(
|
||||
// "SELECT 'TrainingGroupID', TrainingGroupName " +
|
||||
// "FROM TrainingGroups " +
|
||||
// "ORDER BY TrainingGroupID ");
|
||||
|
||||
//db.Open();
|
||||
//var lookup = new Dictionary<int, TrainingGroup>();
|
||||
////List<TrainingGroup> data = this.db.Query<TrainingGroup>(sql.ToString()
|
||||
//return this.db.Query<TrainingGroup>(sql.ToString()).ToList();
|
||||
var TrainingGroups = from a in FabApprovalDB.TrainingGroups select a;
|
||||
List<TrainingGroup> GroupsToReturn = TrainingGroups.ToList();
|
||||
|
||||
return GroupsToReturn;
|
||||
}
|
||||
public void AddNewTrainingGroup(string groupName)
|
||||
{
|
||||
TrainingGroup existing = null;
|
||||
//Check to see that the group name doesn't exist.
|
||||
try
|
||||
{
|
||||
existing = (from a in FabApprovalDB.TrainingGroups where a.TrainingGroupName == groupName select a).FirstOrDefault();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// string test = "";
|
||||
}
|
||||
|
||||
|
||||
if (existing == null)
|
||||
{
|
||||
//string sql = new StringBuilder();
|
||||
string sql = "INSERT INTO TrainingGroups (TrainingGroupName) " + "VALUES ('" + groupName + "') ";
|
||||
|
||||
|
||||
this.db.Open();
|
||||
this.db.Execute(sql);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteTrainingGroup(int groupID)
|
||||
{
|
||||
try
|
||||
{
|
||||
string sql = "DELETE FROM TrainingGroups WHERE TrainingGroupID = " + groupID;
|
||||
this.db.Open();
|
||||
this.db.Execute(sql);
|
||||
|
||||
sql = "DELETE FROM TrainingGroupMembers WHERE TrainingGroupID = " + groupID;
|
||||
this.db.Execute(sql);
|
||||
return;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
public List<TrainingGroupMember> GetTrainingGroupMembers(int GroupID)
|
||||
{
|
||||
return (from a in FabApprovalDB.TrainingGroupMembers where a.TrainingGroupID == GroupID select a).ToList();
|
||||
}
|
||||
public void AddUserToGroup(int userId, int groupId)
|
||||
{
|
||||
UserAccountDMO userDB = new UserAccountDMO();
|
||||
string userFullName = userDB.GetUserByID(userId).FullName;
|
||||
|
||||
TrainingGroupMember existing = null;
|
||||
|
||||
existing = (from a in FabApprovalDB.TrainingGroupMembers where a.TrainingGroupID == groupId && a.UserID == userId select a).FirstOrDefault();
|
||||
if (existing == null)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
|
||||
parameters = new DynamicParameters();
|
||||
parameters.Add("@GroupID", groupId);
|
||||
parameters.Add("@UserID", userId);
|
||||
parameters.Add("@UserFullName", userFullName);
|
||||
|
||||
this.db.Execute("AddUserToTrainingGroup", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("The user already exists in this training group.");
|
||||
}
|
||||
|
||||
|
||||
//if (existing == null)
|
||||
//{
|
||||
// //string sql = new StringBuilder();
|
||||
|
||||
// string sql = "INSERT INTO TrainingGroupMembers (TrainingGroupID, UserID, FullName) " + "VALUES ('" + groupId + "','" + userId + "','" + userFullName + "') ";
|
||||
|
||||
// try
|
||||
// {
|
||||
// this.db.Open();
|
||||
// this.db.Execute(sql);
|
||||
// }
|
||||
// catch(Exception e)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// return;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// return;
|
||||
|
||||
}
|
||||
public void DeleteFromGroup(int userId, int groupId)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
|
||||
parameters = new DynamicParameters();
|
||||
parameters.Add("@GroupID", groupId);
|
||||
parameters.Add("@UserID", userId);
|
||||
|
||||
this.db.Execute("DeleteUserFromTrainingGroup", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
32
Fab2ApprovalSystem/DMO/ApprovalLogDMO.cs
Normal file
32
Fab2ApprovalSystem/DMO/ApprovalLogDMO.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using Fab2ApprovalSystem.Models;
|
||||
using Dapper;
|
||||
using System.Configuration;
|
||||
|
||||
namespace Fab2ApprovalSystem.DMO
|
||||
{
|
||||
public static class ApprovalLogDMO
|
||||
{
|
||||
|
||||
private static IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
|
||||
public static void Add(ApprovalLog appLog)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@IssueID", appLog.IssueID);
|
||||
parameters.Add("@UserID", appLog.UserID);
|
||||
parameters.Add("@OperationType", appLog.OperationType);
|
||||
parameters.Add("@SubRoleID", appLog.SubRoleID);
|
||||
parameters.Add("@OperationLog", appLog.OperationLog);
|
||||
parameters.Add("@DocumentTypeID", appLog.DocumentTypeID);
|
||||
|
||||
db.Execute("InsertApprovalLogByDocument", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
658
Fab2ApprovalSystem/DMO/AuditDMO.cs
Normal file
658
Fab2ApprovalSystem/DMO/AuditDMO.cs
Normal file
@ -0,0 +1,658 @@
|
||||
using Dapper;
|
||||
using Fab2ApprovalSystem.Models;
|
||||
using Fab2ApprovalSystem.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Data.Linq;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Transactions;
|
||||
using System.Web;
|
||||
|
||||
namespace Fab2ApprovalSystem.DMO
|
||||
{
|
||||
public class AuditDMO
|
||||
{
|
||||
private IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
WorkflowDMO wfDMO = new WorkflowDMO();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="audit"></param>
|
||||
/// <returns></returns>
|
||||
public Audit InsertAudit(Audit audit)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
|
||||
parameters = new DynamicParameters();
|
||||
parameters.Add("@AuditNo", value: audit.AuditNo, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
|
||||
parameters.Add("@OriginatorID", audit.OriginatorID);
|
||||
|
||||
this.db.Execute("_8DInsertAuditItem", parameters, commandType: CommandType.StoredProcedure);
|
||||
audit.AuditNo = parameters.Get<int>("@AuditNo");
|
||||
|
||||
return audit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="auditNo"></param>
|
||||
/// <param name="isITAR"></param>
|
||||
/// <param name="userID"></param>
|
||||
/// <returns></returns>
|
||||
public Audit GetAuditItem(int auditNo, int userID)
|
||||
{
|
||||
Audit audit = new Audit();
|
||||
|
||||
//isITAR = 2;
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@AuditNo", value: auditNo);
|
||||
parameters.Add("@UserID", userID);
|
||||
//parameters.Add("@IsITAR", value: isITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
|
||||
|
||||
//audit = this.db.Query<Audit>("_8DGetAuditItem", parameters, commandType: CommandType.StoredProcedure).Single();
|
||||
|
||||
|
||||
|
||||
using (var multipleResultItems = this.db.QueryMultiple("_8DGetAuditItem", parameters, commandType: CommandType.StoredProcedure))
|
||||
{
|
||||
audit = multipleResultItems.Read<Audit>().SingleOrDefault();
|
||||
|
||||
var auditors = multipleResultItems.Read<int>().ToList();
|
||||
|
||||
|
||||
if (audit != null && auditors != null)
|
||||
{
|
||||
if (auditors.Count > 0)
|
||||
audit.AuditorIDs.AddRange(auditors);
|
||||
}
|
||||
|
||||
var auditorTypes = multipleResultItems.Read<int>().ToList();
|
||||
if (audit != null && auditorTypes != null)
|
||||
{
|
||||
if (auditorTypes.Count > 0)
|
||||
audit.AuditTypeIDs.AddRange(auditorTypes);
|
||||
}
|
||||
|
||||
var auditorAreas = multipleResultItems.Read<int>().ToList();
|
||||
if (audit != null && auditorAreas != null)
|
||||
{
|
||||
if (auditorAreas.Count > 0)
|
||||
audit.AuditedAreaIDs.AddRange(auditorAreas);
|
||||
}
|
||||
}
|
||||
//FabApprovalSystemEntitiesAll auditDb = new FabApprovalSystemEntitiesAll();
|
||||
|
||||
//var auditedStandardIDs = (from a in auditDb.C_8DAuditedStandardByAudit where a.AuditNo == audit.AuditNo select a.AuditedStandardID).ToList();
|
||||
|
||||
//foreach (var id in auditedStandardIDs)
|
||||
//{
|
||||
// audit.AuditedStandardIDs.Add(id);
|
||||
//}
|
||||
|
||||
return audit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="auditNo"></param>
|
||||
/// <param name="userID"></param>
|
||||
/// <returns></returns>
|
||||
public Audit GetAuditItemReadOnly(int auditNo, int userID)
|
||||
{
|
||||
Audit audit = new Audit();
|
||||
|
||||
//isITAR = 2;
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@AuditNo", value: auditNo);
|
||||
parameters.Add("@UserID", userID);
|
||||
//parameters.Add("@IsITAR", value: isITAR, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
|
||||
|
||||
//audit = this.db.Query<Audit>("_8DGetAuditItem", parameters, commandType: CommandType.StoredProcedure).Single();
|
||||
|
||||
|
||||
|
||||
using (var multipleResultItems = this.db.QueryMultiple("_8DGetAuditItemReadOnly", parameters, commandType: CommandType.StoredProcedure))
|
||||
{
|
||||
audit = multipleResultItems.Read<Audit>().SingleOrDefault();
|
||||
|
||||
var auditors = multipleResultItems.Read<int>().ToList();
|
||||
|
||||
|
||||
if (audit != null && auditors != null)
|
||||
{
|
||||
if (auditors.Count > 0)
|
||||
audit.AuditorIDs.AddRange(auditors);
|
||||
}
|
||||
|
||||
var auditorTypes = multipleResultItems.Read<int>().ToList();
|
||||
if (audit != null && auditorTypes != null)
|
||||
{
|
||||
if (auditorTypes.Count > 0)
|
||||
audit.AuditTypeIDs.AddRange(auditorTypes);
|
||||
}
|
||||
|
||||
var auditorAreas = multipleResultItems.Read<int>().ToList();
|
||||
if (audit != null && auditorAreas != null)
|
||||
{
|
||||
if (auditorAreas.Count > 0)
|
||||
audit.AuditedAreaIDs.AddRange(auditorAreas);
|
||||
}
|
||||
}
|
||||
|
||||
return audit;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<AuditType> GetAuditTypeList()
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
|
||||
|
||||
var auditTypeList = this.db.Query<AuditType>("_8DGetAuditTypeList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return auditTypeList;
|
||||
|
||||
}
|
||||
|
||||
public IEnumerable<C_8DAuditedStandard> GetAuditStandardList()
|
||||
{
|
||||
|
||||
FabApprovalSystemEntitiesAll db = new FabApprovalSystemEntitiesAll();
|
||||
|
||||
var auditStandardList = from a in db.C_8DAuditedStandard select a;
|
||||
|
||||
return auditStandardList;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<Auditor> GetAuditorList()
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
|
||||
|
||||
var auditorList = this.db.Query<Auditor>("_8DGetAuditorList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return auditorList;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<AuditedArea> GetAuditAreaList()
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
|
||||
var auditAreaList = this.db.Query<AuditedArea>("_8DGetAuditAreaList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return auditAreaList;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="audit"></param>
|
||||
public void UpdateAudit(Audit audit, int userID)
|
||||
{
|
||||
int result = 0;
|
||||
var parameters = new DynamicParameters();
|
||||
|
||||
using(var transaction = new TransactionScope())
|
||||
{
|
||||
try
|
||||
{
|
||||
parameters.Add("AuditNo", audit.AuditNo);
|
||||
parameters.Add("Title", audit.AuditTitle);
|
||||
//parameters.Add("AuditTypeID", audit.AuditTypeID);
|
||||
parameters.Add("AuditDate", audit.AuditDate);
|
||||
parameters.Add("AuditStatus", audit.AuditStatus);
|
||||
parameters.Add("AuditScore", audit.AuditScore);
|
||||
//parameters.Add("AuditedAreaID", audit.AuditedAreaID);
|
||||
parameters.Add("Auditees", audit.Auditees);
|
||||
this.db.Execute("_8DUpdateAudit", param: parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
parameters = new DynamicParameters();
|
||||
parameters.Add("@AuditNo", audit.AuditNo);
|
||||
this.db.Execute("_8DDeleteAuditors", parameters, commandType: CommandType.StoredProcedure);
|
||||
List<int> auditors = audit.AuditorIDs;
|
||||
if (auditors != null)
|
||||
{
|
||||
foreach (int auditorID in auditors)
|
||||
{
|
||||
parameters = new DynamicParameters();
|
||||
parameters.Add("@AuditNo", audit.AuditNo);
|
||||
parameters.Add("@AuditorID", auditorID);
|
||||
this.db.Execute("_8DInsertAuditor", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
parameters = new DynamicParameters();
|
||||
parameters.Add("@AuditNo", audit.AuditNo);
|
||||
this.db.Execute("_8DDeleteAuditTypes", parameters, commandType: CommandType.StoredProcedure);
|
||||
List<int> auditTypes = audit.AuditTypeIDs;
|
||||
if (auditTypes != null)
|
||||
{
|
||||
foreach (int auditTypeID in auditTypes)
|
||||
{
|
||||
parameters = new DynamicParameters();
|
||||
parameters.Add("@AuditNo", audit.AuditNo);
|
||||
parameters.Add("@AuditTypeID", auditTypeID);
|
||||
this.db.Execute("_8DInsertAuditType", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
}
|
||||
|
||||
parameters = new DynamicParameters();
|
||||
parameters.Add("@AuditNo", audit.AuditNo);
|
||||
this.db.Execute("_8DDeleteAuditedAreas", parameters, commandType: CommandType.StoredProcedure);
|
||||
List<int> auditedAreas = audit.AuditedAreaIDs;
|
||||
if (auditedAreas != null)
|
||||
{
|
||||
foreach (int auditedAreaID in auditedAreas)
|
||||
{
|
||||
parameters = new DynamicParameters();
|
||||
parameters.Add("@AuditNo", audit.AuditNo);
|
||||
parameters.Add("@AuditedAreaID", auditedAreaID);
|
||||
this.db.Execute("_8DInsertAuditedArea", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
}
|
||||
|
||||
transaction.Complete();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
transaction.Dispose();
|
||||
throw new Exception(ex.Message + " " + ex.InnerException);
|
||||
}
|
||||
}
|
||||
//FabApprovalSystemEntitiesAll auditDb = new FabApprovalSystemEntitiesAll();
|
||||
|
||||
//List<int> auditedStandards = audit.AuditedStandardIDs;
|
||||
//if (auditedStandards != null)
|
||||
//{
|
||||
// foreach (int auditedStandard in auditedStandards)
|
||||
// {
|
||||
// var auditStandardExists = (from a in auditDb.C_8DAuditedStandardByAudit where a.AuditNo == audit.AuditNo && a.AuditedStandardID == auditedStandard select a).ToList();
|
||||
// if (auditStandardExists.Count() <= 0)
|
||||
// {
|
||||
// C_8DAuditedStandardByAudit standard = new C_8DAuditedStandardByAudit
|
||||
// {
|
||||
// AuditNo = audit.AuditNo,
|
||||
// AuditedStandardID = auditedStandard
|
||||
// };
|
||||
// auditDb.C_8DAuditedStandardByAudit.Add(standard);
|
||||
// auditDb.SaveChanges();
|
||||
// }
|
||||
|
||||
// }
|
||||
//}
|
||||
|
||||
//parameters = new DynamicParameters();
|
||||
//parameters.Add("AuditNo", audit.AuditNo);
|
||||
//this.db.Execute("_8DUpdateAuditScore", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="issueID"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<AuditReportAttachment> GetAuditReportAttachments(int auditNo)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@AuditNo", auditNo);
|
||||
var data = this.db.Query<AuditReportAttachment>("_8DGetAuditReportAttachments", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="auditNo"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<AuditReportAttachment> GetCAFindingsItemAttachments(int caFindingsID)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CAFindingsID", caFindingsID);
|
||||
var data = this.db.Query<AuditReportAttachment>("_8DGetCAFindingsItemAttachments", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<CAUserList> GetUserList()
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
var userList = this.db.Query<CAUserList>("_8DGetUserList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return userList;
|
||||
}
|
||||
|
||||
public AuditFindings GetAuditFindingsByID(int auditFindingsID)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@AuditFindingsID", auditFindingsID);
|
||||
var data = this.db.Query<AuditFindings>("SELECT * FROM _8DAuditFinding WHERE ID = @AuditFindingsID", parameters).SingleOrDefault();
|
||||
return data;
|
||||
}
|
||||
public IEnumerable<int> GetAuditFindingCategoryIdsByFindingId(int auditFindingsID)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@AuditFindingID", auditFindingsID);
|
||||
var data = this.db.Query<int>("SELECT CategoryID FROM _8DAuditFindingCategoryByAuditFinding WHERE AuditFindingID = @AuditFindingID", parameters).ToList();
|
||||
return data;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="auditNo"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<AuditFindings> GetAuditFindingsList(int auditNo)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@AuditNo", auditNo);
|
||||
var data = this.db.Query<AuditFindings>("_8DGetAuditFindingsList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="attachmentID"></param>
|
||||
public void DeleteAuditReportAttachment(int attachmentID)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@AttachmentID", attachmentID);
|
||||
this.db.Execute("_8DDeleteAuditReportAttachments", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="attach"></param>
|
||||
public void InsertAuditReportAttachment(AuditReportAttachment attach)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@AuditNo", attach.AuditNo);
|
||||
parameters.Add("@CAFindingsID", attach.CAFindingsID);
|
||||
parameters.Add("@UploadedByID", attach.UploadedByID);
|
||||
parameters.Add("@FileName", attach.FileName);
|
||||
parameters.Add("@FileGUID", attach.FileGUID);
|
||||
|
||||
this.db.Execute("_8DInsertAuditReportAttachment", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="fileGUID"></param>
|
||||
/// <returns></returns>
|
||||
internal string GetAuditReportAttachmentFileName(string fileGUID)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@FileGUID", fileGUID);
|
||||
var fileName = this.db.Query<string>("_8DGetAuditReportAttachmentFileName", parameters, commandType: CommandType.StoredProcedure).Single();
|
||||
return fileName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
internal void InsertAuditFindingsItem(AuditFindings data)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@AuditNo", data.AuditNo);
|
||||
parameters.Add("@Findings", data.Findings);
|
||||
parameters.Add("@ViolatedClause", data.ViolatedClause);
|
||||
parameters.Add("@FindingType", data.FindingType);
|
||||
parameters.Add("@FindingCategories", data.FindingCategories);
|
||||
parameters.Add("@CANo", data.CANo);
|
||||
parameters.Add("@Title", data.Title);
|
||||
|
||||
|
||||
this.db.Execute("_8DInsertAuditFinding", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
internal void UpdateAuditFindingsItem(AuditFindings data)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@AuditFindingsID", data.ID);
|
||||
parameters.Add("@Findings", data.Findings);
|
||||
parameters.Add("@ViolatedClause", data.ViolatedClause);
|
||||
parameters.Add("@FindingType", data.FindingType);
|
||||
parameters.Add("@FindingCategories", data.FindingCategories);
|
||||
parameters.Add("@CANo", data.CANo);
|
||||
parameters.Add("@Title", data.Title);
|
||||
|
||||
|
||||
|
||||
this.db.Execute("_8DUpdateAuditFinding", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="auditFindingsID"></param>
|
||||
internal void DeleteAuditFindingsItem(int auditFindingsID )
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@AuditFindingsID", auditFindingsID);
|
||||
|
||||
this.db.Execute("_8DDeleteAuditFinding", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal List<AuditFindingCategory> GetAuditFindingCategories()
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
return this.db.Query<AuditFindingCategory>("_8DGetAuditFindingCategories", commandType: CommandType.StoredProcedure).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="userID"></param>
|
||||
/// <param name="issueID"></param>
|
||||
public void ReleaseLockOnDocument(int userID, int issueID)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@AuditNo", issueID);
|
||||
parameters.Add("@UserID", userID);
|
||||
this.db.Execute("_8DReleaseLockOnAuditDocuments", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<CANoList> GetCorrectiveActionNoList()
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
var dataList = this.db.Query<CANoList>("_8DGetCorrectiveActionNoList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return dataList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="subRoleCategoryID"></param>
|
||||
/// <returns></returns>
|
||||
public List<int> Get8DQA()
|
||||
{
|
||||
List<int> users = new List<int>();
|
||||
var parameters = new DynamicParameters();
|
||||
users = this.db.Query<int>("_8DGet8DQA", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return users;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="auditNo"></param>
|
||||
/// <returns></returns>
|
||||
public int GetOpenCACountByAuditNo(int auditNo)
|
||||
{
|
||||
|
||||
int rowCount = 0 ;
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@AuditNo", auditNo);
|
||||
rowCount = this.db.Query<int>("_8DGetOpenCACountByAuditNo", parameters, commandType: CommandType.StoredProcedure).Single();
|
||||
return rowCount;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// CA Findings ====================================================================================================================================
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
public void InsertCAFindings(CAFindings model)
|
||||
{
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@AuditNo", model.AuditNo);
|
||||
parameters.Add("@CAFinding", model.CAFinding);
|
||||
parameters.Add("@CorrectiveAction", model.CorrectiveAction);
|
||||
parameters.Add("@Result", model.Result);
|
||||
parameters.Add("@ResponsibilityOwnerID", model.ResponsibilityOwnerID);
|
||||
parameters.Add("@ECD", model.ECD);
|
||||
parameters.Add("@ImplementedDate", model.ImplementedDate);
|
||||
|
||||
this.db.Execute("_8DInsertCAFindings", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
public void UpdateCAFindings(CAFindings model)
|
||||
{
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CAFindingsID", model.ID);
|
||||
parameters.Add("@CAFinding", model.CAFinding);
|
||||
parameters.Add("@CorrectiveAction", model.CorrectiveAction);
|
||||
parameters.Add("@Result", model.Result);
|
||||
parameters.Add("@ResponsibilityOwnerID", model.ResponsibilityOwnerID);
|
||||
parameters.Add("@ECD", model.ECD);
|
||||
parameters.Add("@ImplementedDate", model.ImplementedDate);
|
||||
|
||||
this.db.Execute("_8DUpdateCAFindings", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="caFindingsID"></param>
|
||||
public void DeleteCAFindingsItem(int caFindingsID)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CAFindingsID", caFindingsID);
|
||||
|
||||
this.db.Execute("_8DDeleteCAFindingsItem", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="caFindingsID"></param>
|
||||
/// <returns></returns>
|
||||
public CAFindings GetCAFindingsItem(int caFindingsID)
|
||||
{
|
||||
var model = new CAFindings();
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CAFindingsID", caFindingsID);
|
||||
var data = this.db.Query<CAFindings>("_8DGetCAFindings", parameters, commandType: CommandType.StoredProcedure).Single();
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="caNo"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<CAFindings> GetCAFindingsList(int auditNo)
|
||||
{
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@AuditNo", auditNo);
|
||||
var dataList = this.db.Query<CAFindings>("_8DGetCAFindingsList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return dataList;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="CANo"></param>
|
||||
/// <returns></returns>
|
||||
public int IsCAAssignedToAudit(int CANo, int auditNo)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
int returnValue = 1;
|
||||
parameters.Add("@CANo", CANo);
|
||||
parameters.Add("@AuditNo", auditNo);
|
||||
parameters.Add("@IsCAAssignedToAudit", returnValue, direction: ParameterDirection.Output);
|
||||
|
||||
this.db.Execute("_8DIsCAAssignedtoAudit", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
returnValue = parameters.Get<int>("IsCAAssignedToAudit");
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
1098
Fab2ApprovalSystem/DMO/ChangeControlDMO.cs
Normal file
1098
Fab2ApprovalSystem/DMO/ChangeControlDMO.cs
Normal file
File diff suppressed because it is too large
Load Diff
896
Fab2ApprovalSystem/DMO/CorrectiveActionDMO.cs
Normal file
896
Fab2ApprovalSystem/DMO/CorrectiveActionDMO.cs
Normal file
@ -0,0 +1,896 @@
|
||||
using Dapper;
|
||||
using Fab2ApprovalSystem.Misc;
|
||||
using Fab2ApprovalSystem.Models;
|
||||
using Fab2ApprovalSystem.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Transactions;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Fab2ApprovalSystem.DMO
|
||||
{
|
||||
|
||||
public class CorrectiveActionDMO
|
||||
{
|
||||
private IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
WorkflowDMO wfDMO = new WorkflowDMO();
|
||||
|
||||
public CorrectiveAction InsertCA(CorrectiveAction ca)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
|
||||
parameters = new DynamicParameters();
|
||||
parameters.Add("@CANo", value: ca.CANo, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
|
||||
parameters.Add("@RequestorID", ca.RequestorID);
|
||||
|
||||
this.db.Execute("_8DInsertCAItem", parameters, commandType: CommandType.StoredProcedure);
|
||||
ca.CANo = parameters.Get<int>("@CANo");
|
||||
|
||||
return ca;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
public void UpdateCorrectiveAction(CorrectiveAction model)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
|
||||
using (var transaction = new TransactionScope())
|
||||
{
|
||||
try
|
||||
{
|
||||
parameters.Add("@CANo", model.CANo);
|
||||
parameters.Add("@CATitle", model.CATitle);
|
||||
parameters.Add("@RequestorID", model.RequestorID);
|
||||
parameters.Add("@IssueDate", model.IssueDate);
|
||||
parameters.Add("@D1AssigneeID", model.D1AssigneeID);
|
||||
parameters.Add("@CAType", model.CAType);
|
||||
parameters.Add("@CASourceID", model.CASourceID);
|
||||
parameters.Add("@ModuleID", model.ModuleID);
|
||||
parameters.Add("@QAID", model.QAID);
|
||||
parameters.Add("@D8DueDate", model.D8DueDate);
|
||||
parameters.Add("@Tool", model.Tools);
|
||||
parameters.Add("@ApprovedDate", model.ApprovedDate);
|
||||
parameters.Add("@RelatedMRB", model.RelatedMRB);
|
||||
parameters.Add("@RelatedAudit", model.RelatedAudit);
|
||||
parameters.Add("@D0Comments", model.D0Comments);
|
||||
parameters.Add("@D2ProblemDescription", model.D2ProblemDescription);
|
||||
parameters.Add("@D3RiskAssessmentNotes", model.D3RiskAssessmentNotes);
|
||||
parameters.Add("@D0Completed", model.D0Completed);
|
||||
parameters.Add("@D0Approved", model.D0Approved);
|
||||
parameters.Add("@D3Completed", model.D3Completed);
|
||||
parameters.Add("@D3Approved", model.D3Approved);
|
||||
parameters.Add("@D4RootCause1", model.D4RootCause1);
|
||||
parameters.Add("@D4RootCause2", model.D4RootCause2);
|
||||
parameters.Add("@D4RootCause3", model.D4RootCause3);
|
||||
parameters.Add("@D4RootCause4", model.D4RootCause4);
|
||||
parameters.Add("@D4Completed", model.D4Completed);
|
||||
parameters.Add("@D4Approved", model.D4Approved);
|
||||
parameters.Add("@D5Completed", model.D5Completed);
|
||||
parameters.Add("@D5Approved", model.D5Approved);
|
||||
parameters.Add("@D6Validated", model.D6Validated);
|
||||
parameters.Add("@D7Completed", model.D7Completed);
|
||||
parameters.Add("@D8Completed", model.D8Completed);
|
||||
parameters.Add("@D8Approved", model.D8Approved);
|
||||
parameters.Add("@D8TeamRecognition", model.D8TeamRecognition);
|
||||
parameters.Add("@D8LessonsLearned", model.D8LessonsLearned);
|
||||
parameters.Add("@TeamCaptainID", model.TeamCaptainID);
|
||||
parameters.Add("@CASponsorID", model.CASponsorID);
|
||||
parameters.Add("@CustomerName", model.CustomerName);
|
||||
parameters.Add("@CustomerPartNo", model.CustomerPartNo);
|
||||
parameters.Add("@IFXPartNo", model.IFXPartNo);
|
||||
parameters.Add("@PartQty", model.PartQty);
|
||||
parameters.Add("@InvoiceNo", model.InvoiceNo);
|
||||
parameters.Add("@PurchaseOrderNo", model.PurchaseOrderNo);
|
||||
parameters.Add("@SalesOrderNo", model.SalesOrderNo);
|
||||
parameters.Add("@DollarImpact", model.DollarImpact);
|
||||
parameters.Add("@BackgroundInfo", model.BackgroundInfo);
|
||||
parameters.Add("@Analysis", model.Analysis);
|
||||
parameters.Add("@VisualVerification", model.VisualVerification);
|
||||
parameters.Add("@InterimContainmentAction", model.InterimContainmentAction);
|
||||
parameters.Add("@ICAVerificationResults", model.ICAVerificationResults);
|
||||
parameters.Add("@ICAValidationActivities", model.ICAValidationActivities);
|
||||
parameters.Add("@RootCauseVerification", model.RootCauseVerification);
|
||||
parameters.Add("@EscapePoint", model.EscapePoint);
|
||||
parameters.Add("@FollowUpDate", model.FollowUpDate);
|
||||
parameters.Add("@CASubmitted", model.CASubmitted);
|
||||
|
||||
this.db.Execute("_8DUpdateCorrectiveAction", parameters, commandType: CommandType.StoredProcedure);
|
||||
EventLogDMO.Add(new WinEventLog { UserID = "System", Comments = "Saved Corrective Action", DocumentType = "9", IssueID = model.CANo, OperationType = "Status", SysDocumentID = 1 });
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
parameters = new DynamicParameters();
|
||||
parameters.Add("@CANo", model.CANo);
|
||||
this.db.Execute("_8DDeleteCAModuleID", parameters, commandType: CommandType.StoredProcedure);
|
||||
List<int> moduleIDs = model.ModuleIDs;
|
||||
if (moduleIDs != null)
|
||||
{
|
||||
foreach (int moduleID in moduleIDs)
|
||||
{
|
||||
parameters = new DynamicParameters();
|
||||
parameters.Add("@CANo", model.CANo);
|
||||
parameters.Add("@ModuleID", moduleID);
|
||||
this.db.Execute("_8DInsertCAModuleID", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
}
|
||||
|
||||
parameters = new DynamicParameters();
|
||||
parameters.Add("@CANo", model.CANo);
|
||||
this.db.Execute("_8DDeleteRiskAssessmentAres", parameters, commandType: CommandType.StoredProcedure);
|
||||
List<int> riskAssessmentAreaIDs = model.RiskAssessmentAreaIDs;
|
||||
if (riskAssessmentAreaIDs != null)
|
||||
{
|
||||
foreach (int riskAssessmentAreaID in riskAssessmentAreaIDs)
|
||||
{
|
||||
parameters = new DynamicParameters();
|
||||
parameters.Add("@CANo", model.CANo);
|
||||
parameters.Add("@RiskAssessmentAreaID", riskAssessmentAreaID);
|
||||
this.db.Execute("_8DInsertRiskAssessmentArea", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
parameters = new DynamicParameters();
|
||||
parameters.Add("@CANo", model.CANo);
|
||||
this.db.Execute("_8DDeleteTeamMembers", parameters, commandType: CommandType.StoredProcedure);
|
||||
List<int> teamMemberIDs = model.TeamMemberIDs;
|
||||
if (teamMemberIDs != null)
|
||||
{
|
||||
foreach (int teamMemberID in teamMemberIDs)
|
||||
{
|
||||
parameters = new DynamicParameters();
|
||||
parameters.Add("@CANo", model.CANo);
|
||||
parameters.Add("@TeamMemberID", teamMemberID);
|
||||
this.db.Execute("_8DInsertTeamMemberID", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
}
|
||||
|
||||
transaction.Complete();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
transaction.Dispose();
|
||||
throw new Exception(ex.Message + " " + ex.InnerException);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="caNo"></param>
|
||||
/// <param name="userID"></param>
|
||||
/// <returns></returns>
|
||||
public CorrectiveAction GetCAItem(int caNo, int userID)
|
||||
{
|
||||
CorrectiveAction ca = new CorrectiveAction();
|
||||
|
||||
//isITAR = 2;
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CANo", value: caNo);
|
||||
parameters.Add("@UserID", userID);
|
||||
|
||||
using (var multipleResultItems = this.db.QueryMultiple("_8DGetCAItem", parameters, commandType: CommandType.StoredProcedure))
|
||||
{
|
||||
ca = multipleResultItems.Read<CorrectiveAction>().SingleOrDefault();
|
||||
|
||||
|
||||
var moduleIDs = multipleResultItems.Read<int>().ToList();
|
||||
if (ca != null && moduleIDs != null)
|
||||
{
|
||||
if (moduleIDs.Count > 0)
|
||||
ca.ModuleIDs.AddRange(moduleIDs);
|
||||
}
|
||||
|
||||
var teamMembers = multipleResultItems.Read<int>().ToList();
|
||||
if (ca != null && teamMembers != null)
|
||||
{
|
||||
if (teamMembers.Count > 0)
|
||||
ca.TeamMemberIDs.AddRange(teamMembers);
|
||||
}
|
||||
|
||||
var riskAssessments = multipleResultItems.Read<int>().ToList();
|
||||
if (ca != null && riskAssessments != null)
|
||||
{
|
||||
if (riskAssessments.Count > 0)
|
||||
ca.RiskAssessmentAreaIDs.AddRange(riskAssessments);
|
||||
}
|
||||
}
|
||||
|
||||
return ca;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="caNo"></param>
|
||||
/// <param name="userID"></param>
|
||||
/// <returns></returns>
|
||||
public CorrectiveAction GetCAItemReadOnly(int caNo, int userID)
|
||||
{
|
||||
CorrectiveAction ca = new CorrectiveAction();
|
||||
|
||||
//isITAR = 2;
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CANo", value: caNo);
|
||||
parameters.Add("@UserID", userID);
|
||||
|
||||
using (var multipleResultItems = this.db.QueryMultiple("_8DGetCAItemReadOnly", parameters, commandType: CommandType.StoredProcedure))
|
||||
{
|
||||
ca = multipleResultItems.Read<CorrectiveAction>().SingleOrDefault();
|
||||
|
||||
var moduleIDs = multipleResultItems.Read<int>().ToList();
|
||||
if (ca != null && moduleIDs != null)
|
||||
{
|
||||
if (moduleIDs.Count > 0)
|
||||
ca.ModuleIDs.AddRange(moduleIDs);
|
||||
}
|
||||
|
||||
var teamMembers = multipleResultItems.Read<int>().ToList();
|
||||
if (ca != null && teamMembers != null)
|
||||
{
|
||||
if (teamMembers.Count > 0)
|
||||
ca.TeamMemberIDs.AddRange(teamMembers);
|
||||
}
|
||||
|
||||
var riskAssessments = multipleResultItems.Read<int>().ToList();
|
||||
if (ca != null && riskAssessments != null)
|
||||
{
|
||||
if (riskAssessments.Count > 0)
|
||||
ca.RiskAssessmentAreaIDs.AddRange(riskAssessments);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return ca;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<CAUserList> GetUserList()
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
var userList = this.db.Query<CAUserList>("_8DGetUserList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return userList;
|
||||
}
|
||||
public IEnumerable<CAUserList> GetAllUserList()
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
var userList = this.db.Query<CAUserList>("_8DGetAllUserList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return userList;
|
||||
}
|
||||
public IEnumerable<CASource> GetCASourceList()
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
var caSourceList = this.db.Query<CASource>("_8DGetCASourceList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return caSourceList;
|
||||
}
|
||||
|
||||
public IEnumerable<Module> GetModuleList()
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
var moduleList = this.db.Query<Module>("_8DGetCAModuleList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return moduleList;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="attach"></param>
|
||||
public void InsertCAAttachment(CA_Attachment attach)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CANo", attach.CANo);
|
||||
parameters.Add("@D5D6CAID", attach.D5D6CAID);
|
||||
parameters.Add("@D7PAID", attach.D7PAID);
|
||||
parameters.Add("@CAFindingsID", attach.CAFindingsID);
|
||||
parameters.Add("@UploadedByID", attach.UploadedByID);
|
||||
parameters.Add("@FileName", attach.FileName);
|
||||
parameters.Add("@FileGUID", attach.FileGUID);
|
||||
parameters.Add("@Section", attach.Section);
|
||||
|
||||
this.db.Execute("_8DInsertCAAttachment", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="caNo"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<CA_Attachment> GetCAAttachmentsList(int caNo, string section)
|
||||
{
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CANo", caNo);
|
||||
parameters.Add("@Section", section);
|
||||
var caAttachmentList = this.db.Query<CA_Attachment>("[_8DGetCAAttachmentList]", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return caAttachmentList;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="caNo"></param>
|
||||
public void DeleteCAAttachment(int attachmentID)
|
||||
{
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@AttachmentID", attachmentID);
|
||||
this.db.Execute("_8DDeleteCAAttachment", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="fileGUID"></param>
|
||||
/// <returns></returns>
|
||||
public string GetCAAttachmentFileName(string fileGUID)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@FileGUID", fileGUID);
|
||||
var fileName = this.db.Query<string>("_8DGetCAAttachmentFileName", parameters, commandType: CommandType.StoredProcedure).Single();
|
||||
return fileName;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="caNo"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<D3ContainmentAction> GetD3ContainmentActions(int caNo)
|
||||
{
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CANo", caNo);
|
||||
var d3ContainmentActionList = this.db.Query<D3ContainmentAction>("_8DGetD3ContainmentActions", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return d3ContainmentActionList;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
public void UpdateD3ContainmentAction(D3ContainmentAction model)
|
||||
{
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@ID", model.ID);
|
||||
parameters.Add("@ContainmentAction", model.ContainmentAction);
|
||||
parameters.Add("@Result", model.Result);
|
||||
parameters.Add("@ECNLinks", model.ECNLinks);
|
||||
parameters.Add("@ResponsibilityOwnerID", model.ResponsibilityOwnerID);
|
||||
parameters.Add("@ECD", model.ECD);
|
||||
parameters.Add("@ImplementedDate", model.ImplementedDate);
|
||||
|
||||
this.db.Execute("_8DUpdateD3ContainmentAction", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
}
|
||||
|
||||
public void InsertD3ContainmentAction(D3ContainmentAction model)
|
||||
{
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CANo", model.CANo);
|
||||
parameters.Add("@ContainmentAction", model.ContainmentAction);
|
||||
parameters.Add("@Result", model.Result);
|
||||
parameters.Add("@ECNLinks", model.ECNLinks);
|
||||
parameters.Add("@ResponsibilityOwnerID", model.ResponsibilityOwnerID);
|
||||
parameters.Add("@ECD", model.ECD);
|
||||
parameters.Add("@ImplementedDate", model.ImplementedDate);
|
||||
|
||||
this.db.Execute("_8DInsertD3ContainmentAction", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void DeleteD3ContainmentActionItem(int d3ContainmentActionID)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@D3ContainmentActionID", d3ContainmentActionID);
|
||||
|
||||
this.db.Execute("_8DDeleteD3ContainmentActionItem", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<RiskAssessmentArea> GetD3RiskAssessmentAreas()
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
var dataList = this.db.Query<RiskAssessmentArea>("_8DGetD3RiskAssessmentAreas", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return dataList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="caNo"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<D5D6CorrectivetAction> GetD5D6CorrectivetActions(int caNo)
|
||||
{
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CANo", caNo);
|
||||
var dataList = this.db.Query<D5D6CorrectivetAction>("_8DGetD5D6_CAList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return dataList;
|
||||
|
||||
}
|
||||
public bool IsAIAssignee(int userId, int caId)
|
||||
{
|
||||
bool isAssignee = false;
|
||||
int aiIndex = 0;
|
||||
List<D5D6CorrectivetAction> actionItems = GetD5D6CorrectivetActions(caId).ToList();
|
||||
while (isAssignee == false && aiIndex < actionItems.Count())
|
||||
{
|
||||
D5D6CorrectivetAction actionItem = actionItems[aiIndex];
|
||||
if(actionItem.ResponsibilityOwnerID == userId && actionItem.ImplementedDate == null && actionItem.Approved)
|
||||
{
|
||||
isAssignee = true;
|
||||
}
|
||||
aiIndex++;
|
||||
}
|
||||
return isAssignee;
|
||||
|
||||
}
|
||||
public IEnumerable<D5D6Improvement> GetD5D6Improvement()
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
var dataList = this.db.Query<D5D6Improvement>("_8DGetD5D6Improvement", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return dataList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
public void InsertD5D6CorrectivetAction(D5D6CorrectivetAction model)
|
||||
{
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CANo", model.CANo);
|
||||
parameters.Add("@CorrectiveAction", model.CorrectiveAction);
|
||||
parameters.Add("@Result", model.Result);
|
||||
parameters.Add("@ECNLinks", model.ECNLinks);
|
||||
parameters.Add("@ResponsibilityOwnerID", model.ResponsibilityOwnerID);
|
||||
parameters.Add("@ECD", model.ECD);
|
||||
parameters.Add("@ImprovementIDs", model.ImprovementID);
|
||||
parameters.Add("@ImplementedDate", model.ImplementedDate);
|
||||
parameters.Add("@CARequired", (model.CARequired));
|
||||
parameters.Add("@ActionType", (model.ActionType));
|
||||
|
||||
this.db.Execute("_8DInsertD5D6CorrectiveAction", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
public void UpdateD5D6CorrectivetAction(D5D6CorrectivetAction model)
|
||||
{
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@D5D6CAID", model.ID);
|
||||
parameters.Add("@CorrectiveAction", model.CorrectiveAction);
|
||||
parameters.Add("@Result", model.Result);
|
||||
parameters.Add("@ECNLinks", model.ECNLinks);
|
||||
parameters.Add("@ResponsibilityOwnerID", model.ResponsibilityOwnerID);
|
||||
parameters.Add("@ECD", model.ECD);
|
||||
parameters.Add("@ImprovementIDs", model.ImprovementID);
|
||||
parameters.Add("@ImplementedDate", model.ImplementedDate);
|
||||
parameters.Add("@CARequired", (model.@CARequired));
|
||||
parameters.Add("@ActionType", (model.ActionType));
|
||||
|
||||
this.db.Execute("_8DUpdateD5D6CorrectiveAction", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void DeleteD5D6CorrectivetAction(int d5d6CAID)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@D5D6CAID", d5d6CAID);
|
||||
|
||||
this.db.Execute("_8DDeleteD5D6CorrectiveActionItem", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public D5D6CorrectivetAction GetD5D5CAItem(int d5d6CAID)
|
||||
{
|
||||
var model = new D5D6CorrectivetAction();
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@D5D6CAID", d5d6CAID);
|
||||
var data = this.db.Query<D5D6CorrectivetAction>("_8DGetD5D6CA", parameters, commandType: CommandType.StoredProcedure).Single();
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="d5d6CAID"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<CA_Attachment> GetD5D6ItemAttachments(int d5d6CAID)
|
||||
{
|
||||
var model = new D5D6CorrectivetAction();
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@D5D6CAID", d5d6CAID);
|
||||
var data = this.db.Query<CA_Attachment>("_8DGetD5D6ItemAttachmentList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// D7=================================================================================================
|
||||
|
||||
|
||||
public IEnumerable<D7PreventiveAction> GetD7PreventiveActions(int caNo)
|
||||
{
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CANo", caNo);
|
||||
var dataList = this.db.Query<D7PreventiveAction>("_8DGetD7_PAList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return dataList;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
public void InsertD7PreventiveAction(D7PreventiveAction model)
|
||||
{
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CANo", model.CANo);
|
||||
parameters.Add("@PreventiveAction", model.PreventiveAction);
|
||||
parameters.Add("@Result", model.Result);
|
||||
parameters.Add("@ECNLinks", model.ECNLinks);
|
||||
parameters.Add("@ResponsibilityOwnerID", model.ResponsibilityOwnerID);
|
||||
parameters.Add("@ECD", model.ECD);
|
||||
parameters.Add("@ImplementedDate", model.ImplementedDate);
|
||||
|
||||
this.db.Execute("_8DInsertD7PreventiveAction", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
public void UpdateD7PreventiveAction(D7PreventiveAction model)
|
||||
{
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@D7PAID", model.ID);
|
||||
parameters.Add("@PreventiveAction", model.PreventiveAction);
|
||||
parameters.Add("@Result", model.Result);
|
||||
parameters.Add("@ECNLinks", model.ECNLinks);
|
||||
parameters.Add("@ResponsibilityOwnerID", model.ResponsibilityOwnerID);
|
||||
parameters.Add("@ECD", model.ECD);
|
||||
parameters.Add("@ImplementedDate", model.ImplementedDate);
|
||||
|
||||
this.db.Execute("_8DUpdateD7PreventiveAction", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public D7PreventiveAction GetD7PAItem(int d7PAID)
|
||||
{
|
||||
var model = new D7PreventiveAction();
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@D7PAID", d7PAID);
|
||||
var data = this.db.Query<D7PreventiveAction>("_8DGetD7PA", parameters, commandType: CommandType.StoredProcedure).Single();
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="D7PAID"></param>
|
||||
public void DeleteD7PreventiveActionItem(int D7PAID)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@D7PAID", D7PAID);
|
||||
|
||||
this.db.Execute("_8DDeleteD7PreventiveActionItem", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="d7PAID"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<CA_Attachment> GetD7ItemAttachments(int d7PAID)
|
||||
{
|
||||
var model = new D7PreventiveAction();
|
||||
var parameters = new DynamicParameters();
|
||||
|
||||
parameters.Add("@D7PAID", d7PAID);
|
||||
var data = this.db.Query<CA_Attachment>("_8DGetD7ItemAttachmentList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="caFindingsID"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<CA_Attachment> GetCAFindingsItemAttachments(int caFindingsID)
|
||||
{
|
||||
var model = new D7PreventiveAction();
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CAFindingsID", caFindingsID);
|
||||
var data = this.db.Query<CA_Attachment>("_8DGetCAFindingsItemAttachmentList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="userID"></param>
|
||||
/// <param name="issueID"></param>
|
||||
public void ReleaseLockOnDocument(int userID, int issueID)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CANo", issueID);
|
||||
parameters.Add("@UserID", userID);
|
||||
this.db.Execute("_8DReleaseLockOnCADocuments", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="issueID"></param>
|
||||
/// <returns></returns>
|
||||
public List<string> GetRejectionAssigneeEmailList(int caNo)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CANo", caNo);
|
||||
var emailList = this.db.Query<string>("_8DGetRejectionAssigneeEmailList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return emailList;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="issueID"></param>
|
||||
/// <param name="userID"></param>
|
||||
/// <returns></returns>
|
||||
public int StartApproval(int issueID, int userID, int worlflowNumber)
|
||||
{
|
||||
string subRoles = wfDMO.GetSubRoleItems(issueID, (int)GlobalVars.DocumentType.CorrectiveActionSection);
|
||||
|
||||
// bubble the error
|
||||
int appoverCount = 0;
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CANo", issueID);
|
||||
parameters.Add("@UserID", userID);
|
||||
parameters.Add("@DocumentTypeID", (int)GlobalVars.DocumentType.CorrectiveAction);
|
||||
parameters.Add("@SubRoleCategoriesClause", subRoles);
|
||||
parameters.Add("@WorkFlowNumber", worlflowNumber);
|
||||
parameters.Add("@AppoverCount", appoverCount, dbType: DbType.Int32, direction: ParameterDirection.Output);
|
||||
|
||||
this.db.Execute("_8DSubmitForApproval", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
appoverCount = parameters.Get<int>("@AppoverCount");
|
||||
return appoverCount;
|
||||
|
||||
}
|
||||
//public int StartSectionApproval(int issueID, int userID, int worlflowNumber)
|
||||
//{
|
||||
// string subRoles = wfDMO.GetSubRoleItems(issueID, (int)GlobalVars.DocumentType.CorrectiveActionSection);
|
||||
|
||||
// // bubble the error
|
||||
// int appoverCount = 0;
|
||||
// var parameters = new DynamicParameters();
|
||||
// parameters.Add("@CANo", issueID);
|
||||
// parameters.Add("@UserID", userID);
|
||||
// parameters.Add("@DocumentTypeID", (int)GlobalVars.DocumentType.CorrectiveActionSection);
|
||||
// parameters.Add("@SubRoleCategoriesClause", subRoles);
|
||||
// parameters.Add("@WorkFlowNumber", worlflowNumber);
|
||||
// parameters.Add("@AppoverCount", appoverCount, dbType: DbType.Int32, direction: ParameterDirection.Output);
|
||||
|
||||
// this.db.Execute("_8DSubmitForSectionApproval", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
// appoverCount = parameters.Get<int>("@AppoverCount");
|
||||
// return appoverCount;
|
||||
|
||||
//}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<int> Get8DQA()
|
||||
{
|
||||
List<int> users = new List<int>();
|
||||
var parameters = new DynamicParameters();
|
||||
users = this.db.Query<int>("_8DGet8DQA", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return users;
|
||||
|
||||
}
|
||||
|
||||
public void StartSectionApproval(int issueID, int userID, string DSection)
|
||||
{
|
||||
//string subRoles = wfDMO.GetSubRoleItems(issueID, (int)GlobalVars.DocumentType.CorrectiveActionSection);
|
||||
|
||||
// bubble the error
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CANo", issueID);
|
||||
parameters.Add("@8DQAUserID", userID);
|
||||
parameters.Add("@DSection", DSection);
|
||||
|
||||
this.db.Execute("_8DSubmitForSectionApproval", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
public void ApproveSection(int issueID, int userID, string DSection)
|
||||
{
|
||||
//string subRoles = wfDMO.GetSubRoleItems(issueID, (int)GlobalVars.DocumentType.CorrectiveActionSection);
|
||||
|
||||
// bubble the error
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@UserID", userID);
|
||||
parameters.Add("@CANo", issueID);
|
||||
parameters.Add("@DSection", DSection);
|
||||
|
||||
this.db.Execute("UpdateCASectionApproval", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
public bool IsLastSectionApprover(int caNo, string dSection)
|
||||
{
|
||||
bool islastApprover = false;
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CaNo", caNo);
|
||||
parameters.Add("@DSection", dSection);
|
||||
parameters.Add("@IsLastApprover", islastApprover, dbType: DbType.Boolean, direction: ParameterDirection.Output);
|
||||
|
||||
|
||||
|
||||
this.db.Execute("_8DIsLastSectionApprover", parameters, commandType: CommandType.StoredProcedure);
|
||||
islastApprover = parameters.Get<bool>("@IsLastApprover");
|
||||
|
||||
return islastApprover;
|
||||
}
|
||||
public void RejectSection(int issueID, int userID, string DSection, string comments)
|
||||
{
|
||||
//string subRoles = wfDMO.GetSubRoleItems(issueID, (int)GlobalVars.DocumentType.CorrectiveActionSection);
|
||||
|
||||
// bubble the error
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@UserID", userID);
|
||||
parameters.Add("@CANo", issueID);
|
||||
parameters.Add("@DSection", DSection);
|
||||
parameters.Add("@Comments", comments);
|
||||
|
||||
this.db.Execute("RejectCASectionApproval", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
public bool IsUserSectionApprover(int issueId, int userId)
|
||||
{
|
||||
bool isApprover = false;
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@issueId", issueId);
|
||||
parameters.Add("@userID", userId);
|
||||
parameters.Add("@isApprover", isApprover, dbType: DbType.Boolean, direction: ParameterDirection.Output);
|
||||
|
||||
this.db.Execute("_8DIsUserApprover", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
isApprover = parameters.Get<bool>("@isApprover");
|
||||
return isApprover;
|
||||
}
|
||||
public IEnumerable<CASectionApproval> GetCASectionApprovalLog(int caNo)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CaNo", caNo);
|
||||
var ApprovalLogList = this.db.Query<CASectionApproval>("_8DGetSectionApprovalLog", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return ApprovalLogList;
|
||||
}
|
||||
public DateTime SetCAComplete(int issueID)
|
||||
{
|
||||
DateTime followUpDate = new DateTime();
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CaNo", issueID);
|
||||
parameters.Add("@followUpDate", followUpDate, dbType: DbType.DateTime, direction: ParameterDirection.Output);
|
||||
|
||||
this.db.Execute("_8DSetAsComplete", parameters, commandType: CommandType.StoredProcedure);
|
||||
followUpDate = parameters.Get<DateTime>("@followUpDate");
|
||||
return followUpDate;
|
||||
}
|
||||
public DateTime SetCAD3DueDate(int issueID)
|
||||
{
|
||||
DateTime d3DueDate = new DateTime();
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CaNo", issueID);
|
||||
parameters.Add("@D3DueDate", d3DueDate, dbType: DbType.DateTime, direction: ParameterDirection.Output);
|
||||
|
||||
this.db.Execute("_8DSetD3DueDate", parameters, commandType: CommandType.StoredProcedure);
|
||||
d3DueDate = parameters.Get<DateTime>("@D3DueDate");
|
||||
return d3DueDate;
|
||||
}
|
||||
public DateTime SetCAD5D7DueDate(int issueID)
|
||||
{
|
||||
DateTime d5d7DueDate = new DateTime();
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@CaNo", issueID);
|
||||
parameters.Add("@D5D7DueDate", d5d7DueDate, dbType: DbType.DateTime, direction: ParameterDirection.Output);
|
||||
|
||||
this.db.Execute("_8DSetD5D7DueDate", parameters, commandType: CommandType.StoredProcedure);
|
||||
d5d7DueDate = parameters.Get<DateTime>("@D5D7DueDate");
|
||||
return d5d7DueDate;
|
||||
}
|
||||
public IEnumerable<CAD3D5D7Due> GetCAD3D5D7Due()
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
var dueList = this.db.Query<CAD3D5D7Due>("_8DGetDueD3D5D7", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return dueList;
|
||||
}
|
||||
public void SetD3D5D7NotificationDate(int caNo, string section)
|
||||
{
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@issueId", caNo);
|
||||
switch (section)
|
||||
{
|
||||
case "D3":
|
||||
this.db.Execute("_8DSetD3LastNotificationDate", parameters, commandType: CommandType.StoredProcedure);
|
||||
break;
|
||||
case "D5D7":
|
||||
this.db.Execute("_8DSetD5D7LastNotificationDate", parameters, commandType: CommandType.StoredProcedure);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
public IEnumerable<IssuesViewModel> GetECNList()
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
var ecnList = this.db.Query<IssuesViewModel>("ECNGetECNList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return ecnList;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
40
Fab2ApprovalSystem/DMO/ECNTypeChangeLogDMO.cs
Normal file
40
Fab2ApprovalSystem/DMO/ECNTypeChangeLogDMO.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using Fab2ApprovalSystem.Models;
|
||||
using Dapper;
|
||||
using System.Configuration;
|
||||
|
||||
namespace Fab2ApprovalSystem.DMO
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class ECNTypeChangeLogDMO
|
||||
{
|
||||
private static IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="changeLog"></param>
|
||||
public static void Add(ECNTypeChangeLog changeLog)
|
||||
{
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@ECNNumber", changeLog.ECNNumber);
|
||||
parameters.Add("@UserID", changeLog.UserID);
|
||||
parameters.Add("@ECNTypeFrom", changeLog.ECNTypeFrom);
|
||||
parameters.Add("@ECNTypeTo", changeLog.ECNTypeTo);
|
||||
|
||||
db.Execute("ECNInsertECNTypeChangeLog", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
1065
Fab2ApprovalSystem/DMO/ECN_DMO.cs
Normal file
1065
Fab2ApprovalSystem/DMO/ECN_DMO.cs
Normal file
File diff suppressed because it is too large
Load Diff
51
Fab2ApprovalSystem/DMO/EventLogDMO.cs
Normal file
51
Fab2ApprovalSystem/DMO/EventLogDMO.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using Fab2ApprovalSystem.Models;
|
||||
using Dapper;
|
||||
using System.Transactions;
|
||||
using Fab2ApprovalSystem.ViewModels;
|
||||
using System.Reflection;
|
||||
using Fab2ApprovalSystem.Misc;
|
||||
|
||||
namespace Fab2ApprovalSystem.DMO
|
||||
{
|
||||
|
||||
public static class EventLogDMO
|
||||
{
|
||||
private static IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
|
||||
//public static void Add(WinEventLog eventLog)
|
||||
//{
|
||||
// var parameters = new DynamicParameters();
|
||||
// parameters.Add("@IssueID", eventLog.IssueID);
|
||||
// parameters.Add("@UserID", eventLog.UserID);
|
||||
// parameters.Add("@OperationType", eventLog.OperationType);
|
||||
// parameters.Add("@Comments", eventLog.Comments);
|
||||
|
||||
// db.Execute("InsertEventLog", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
//}
|
||||
|
||||
|
||||
public static void Add(WinEventLog eventLog)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@IssueID", eventLog.IssueID);
|
||||
parameters.Add("@UserID", eventLog.UserID);
|
||||
parameters.Add("@DocumentType", eventLog.DocumentType);
|
||||
parameters.Add("@OperationType", eventLog.OperationType);
|
||||
parameters.Add("@Comments", eventLog.Comments);
|
||||
|
||||
db.Execute("InsertEventLogByDocument", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
1416
Fab2ApprovalSystem/DMO/LotDispositionDMO.cs
Normal file
1416
Fab2ApprovalSystem/DMO/LotDispositionDMO.cs
Normal file
File diff suppressed because it is too large
Load Diff
1651
Fab2ApprovalSystem/DMO/LotTravelerDMO.cs
Normal file
1651
Fab2ApprovalSystem/DMO/LotTravelerDMO.cs
Normal file
File diff suppressed because it is too large
Load Diff
1349
Fab2ApprovalSystem/DMO/MRB_DMO.cs
Normal file
1349
Fab2ApprovalSystem/DMO/MRB_DMO.cs
Normal file
File diff suppressed because it is too large
Load Diff
632
Fab2ApprovalSystem/DMO/MiscDMO.cs
Normal file
632
Fab2ApprovalSystem/DMO/MiscDMO.cs
Normal file
@ -0,0 +1,632 @@
|
||||
using Fab2ApprovalSystem.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Dapper;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Configuration;
|
||||
using System.Text;
|
||||
using Fab2ApprovalSystem.Misc;
|
||||
using Fab2ApprovalSystem.ViewModels;
|
||||
|
||||
namespace Fab2ApprovalSystem.DMO
|
||||
{
|
||||
public static class MiscDMO
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="searchText"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Lot> SearchLots(string searchText, string searchBy)
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
IEnumerable<Lot> lotList;
|
||||
|
||||
string sql = "";
|
||||
if (GlobalVars.DBConnection.ToUpper() == "TEST" || GlobalVars.DBConnection.ToUpper() == "QUALITY")
|
||||
{
|
||||
if (searchBy == GlobalVars.LOT_NO)
|
||||
//sql = "SELECT WP_LOT_NO + '/' + ISNULL(WP_LOT_NO,'') AS LotNumber FROM WP_RECORD_MJ WHERE WP_LOT_NO LIKE '%" + searchText + "%' ";
|
||||
sql = "SELECT WP_LOT_NO + '/' + ISNULL(WP_LOT_NO,'') AS LotNumber FROM SPNLot WHERE WP_LOT_NO LIKE '%" + searchText + "%' ";
|
||||
else if (searchBy == GlobalVars.LOCATION)
|
||||
{
|
||||
sql = "SELECT WP_LOT_NO + '/' + ISNULL(WP_LOT_NO,'') AS LotNumber FROM SPNLot WHERE WP_CURRENT_LOCATION = '" + searchText.Trim() + "' AND WP_LOT_NO + '/' + ISNULL(WP_LOT_NO,'') IS NOT NULL";
|
||||
}
|
||||
lotList = db.Query<Lot>(sql).ToList();
|
||||
db.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (searchBy == GlobalVars.LOT_NO)
|
||||
sql = "SELECT WP_LOT_NO + '/' + ISNULL(DieLotNumber,'') AS LotNumber FROM SPNLot WHERE WP_LOT_NO LIKE '%" + searchText + "%' OR DieLotNumber LIKE '%" + searchText + "%' ";
|
||||
else if (searchBy == GlobalVars.LOCATION)
|
||||
{
|
||||
sql = "SELECT WP_LOT_NO + '/' + ISNULL(DieLotNumber,'') AS LotNumber FROM SPNLot WHERE WP_CURRENT_LOCATION = '" + searchText.Trim() + "' AND WP_LOT_NO + '/' + ISNULL(DieLotNumber,'') IS NOT NULL";
|
||||
}
|
||||
lotList = db.Query<Lot>(sql).ToList();
|
||||
db.Close();
|
||||
}
|
||||
|
||||
|
||||
return lotList;
|
||||
}
|
||||
public static IEnumerable<int> GetUserIDsBySubRoleID(int subRoleID)
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
IEnumerable<int> userList;
|
||||
|
||||
string sql = "";
|
||||
sql = "SELECT UserID FROM UserSubRole WHERE SubRoleID = " + subRoleID;
|
||||
userList = db.Query<int>(sql).ToList();
|
||||
db.Close();
|
||||
return userList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="searchText"></param>
|
||||
/// <param name="searchBy"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Lot> SearchLTLots(string searchText, string searchBy)
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
string sql = "";
|
||||
|
||||
|
||||
if (searchBy == GlobalVars.LOT_NO)
|
||||
sql = "SELECT DISTINCT WP_LOT_NO AS LotNumber FROM vFAB2SPN_WP_RECORD WP WHERE WP_LOT_NO LIKE '%" + searchText.Trim() + "%' ";
|
||||
else if (searchBy == GlobalVars.LOCATION)
|
||||
{
|
||||
sql = "SELECT DISTINCT WP_LOT_NO AS LotNumber FROM vFAB2SPN_WP_RECORD WP WHERE WP_CURRENT_LOCATION = '" + searchText.Trim() + "'";
|
||||
}
|
||||
var lotList = db.Query<Lot>(sql).ToList();
|
||||
db.Close();
|
||||
return lotList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="searchText"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<WIPPart> SearchLTParts(string searchText)
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.Append("SELECT PartNumber + '~' + SiliconPart + '~' + ProcessFlow + '~' + PartDescription AS WIPPartData ");
|
||||
sql.Append("FROM vWIPPartData WHERE PartNumber LIKE '%" + searchText + "%' ORDER BY PartNumber");
|
||||
|
||||
//StringBuilder sql = new StringBuilder();
|
||||
//sql.Append("SELECT TO_PART AS PartNumber, FROM_PART AS SiliconPart, P.MP_DESCRIPTION AS PartDescirption, ");
|
||||
//sql.Append("RTRIM(LTRIM(SUBSTRING(TO_PART_PROC, PATINDEX('% %', TO_PART_PROC), LEN(TO_PART_PROC)))) AS ProcessFlow ");
|
||||
//sql.Append("FROM TEMIRWAP019.FAB2SPN.dbo.PG_RECORD W ");
|
||||
//sql.Append("INNER JOIN TEMIRWAP019.Fab2SPN.dbo.MP_RECORD P ON W.TO_PART = P.MP_PART_NUMBER ");
|
||||
//sql.Append("WHERE PartNumber LIKE '%" + searchText + "%' ORDER BY PartNumber ");
|
||||
|
||||
|
||||
var parList = db.Query<WIPPart>(sql.ToString()).ToList();
|
||||
db.Close();
|
||||
return parList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="lot"></param>
|
||||
public static void GetLotInformation(Lot lot)
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
//IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnectionProd"].ConnectionString);
|
||||
StringBuilder qryLotInfo = new StringBuilder();
|
||||
qryLotInfo.Append("SELECT WP_STATUS , WP_LOT_NO, WP_PART_NUMBER, MP_PRODUCT_FAMILY, MP_DESCRIPTION, ");
|
||||
qryLotInfo.Append("WP_CURRENT_QTY, WP_CURRENT_LOCATION, DieLotNumber, DiePartNo, DieCount, MP_QUALITY_CODE FROM SPNLot ");
|
||||
qryLotInfo.Append("WHERE WP_Lot_No = @LotNumber ");
|
||||
|
||||
//var tempLotNumber = lot.LotNumber.Substring(0, 9);
|
||||
var tempLotNumber = "";
|
||||
if (lot.LotNumber.IndexOf('/') >= 0)
|
||||
{
|
||||
tempLotNumber = lot.LotNumber.Substring(0, lot.LotNumber.IndexOf('/'));
|
||||
}
|
||||
else
|
||||
tempLotNumber = lot.LotNumber;
|
||||
|
||||
lot.LotNumber = tempLotNumber;
|
||||
var lotInfoRow = db.Query<dynamic>(qryLotInfo.ToString(), new { LotNumber = tempLotNumber }).ToList();
|
||||
foreach (dynamic lotInfoColumn in lotInfoRow)
|
||||
{
|
||||
lot.LotNumber = lotInfoColumn.WP_LOT_NO;
|
||||
if (lot.DieLotNumber == null || lot.DieLotNumber == "")
|
||||
lot.DieLotNumber = lotInfoColumn.DieLotNumber;
|
||||
|
||||
if (lotInfoColumn.WP_PART_NUMBER != null)
|
||||
lot.WipPartNo = lotInfoColumn.WP_PART_NUMBER.Trim();
|
||||
|
||||
if (lotInfoColumn.WP_CURRENT_LOCATION != null)
|
||||
{
|
||||
// The data is returned from a view which is a combination from various sources and at times when the
|
||||
// Lot is at the QDB location, which is extracted out of SAP, it also shows up at the 6600 location in SPN.
|
||||
// There is a duplication.
|
||||
//if the result returns 2 records , QDB overrides the other location (6600)
|
||||
if (lot.Location == "QDB" && lotInfoColumn.WP_CURRENT_LOCATION == "6600")
|
||||
lot.Location = "QDB";
|
||||
else
|
||||
lot.Location = lotInfoColumn.WP_CURRENT_LOCATION;
|
||||
}
|
||||
|
||||
|
||||
if (lotInfoColumn.MP_DESCRIPTION != null)
|
||||
{
|
||||
lot.Description = lotInfoColumn.MP_DESCRIPTION;
|
||||
if (lot.Description.Length > 0)
|
||||
{
|
||||
string[] temp = lot.Description.Split(new char[] { ',' });
|
||||
if (temp.Length > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
lot.ProductFamily = temp[0];
|
||||
}
|
||||
catch { } // ignore the error
|
||||
|
||||
try
|
||||
{
|
||||
//lot.Gen = double.Parse(temp[2].Substring(1, temp[2].Length - 1));
|
||||
if (lot.Description.StartsWith("MA,"))
|
||||
lot.Gen = temp[2];
|
||||
else
|
||||
lot.Gen = temp[2].Substring(1, temp[2].Length - 1);
|
||||
}
|
||||
catch { }// ignore the error
|
||||
try
|
||||
{
|
||||
//lot.Hexsize = double.Parse(temp[6]);
|
||||
lot.Hexsize = temp[6];
|
||||
}
|
||||
catch { }// ignore the error
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lotInfoColumn.WP_STATUS != null)
|
||||
lot.Status = lotInfoColumn.WP_STATUS;
|
||||
|
||||
|
||||
|
||||
if (lotInfoColumn.DiePartNo != null)
|
||||
lot.DiePartNo = lotInfoColumn.DiePartNo.Trim();
|
||||
|
||||
if (lotInfoColumn.WP_CURRENT_QTY != null)
|
||||
lot.WaferCount = lotInfoColumn.WP_CURRENT_QTY;
|
||||
|
||||
if (lot.WipPartNo.Length > 0 || lot.DiePartNo.Length > 0)
|
||||
{
|
||||
qryLotInfo.Clear();
|
||||
qryLotInfo.Append("SELECT DiePartNo, SourceFAB, Diameter, Silicon, Gen, Layers,HexSize,Voltage,Channel, Type AS ProductFamily, ");
|
||||
qryLotInfo.Append("WaferCost, DieCost FROM StdCost WHERE WIPWaferNo = @WIPPartNo OR DiePartNo = @DiePartNo ");
|
||||
var moreLotInfoRow = db.Query<dynamic>(qryLotInfo.ToString(), new { WIPPartNo = lot.WipPartNo, DiePartNo = lot.DiePartNo }).ToList();
|
||||
|
||||
foreach (var moreLotInfoColumn in moreLotInfoRow)
|
||||
{
|
||||
if (lotInfoColumn.DieCount != null && lotInfoColumn.DieCount != 0)
|
||||
lot.DieCount = int.Parse(lotInfoColumn.DieCount.ToString());
|
||||
lot.DieCost = double.Parse(moreLotInfoColumn.DieCost.ToString());
|
||||
lot.WaferCost = double.Parse(moreLotInfoColumn.WaferCost.ToString());
|
||||
|
||||
|
||||
|
||||
if (moreLotInfoColumn.Channel != null)
|
||||
lot.Channel = moreLotInfoColumn.Channel;
|
||||
|
||||
if (moreLotInfoColumn.Hexsize != null)
|
||||
lot.Hexsize = moreLotInfoColumn.Hexsize;
|
||||
|
||||
if (moreLotInfoColumn.Voltage != null)
|
||||
lot.Voltage = moreLotInfoColumn.Voltage;
|
||||
|
||||
|
||||
if (lot.DieCount > 0)
|
||||
lot.TotalCost = Math.Round(lot.DieCount * lot.DieCost, 2);
|
||||
else if (lot.WaferCount > 0)
|
||||
lot.TotalCost = Math.Round(lot.WaferCount * lot.WaferCost, 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// added this code if the data shows up at the 6600 location and also at QDB for a lot.
|
||||
//if (lot.DieCost > 0)
|
||||
// lot.Location = "QDB";
|
||||
|
||||
if (lotInfoColumn.MP_QUALITY_CODE != null)
|
||||
lot.QualityCode = lotInfoColumn.MP_QUALITY_CODE.Trim();
|
||||
|
||||
}
|
||||
|
||||
db.Close();
|
||||
//return lotStatusOption;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// /
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<UserProfile> GetUserList()
|
||||
{
|
||||
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.Append("SELECT FirstName + ' ' + LastName AS FullName, U.UserID AS UserId ");
|
||||
sql.Append("FROM Users U ");
|
||||
sql.Append("ORDER BY FirstName");
|
||||
|
||||
return db.Query<UserProfile>(sql.ToString()).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="issueID"></param>
|
||||
/// <param name="step"></param>
|
||||
/// <param name="documentType"></param>
|
||||
/// <returns></returns>
|
||||
public static List<string> GetApproverEmailListByDocument(int issueID, byte step, int documentType)
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@DocumentTypeID", documentType);
|
||||
parameters.Add("@IssueID", issueID);
|
||||
parameters.Add("@Step", step);
|
||||
var emailList = db.Query<string>("GetApproverEmailListByDocument", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return emailList;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="issueID"></param>
|
||||
/// <param name="step"></param>
|
||||
/// <param name="documentType"></param>
|
||||
/// <returns></returns>
|
||||
public static List<ApproversListViewModel> GetApproversListByDocument(int issueID, byte step, int documentType)
|
||||
{
|
||||
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@DocumentTypeID", documentType);
|
||||
parameters.Add("@IssueID", issueID);
|
||||
parameters.Add("@Step", step);
|
||||
var approverList = db.Query<ApproversListViewModel>("GetApproversListByDocument", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return approverList;
|
||||
}
|
||||
|
||||
public static IEnumerable<ApprovalModel> GetApprovalsByDocument(int issueID, int documentType)
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@DocumentTypeID", documentType);
|
||||
parameters.Add("@IssueID", issueID);
|
||||
var approvalList = db.Query<ApprovalModel>(
|
||||
"SELECT * FROM Approval WHERE IssueID = @IssueID AND DocumentTypeID = @DocumentTypeID", parameters);
|
||||
return approvalList.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// NOT IN USE YET
|
||||
/// </summary>
|
||||
/// <param name="issueID"></param>
|
||||
/// <param name="currentStep"></param>
|
||||
/// <param name="documentType"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<LoginModel> GetApprovedApproversListByDocument(int issueID, int currentStep, int documentType)
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
return db.Query<LoginModel>("GetApprovedApproversListByDocument", new { @DocumentTypeID = documentType, @IssueID = issueID, @Step = currentStep }, commandType: CommandType.StoredProcedure).ToList();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="issueID"></param>
|
||||
/// <param name="step"></param>
|
||||
/// <param name="documentType"></param>
|
||||
/// <returns></returns>
|
||||
public static List<ApproversListViewModel> GetPendingApproversListByDocument(int issueID, byte step, int documentType)
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@DocumentTypeID", documentType);
|
||||
parameters.Add("@IssueID", issueID);
|
||||
parameters.Add("@Step", step);
|
||||
var approverList = db.Query<ApproversListViewModel>("GetPendingApproversListByDocument", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return approverList;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="ecnNumber"></param>
|
||||
/// <returns></returns>
|
||||
public static List<string> GetEmergencyTECNApprovalNotifyList(int ecnNumber)
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@ECNNumber", ecnNumber);
|
||||
var approverList = db.Query<string>("ECNGetETECNApprovalNotificationList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return approverList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="ecnNumber"></param>
|
||||
/// <returns></returns>
|
||||
public static List<string> GetTECNCancelledApprovalNotifyList(int ecnNumber)
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@ECNNumber", ecnNumber);
|
||||
var approverList = db.Query<string>("ECN_TECNCancelledApprovalNotifyList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return approverList;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="workRequestID"></param>
|
||||
/// <returns></returns>
|
||||
public static List<string> GetFabGroupNotifyList(int workRequestID)
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@WorkRequestID", workRequestID);
|
||||
var notifyList = db.Query<string>("LTFabGroupApprovalNotificationList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return notifyList;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="workRequestID"></param>
|
||||
/// <returns></returns>
|
||||
public static List<string> GetWorkRequestRevisionNotifyList(int notificationType, int workRequestID, int userID)
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@NotificationType", notificationType);
|
||||
parameters.Add("@UserID", userID);
|
||||
parameters.Add("@WorkRequestID", workRequestID);
|
||||
var notifyList = db.Query<string>("LTGetWorkRequestRevisionNotifyList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return notifyList;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="notificationType"></param>
|
||||
/// <param name="workRequestID"></param>
|
||||
/// <param name="userID"></param>
|
||||
/// <returns></returns>
|
||||
public static List<string> GetWorkRequestApprovedNotifyList(int notificationType, int workRequestID, int userID)
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@NotificationType", notificationType);
|
||||
parameters.Add("@UserID", userID);
|
||||
parameters.Add("@WorkRequestID", workRequestID);
|
||||
var notifyList = db.Query<string>("LTGetWorkRequestApprovedNotifyList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return notifyList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="notificationType"></param>
|
||||
/// <param name="workRequestID"></param>
|
||||
/// <param name="userID"></param>
|
||||
/// <returns></returns>
|
||||
public static List<string> GetLotTravelerCreationAndRevisionNotifyList(int ltLotID, int workRequestID, int userID)
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@LotID", ltLotID);
|
||||
parameters.Add("@UserID", userID);
|
||||
parameters.Add("@WorkRequestID", workRequestID);
|
||||
var notifyList = db.Query<string>("LTGetLotTravelerCreationAndRevisionNotifyList", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return notifyList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="oooUserID"></param>
|
||||
/// <param name="delegatedTo"></param>
|
||||
/// <param name="startDate"></param>
|
||||
/// <param name="endDate"></param>
|
||||
public static int EnableOOOStatus(int oooUserID, int delegatedTo, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
int returnValue = 0;
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@OOOUserID", oooUserID);
|
||||
parameters.Add("@DelegatedTo", delegatedTo);
|
||||
parameters.Add("@OOOStartDate", startDate);
|
||||
parameters.Add("@OOOExpirationDate", endDate);
|
||||
parameters.Add("@ReturnValue", value: returnValue, direction: ParameterDirection.Output);
|
||||
|
||||
db.Execute("EnableOOOStatus", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
returnValue = parameters.Get<int>("@ReturnValue");
|
||||
|
||||
return returnValue;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="oooUserID"></param>
|
||||
/// <param name="delegatedTo"></param>
|
||||
/// <param name="startDate"></param>
|
||||
/// <param name="endDate"></param>
|
||||
public static void ExpireOOOStatus(int oooUserID)
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@OOOUserID", oooUserID);
|
||||
var approverList = db.Execute("ExpireOOOStatus", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static List<Department> GetDepartments()
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
var departments = db.Query<Department>("GetDepartments", null, commandType: CommandType.StoredProcedure).ToList();
|
||||
return departments;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static List<AffectedModule> GetModules()
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
|
||||
var modules = db.Query<AffectedModule>("GetModules", null, commandType: CommandType.StoredProcedure).ToList();
|
||||
return modules;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="lot"></param>
|
||||
public static void GetLTLotInformation(LTLot lot)
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
StringBuilder qryLotInfo = new StringBuilder();
|
||||
//qryLotInfo.Append("SELECT DISTINCT ");
|
||||
//qryLotInfo.Append("WP_LOT_NO, WP_CURRENT_QTY, WP.WP_PART_NUMBER, MP_DESCRIPTION, WP_PROCESS, WO_LOCATION, WO_OPER_NO, WP_STATUS ");
|
||||
//qryLotInfo.Append("FROM TEMIRWAP019.FAB2SPN.dbo.WO_RECORD WO ");
|
||||
//qryLotInfo.Append("INNER JOIN TEMIRWAP019.FAB2SPN.dbo.WP_RECORD WP ");
|
||||
//qryLotInfo.Append("ON WO.WO_LOT_NO = WP.WP_LOT_NO AND WO.InTime = (SELECT MAX(InTime) FROM TEMIRWAP019.FAB2SPN.dbo.WO_RECORD WHERE WO_LOT_NO = @LotNumber) ");
|
||||
//qryLotInfo.Append("LEFT JOIN TEMIRWAP019.FAB2SPN.dbo.MP_RECORD MP ");
|
||||
//qryLotInfo.Append("ON WP.WP_PART_NUMBER = MP.MP_PART_NUMBER ");
|
||||
//qryLotInfo.Append("WHERE WO_LOT_NO = @LotNumber ");
|
||||
|
||||
qryLotInfo.Append("SELECT DISTINCT ");
|
||||
qryLotInfo.Append("WP_LOT_NO, WP_CURRENT_QTY, WP.WP_PART_NUMBER, MP_DESCRIPTION, WP_PROCESS, WP_CURRENT_LOCATION, WP_OPER_NO, WP_STATUS ");
|
||||
qryLotInfo.Append("FROM vFAB2SPN_WP_RECORD WP ");
|
||||
qryLotInfo.Append("LEFT JOIN vFAB2SPN_MP_RECORD MP ");
|
||||
qryLotInfo.Append("ON WP.WP_PART_NUMBER = MP.MP_PART_NUMBER ");
|
||||
qryLotInfo.Append("WHERE WP_LOT_NO = @LotNumber ");
|
||||
|
||||
//var tempLotNumber = lot.LotNumber.Substring(0, 9);
|
||||
|
||||
var tempLotNumber = "";
|
||||
if (lot.LotNumber.IndexOf('/') >= 0)
|
||||
{
|
||||
tempLotNumber = lot.LotNumber.Substring(0, lot.LotNumber.IndexOf('/'));
|
||||
}
|
||||
else
|
||||
tempLotNumber = lot.LotNumber;
|
||||
|
||||
lot.LotNumber = tempLotNumber;
|
||||
|
||||
lot.LotNumber = tempLotNumber;
|
||||
var lotInfoRow = db.Query<dynamic>(qryLotInfo.ToString(), new { LotNumber = tempLotNumber }).ToList();
|
||||
foreach (dynamic lotInfoColumn in lotInfoRow)
|
||||
{
|
||||
lot.WIPPartNumber = lotInfoColumn.WP_PART_NUMBER;
|
||||
lot.WaferQty = lotInfoColumn.WP_CURRENT_QTY;
|
||||
lot.PartDescription = lotInfoColumn.MP_DESCRIPTION;
|
||||
lot.Process = lotInfoColumn.WP_PROCESS;
|
||||
lot.Operation = lotInfoColumn.WP_OPER_NO;
|
||||
lot.LotStatus = lotInfoColumn.WP_STATUS;
|
||||
lot.Location = lotInfoColumn.WP_CURRENT_LOCATION;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="userID"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetEmail(int? userID)
|
||||
{
|
||||
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@UserID", userID);
|
||||
var email = db.Query<string>("GetEmail", parameters, commandType: CommandType.StoredProcedure).Single();
|
||||
return email;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="issueID"></param>
|
||||
/// <returns></returns>
|
||||
public static List<string> Get8DEmailListForClosureNotification(int issueID)
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
|
||||
parameters.Add("@DocID", issueID);
|
||||
var emailList = db.Query<string>("_8DGetEmailListClosureNotification", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return emailList;
|
||||
|
||||
}
|
||||
|
||||
public static CredentialsStorage GetCredentialsInfo(string serverName, string credentialType) // TODO - need to use an enum for the credentialType
|
||||
{
|
||||
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@ServerName", serverName);
|
||||
parameters.Add("@CredentialType", credentialType);
|
||||
var data = db.Query<CredentialsStorage>("GetCredentialsInfo", param: parameters, commandType: CommandType.StoredProcedure).Single();
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
//================================================================== End of Class
|
||||
}
|
||||
}
|
129
Fab2ApprovalSystem/DMO/PartsRequestDMO.cs
Normal file
129
Fab2ApprovalSystem/DMO/PartsRequestDMO.cs
Normal file
@ -0,0 +1,129 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Fab2ApprovalSystem.Models;
|
||||
using Dapper;
|
||||
using System.Transactions;
|
||||
using Fab2ApprovalSystem.Misc;
|
||||
|
||||
namespace Fab2ApprovalSystem.DMO
|
||||
{
|
||||
public class PartsRequestDMO
|
||||
{
|
||||
private IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
|
||||
WorkflowDMO wfDMO = new WorkflowDMO();
|
||||
|
||||
public IEnumerable<PartsRequestList> GetPartsRequestList()
|
||||
{
|
||||
var r = this.db.Query<PartsRequestList>("PartsRequestGetList", commandType: CommandType.StoredProcedure).ToList();
|
||||
return r;
|
||||
}
|
||||
|
||||
public void Insert(PartsRequest pr)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@PRNumber", value: pr.PRNumber, dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
|
||||
parameters.Add("@OriginatorID", pr.OriginatorID);
|
||||
|
||||
this.db.Execute("PartsRequestInsert", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
pr.PRNumber = parameters.Get<int>("@PRNumber");
|
||||
}
|
||||
|
||||
public void Update(PartsRequest pr)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@PRNumber", pr.PRNumber);
|
||||
parameters.Add("@Title", pr.Title);
|
||||
parameters.Add("@RequestorID", pr.RequestorID);
|
||||
parameters.Add("@TechLeadID", pr.TechLeadID);
|
||||
parameters.Add("@Description", pr.Description);
|
||||
|
||||
this.db.Execute("PartsRequestUpdate", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
|
||||
public PartsRequest Get(int PRNumber)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@PRNumber", value: PRNumber, dbType: DbType.Int32);
|
||||
|
||||
return this.db.Query<PartsRequest>("PartsRequestGet", parameters, commandType: CommandType.StoredProcedure).SingleOrDefault();
|
||||
}
|
||||
|
||||
public IEnumerable<PartsRequestAttachmentList> GetAttachments(int prNumber)
|
||||
{
|
||||
var attachments = this.db.Query<PartsRequestAttachmentList>(
|
||||
"SELECT AttachmentID, PRNumber, FileName, A.UserID, UploadDate, U.FirstName + ' ' + U.LastName AS FullName " +
|
||||
"FROM PartsRequestAttachment A " +
|
||||
"INNER JOIN Users U ON U.UserID = A.UserID " +
|
||||
"WHERE PRNumber = @PRNumber",
|
||||
new { PRNumber = prNumber }).ToList();
|
||||
return attachments;
|
||||
}
|
||||
|
||||
public void InsertAttachment(PartsRequestAttachment attach)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@PRNumber", attach.PRNumber);
|
||||
parameters.Add("@UserID", attach.UserID);
|
||||
parameters.Add("@FileName", attach.FileName);
|
||||
|
||||
this.db.Execute("PartsRequestInsertAttachment", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
|
||||
public string GetFileName(string attachmentID)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@AttachmentID", attachmentID);
|
||||
var fileName = this.db.Query<string>("PartsRequestGetAttachmentFileName", parameters, commandType: CommandType.StoredProcedure).Single();
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void DeleteAttachment(int attachmentID)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@AttachmentID", attachmentID);
|
||||
this.db.Execute("PartsRequestDeleteAttachment", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
|
||||
public void Submit(int prNumber, int userID)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@PRNumber", prNumber);
|
||||
parameters.Add("@UserID", userID);
|
||||
this.db.Execute("PartsRequestSubmitForApproval", parameters, commandType: CommandType.StoredProcedure );
|
||||
}
|
||||
|
||||
public IEnumerable<ApprovalLogHistory> GetApprovalLogHistory(int prNumber)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@PRNumber", prNumber);
|
||||
var approverList = this.db.Query<ApprovalLogHistory>("PartsRequestGetApprovalLogHistory", parameters, commandType: CommandType.StoredProcedure).ToList();
|
||||
return approverList;
|
||||
}
|
||||
|
||||
public IEnumerable<MyPartsRequestList> GetMyPartsRequests(int userID)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@UserID", userID);
|
||||
|
||||
var r = this.db.Query<MyPartsRequestList>("PartsRequestGetListByUser", parameters, commandType: CommandType.StoredProcedure);
|
||||
return r.ToList();
|
||||
}
|
||||
|
||||
public void DeleteDocument(int prNumber, int userid)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@UserID", userid);
|
||||
parameters.Add("@PRNumber", prNumber);
|
||||
|
||||
this.db.Execute("PartsRequestDelete", parameters, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
29
Fab2ApprovalSystem/DMO/SAM_DMO.cs
Normal file
29
Fab2ApprovalSystem/DMO/SAM_DMO.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Dapper;
|
||||
using System.Text;
|
||||
|
||||
namespace Fab2ApprovalSystem.DMO
|
||||
{
|
||||
public class SAM_DMO
|
||||
{
|
||||
private IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["SAMDBConnectionString"].ConnectionString);
|
||||
|
||||
|
||||
public int HasITARAccess(string userID)
|
||||
{
|
||||
|
||||
StringBuilder query = new StringBuilder("SELECT COUNT(*) FROM dbo.fnIsUserITARCompliant(@UserID) ");
|
||||
//query.Append("WHERE UserID = @UserID AND AND EmployeeStatus = 'Active'");
|
||||
return this.db.Query<int>(query.ToString(), new { UserID = userID }).SingleOrDefault();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
452
Fab2ApprovalSystem/DMO/TrainingDMO.cs
Normal file
452
Fab2ApprovalSystem/DMO/TrainingDMO.cs
Normal file
@ -0,0 +1,452 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Dapper;
|
||||
using Fab2ApprovalSystem.Models;
|
||||
using System.Text;
|
||||
|
||||
namespace Fab2ApprovalSystem.DMO
|
||||
{
|
||||
public class TrainingDMO
|
||||
{
|
||||
private IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
private static FabApprovalTrainingEntities FabApprovalDB = new FabApprovalTrainingEntities();
|
||||
|
||||
public int Create(int issueId)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
|
||||
parameters = new DynamicParameters();
|
||||
parameters.Add("@TrainingId", dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
|
||||
parameters.Add("@ECNNumber", issueId);
|
||||
|
||||
this.db.Execute("InsertTrainingItem", parameters, commandType: CommandType.StoredProcedure);
|
||||
int trainingId = parameters.Get<int>("@TrainingId");
|
||||
|
||||
return trainingId;
|
||||
}
|
||||
public int CreateAssignment(int trainingId, int userId)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
|
||||
parameters = new DynamicParameters();
|
||||
//parameters.Add("@TrainingId", dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
|
||||
parameters.Add("@TrainingID", trainingId);
|
||||
parameters.Add("@UserID", userId);
|
||||
parameters.Add("@AssignmentID", dbType: DbType.Int32, direction: ParameterDirection.InputOutput);
|
||||
|
||||
this.db.Execute("InsertTrainingAssignment", parameters, commandType: CommandType.StoredProcedure);
|
||||
int assignmentId = parameters.Get<int>("@AssignmentID");
|
||||
|
||||
return assignmentId;
|
||||
}
|
||||
public IEnumerable<Training> GetAllTrainings()
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
IEnumerable<Training> allTrainings = (from a in db.Trainings select a).ToList();
|
||||
|
||||
return allTrainings;
|
||||
}
|
||||
public Training GetTraining(int trainingId)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
Training trainingRecord = new Training();
|
||||
trainingRecord = (from a in db.Trainings where a.TrainingID == trainingId select a).FirstOrDefault();
|
||||
return trainingRecord;
|
||||
}
|
||||
public TrainingAssignment GetAssignment(int assignmentId)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
TrainingAssignment assignmentRecord = (from a in db.TrainingAssignments where a.ID == assignmentId select a).FirstOrDefault();
|
||||
return assignmentRecord;
|
||||
}
|
||||
public int GetTrainingId(int issueId)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
int ECNId = issueId;
|
||||
int trainingId = (from a in db.Trainings where a.ECN == ECNId select a.TrainingID).FirstOrDefault();
|
||||
|
||||
return trainingId;
|
||||
}
|
||||
public List<int> GetTrainees(int groupId)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
var users = (from a in db.TrainingGroupMembers where a.TrainingGroupID == groupId select a.UserID).ToList();
|
||||
|
||||
return users;
|
||||
}
|
||||
public bool isUserTrainingMember(int groupId, int userId)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
var users = (from a in db.TrainingGroupMembers where a.TrainingGroupID == groupId && a.UserID == userId select a).FirstOrDefault();
|
||||
|
||||
if (users == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
public List<TrainingGroup> GetTrainingGroups()
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
return (from a in db.TrainingGroups select a).ToList();
|
||||
}
|
||||
public TrainingGroup GetTrainingGroupByID(int groupId)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
TrainingGroup groups = (from a in db.TrainingGroups where a.TrainingGroupID == groupId select a).FirstOrDefault();
|
||||
return groups;
|
||||
}
|
||||
public List<int> GetECNAssignedTrainingGroups(int ECNNumber)
|
||||
{
|
||||
List<int> trainingGroups = (from a in FabApprovalDB.ECNTrainingBies where a.ECNNumber == ECNNumber select a.AcknowledgementTrainingByID).ToList();
|
||||
|
||||
return trainingGroups;
|
||||
}
|
||||
public void AddTrainingGroupToECN(int ECNNumber, int groupId)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
//ECNTrainingBy ecnTraining = new ECNTrainingBy();
|
||||
//ecnTraining.AcknowledgementTrainingByID = groupId;
|
||||
//ecnTraining.ECNNumber = ECNNumber;
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@ECNNumber", ECNNumber);
|
||||
parameters.Add("@TrainingByID", groupId);
|
||||
|
||||
this.db.Execute("ECNInsertTrainingBy", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
|
||||
|
||||
|
||||
//db.ECNTrainingBies.Add(ecnTraining);
|
||||
|
||||
}
|
||||
public void SetTrainingFlag(int ECNNumber)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
//ECNTrainingBy ecnTraining = new ECNTrainingBy();
|
||||
//ecnTraining.AcknowledgementTrainingByID = groupId;
|
||||
//ecnTraining.ECNNumber = ECNNumber;
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@ECNNumber", ECNNumber);
|
||||
|
||||
this.db.Execute("ECNSetTrainingFlag", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
|
||||
|
||||
|
||||
//db.ECNTrainingBies.Add(ecnTraining);
|
||||
|
||||
}
|
||||
public List<TrainingAssignment> GetAllTrainingAssignments(int TrainingID)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
var TrainingData = from a in db.TrainingAssignments where a.TrainingID == TrainingID select a;
|
||||
|
||||
return TrainingData.ToList();
|
||||
}
|
||||
public List<TrainingAssignment> GetTrainingAssignments(int TrainingID)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
var TrainingData = from a in db.TrainingAssignments where a.TrainingID == TrainingID && a.Deleted != true select a;
|
||||
|
||||
return TrainingData.ToList();
|
||||
}
|
||||
public List<TrainingAssignment> GetTrainingAssignmentsByUser(int TrainingID, int userID)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
var TrainingData = from a in db.TrainingAssignments where a.TrainingID == TrainingID && a.UserID == userID select a;
|
||||
|
||||
return TrainingData.ToList();
|
||||
}
|
||||
public List<TrainingDocAck> GetAssignedDocs(int trainingAssignmentId)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
var docs = (from a in db.TrainingDocAcks where a.TrainingAssignmentID == trainingAssignmentId && a.Deleted != true select a).ToList();
|
||||
|
||||
return docs;
|
||||
}
|
||||
public void AcknowledgeDocument(int trainingDocAckID)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
|
||||
parameters = new DynamicParameters();
|
||||
parameters.Add("@TrainingDocAckID", trainingDocAckID);
|
||||
//parameters.Add("@AttachmentID", attachmentID);
|
||||
|
||||
this.db.Execute("TrainingAcknowledgeDocument", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
}
|
||||
public void UpdateAssignmentStatus(int trainingAssignmentID)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
var RecordToUpdate = (from a in db.TrainingAssignments where a.ID == trainingAssignmentID select a).SingleOrDefault();
|
||||
if(RecordToUpdate.status != true)
|
||||
{
|
||||
RecordToUpdate.DateCompleted = DateTime.Now;
|
||||
RecordToUpdate.status = true;
|
||||
try
|
||||
{
|
||||
db.SaveChanges();
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
string exception = e.ToString();
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public int GetTrainingIdByAssignment(int trainingAssignmentID)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
int trainingID = (from a in db.TrainingAssignments where a.ID == trainingAssignmentID select a.TrainingID).SingleOrDefault();
|
||||
|
||||
return trainingID;
|
||||
}
|
||||
public void UpdateTrainingStatus(int trainingId)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
Training training = (from a in db.Trainings where a.TrainingID == trainingId select a).SingleOrDefault();
|
||||
|
||||
if (training != null)
|
||||
{
|
||||
training.CompletedDate = DateTime.Now;
|
||||
training.Status = true;
|
||||
|
||||
try
|
||||
{
|
||||
db.SaveChanges();
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
string exception = e.ToString();
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void reOpenTraining(int trainingId)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
Training training = (from a in db.Trainings where a.TrainingID == trainingId select a).SingleOrDefault();
|
||||
|
||||
if (training != null)
|
||||
{
|
||||
training.CompletedDate = null;
|
||||
training.Status = false;
|
||||
|
||||
try
|
||||
{
|
||||
db.SaveChanges();
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
string exception = e.ToString();
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckTrainingStatus(int trainingAssignmentID)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
bool isFinished = true;
|
||||
int trainingID = (from a in db.TrainingAssignments where a.ID == trainingAssignmentID select a.TrainingID).SingleOrDefault();
|
||||
var trainingAssignments = from a in db.TrainingAssignments where a.TrainingID == trainingID && a.Deleted != true select a;
|
||||
|
||||
foreach (var training in trainingAssignments)
|
||||
{
|
||||
if (training.status == false)
|
||||
{
|
||||
isFinished = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return isFinished;
|
||||
}
|
||||
|
||||
public bool CheckTrainingAssignmentStatus(int trainingAssignmentID)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
bool isFinished = true;
|
||||
//TrainingDocAck docsAssigned = null;
|
||||
|
||||
var docsAssigned = from a in db.TrainingDocAcks where a.TrainingAssignmentID == trainingAssignmentID && a.Deleted != true select a;
|
||||
|
||||
|
||||
|
||||
|
||||
foreach (var doc in docsAssigned)
|
||||
{
|
||||
if (doc.Reviewed == false)
|
||||
{
|
||||
isFinished = false;
|
||||
}
|
||||
}
|
||||
|
||||
return isFinished;
|
||||
}
|
||||
public bool IsUserAssigned(int userId, int trainingId)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
bool userHasAssignment = false;
|
||||
|
||||
var assignments = (from a in db.TrainingAssignments where a.TrainingID == trainingId && a.UserID == userId && a.Deleted != true select a).ToList();
|
||||
|
||||
if(assignments.Count() > 0)
|
||||
{
|
||||
userHasAssignment = true;
|
||||
}
|
||||
|
||||
return userHasAssignment;
|
||||
}
|
||||
public List<Training> GetTrainings()
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
var trainings = from a in db.Trainings select a;
|
||||
|
||||
return trainings.ToList();
|
||||
}
|
||||
public List<TrainingAssignment> GetTrainingAssignmentsByUserID(int userID)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
var trainingAssignments = from a in db.TrainingAssignments where a.UserID == userID && a.Deleted != true select a;
|
||||
|
||||
return trainingAssignments.ToList();
|
||||
}
|
||||
|
||||
public void DeleteTrainingAssignment(int trainingAssignmentId)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
var trainingAssignments = from a in db.TrainingAssignments where a.ID == trainingAssignmentId select a;
|
||||
|
||||
foreach (var item in trainingAssignments)
|
||||
{
|
||||
item.Deleted = true;
|
||||
item.DeletedDate = DateTime.Now;
|
||||
}
|
||||
try
|
||||
{
|
||||
db.SaveChanges();
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
string exception = e.ToString();
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
public void DeleteTrainingDocAck(int trainingAssignmentId)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
var trainingDocAcks = from a in db.TrainingDocAcks where a.TrainingAssignmentID == trainingAssignmentId select a;
|
||||
|
||||
foreach (var item in trainingDocAcks)
|
||||
{
|
||||
item.Deleted = true;
|
||||
item.DeletedDate = DateTime.Now;
|
||||
}
|
||||
try
|
||||
{
|
||||
db.SaveChanges();
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
string exception = e.ToString();
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
public void DeleteTraining(int trainingId)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
Training training = (from a in db.Trainings where a.TrainingID == trainingId select a).FirstOrDefault();
|
||||
|
||||
training.Deleted = true;
|
||||
training.DeletedDate = DateTime.Now;
|
||||
|
||||
List<TrainingAssignment> trainingAssignments = (from a in db.TrainingAssignments where a.TrainingID == trainingId select a).ToList();
|
||||
db.SaveChanges();
|
||||
foreach (TrainingAssignment trainingAssignment in trainingAssignments)
|
||||
{
|
||||
DeleteTrainingAssignment(trainingAssignment.ID);
|
||||
DeleteTrainingDocAck(trainingAssignment.ID);
|
||||
//db.SaveChanges();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public void DeleteAssignmentByUserId(int userId)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
|
||||
var userAssignments = (from a in db.TrainingAssignments where a.UserID == userId select a).ToList();
|
||||
|
||||
foreach (var item in userAssignments)
|
||||
{
|
||||
//get document assignments
|
||||
var docAssignments = (from a in db.TrainingDocAcks where a.TrainingAssignmentID == item.TrainingID select a).ToList();
|
||||
//delete each docAssignment
|
||||
foreach (var docAssignment in docAssignments)
|
||||
{
|
||||
DeleteTrainingDocAck(docAssignment.ID);
|
||||
}
|
||||
DeleteTrainingAssignment(item.ID);
|
||||
}
|
||||
}
|
||||
public bool CheckValidDocAck(int docAckId)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
TrainingDocAck ack = (from a in db.TrainingDocAcks where a.ID == docAckId select a).FirstOrDefault();
|
||||
|
||||
//TODO Check the user is valid
|
||||
|
||||
//Check that the assignment exists
|
||||
if (ack != null)
|
||||
{
|
||||
//Check that the assignment isn't deleted
|
||||
if (ack.Deleted == true)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//Check that the assignment isn't completed
|
||||
else if (ack.Reviewed == true)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
public List<Training> GetAllOpenTrainings()
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
List<Training> openTrainings = (from a in db.Trainings where a.Status != true && a.Deleted != true select a).ToList();
|
||||
return openTrainings;
|
||||
}
|
||||
public List<TrainingAssignment> GetOpenAssignmentsByTrainingID(int trainingID)
|
||||
{
|
||||
FabApprovalTrainingEntities db = new FabApprovalTrainingEntities();
|
||||
List<TrainingAssignment> openAssignments = (from a in FabApprovalDB.TrainingAssignments where a.TrainingID == trainingID && a.status != true && a.Deleted != true select a).ToList();
|
||||
return openAssignments;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
212
Fab2ApprovalSystem/DMO/UserAccountDMO.cs
Normal file
212
Fab2ApprovalSystem/DMO/UserAccountDMO.cs
Normal file
@ -0,0 +1,212 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Dapper;
|
||||
using Fab2ApprovalSystem.Models;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace Fab2ApprovalSystem.DMO
|
||||
{
|
||||
public class UserAccountDMO
|
||||
{
|
||||
private IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["FabApprovalConnection"].ConnectionString);
|
||||
|
||||
|
||||
//public List<LoginModel> GetUser(string loginID)
|
||||
//{
|
||||
// StringBuilder sql = new StringBuilder();
|
||||
// sql.Append("SELECT * FROM Users WHERE LoginID = '" + loginID + "'");
|
||||
|
||||
// return this.db.Query<LoginModel>(sql.ToString()).ToList();
|
||||
//}
|
||||
|
||||
public IEnumerable<LoginModel> GetAllUsers()
|
||||
{
|
||||
StringBuilder sql = new StringBuilder();
|
||||
//sql.Append("SELECT U.FirstName + ' ' + U.LastName AS FullName, U1.FirstName + ' ' + U1.LastName AS DelegatedToFullName, U.* ");
|
||||
//sql.Append("FROM Users U LEFT JOIN Users U1 ");
|
||||
//sql.Append("ON U.UserID = U1.DelegatedTo ORDER BY FirstName ");
|
||||
|
||||
//sql.Append("SELECT FirstName + ' ' + LastName AS FullName, * FROM Users ORDER BY FirstName ");
|
||||
sql.Append(" SELECT U.FirstName + ' ' + U.LastName AS FullName, U.* , U1.FirstName + ' ' + U1.LastName AS DelegatedToFullName ");
|
||||
sql.Append("FROM Users U LEFT JOIN Users U1 ON U.DelegatedTo = U1.UserID ");
|
||||
sql.Append("ORDER BY FirstName ");
|
||||
|
||||
return this.db.Query<LoginModel>(sql.ToString()).ToList();
|
||||
}
|
||||
public IEnumerable<LoginModel> GetAllActiveUsers()
|
||||
{
|
||||
StringBuilder sql = new StringBuilder();
|
||||
//sql.Append("SELECT U.FirstName + ' ' + U.LastName AS FullName, U1.FirstName + ' ' + U1.LastName AS DelegatedToFullName, U.* ");
|
||||
//sql.Append("FROM Users U LEFT JOIN Users U1 ");
|
||||
//sql.Append("ON U.UserID = U1.DelegatedTo ORDER BY FirstName ");
|
||||
|
||||
//sql.Append("SELECT FirstName + ' ' + LastName AS FullName, * FROM Users ORDER BY FirstName ");
|
||||
sql.Append(" SELECT U.FirstName + ' ' + U.LastName AS FullName, U.* , U1.FirstName + ' ' + U1.LastName AS DelegatedToFullName ");
|
||||
sql.Append("FROM Users U LEFT JOIN Users U1 ON U.DelegatedTo = U1.UserID ");
|
||||
sql.Append("WHERE U.IsActive = 1 ");
|
||||
sql.Append("ORDER BY FirstName ");
|
||||
|
||||
return this.db.Query<LoginModel>(sql.ToString()).ToList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public LoginModel GetUser(string loginID)
|
||||
{
|
||||
//StringBuilder sql = new StringBuilder();
|
||||
//sql.Append("SELECT * FROM Users WHERE LoginID = '" + loginID + "'");
|
||||
|
||||
//return this.db.Query<LoginModel>(sql.ToString()).SingleOrDefault();
|
||||
|
||||
|
||||
return this.db.Query<LoginModel>("SELECT FirstName + ' ' + LastName AS FullName, * FROM Users WHERE LoginID = @loginID AND IsActive = 1 ", new { loginID = loginID }).Take(1).SingleOrDefault();
|
||||
}
|
||||
|
||||
public LoginModel GetUserByID(int userID)
|
||||
{
|
||||
return this.db.Query<LoginModel>(
|
||||
"SELECT FirstName + ' ' + LastName AS FullName, * FROM Users WHERE UserID = @UserID ",
|
||||
new { UserID = userID }).Take(1).SingleOrDefault();
|
||||
}
|
||||
|
||||
public string GetUserEmailByID(string userID)
|
||||
{
|
||||
return this.db.Query<string>(
|
||||
"SELECT Email FROM Users WHERE UserID = @UserID ",
|
||||
new { UserID = userID }).Take(1).SingleOrDefault();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
internal void UpdateUser(LoginModel model)
|
||||
{
|
||||
string sql;
|
||||
sql = "UPDATE Users SET LoginID = @LoginID, FirstName = @FirstName, LastName = @LastName, Email = @Email, IsActive = @IsActive, IsAdmin = @IsAdmin WHERE UserID = @UserID";
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@UserID", model.UserID);
|
||||
parameters.Add("@LoginID", model.LoginID);
|
||||
parameters.Add("@FirstName", model.FirstName);
|
||||
parameters.Add("@LastName", model.LastName );
|
||||
parameters.Add("@Email", model.Email);
|
||||
parameters.Add("@IsAdmin", model.IsAdmin);
|
||||
parameters.Add("@IsActive", model.IsActive);
|
||||
|
||||
this.db.Execute(sql, parameters);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
internal void DeleteUser(LoginModel model)
|
||||
{
|
||||
string sql;
|
||||
//sql = "DELETE Users WHERE UserID = @UserID";
|
||||
sql = "UPDATE Users SET IsActive = 0 WHERE UserID = @UserID";
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@UserID", model.UserID);
|
||||
|
||||
this.db.Execute(sql, parameters);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
internal void InsertUser(LoginModel model)
|
||||
{
|
||||
//string sql;
|
||||
//sql = "INSERT Users (LoginID, FirstName, LastName, IsAdmin) VALUES (@LoginID, @FirstName, @LastName, @IsAdmin )";
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@UserID", model.UserID, DbType.Int32, direction: ParameterDirection.InputOutput);
|
||||
parameters.Add("@LoginID", model.LoginID);
|
||||
parameters.Add("@FirstName", model.FirstName);
|
||||
parameters.Add("@LastName", model.LastName);
|
||||
parameters.Add("@Email", model.Email);
|
||||
parameters.Add("@IsAdmin", model.IsAdmin);
|
||||
|
||||
this.db.Execute("InsertUsers", parameters, commandType: CommandType.StoredProcedure);
|
||||
int userid = parameters.Get<int>("@UserID");
|
||||
model.UserID = userid;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="userID"></param>
|
||||
/// <param name="hasITARAccess"></param>
|
||||
internal void UpdateInsertITARAccess(string userID, string hasITARAccess)
|
||||
{
|
||||
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@UserID", userID);
|
||||
parameters.Add("@HasITARAccess", hasITARAccess);
|
||||
|
||||
this.db.Execute("ITARAccessUpdateInsert", parameters, commandType: CommandType.StoredProcedure);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="userID"></param>
|
||||
/// <returns></returns>
|
||||
internal bool GetITARAccess(int userID)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@UserID", userID);
|
||||
|
||||
var results = this.db.Query<string>(
|
||||
"SELECT HasITARAccess FROM SAMUsers, Users WHERE Users.UserID = @UserID AND SAMUsers.UserID = Users.LoginID",
|
||||
parameters, commandType: CommandType.Text);
|
||||
if ((results != null) && (results.Count() > 0) && (results.First() == "1"))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="userID"></param>
|
||||
/// <returns></returns>
|
||||
internal bool GetEC_AD_Users(string userID)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@UserID", userID);
|
||||
|
||||
var results = this.db.Query<string>(
|
||||
"SELECT UserID FROM EC_AD_Users WHERE UserID = @UserID",
|
||||
parameters, commandType: CommandType.Text);
|
||||
if ((results != null) && (results.Count() > 0))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
internal void ProcessOoO()
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
this.db.Execute("ProcesOOOEnableStatus", commandType: CommandType.StoredProcedure);
|
||||
|
||||
}
|
||||
internal void ExpireOoO()
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
this.db.Execute("ProcesOOOExpiration", commandType: CommandType.StoredProcedure);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
1015
Fab2ApprovalSystem/DMO/WorkflowDMO.cs
Normal file
1015
Fab2ApprovalSystem/DMO/WorkflowDMO.cs
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user