Ejemplo n.º 1
0
        //public static string MudraUserDetails(string name, string mobile, string BusinessPurpose, string loantype, string amount)
        public static string MudraUserDetails(string name, string mobile, string BusinessPurpose, string Email)
        {
            UserShema  objUserShema  = new UserShema();
            UserDataBL objUserDataBL = new UserDataBL();
            string     mudraresult   = string.Empty;
            int        result        = 0;
            SendSMS    objSendSMS    = new SendSMS();
            int        LangID        = 0;

            objUserShema.Name   = name;
            objUserShema.Mobile = mobile;
            //if (!string.IsNullOrEmpty(amount))
            //{
            //    objUserShema.Amount = Convert.ToDecimal(amount);
            //}
            //else
            //{
            //    objUserShema.Amount = 0;
            //}

            //objUserShema.Loantype = Convert.ToInt32(loantype);
            objUserShema.Email               = Email;
            objUserShema.Buspurpose          = Convert.ToInt32(BusinessPurpose);
            objUserShema.Applicant_SessionId = System.Web.HttpContext.Current.Session.SessionID;
            result = objUserDataBL.insertUserData(objUserShema);
            if (result == 1)
            {
                mudraresult = "success";
                if (objUserShema.Mobile.ToString() != "" || objUserShema.Mobile.ToString() != string.Empty)
                {
                    objSendSMS.SMSSend(objUserShema.Mobile, "", "welcome");
                }
                if (objUserShema.Email.ToString() != "" || objUserShema.Email.ToString() != string.Empty)
                {
                    SendEamil(objUserShema.Email.ToString());
                }
            }
            else
            {
                mudraresult = "Failed";
            }
            return(mudraresult);
        }
Ejemplo n.º 2
0
        private void ConvertToPDF(string ApplicationId)

        {
            string         imagepath = Server.MapPath("~/Images"); Response.Cache.SetCacheability(HttpCacheability.NoCache);
            StringWriter   sw        = new StringWriter();
            HtmlTextWriter hw        = new HtmlTextWriter(sw);

            this.Page.RenderControl(hw);
            StringReader sr         = new StringReader(sw.ToString());
            Document     pdfDoc     = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
            HTMLWorker   htmlparser = new HTMLWorker(pdfDoc);

            //string fromusername = ConfigurationManager.AppSettings["userNameEmail"];
            //string Tousername = ConfigurationManager.AppSettings["TouserName"];
            //string EmailPassword = ConfigurationManager.AppSettings["EmailPassword"];
            //string cc1username = ConfigurationManager.AppSettings["NotificationtoDepartment1"];
            //string cc2username = ConfigurationManager.AppSettings["NotificationtoDepartment2"];
            using (MemoryStream memoryStream = new MemoryStream())
            {
                iTextSharp.text.Image addLogo = default(iTextSharp.text.Image);
                // iTextSharp.text.Image gif = iTextSharp.text.Image.GetInstance(imagepath + "/mudra.jpg");
                addLogo = iTextSharp.text.Image.GetInstance(imagepath + "/logo.png");

                iTextSharp.text.Image BankLogo = default(iTextSharp.text.Image);
                // iTextSharp.text.Image gif = iTextSharp.text.Image.GetInstance(imagepath + "/mudra.jpg");
                BankLogo = iTextSharp.text.Image.GetInstance(imagepath + "/logo.png");
                PdfWriter writer = PdfWriter.GetInstance(pdfDoc, memoryStream);


                // addLogo.SetAbsolutePosition(0, docWorkingDocument.PageSize.Height - 100)

                pdfDoc.Open();
                addLogo.ScaleToFit(128, 37);
                addLogo.Alignment = iTextSharp.text.Image.ALIGN_LEFT;
                pdfDoc.Add(addLogo);

                htmlparser.Parse(sr);

                pdfDoc.Close();
                byte[] bytes = memoryStream.ToArray();
                memoryStream.Close();


                // Added by Anand Dated on 04-10-2018

                ObjEmailSchema.ApplicationID = ApplicationId;
                string Mobile = string.Empty;

                ds = new DataSet();
                ds = objemail.GetEmailDetails(ObjEmailSchema);
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    string      t_XMLName = HttpContext.Current.Server.MapPath("~/APP_Data/MailConfig.XML");
                    XmlDocument xmlDoc    = new XmlDocument();
                    xmlDoc.Load(t_XMLName);
                    XmlNode     xnod     = xmlDoc.DocumentElement;
                    XmlNodeList nodeList = xnod.SelectNodes("Mail");

                    Mobile = ds.Tables[0].Rows[0]["MobileNo"].ToString().Trim();

                    objSendSMS.SMSSend(Mobile, ObjEmailSchema.ApplicationID, "application");

                    foreach (XmlNode _node in nodeList)
                    {
                        string SMTPstr = string.Empty, Portstr = string.Empty, FromEamil = string.Empty, To = string.Empty, Subject = string.Empty, Body = string.Empty, BodyU = string.Empty, FromEmailPwd = string.Empty;

                        //SMTPstr = _node.SelectSingleNode("host").InnerText.Trim();
                        //Portstr = _node.SelectSingleNode("port").InnerText.Trim();
                        //FromEamil = _node.SelectSingleNode("from").InnerText.Trim();
                        //FromEmailPwd = _node.SelectSingleNode("pwd").InnerText.Trim();

                        String SMTP_HOST_NAME = ConfigurationManager.AppSettings["host"];
                        String SMTP_AUTH_USER = ConfigurationManager.AppSettings["FromEmail"];
                        String SMTP_AUTH_PWD  = ConfigurationManager.AppSettings["EmailPassword"];



                        if (_node.Attributes["Profile"].Value.ToString().ToLower() == "pmmycustomer")
                        {
                            To = ds.Tables[0].Rows[0]["CustEmailID"].ToString().Trim();

                            Subject = _node.SelectSingleNode("subject").InnerText.Trim();
                            Body    = _node.SelectSingleNode("body").InnerText.Trim();

                            Subject = Subject.Replace("#ApplicationID", ds.Tables[0].Rows[0]["ApplicationID"].ToString().Trim());
                            Subject = Subject.Replace("#LoanType", ds.Tables[0].Rows[0]["LoanType"].ToString().Trim());

                            Body = Body.Replace("#ApplicantName", ds.Tables[0].Rows[0]["ApplicantName"].ToString().Trim());
                            Body = Body.Replace("#ApplicationID", ds.Tables[0].Rows[0]["ApplicationID"].ToString().Trim());
                            Body = Body.Replace("#LoanType", ds.Tables[0].Rows[0]["LoanType"].ToString().Trim());
                            Body = Body.Replace("#ApplicationDate", ds.Tables[0].Rows[0]["ApplicationDate"].ToString().Trim());
                        }

                        if (_node.Attributes["Profile"].Value.ToString().ToLower() == "pmmydpo")
                        {
                            //To = ds.Tables[0].Rows[0]["DPOEmailID"].ToString().Trim();
                            To      = "*****@*****.**";
                            Subject = _node.SelectSingleNode("subject").InnerText.Trim();
                            Body    = _node.SelectSingleNode("body").InnerText.Trim();

                            Subject = Subject.Replace("#ApplicationID", ds.Tables[0].Rows[0]["ApplicationID"].ToString().Trim());
                            Subject = Subject.Replace("#LoanType", ds.Tables[0].Rows[0]["LoanType"].ToString().Trim());

                            Body = Body.Replace("#ApplicantName", ds.Tables[0].Rows[0]["ApplicantName"].ToString().Trim());
                            Body = Body.Replace("#ApplicationID", ds.Tables[0].Rows[0]["ApplicationID"].ToString().Trim());
                            Body = Body.Replace("#LoanType", ds.Tables[0].Rows[0]["LoanType"].ToString().Trim());
                        }

                        if (_node.Attributes["Profile"].Value.ToString().ToLower() == "pmmybank")
                        {
                            //To = ds.Tables[0].Rows[0]["BankEmailID"].ToString().Trim();
                            To      = "*****@*****.**";
                            Subject = _node.SelectSingleNode("subject").InnerText.Trim();
                            Body    = _node.SelectSingleNode("body").InnerText.Trim();

                            Subject = Subject.Replace("#ApplicationID", ds.Tables[0].Rows[0]["ApplicationID"].ToString().Trim());
                            Subject = Subject.Replace("#LoanType", ds.Tables[0].Rows[0]["LoanType"].ToString().Trim());

                            Body = Body.Replace("#ApplicantName", ds.Tables[0].Rows[0]["ApplicantName"].ToString().Trim());
                            Body = Body.Replace("#ApplicationID", ds.Tables[0].Rows[0]["ApplicationID"].ToString().Trim());
                            Body = Body.Replace("#LoanType", ds.Tables[0].Rows[0]["LoanType"].ToString().Trim());
                        }

                        if (To.ToString() != "" || To.ToString().Trim() != string.Empty)
                        {
                            SmtpClient client = new SmtpClient();
                            client.Port = Convert.ToInt16(ConfigurationManager.AppSettings["port"]);
                            client.Host = SMTP_HOST_NAME;

                            client.EnableSsl = true;
                            client.Timeout   = 600000;

                            client.DeliveryMethod        = SmtpDeliveryMethod.Network;
                            client.UseDefaultCredentials = false;
                            client.Credentials           = new System.Net.NetworkCredential(SMTP_AUTH_USER, SMTP_AUTH_PWD);

                            MailMessage mm = new MailMessage(SMTP_AUTH_USER, To, Subject, Body);
                            mm.Attachments.Add(new Attachment(new MemoryStream(bytes), "" + Convert.ToString(ApplicationId) + ".pdf"));
                            mm.IsBodyHtml   = true;
                            mm.BodyEncoding = UTF8Encoding.UTF8;
                            mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;

                            ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
                            { return(true); };

                            client.Send(mm);

                            //using (MailMessage mm = new MailMessage(FromEamil, To))
                            //{
                            //    mm.Subject = Subject;
                            //    mm.Body = Body;
                            //    mm.Attachments.Add(new Attachment(new MemoryStream(bytes), "" + Convert.ToString(ApplicationId) + ".pdf"));
                            //    mm.IsBodyHtml = true;
                            //    using (SmtpClient smtp = new SmtpClient())
                            //    {
                            //        smtp.Host = SMTPstr;
                            //        smtp.EnableSsl = true;
                            //        NetworkCredential NetworkCred = new NetworkCredential();
                            //        NetworkCred.UserName = FromEamil;//"[email protected] ";
                            //        NetworkCred.Password = FromEmailPwd;//"Pass@123";
                            //        smtp.UseDefaultCredentials = true;
                            //        smtp.Credentials = NetworkCred;
                            //        smtp.Port = Convert.ToInt16(Portstr);
                            //        smtp.TargetName = "STARTTLS/smtp.gmail.com";
                            //        //ServicePointManager.ServerCertificateValidationCallback = delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
                            //        //{ return true; };
                            //        smtp.Send(mm);

                            //    }
                            //}
                        }
                    }

                    Response.Redirect("FrmPMMYLoanForm.aspx");
                }

                //End  04-10-2018
            }
        }