// public void SendEmailWithAttachment(string fromEmail, string toEmail, string ccEmail, string emailSubject, string emailBody, Stream attachment, string attachmentFilename) public void SendEmailWithAttachment(EmailRequest request) { SMTPClient emailClient = new SMTPClient(); try { EmailHelper emailHelper = new EmailHelper(emailClient); emailHelper.SendMail(request.FromEmail, request.ToEmail, request.CcEmail, request.EmailSubject, request.EmailBody, request.Attachment, request.AttachmentFilename); } catch (Exception ex) { /*log error locally */ string message = string.Format( "Error in public void SendEmail(string fromEmail:{0}, string toEmail:{1}, string ccEmail:{2}, string emailSubject:{3}, string emailBody:{4}); string attachment filename: {6}; Detailed exception:{5}", request.FromEmail, request.ToEmail, request.CcEmail, request.EmailSubject, request.EmailBody, ex.ToString(), request.AttachmentFilename); Exception custom = new Exception(message); ExceptionManager.HandleException(custom); ServiceErrorFault fault = new ServiceErrorFault(); fault.Operation = "Send Email"; fault.ProblemType = "Error sending email"; throw new FaultException <ServiceErrorFault>(fault); } }
public void SendEmail(string fromEmail, string toEmail, string ccEmail, string emailSubject, string emailBody) { SMTPClient emailClient = new SMTPClient(); try { EmailHelper emailHelper = new EmailHelper(emailClient); emailHelper.SendMail(fromEmail, toEmail, ccEmail, emailSubject, emailBody); } catch (Exception ex) { /*log erorr locally */ string message = string.Format("Error in public void SendEmail(string fromEmail:{0}, string toEmail:{1}, string ccEmail:{2}, string emailSubject:{3}, string emailBody:{4}); Detailed exception:{5}", fromEmail, toEmail, ccEmail, emailSubject, emailBody, ex.ToString()); Exception custom = new Exception(message); ExceptionManager.HandleException(custom); ServiceErrorFault fault = new ServiceErrorFault(); fault.Operation = "Send Email"; fault.ProblemType = "Error sending email"; throw new FaultException <ServiceErrorFault>(fault); } }
/// <summary> /// Returns AD User for passed in Login Id /// </summary> /// <param name="samAccountName"></param> /// <returns></returns> public ADUser SearchUserByLogin(string samAccountName) { try { var searcher = new RealPrincipalSearcher(); ActiveDirectoryHelper helper = new ActiveDirectoryHelper(searcher); return(helper.SearchUserByLogin(samAccountName)); } catch (Exception ex) { ///*log erorr locally */ string message = string.Format("Error in SearchUserByLogin(string samAccountName:{0}); Detailed exception:{1}", samAccountName, ex.ToString()); Exception custom = new Exception(message); ExceptionManager.HandleException(custom); ServiceErrorFault fault = new ServiceErrorFault(); fault.Operation = "Directory Service"; fault.ProblemType = "Error in SearchUserByLogin"; var faultExp = new FaultException <ServiceErrorFault>(fault, ex.ToString()); throw faultExp; } }
public void ShieldException(Exception e) { PublishException(e); ServiceErrorFault fault = new ServiceErrorFault(); fault.Operation = "Document Upload Service"; fault.ProblemType = e.Message; throw new FaultException <ServiceErrorFault>(fault); }
/// <summary> /// Returns List of AD Users, searched by first and last name, /// Supports wild card. /// </summary> /// <param name="firstName"></param> /// <param name="lastName"></param> /// <returns></returns> public List <ADUser> SearchUserByName(string firstName, string lastName) { try { var searcher = new RealPrincipalSearcher(); ActiveDirectoryHelper helper = new ActiveDirectoryHelper(searcher); return(helper.SearchUserByName(firstName, lastName)); } catch (Exception ex) { /*log erorr locally */ string message = string.Format("Error in SearchUserByName(string firstName:{0}, string lastName{1}); Detailed exception:{2}", firstName, lastName, ex.ToString()); Exception custom = new Exception(message); ExceptionManager.HandleException(custom); ServiceErrorFault fault = new ServiceErrorFault(); fault.Operation = "Directory Service"; fault.ProblemType = "Error in SearchUserByName"; throw new FaultException <ServiceErrorFault>(fault); } }
/// <summary> /// Retrives all users in Group /// </summary> /// <param name="groupName"></param> /// <returns></returns> public List <ADUser> GetUsersInGroupMembership(string groupName) { try { var searcher = new RealPrincipalSearcher(); ActiveDirectoryHelper helper = new ActiveDirectoryHelper(searcher); return(helper.GetUsersInGroupMembership(groupName)); } catch (Exception ex) { /*log erorr locally */ string message = string.Format("Error in GetUsersInGroupMembership(string groupName:{0} Detailed exception:{1}", groupName, ex.ToString()); Exception custom = new Exception(message); ExceptionManager.HandleException(custom); ServiceErrorFault fault = new ServiceErrorFault(); fault.Operation = "Directory Service"; fault.ProblemType = "Error in GetUsersInGroupMembership"; throw new FaultException <ServiceErrorFault>(fault); } }