public static void RequestAccess(string engNum, WsUserType wsUserType, string emailUsers, string comment = null) { var dtNow = DateTime.Now; var wsModel = Workspace.GetEngByEngNum(engNum, WsLoadType.Groups, true).FirstOrDefault(); var recepients = Workspace.GetEmailRecepientsForEng(wsModel, EmailRecepientType.ADMIN, true); emailUsers = emailUsers.ToUpper(); var sp_emailUsers = emailUsers.Split(',').ToList(); var filterRecepients = recepients.Where(x => (sp_emailUsers.Contains((x.Item2 + "@kpmg.com").ToUpper()) || (x.Item2.Equals(AuditManager.Common.AmUtil.GetCurrentUser, StringComparison.OrdinalIgnoreCase)))).ToList(); var mailText = AmUtil.SendMail_RequestAccess(WsActivityType.Workspace_RequestAccess.ToString(), wsModel.WsProfile.EngNum, wsModel.Name, filterRecepients, wsUserType.ToString(), comment); var recepientArray = string.Join(",", filterRecepients.Select(x => x.Item2).ToList()); //INSERT INTO [AuditManager].[dbo].[WsActivity] VALUES (25, 'Workspace') //INSERT INTO [AuditManager].[dbo].[WsActivity] VALUES (26, 'Workspace_RequestAccess') using (var db = new AmDbContext()) { var wsActivityHistory = db.WsActivityHistory.Add( new WsActivityHistory { EngNum = engNum, UserId = AmUtil.GetCurrentUser, WsActivityTypeId = WsActivityType.Workspace, WsSubActivityTypeId = WsActivityType.Workspace_RequestAccess, Comment = comment, WsActivityInfo = wsUserType.ToString(), DateCreated = dtNow } ); db.SaveChanges(); var wsMail = db.WsMail.Add(new WsMail { WsActivityHistoryId = wsActivityHistory.WsActivityHistoryId, WsMailStatusTypeId = WsMailStatusType.Success, MailText = mailText, RecepientArray = recepientArray }); db.SaveChanges(); } }
public void RequestAccess(string engNum, WsUserType wsUserType, string emailUsers, string comment) { AuditManager.Rep.WsCreate.RequestAccess(engNum, wsUserType, emailUsers, comment); }