/// <summary> /// This method is used to send email /// </summary> /// <param name="s_CompanyName">string: company name</param> /// <param name="objEmailProperties">EmailProperties object with all details</param> /// <returns>is mail send or not</returns> public bool SendMailAlerts(string s_CompanyName, EmailProperties objEmailProperties) { bool bReturn = false; NotificationSL objNotificationSL = new NotificationSL(); CompanyDetailsForNotificationDTO objCompanyDetailsForNotificationDTO; objCompanyDetailsForNotificationDTO = objNotificationSL.GetCompanyDetailsForNotification(CommonModel.getSystemConnectionString(), 0, s_CompanyName); using (SmtpClient client = new SmtpClient(objCompanyDetailsForNotificationDTO.SmtpServer)) { //Set the port for the SMTP client if available otherwise the default will be considered. if (objCompanyDetailsForNotificationDTO.SmtpPortNumber != null && objCompanyDetailsForNotificationDTO.SmtpPortNumber != "") { client.Port = Convert.ToInt32(objCompanyDetailsForNotificationDTO.SmtpPortNumber); } string FromEmaild = objEmailProperties.s_MailFrom; string pwd = objCompanyDetailsForNotificationDTO.SmtpPassword; using (MailMessage mailMessage = new MailMessage()) { if (!string.IsNullOrEmpty(pwd)) { NetworkCredential nCredentials = new NetworkCredential(FromEmaild, pwd); client.Credentials = nCredentials; } mailMessage.From = new MailAddress(FromEmaild); mailMessage.To.Add(objEmailProperties.s_MailTo); if (!string.IsNullOrEmpty(objEmailProperties.s_MailCC)) { mailMessage.CC.Add(objEmailProperties.s_MailCC); } if (!string.IsNullOrEmpty(objEmailProperties.s_MailBCC)) { mailMessage.Bcc.Add(objEmailProperties.s_MailBCC); } mailMessage.Subject = objEmailProperties.s_MailSubject; mailMessage.Body = objEmailProperties.s_MailBody; mailMessage.IsBodyHtml = objEmailProperties.b_IsBodyHtml; foreach (string s_FilePath in objEmailProperties.Attachments) { mailMessage.Attachments.Add(new Attachment(s_FilePath)); } try { client.Send(mailMessage); Thread.Sleep(Convert.ToInt32(ConfigurationManager.AppSettings["ThreadSleepTime"])); bReturn = true; } catch (Exception ex) { bReturn = false; throw ex; } } } return(bReturn); }
public ActionResult View(int acid, int NotificationId) { LoginUserDetails objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails); NotificationModel objNotificationModel = new NotificationModel(); //CommunicationRuleMasterSL objCommunicationRuleMasterSL = new CommunicationRuleMasterSL(); NotificationDTO objNotificationDTO = new NotificationDTO(); //NotificationSL objNotificationSL = new NotificationSL(); List <PopulateComboDTO> lstList = new List <PopulateComboDTO>(); try { lstList = FillComboValues(ConstEnum.ComboType.ListOfCode, Convert.ToInt32(ConstEnum.CodeGroup.CommunicationModes).ToString(), Convert.ToInt32(ConstEnum.Code.CommunicationCategory).ToString(), null, null, null, true); ViewBag.ModeCodeList = lstList; if (NotificationId > 0) { using (var objNotificationSL = new NotificationSL()) { objNotificationDTO = objNotificationSL.GetDetails(objLoginUserDetails.CompanyDBConnectionString, NotificationId); } InsiderTrading.Common.Common.CopyObjectPropertyByName(objNotificationDTO, objNotificationModel); objNotificationModel.Contents = objNotificationModel.Contents.Replace("\\r\\n", "<br/>"); if (objNotificationModel.Signature != null) { objNotificationModel.Signature = objNotificationModel.Signature.Replace("\\r\\n", "<br/>"); } } ViewBag.ModeCodeId = objNotificationDTO.ModeCodeId; ViewBag.NotificationQueueId = NotificationId; ViewBag.UserId = objLoginUserDetails.LoggedInUserID; //ViewBag.CommunicationMode_id = objCommunicationRuleMasterModel.CommunicationModeCodeId; return(View("View", objNotificationModel)); } catch (Exception exp) { //NotificationModel objNotificationModel = new NotificationModel(); string sErrMessage = Common.Common.getResource(exp.InnerException.Data[0].ToString()); ModelState.AddModelError("Error", sErrMessage); return(View("View", objNotificationModel)); } finally { objLoginUserDetails = null; objNotificationModel = null; objNotificationDTO = null; lstList = null; } }
public ActionResult PopupNotification() { LoginUserDetails objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails); NotificationModel objNotificationModel = new NotificationModel(); objLoginUserDetails.ShowNotificationPopup = false; Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); //NotificationSL objNotificationSL = new NotificationSL(); List <NotificationDTO> lstList = new List <NotificationDTO>(); try { ViewBag.NoRecord = false; using (var objNotificationSL = new NotificationSL()) { lstList = objNotificationSL.GetNotificationAlertList(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID, "POPUP"); } if (lstList.Count > 0) { foreach (var objItem in lstList) { objItem.Contents = objItem.Contents.Replace("<br />", Environment.NewLine); } ViewBag.NotificationDictionary = lstList; return(PartialView("PopupNotificationView")); } else { ViewBag.NoRecord = true; return(PartialView("PopupNotificationView")); } } catch (Exception exp) { //NotificationModel objNotificationModel = new NotificationModel(); string sErrMessage = Common.Common.getResource(exp.InnerException.Data[0].ToString()); ModelState.AddModelError("Error", sErrMessage); ViewBag.NoRecord = true; return(PartialView("PopupNotificationView")); } finally { objLoginUserDetails = null; objNotificationModel = null; lstList = null; } }
public ActionResult DashboardNotification() { LoginUserDetails objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails); NotificationModel objNotificationModel = new NotificationModel(); objLoginUserDetails.ShowNotificationPopup = false; Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); //NotificationSL objNotificationSL = new NotificationSL(); List <NotificationDTO> lstList = new List <NotificationDTO>(); try { CheckAppliedModule(); ViewBag.NoRecord = false; using (var objNotificationSL = new NotificationSL()) { lstList = objNotificationSL.GetDashboardNotificationList(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID); } if (lstList.Count > 0) { ViewBag.UserId = objLoginUserDetails.LoggedInUserID; // FillGrid(ConstEnum.GridType.DashBboardNotificationList, Convert.ToString(objLoginUserDetails.LoggedInUserID), Convert.ToString(Common.ConstEnum.Code.CommunicationModeForEmail), null, null, null); ViewBag.NotificationDictionary = lstList; return(PartialView("DashboardNotificationIndex")); } else { ViewBag.NoRecord = true; return(PartialView("DashboardNotificationIndex")); } } catch (Exception exp) { //NotificationModel objNotificationModel = new NotificationModel(); string sErrMessage = Common.Common.getResource(exp.InnerException.Data[0].ToString()); ModelState.AddModelError("Error", sErrMessage); ViewBag.UserId = objLoginUserDetails.LoggedInUserID; FillGrid(ConstEnum.GridType.DashBboardNotificationList, Convert.ToString(objLoginUserDetails.LoggedInUserID), Convert.ToString(Common.ConstEnum.Code.CommunicationModeForEmail), null, null, null); return(PartialView("DashboardNotificationIndex")); } finally { objLoginUserDetails = null; objNotificationModel = null; lstList = null; } }
public ActionResult DisplayAlert() { LoginUserDetails objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails); NotificationModel objNotificationModel = new NotificationModel(); // NotificationSL objNotificationSL = new NotificationSL(); List <NotificationDTO> lstList = new List <NotificationDTO>(); try { ViewBag.NoRecord = true; using (var objNotificationSL = new NotificationSL()) { lstList = objNotificationSL.GetNotificationAlertList(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID, "ALERT"); } if (lstList.Count > 0) { foreach (var objItem in lstList) { objItem.Contents = objItem.Contents.Replace("<br />", Environment.NewLine); } ViewBag.NoRecord = false; } ViewBag.NotificationDictionary = lstList; //ViewBag.ModeCodeId = objNotificationDTO.ModeCodeId; //ViewBag.NotificationQueueId = NotificationId; //ViewBag.UserId = objLoginUserDetails.LoggedInUserID; //ViewBag.CommunicationMode_id = objCommunicationRuleMasterModel.CommunicationModeCodeId; return(PartialView("PartialCreate")); } catch (Exception exp) { //NotificationModel objNotificationModel = new NotificationModel(); string sErrMessage = Common.Common.getResource(exp.InnerException.Data[0].ToString()); ModelState.AddModelError("Error", sErrMessage); return(View("View", objNotificationModel)); } finally { objLoginUserDetails = null; objNotificationModel = null; lstList = null; } }
public ActionResult NotificationCount() { LoginUserDetails objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails); NotificationModel objNotificationModel = new NotificationModel(); //NotificationSL objNotificationSL = new NotificationSL(); List <NotificationDTO> lstList = new List <NotificationDTO>(); try { ViewBag.NoRecord = true; using (var objNotificationSL = new NotificationSL()) { lstList = objNotificationSL.GetNotificationAlertList(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID, "ALERTCOUNT"); } if (lstList.Count > 0) { foreach (var objItem in lstList) { if (objItem.AlertCount > 0) { ViewBag.AlertCount = objItem.AlertCount; ViewBag.NoRecord = false; break; } } } return(PartialView("NotificationCountView")); } catch (Exception exp) { //NotificationModel objNotificationModel = new NotificationModel(); string sErrMessage = Common.Common.getResource(exp.InnerException.Data[0].ToString()); ModelState.AddModelError("Error", sErrMessage); ViewBag.AlertCount = 0; ViewBag.NoRecord = true; return(PartialView("NotificationCountView")); } finally { objLoginUserDetails = null; objNotificationModel = null; lstList = null; } }