示例#1
0
        public void GenerateUprdStatusFireAlert(DateTime date)
        {
            var           path  = Path.Combine(HostingEnvironment.MapPath("~/App_Data/TestFile.txt"));
            List <string> lines = new List <string>();

            try
            {
                UprdStatusRepository uprdStatusRepo = new UprdStatusRepository();
                List <UPRDStatusDTO> uprdList       = new List <UPRDStatusDTO>();
                string Environment = ConfigurationManager.AppSettings.Get("Environment");
                lines.Add("Uprd Job Called");
                uprdList = uprdStatusRepo.GetUprdOnDateAndPipelineDuns(date);
                lines.Add("Uprd List count -- " + uprdList.Count);
                if (uprdList != null)
                {
                    lines.Add("Inside if loop");
                    string EmailContent = BuildEmailTemplate(uprdList.OrderBy(a => a.Pipeline).ToList());
                    string subject      = string.Format("Uprd Status Alerts dated: {0} from {1}", DateTime.Now.Date.ToString("MM/dd/yyyy"), Environment);
                    string FilePath     = Path.Combine(HostingEnvironment.MapPath("~/App_Data/UprdEmails.csv"));
                    var    recipients   = File.ReadAllLines(FilePath).Select(a => a).ToArray();
                    string from         = ConfigurationManager.AppSettings.Get("EmailIdForAlert");
                    #region Send Email
                    var isSend = EmailandSMSservice.SendGmail(subject, EmailContent, recipients, from);
                    #endregion
                    System.IO.File.WriteAllLines(path, lines.ToArray());
                }
                lines.Add("Out of loop now");
                System.IO.File.WriteAllLines(path, lines.ToArray());
            }
            catch (Exception ex)
            {
                lines.Add(ex.Message + " --> " + ex.ToString());
                System.IO.File.WriteAllLines(path, lines.ToArray());
            }
        }
示例#2
0
        public async Task <bool> SendNewPasswordToEmail(string NewPassword, string Email)
        {
            string Body    = BuildResetPasswordEmailBody(NewPassword);
            string subject = "New Password for NatGasHub";

            string[] recipients;
            if (ConfigurationManager.AppSettings.Get("Environment") == "Local")
            {
                recipients = new string[] { "*****@*****.**", "*****@*****.**" };
            }
            else
            {
                recipients = new string[] { Email };
            }
            string from = ConfigurationManager.AppSettings.Get("EmailIdForAlert");

            #region Send Email
            var isSend = EmailandSMSservice.SendGmail(subject, Body, recipients, from);
            if (isSend)
            {
                return(true);
            }
            else
            {
                return(false);
            }
            #endregion
        }
示例#3
0
        private async Task <bool> SendOTPToEmail(ApplicationUser user, ApplicationUserManager userManager, string userId)
        {
            try
            {
                string code = await UserManager.GenerateTwoFactorTokenAsync(userId, "Email Code");

                //string validity = DateTime.Now.AddMinutes(12).ToString("hh:mm tt");
                string   Body    = BuildOTPEmail(code);
                string   subject = "Your NatGasHub 2 Factor verification code";
                string[] recipients;
                if (ConfigurationManager.AppSettings.Get("Environment") == "Local")
                {
                    recipients = new string[] { "*****@*****.**", "*****@*****.**" };
                }
                else
                {
                    recipients = new string[] { userManager.GetEmail(userId) };
                }
                string from = ConfigurationManager.AppSettings.Get("EmailIdForAlert");
                #region Send Email
                var isSend = EmailandSMSservice.SendGmail(subject, Body, recipients, from);
                if (isSend)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
                #endregion
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(false);
            }
        }