using GrossreeApi.BajajLiveService; using GrossreeApi.DBManager; using GrossreeApi.Models; using GrossreeApi.Proposals; using Newtonsoft.Json; using RestSharp; using SendGrid; using SendGrid.Helpers.Mail; using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Net; using System.Net.Mail; using System.Net.Mime; using System.Text; using System.Web; namespace GrossreeApi.Common { public class EmailService { string _BccEmail = "developer.durgesh@gmail.com"; string _AdminEmail = "developer.durgesh@gmail.com";//"cst@policybonanza.com"; string _ViewQuoteMail = "developer.durgesh@gmail.com"; string _FromEmail = "developer.durgesh@gmail.com";// "prstargroup@stargroupindia.biz" after purchase ... from info@policybonanaza.com; string _Userid = "stariglobaltech@gmail.com";// "prstargroup@stargroupindia.biz"; string _Password = "Star@12345";//"Star@123"; int _Port = 25; string _Host = "smtp.gmail.com"; bool _UseDefaultCredential = true; bool _EnableSsl = true; bool isBodyHtml = true; public string shareResult(ShareModel model) { string Response = ""; string body = ""; try { string Clientname = HostName(model.ClientURL); Clientname = DBManager.DBHelper.ExecuteSQLSingleValue("select companyName from ClientMaster where companyURL like '%" + Clientname + "%'"); string motortype = model.TypeOfMoter.ToUpper().Contains("TWO") ? "Two Wheeler Summary And Payment Link" : "Private Car Summary And Payment Link"; motortype = model.UserName == null ? motortype : model.UserName + ": " + motortype; string Productname = model.TypeOfMoter.ToUpper().Contains("TWO") ? "Two Wheeler" : "Private Car"; string imgurl = model.ClientURL.Contains("insta") ? "https://insta-policy.com/Content/PolicyMart/images/InstaPolicy/logo.png" : ""; Int64 a; bool issms; try { a = Convert.ToInt64(model.ToEmail); issms = true; } catch (Exception) { issms = false; } if (!issms) { if (model.Url.Contains("smcinsurance") && ((model.Role != null) && (model.Role != ""))) { body = "

logo-email.jpg

Hi,

Your proposal information page is ready for review. Please click here to view or modify the details.

For any assistance, please call our POS

Best Regards,

email-foo-logo.jpg

Legal Disclaimer: The contents of this email message and any attachments are intended solely for the intended recipient to which it is addressed and may contain confidential and/or privileged information and may be legally protected from disclosure. If you are not the intended recipient of this message, or if this message has been addressed to you in error, please immediately alert the sender by reply email and then delete this message and any attachments. If you are not the intended recipient, you are hereby notified that any use, dissemination, copying, or storage of this message or its attachments is strictly prohibited. Unauthorized disclosure and/or use of information contained in this email may result in civil and criminal liability.

"; } else { body = "" + "" + " " + " " + " aranoz " + "" + "" + " " + " " + " " + " " + " " + " " + "
" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "
 
" + " " + " " + " " + " " + " " + " " + "
\"\"
" + "
 
" + " " + " " + " " + " " + " " + " " + "
" + "

Dear Customer

" + "

Thank you for visiting "+ Clientname + " to insure your "+ Productname + "

" + "
" + "
 
" + " " + " " + " " + " " + " " + " " + "
" + "

Please click on below button to get the Payment Link.

" + "
" + "
 
" + " " + " " + " " + " " + " " + " " + " " + "
" + " " + "
" + "
 
" + " " + " " + " " + " " + " " + " " + " " + "
" + "

Feel free to get in touch with us on mentioned contact number on portal, in case you need anything else.

" + "

Regards,

" + "

"+ Clientname + " Team

" + "
\"\"
" + "
" + "
" + "" + ""; //model.Clientid = Convert.ToInt32(ClientUrl.GetClientID(model.ClientURL)); //body = //"Please click on below button to get " + motortype + " Proposal Summary and to proceed for Payment:" + // //"

Click ME" //"" + //"" + //"" + // "" + //"" + //"" + //"" + //"" + //"" + //"" + //"" + //"" + //"
" + //"logo" + //"
" + //"


Please click on below button to get " + motortype + " Proposal Summary and to proceed for Payment:" + //"

Click ME


" + //"
" + //"
"; } //body = //"Please click on below button to get " + motortype + " Proposal Summary and to proceed for Payment:" + //"

Click ME" //"" + //"" + //"" + // "" + //"" + //"" + //"" + //"" + //"" + //"" + //"" + //"" + //"
" + //"logo" + //"
" + //"


Please click on below button to get " + motortype + " Proposal Summary and to proceed for Payment:" + //"

Click ME


" + //"
" + //"
"; Response = mailMaster(model.ToEmail, model.ClientURL, motortype, body,model.Role); } else { string result = ""; string text = "Please click on below link to get " + motortype + " Proposal\n" + model.Url; // @You may retrieve your quotes and search the same through your Reference id:" + refrenceID + " if (model.Url.Contains("insta-policy")) { result = "http://sendsms.designhost.in/index.php/smsapi/httpapi/?uname=instapolicy&password=InstaPolicy@123&sender=INSPOL&receiver=" + model.ToEmail + "&route=TA&msgtype=1&sms=" + text; } else if (model.Url.Contains("massinsurance")) { result = "http://sms.brainsoft-tech.com/api.php?username=jasvinder&password=551494&sender=SHOPPE&sendto=" + model.ToEmail + "&message=" + text; } else if (model.Url.Contains("advancelifeinsurance")) { result = "http://sendsms.designhost.in/index.php/smsapi/httpapi/?uname=advance&password=ADV@123&sender=ADVLIF&receiver=" + model.ToEmail + "&route=TA&msgtype=1&sms=" + text; } else if (model.Url.Contains("jkbima") && model.Role != "" && model.Role != null) { result = "http://bulkpush.mytoday.com/BulkSms/SingleMsgApi?feedid=362153&username=8010007547&password=tdatm&To=" + model.ToEmail + "&Text=" + text + "&time=200812110950&senderid=JKRMIB"; //jkbima } else if (model.Url.Contains("riskovery")) { // text = "One Time Password For Riskovery Insurance:- " + OTP + " Please do not share this code with anyone @Regards@Team Riskovery Insurance"; // string msg = text.Replace("@", "" + System.Environment.NewLine); result = "http://sendsms.designhost.in/index.php/smsapi/httpapi/?uname=riskovery&password=Riskovery@123&sender=RIWAPR&receiver=" + model.ToEmail + "&route=TA&msgtype=1&sms=" + text; } else if (model.Url.Contains("bimaplanner")) { result = "http://sendsms.designhost.in/index.php/smsapi/httpapi/?uname=ssinsurance&password=SSInsurance@123&sender=BIMPLN&receiver=" + model.ToEmail + "&route=TA&msgtype=1&sms=" + text; } else if (model.Url.Contains("bookmybima")) { result = "http://5.189.149.16/api/pushsms.php?user=t5Sanguine&key=010XY4Zm0nRqU9Q0rNIB&sender=insBMB&mobile=" + model.ToEmail + "&text=" + text; } else if (model.Url.Contains("inshoracover")) { result = "http://sms.mevite.in/smsapi.php?username=inshoracover&password=915841&sender=iCOVER&sendto=" + model.ToEmail + "&message=" + text; } else if (model.Url.Contains("riskfreelife")) { result = "https://api.msg91.com/api/sendhttp.php?authkey=183914AcJo1fuR5a0d1d6b&mobiles=" + model.ToEmail + "&country=91&message=" + text + "&sender=RFLSMS&route=4"; //result = "https://control.msg91.com/api/sendotp.php?authkey=183914AcJo1fuR5a0d1d6b&mobile=" + Model.ToEmail + "&message=##OTP##" + text + "&sender=OTPSMS&otp_expiry=&otp_length=&country=&otp=&email=&template="; } else if (model.Url.Contains("smcinsurance") && (model.Role == "" || model.Role == null)) { result = "https://push3.maccesssmspush.com/servlet/com.aclwireless.pushconnectivity.listeners.TextListener?userId=idsmc&pass=pasmc&appid=smc&subappid=smc&contenttype=1&to=" + model.ToEmail + "&from=SMCINS&text=" + text + "&selfid=true&alert=1&dlrreq=true&intflag=false"; } else if (model.Url.Contains("smcinsurance") && (model.Role != "" && model.Role != null)) { result = "https://push3.maccesssmspush.com/servlet/com.aclwireless.pushconnectivity.listeners.TextListener?userId=idsmc&pass=pasmc&appid=smc&subappid=smc&contenttype=1&to=" + model.ToEmail + "&from=SMCPOS&text=" + text + "&selfid=true&alert=1&dlrreq=true&intflag=false"; } bool issuccess = SendSms(result); Response = issuccess == true ? "Sms Sent Successfully." : ""; } if (Response == "Email Sent Successfully." || Response == "Sms Sent Successfully.") { string Query = "insert into ShareProposalAPI(ClientURL,ToEmail,Url,ProposalReq,ProposalResponse,ProposalAdditionalData,QuotePage,quoteResponse)"; Query += " values('" + model.ClientURL + "','" + model.ToEmail + "','" + model.Url + "','" + model.ProposalReq + "','" + model.ProposalResponse + "','" + model.ProposalAdditionalData + "','" + model.QuotePage + "','" + model.quoteResponse + "')"; DBHelper.ExecuteNonQueryWithOutProc(Query); } try { System.IO.File.WriteAllText(HttpContext.Current.Server.MapPath("~/PVCemailBody.txt"), body); } catch (Exception ex) { } } catch (Exception ex) { Response = ex.Message; } return Response; } public string shareResultold(ShareModel model) { string motortype = model.TypeOfMoter.ToUpper().Contains("TWO") ? "Two Wheeler Summary And Payment Link" : "Private Car Summary And Payment Link"; string Response = ""; try { //model.Clientid = Convert.ToInt32(ClientUrl.GetClientID(model.ClientURL)); string body = //"Please click on below button to get " + motortype + " Proposal Summary and to proceed for Payment:" + //"

Click ME" "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "
" + "logo" + "
" + "


Please click on below button to get " + motortype + " Proposal Summary and to proceed for Payment:" + "

Click ME


" + "
" + "
"; Response = mailMaster(model.ToEmail, model.ClientURL, motortype, body); if (Response == "Email Sent Successfully.") { string Query = "insert into ShareProposalAPI(ClientURL,ToEmail,Url,ProposalReq,ProposalResponse,ProposalAdditionalData,QuotePage,quoteResponse)"; Query += " values('" + model.ClientURL + "','" + model.ToEmail + "','" + model.Url + "','" + model.ProposalReq + "','" + model.ProposalResponse + "','" + model.ProposalAdditionalData + "','" + model.QuotePage + "','"+model.quoteResponse+"')"; DBHelper.ExecuteNonQueryWithOutProc(Query); } try { System.IO.File.WriteAllText(HttpContext.Current.Server.MapPath("~/PVCemailBody.txt"), body); } catch (Exception ex) { } } catch(Exception ex) { Response = ex.Message; } return Response; } public bool SendMail(string toEmail, string subject, string msgBody, string Bcc, string CC, string AttachementFilePath) { bool isSended = false; try { MailMessage mail = new MailMessage(); mail.From = new MailAddress(_FromEmail); mail.Subject = subject; if (toEmail != null) { string[] ToList = toEmail.Split(','); foreach (var Mail in ToList) { mail.To.Add(Mail); } } if (Bcc != null) { string[] BccList = Bcc.Split(','); foreach (var Mail in BccList) { mail.Bcc.Add(Mail); } } if (CC != null && CC != "") { string[] CCList = CC.Split(','); foreach (var Mail in CCList) { mail.CC.Add(Mail); } } System.Net.Mail.Attachment attachment; attachment = new System.Net.Mail.Attachment(AttachementFilePath, MediaTypeNames.Application.Octet); mail.Attachments.Add(attachment); //foreach (HttpPostedFileBase fileUpload in POSTEDFILE) //{ //string fileName1 = Path.GetFileName(fileUpload.FileName); //mail.Attachments.Add(new Attachment(fileUpload.InputStream, fileName1)); //} mail.Body = msgBody; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = _Host; smtp.Port = _Port; smtp.UseDefaultCredentials = _UseDefaultCredential; smtp.Credentials = new System.Net.NetworkCredential(_Userid, _Password); smtp.EnableSsl = _EnableSsl; smtp.Send(mail); isSended = true; } catch (Exception ex) { isSended = false; } return isSended; } public bool SendPolicyMail(string toEmail, string subject, string msgBody, string Bcc, string CC, string AttachementFilePath, int clientid) { if (clientid == 45) { _FromEmail = "noreply@insta-policy.com"; _Userid = "noreply@insta-policy.com"; _Password = "Pol@1234"; _Host = "smtp-mail.outlook.com"; _Port = 587; } else if (clientid == 53) { _FromEmail = "icare@inshoracover.com"; _Userid = "apikey"; _Password = "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";//"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"; _Host = "smtp.sendgrid.net"; _Port = 25; //_FromEmail = "icare@inshoracover.com"; //_Userid = "apikey"; //_Password = "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"; //_Host = "smtp.sendgrid.net"; //_Port = 25; //var apiKey = Environment.GetEnvironmentVariable("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"); //var client = new SendGridClient(apiKey); //var from = new EmailAddress("icare@inshoracover.com", "InshoraCover"); ////var subject = "Sending with SendGrid is Fun"; //var to = new EmailAddress("test@example.com", "Example User"); //var plainTextContent = "and easy to do anywhere, even with C#"; //var htmlContent = "and easy to do anywhere, even with C#"; //var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent); //var response = client.SendEmailAsync(msg); } bool isSended = false; try { MailMessage mail = new MailMessage(); mail.From = new MailAddress(_FromEmail); mail.Subject = subject; if (toEmail != null && toEmail != "") { string[] ToList = toEmail.Split(','); foreach (var Mail in ToList) { mail.To.Add(Mail); } } if (Bcc != null && Bcc != "") { string[] BccList = Bcc.Split(','); foreach (var Mail in BccList) { mail.Bcc.Add(Mail); } } if (CC != null && CC != "") { string[] CCList = CC.Split(','); foreach (var Mail in CCList) { mail.CC.Add(Mail); } } System.Net.Mail.Attachment attachment; attachment = new System.Net.Mail.Attachment(AttachementFilePath, MediaTypeNames.Application.Octet); mail.Attachments.Add(attachment); //foreach (HttpPostedFileBase fileUpload in POSTEDFILE) //{ //string fileName1 = Path.GetFileName(fileUpload.FileName); //mail.Attachments.Add(new Attachment(fileUpload.InputStream, fileName1)); //} mail.Body = msgBody; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = _Host; smtp.Port = _Port; smtp.UseDefaultCredentials = _UseDefaultCredential; smtp.Credentials = new System.Net.NetworkCredential(_Userid, _Password); smtp.EnableSsl = _EnableSsl; smtp.Send(mail); isSended = true; } catch (Exception ex) { isSended = false; } return isSended; } private string mailMaster(string toEmail, string ClientURL, string subject, string msgBody, string Role = null) { string _Host = ""; string Response = ""; string _Userid = "";//"stariglobaltech@gmail.com"; string _Password = ""; int _Port; string _FromEmail = "", _DisplayName = ""; bool _EnableSsl = true; bool _UseDefaultCredential = true; try { if (ClientURL.Contains("insta-policy")) { _FromEmail = "info@insta-policy.com"; _Userid = "info@insta-policy.com"; _Password = "Pol@1234"; _Host = "smtp-mail.outlook.com"; _Port = 587; } //else if (ClientURL.Contains("starinsured")) //{ // _FromEmail = "onlinestarinsured@gmail.com"; // _Userid = "onlinestarinsured@gmail.com"; // _Password = "Star@pos123"; // _Host = "smtp.gmail.com"; // _Port = 587; //} else if (ClientURL.Contains("bimaplanner")) { _FromEmail = "admin@bimaplanner.com";// "stariglobaltech@gmail.com"; _Userid = "apikey"; _Password = "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"; _Host = "smtp.sendgrid.net"; _Port = 25; } else if (ClientURL.Contains("inshoracover")) { _FromEmail = "icare@inshoracover.com"; _Userid = "apikey"; _Password = "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";//"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"; _Host = "smtp.sendgrid.net"; _Port = 25; //_FromEmail = "icare.inshoracover@gmail.com"; //_Userid = "apikey"; //_Password = "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"; //_Host = "smtp.sendgrid.net"; //_Port = 25; } else if (ClientURL.Contains("jkbima")) { _FromEmail = "equote@jkbima.com"; _Userid = "equote@jkbima.com"; _Password = "#Jkins@2020$"; _Host = "Smtp3.netcore.co.in"; _Port = 587; } else if (ClientURL.Contains("riskoveryinsurance")) { _FromEmail = "riskoveryinsurance@gmail.com"; _Userid = "riskoveryinsurance@gmail.com"; _Password = "Starit@2019"; _Host = "smtp.gmail.com"; _Port = 587; } else if (ClientURL.Contains("sarsa")) { _FromEmail = "sarsabima70@gmail.com"; _Userid = "sarsabima70@gmail.com"; _Password = "Sarsa@7071"; _Host = "smtp.gmail.com"; _Port = 587; } else if (ClientURL.Contains("smcinsurance") && (Role != "" && Role != null)) { _FromEmail = "tech@smcinsurance.com"; _Userid = "tech@smcinsurance.com"; _Password = "Q9FSw9E9"; _Host = "smcinsurance.org"; _Port = 25025; _DisplayName = "SMC-POS"; _EnableSsl = false; } else if (ClientURL.Contains("smcinsurance") && (Role == "" || Role == null)) { _FromEmail = "e_connect@smcinsurance.com"; _Userid = "e_connect@smcinsurance.com"; _Password = "xM8hHAJB"; _Host = "smcinsurance.org"; _Port = 25025; _DisplayName = "SMC-INS"; _EnableSsl = false; } else { _FromEmail = "stariglobaltech@gmail.com"; _Host = "smtp.gmail.com"; _Userid = "stariglobaltech@gmail.com";//"stariglobaltech@gmail.com"; _Password = "Star@12345";// "Star@123"; _Port = 25; } //string _FromEmail = "developer.durgesh@gmail.com"; MailMessage mail = new MailMessage(); mail.To.Add(toEmail); mail.From = ClientURL.Contains("smcinsurance") ? new MailAddress(_FromEmail, _DisplayName) : new MailAddress(_FromEmail); //mail.From = new MailAddress(_FromEmail); mail.Subject = subject; mail.Body = msgBody; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = _Host; smtp.Port = _Port; smtp.UseDefaultCredentials = _UseDefaultCredential; smtp.Credentials = new System.Net.NetworkCredential(_Userid, _Password); smtp.EnableSsl = _EnableSsl; smtp.Send(mail); Response = "Email Sent Successfully."; } catch (Exception ex) { Response = ex.Message; } return Response; } public string callserviceforshareAsync(string EnquiryNo) { try { var count = 0; var transactionid = ""; //http://localhost:53266/Home/GetQuote?Enquiry=MASS/ENQ/183719&CompanyType=102 recall: DataTable dt = new DataTable(); dt = DBHelper.ExecuteSQLQuery("select userid, RequestQuoteXml,ResponseQuoteXml,RequestProposalXml,ResponseProposalXml from motorpolicydetails where userid= (select userid from users where enquiryno like '%" + EnquiryNo + "%') order by 1 desc"); var QuoteReq = dt.Rows[0]["RequestQuoteXml"].ToString(); var QuoteRes = dt.Rows[0]["ResponseQuoteXml"].ToString(); var ProposalReq = dt.Rows[0]["RequestProposalXml"].ToString(); var ProposalRes = dt.Rows[0]["ResponseProposalXml"].ToString(); var userid = dt.Rows[0]["UserID"].ToString(); calculateMotorPremiumSigRequest req = JsonConvert.DeserializeObject(QuoteReq); //issuePolicyRequest policyRequest = JsonConvert.DeserializeObject(ProposalReq); //var prvexpdate = Convert.ToDateTime(req.pWeoMotPolicyIn_inout.prvExpiryDate == "" ? "01-JAN-0001" : req.pWeoMotPolicyIn_inout.prvExpiryDate); //var expdate = Convert.ToDateTime(req.pWeoMotPolicyIn_inout.termEndDate); //var startdate = Convert.ToDateTime(req.pWeoMotPolicyIn_inout.termStartDate); //if (req.pWeoMotPolicyIn_inout.polType == "1") //{ // var years = expdate.Year - startdate.Year; // startdate = DateTime.Now.AddDays(1); // expdate = startdate.AddYears(years).AddDays(-1); //} //else //{ // if (req.pWeoMotPolicyIn_inout.prvExpiryDate == "") // { // startdate = DateTime.Now.AddDays(3); // expdate = startdate.AddYears(1).AddDays(-1); // policyRequest.pWeoMotPolicyIn_inout.ncb = req.pWeoMotPolicyIn_inout.ncb = 0; // policyRequest.pWeoMotPolicyIn_inout.prvNcb = req.pWeoMotPolicyIn_inout.prvNcb = 0; // } // else if (prvexpdate.Date == DateTime.Now.Date) // { } // else if (prvexpdate.Date < DateTime.Now.Date) // { // startdate = DateTime.Now.AddDays(3); // expdate = startdate.AddYears(1).AddDays(-1); // policyRequest.pWeoMotPolicyIn_inout.ncb = req.pWeoMotPolicyIn_inout.ncb = 0; // policyRequest.pWeoMotPolicyIn_inout.prvNcb = req.pWeoMotPolicyIn_inout.prvNcb = 0; // } // else // { // startdate = prvexpdate.AddDays(1); // expdate = startdate.AddYears(1).AddDays(-1); // } //} //policyRequest.pWeoMotPolicyIn_inout.termEndDate = //req.pWeoMotPolicyIn_inout.termEndDate = CommonMethods.ConvertDate(expdate, "dd-MMM-yyyy"); //policyRequest.pWeoMotPolicyIn_inout.termStartDate = //req.pWeoMotPolicyIn_inout.termStartDate = CommonMethods.ConvertDate(startdate, "dd-MMM-yyyy"); //policyRequest.pWeoMotPolicyIn_inout.prvExpiryDate = req.pWeoMotPolicyIn_inout.prvExpiryDate; string QuoteReqtest = BajajProposal.BajajQuoteReqforshare(req); var client = new RestClient("http://webservices.bajajallianz.com/BjazMotorWebservice/calculatemotorpremiumsig"); var request = new RestRequest(Method.POST); request.AddHeader("cache-control", "no-cache"); request.AddHeader("Connection", "keep-alive"); request.AddHeader("Content-Length", "3615"); request.AddHeader("Host", "webservices.bajajallianz.com"); request.AddHeader("SoapAction", "calculateMotorPremiumSigAsync"); request.AddHeader("Content-Type", "application/json"); request.AddParameter("undefined", QuoteReqtest, ParameterType.RequestBody); IRestResponse response = client.Execute(request); //JavaScriptSerializer serializer = new JavaScriptSerializer(); dynamic item = JsonConvert.DeserializeObject(response.Content.ToString()); var errorcode = item.errorlist;//["errorlist"]; if (item.errorlist.Count > 0) { var output = errorcode[0]["errtext"]; count++; if (count < 1) { goto recall; } } else { transactionid = item.transactionid;//["transactionid"]; req.pDetariffObj_inout.extCol37 = transactionid.ToString(); dynamic ProposalRequest = JsonConvert.DeserializeObject(ProposalReq); ProposalRequest.transactionid = transactionid.ToString(); ProposalReq = JsonConvert.SerializeObject(ProposalRequest); } var Proposalclient = new RestClient("http://webservices.bajajallianz.com/BjazMotorWebservice/issuepolicy"); var Proposalrequest = new RestRequest(Method.POST); Proposalrequest.AddHeader("cache-control", "no-cache"); Proposalrequest.AddHeader("Connection", "keep-alive"); Proposalrequest.AddHeader("Cookie", "Per22=ffffffff090c167e45525d5f4f58455e445a4a423660"); Proposalrequest.AddHeader("Content-Length", "6377"); Proposalrequest.AddHeader("Accept-Encoding", "gzip, deflate"); Proposalrequest.AddHeader("Host", "webservices.bajajallianz.com"); Proposalrequest.AddHeader("Postman-Token", "25a56a36-2d31-46fb-bf48-76c13c3d44a7,fa68977a-d4f1-408e-b226-0c1ffa5deaf2"); Proposalrequest.AddHeader("Cache-Control", "no-cache"); Proposalrequest.AddHeader("Accept", "*/*"); Proposalrequest.AddHeader("User-Agent", "PostmanRuntime/7.16.3"); Proposalrequest.AddHeader("Content-Type", "application/json"); Proposalrequest.AddParameter("undefined", ProposalReq, ParameterType.RequestBody); IRestResponse Proposalrequestresponse = Proposalclient.Execute(Proposalrequest); dynamic Propitem = JsonConvert.DeserializeObject(Proposalrequestresponse.Content.ToString()); errorcode = Propitem.errorlist; if (Propitem.errorlist.Count == 0) { var RequestQuoteXml = JsonConvert.SerializeObject(req); var RequestProposalXml = ProposalReq; CommonMethods.SavebajajshareRequestdetails(RequestQuoteXml, response.Content, RequestProposalXml, Proposalrequestresponse.Content, transactionid.ToString(), userid); return transactionid; } else { return null; } } catch (Exception ex) { return null; } } public ShareModel GetShareData(string URL) { var uri = new Uri(URL); DataTable Dt = new DataTable(); URL = uri.Query.Replace("?", ""); if (URL != "" && URL != null) { Dt = DBHelper.ExecuteSQLQuery("select ClientURL,ToEmail,Url,ProposalReq,ProposalResponse,ProposalResponse,ProposalAdditionalData,QuotePage,quoteResponse from ShareProposalAPI where Url like '%" + URL + "%' order by id desc"); ShareModel model = Dt.AsEnumerable().Select(row => new ShareModel() { ClientURL = row["ClientURL"].ToString(), ProposalAdditionalData = row["ProposalAdditionalData"].ToString(), ProposalReq = row["ProposalReq"].ToString(), ProposalResponse = row["ProposalResponse"].ToString(), QuotePage = row["QuotePage"].ToString(), quoteResponse = row["quoteResponse"].ToString(), ToEmail = row["ToEmail"].ToString(), //TypeOfMoter= row[""].ToString(), Url = row["Url"].ToString() }).FirstOrDefault(); return model; } else { return null; } } private string HostName(string URL) { try { if (URL.StartsWith("http://www.") == true) URL = URL.Replace("http://www.", ""); if (URL.StartsWith("https://www.") == true) URL = URL.Replace("https://www.", ""); if (URL.StartsWith("http://") == true) URL = URL.Replace("http://", ""); if (URL.StartsWith("https://") == true) URL = URL.Replace("https://", ""); if (URL.StartsWith("www.") == true) URL = URL.Replace("www.", ""); } catch { } return URL; } public string ShareQuotes(ShareQuoteModel Model) { string Clientname = HostName(Model.ClientURL); Clientname = DBManager.DBHelper.ExecuteSQLSingleValue("select companyName from ClientMaster where companyURL like '%" + Clientname + "%'"); string ProductName = Model.Url.Contains("Car") ? "Private Car" : Model.Url.Contains("Two") ? "Two Wheeler" : ""; string msg = ""; try { if (Model.Via.ToLower() == "email") { string body = "" + "" + "" + " " + " " + " aranoz " + "" + "" + " " + " " + " " + " " + " " + " " + "
" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "
 
" + " " + " " + " " + " " + " " + " " + "
\"\"
" + "
 
" + " " + " " + " " + " " + " " + " " + "
" + "

Dear Customer

" + "

Thank you for visiting " + Clientname + " to insure your " + ProductName + "

" + "
" + "
 
" + " " + " " + " " + " " + " " + " " + "
" + "

Please click on below button to get the Quotes.

" + "
" + "
 
" + " " + " " + " " + " " + " " + " " + " " + "
" + " " + "
" + "
 
" + " " + " " + " " + " " + " " + " " + " " + "
" + "

Feel free to get in touch with us on mentioned contact number on portal, in case you need anything else.

" + "

Regards,

" + "

" + Clientname + " Team

" + "
\"\"
" + "
" + "
" + "" + ""; // string body = " Please click on below button to get the Quotes.

Click Me"; //string body = "Please click or copy and past bellow link to ger car Proposal:" + // "

Click Me"; msg = mailMaster(Model.ToEmail, Model.ClientURL, "Share Quotes", body, Model.Role); if (msg == "Email Sent Successfully.") { var quoteResponse = Model.quoteResponse.Replace("='http", "=\"http").Replace("/'> ", "/\"> ").Replace("'", "''"); string Query = "Insert into NewShareQuote(EnqueryNo,QuotePage,GenerateQuote,quoteResponse,Create_date)"; Query += " values('" + Model.EnqueryNo + "','" + Model.QuotePage + "','" + Model.GenerateQuote + "','" + quoteResponse + "',getdate())"; DBHelper.ExecuteNonQueryWithOutProc(Query); } } else if (Model.Via.ToLower() == "sms") { string result = ""; string text = "Please click on below link to get the Quotes\n" + Model.Url; // @You may retrieve your quotes and search the same through your Reference id:" + refrenceID + " if (Model.Url.Contains("insta-policy")) { result = "http://sendsms.designhost.in/index.php/smsapi/httpapi/?uname=instapolicy&password=InstaPolicy@123&sender=INSPOL&receiver=" + Model.ToEmail + "&route=TA&msgtype=1&sms=" + text; } else if (Model.Url.Contains("jkbima") && Model.Role != "" && Model.Role != null) { result = "http://bulkpush.mytoday.com/BulkSms/SingleMsgApi?feedid=362153&username=8010007547&password=tdatm&To=" + Model.ToEmail + "&Text=" + text + "&time=200812110950&senderid=JKRMIB"; //jkbima } else if (Model.Url.Contains("inshoracover")) { result = "http://sms.mevite.in/smsapi.php?username=inshoracover&password=915841&sender=iCOVER&sendto=" + Model.ToEmail + "&message=" + text; } else if (Model.Url.Contains("riskfreelife")) { result = "https://api.msg91.com/api/sendhttp.php?authkey=183914AcJo1fuR5a0d1d6b&mobiles=" + Model.ToEmail + "&country=91&message=" + text + "&sender=RFLSMS&route=4"; //result = "https://control.msg91.com/api/sendotp.php?authkey=183914AcJo1fuR5a0d1d6b&mobile=" + Model.ToEmail + "&message=##OTP##" + text + "&sender=OTPSMS&otp_expiry=&otp_length=&country=&otp=&email=&template="; } else if (Model.Url.Contains("smcinsurance") && (Model.Role == "" || Model.Role == null)) { result = "https://push3.maccesssmspush.com/servlet/com.aclwireless.pushconnectivity.listeners.TextListener?userId=idsmc&pass=pasmc&appid=smc&subappid=smc&contenttype=1&to=" + Model.ToEmail + "&from=SMCINS&text=" + text + "&selfid=true&alert=1&dlrreq=true&intflag=false"; } else if (Model.Url.Contains("smcinsurance") && (Model.Role != "" && Model.Role != null)) { result = "https://push3.maccesssmspush.com/servlet/com.aclwireless.pushconnectivity.listeners.TextListener?userId=idsmc&pass=pasmc&appid=smc&subappid=smc&contenttype=1&to=" + Model.ToEmail + "&from=SMCPOS&text=" + text + "&selfid=true&alert=1&dlrreq=true&intflag=false"; } if (!SendSms(result)) { msg = "Unable to connect to the remote server"; } else//if (SendSms(result)) { var quoteResponse = Model.quoteResponse.Replace("='http", "=\"http").Replace("/'> ", "/\"> ").Replace("'", "''"); msg = "SMS Sent Successfully."; string Query = "Insert into NewShareQuote(EnqueryNo,QuotePage,GenerateQuote,quoteResponse,Create_date)"; Query += " values('" + Model.EnqueryNo + "','" + Model.QuotePage + "','" + Model.GenerateQuote + "','" + quoteResponse + "',getdate())"; DBHelper.ExecuteNonQueryWithOutProc(Query); } } } catch (Exception ex) { msg = "Exception : " + ex.Message; } return msg; } private static bool SendSms(string url) { string result = ""; WebRequest request = null; HttpWebResponse response = null; string status = string.Empty; try { request = WebRequest.Create(url); response = (HttpWebResponse)request.GetResponse(); Stream stream = response.GetResponseStream(); Encoding ec = System.Text.Encoding.GetEncoding("utf-8"); StreamReader reader = new System.IO.StreamReader(stream, ec); result = reader.ReadToEnd(); reader.Close(); stream.Close(); return true; } catch (Exception exp) { Console.WriteLine(exp.ToString()); return false; } finally { if (response != null) response.Close(); } } //public string ShareQuotes(ShareQuoteModel Model) //{ // string msg = ""; // try // { // string body = " Please click on below button to get the Quotes.

Click Me"; // //string body = "Please click or copy and past bellow link to ger car Proposal:" + // // "

Click Me"; // msg = mailMaster(Model.ToEmail,Model.ClientURL, "Share Quotes", body); // if (msg == "Email Sent Successfully.") // { // string Query = "Insert into NewShareQuote(EnqueryNo,QuotePage,GenerateQuote,quoteResponse,Create_date)"; // Query += " values('" + Model.EnqueryNo + "','" + Model.QuotePage + "','" + Model.GenerateQuote + "','" + Model.quoteResponse + "',getdate())"; // DBHelper.ExecuteNonQueryWithOutProc(Query); // } // } // catch (Exception ex) { msg = "Exception : " + ex.Message; } // return msg; //} public ShareQuoteModel GetShareQuoteData(string EnquiryNo) { ShareQuoteModel Data = new ShareQuoteModel(); try { string Query = "select EnqueryNo,QuotePage,GenerateQuote,quoteResponse from NewShareQuote where EnqueryNo='" + EnquiryNo + "'"; DataTable dt = new DataTable(); dt = DBHelper.ExecuteSQLQuery(Query); if (dt.Rows.Count > 0) { Data = dt.AsEnumerable().Select(row => new ShareQuoteModel() { EnqueryNo = row["EnqueryNo"].ToString(), QuotePage = row["QuotePage"].ToString(), GenerateQuote = row["GenerateQuote"].ToString(), quoteResponse = row["quoteResponse"].ToString(), }).FirstOrDefault(); Data.Url = "success"; } else { Data.Url = "Data Not Found"; } } catch (Exception ex) { Data.Url = ex.Message; } return Data; } } }