示例#1
0
 static void Main()
 {
     try
     {
         string  body    = "Hello,</br></br></br>Attached herewith the Monthly report (May'17) for review solicitation of OneFineRate.";
         string  subject = string.Format("Monthly report ({0}, {1})  for review solicitation of OneFineRate.", string.Format("{0:MMM}", DateTime.Now), string.Format("{0:yy}", DateTime.Now));
         DataSet dt      = SqlHelper.ExecuteDataset(ConfigurationManager.AppSettings["ConnectionString"].ToString(), CommandType.StoredProcedure, "[uspTripAdvisorMonthlyReport]");
         if (dt.Tables[0] != null && dt.Tables[0].Rows.Count > 0)
         {
             string path = AppDomain.CurrentDomain.BaseDirectory + "TripAdvisorMonthlyReport";
             if (!Directory.Exists(path))
             {
                 Directory.CreateDirectory(path);
             }
             ExportDatasetToExcel(dt);
             var            fileStream  = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "TripAdvisorMonthlyReport/MonthlyReport.xlsx", FileMode.Open, FileAccess.Read);
             var            displayName = "TripAdvisorMonthlyReport.xlsx";
             var            attachment  = new Attachment(fileStream, displayName);
             SqlParameter[] MyParam     = new SqlParameter[1];
             MyParam[0] = new SqlParameter("@sModule", "TripAdvisor");
             DataSet dataset = SqlHelper.ExecuteDataset(ConfigurationManager.AppSettings["ConnectionString"].ToString(), CommandType.StoredProcedure, "[dbo].[GetEmailByModule]", MyParam);
             if (dataset.Tables[0] != null && dataset.Tables[0].Rows.Count > 0)
             {
                 MailComponent.SendEmail("*****@*****.**", "", "", subject, body, attachment, null, true);
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#2
0
        public ActionResult UpdateBookingOnUpgrade(BiddingHotelsUpgrade obj)
        {
            try
            {
                TempData.Peek("BIdUpgradeHotels");
                TempData.Peek("BidSearchHotels");
                TempData.Peek("BidSearchData");
                int bookingId, PropId;
                PropId    = obj.iPropId;
                bookingId = obj.iBookingId;

                eBidBookingResult Robj = BL_Bidding.UpdateBidBooking(bookingId, PropId);
                if (Robj.Status == "Success")
                {
                    var bookingModel = BL_Booking.GetBooking(bookingId);

                    string Status = "Thank you " + bookingModel.sTitleOFR + " " + bookingModel.sFirstNameOFR + "! We have recieved your final payment.";
                    Task.Run(() => MailComponent.SendEmail(bookingModel.sEmailOFR, "", "", "Hotel Selected", Status, null, null, false, null, null));
                    Task.Run(() => clsUtils.sendSMS(bookingModel.sMobileOFR, Status));
                    Session["Result"] = "Hotel selected successfully!";
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception E)
            {
                Session["Result"] = "There was an error selecting the hotel. Please try again.";
            }
            return(RedirectToAction("Index"));
        }
示例#3
0
        public ActionResult GetLeftPayment(BiddingHotelsUpgrade objUpgrade)
        {
            try
            {
                var obj = new BiddingHotelsUpgrade();
                if (TempData["BIdUpgradeHotels"] != null)
                {
                    TempData.Keep(); obj = TempData["BIdUpgradeHotels"] as BiddingHotelsUpgrade;
                }

                var prop = obj.lstRoomsData.Where(u => u.iRoomId == objUpgrade.iRoomId).SingleOrDefault();

                var obj1 = new eBiddingHotelsUpgradeRoomsList();
                obj1 = prop as eBiddingHotelsUpgradeRoomsList;
                var result = BL_Bidding.UpdateUpgradeBidBookingUnfinished(Convert.ToInt64(objUpgrade.iBookingId), obj.iPropId, objUpgrade.iRoomId, obj1.TotalDifference, obj1.TaxDifference, objUpgrade.sAuthCode);
                if (result.Status == "Success")
                {
                    var bookingModel = BL_Booking.GetBooking(Convert.ToInt64(objUpgrade.iBookingId));

                    string Status = "Thank you " + bookingModel.sTitleOFR + " " + bookingModel.sFirstNameOFR + "! We have recieved your final payment.";
                    Task.Run(() => MailComponent.SendEmail(bookingModel.sEmailOFR, "", "", "Hotel Selected", Status, null, null, false, null, null));
                    Task.Run(() => clsUtils.sendSMS(bookingModel.sMobileOFR, Status));
                    Session["Result"] = "Hotel selected successfully!";
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception E)
            {
                Session["Result"] = "There was an error selecting the hotel. Please try again.";
            }
            return(RedirectToAction("Index"));
        }
示例#4
0
        //Log4net
        //static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        static void Main(string[] args)
        {
            string sErrorEmail = "[email protected],[email protected]";

            try { sErrorEmail = SqlHelper.ExecuteScalar(ConfigurationManager.ConnectionStrings["OFR_DataContext"].ToString(), CommandType.Text, "SELECT TOP 1 sEmail FROM tblEmailSettingsM WHERE sModule = 'TravelGuruSync'").ToString(); } catch (Exception) { }

            try
            {
                //Log4net configuration
                //BasicConfigurator.Configure();

                string staticDumpUrl = ConfigurationManager.AppSettings["StaticTextDumpUrl"].ToString();
                string userName      = ConfigurationManager.AppSettings["UserName"].ToString();
                string password      = ConfigurationManager.AppSettings["Password"].ToString();

                //For Testing Purpose
                //System.Threading.Thread.Sleep(1000 * 60 * 3);

                new DumpDataManager(sErrorEmail).DownloadAndProcessData(sourceUrl: staticDumpUrl, userName: userName, password: password);
            }
            catch (Exception ex)
            {
                try
                {
                    MailComponent.SendEmail(sErrorEmail, "", "", "TravelGuru Sync Error", ex.ToString(), null, null, false, null, null);
                }
                catch (Exception exMail)
                {
                    LogExceptionDetails(exMail);
                }

                LogExceptionDetails(ex);
            }
        }
示例#5
0
        public Task SendAsync(IdentityMessage message)
        {
            // Plug in your email service here to send an email.

            MailComponent.SendEmail(message.Subject, "", "", "Link to reset your password for " + clsUtils.ApplicationName() + "", message.Body, null, null, true, null, null);

            return(Task.FromResult(0));
        }
示例#6
0
        //[HttpPost]
        public ActionResult SendMailAndUpdateTaxAffectedBookings(string selectedBookingIds)
        {
            try
            {
                if (!string.IsNullOrEmpty(selectedBookingIds))
                {
                    var userId = ((BL_Login.UserDetails)Session["UserDetails"]).iUserId;

                    List <string> deliveredBookingIdInEmail = new List <string>();

                    long[] bookingIdArr = selectedBookingIds.Split(',').Select(long.Parse).ToArray();

                    var affectedBoolingList = BL_Booking.GetTaxAffectedBookings(bookingIdArr);

                    bool isError = false;

                    foreach (var item in affectedBoolingList)
                    {
                        try
                        {
                            item.sCheckIn  = item.dtCheckIn.ToString("dd MMM yyyy");
                            item.sCheckOut = item.dtCheckOut.ToString("dd MMM yyyy");

                            var html_Customer = this.RenderViewToString("_TaxChangeBookingAlert", item);

                            //TO DO
                            var ccMail = string.Empty;
                            ccMail = "*****@*****.**";
                            MailComponent.SendEmail(item.sEmailOFR, ccMail, "", "OneFineRate! Confirmation No:" + item.iBookingId, html_Customer, null, null, true, null, null);
                            deliveredBookingIdInEmail.Add(item.iBookingId.ToString());
                        }
                        catch (Exception ex)
                        {
                            isError = true;
                        }
                    }

                    var result = BL_Booking.UpdateTaxAffectedBookings(deliveredBookingIdInEmail.ToArray(), userId);

                    if (isError)
                    {
                        return(Json(new { status = false, message = "An error occured occurred while sending email." }, JsonRequestBehavior.AllowGet));
                    }

                    return(Json(new { status = true, message = "Record updated and email sent to selected record successfully!" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { status = false, message = "Please select at least one booking." }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { status = false, message = "An error occurred while updating the record!" }, JsonRequestBehavior.AllowGet));
            }
        }
示例#7
0
        public static string ChangePasswordUrl(string emailID)
        {
            object result    = null;
            string strReturn = string.Empty;

            try
            {
                string mainkey = clsUtils.getmainkey();
                string sUrl    = "";

                using (OneFineRateEntities db = new OneFineRateEntities())
                {
                    var dbobj = (from s in db.tblUserMs
                                 select new
                    {
                        s.iUserId,
                        s.sFirstName,
                        s.sLastName,
                        s.sEmail,
                    }).Where(u => u.sEmail.ToLower() == emailID.ToLower()).FirstOrDefault();

                    //  emailID = "*****@*****.**";

                    if (dbobj != null)
                    {
                        sUrl = clsUtils.ExtranetBaseUrl() + "Account/ChangePassword?id=" + System.Web.HttpUtility.UrlEncode(Encription.AESEncryption.EncryptData(dbobj.iUserId.ToString(), mainkey));
                        StringBuilder stringBuilder = new StringBuilder();

                        stringBuilder.Append("<font face=Verdana size=6 color=navy><pre>Dear " + dbobj.sFirstName + " " + dbobj.sLastName + ",\n");
                        stringBuilder.Append("\nClick <a href = " + sUrl + ">here</a> to reset your password for " + clsUtils.ApplicationName() + " application.");
                        stringBuilder.Append("\n\n\nIn case the above link doesn't work then please copy the url mentioned below and paste it on browser.");
                        stringBuilder.Append("\n\n" + sUrl);
                        stringBuilder.Append("\n\n\nThis is system generated email, Please do not reply.");
                        stringBuilder.Append("\n\nRegards");
                        stringBuilder.Append("\nAdministrator</pre></font>");
                        MailComponent.SendEmail(emailID, "", "", "Link to reset your password for " + clsUtils.ApplicationName() + "", stringBuilder.ToString(), null, null, true, null, null);
                        result = new { st = 1, msg = "Link to reset your password has been sent to your email." };
                    }
                    else
                    {
                        result = new { st = 0, msg = "Invalid Email ID." };
                    }
                }
            }
            catch (Exception ex)
            {
                result = new { st = 0, msg = "Kindly try after some time." };
            }

            strReturn = OneFineRateAppUtil.clsUtils.ConvertToJson(result);
            return(strReturn);
        }
示例#8
0
        public ActionResult BecomeCorporate(eCorporateCompanyM model)
        {
            try
            {
                model.dtActionDate = DateTime.Now;

                if (!string.IsNullOrEmpty(model.sEmailAddress))
                {
                    TempData["msg"] = "Thank you for your Registration. Our executive will contact you shortly.";

                    string sToEmail  = model.sEmailAddress;
                    string sCcEmail  = "";
                    string sBCcEmail = "";
                    string sSubject  = "Become Corporate Application Submitted Successfully";
                    string sBody     = "Your application has been submitted successfully. Thank you.";
                    MailComponent.SendEmail(sToEmail, sCcEmail, sBCcEmail, sSubject, sBody, null, null, true, null, null);

                    string adminEmail     = BL_tblHotelPartner.GetPartnerEmailId();
                    string adminsCcEmail  = "";
                    string adminsBCcEmail = "";
                    string adminsSubject  = "Corporate Partner Application Submitted Successfully";
                    string adminsBody     = "<table border='1'>";
                    adminsBody += "<tr><td>Company Name: </td><td>" + model.sCompanyName + "</td>";
                    adminsBody += "<tr><td>Email Address: </td><td>" + model.sEmailAddress + "</td>";
                    adminsBody += "<tr><td>Telephone Number: </td><td>" + model.sTelephoneNumber + "</td>";
                    adminsBody += "<tr><td>Mobile Number: </td><td>" + model.sMobileNumber + "</td>";
                    //adminsBody += "<tr><td>Action Date: </td><td>" + DateTime.Now + "</td>";
                    adminsBody += "</table>";
                    MailComponent.SendEmail(adminEmail, adminsCcEmail, adminsBCcEmail, adminsSubject, adminsBody, null, null, true, null, null);
                }
                else
                {
                    ModelState.AddModelError("", "Email Address Required!");
                    return(View(model));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex);
                return(View(model));
            }
            ModelState.Clear();
            return(View());
        }
示例#9
0
        /// <summary>
        /// This function will send error report to the respective person with complete error logs as provide in parameter.
        /// </summary>
        /// <param name="errorDescription">Complete logs of error that need to send.</param>
        /// <returns>Status of the process as int : 1 means success and -1 means fail</returns>
        public int SendErrorReport(string errorDescription)
        {
            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                var errorSpecificEmails = db.tblEmailSettingsMs.Where(x => x.sModule == EmailSetting.WebSiteError.ToString()).FirstOrDefault();

                if (errorSpecificEmails != null)
                {
                    try
                    {
                        MailComponent.SendEmail(errorSpecificEmails.sEmail, "", "", "Error", errorDescription, null, null, false, null, null);
                        return(1);
                    }
                    catch (Exception)
                    {
                    }
                }
                return(-1);
            }
        }
示例#10
0
        public ActionResult UnfinishedBalanceToBePaidSendLink(etblUnfinishedTransactionsToBePaid objData)
        {
            string adminEmail     = objData.sCustomerEmailID;
            string adminsCcEmail  = "";// "*****@*****.**";
            string adminsBCcEmail = "";
            string adminsSubject  = "Unfinished Transaction - Balance To Be Paid";
            string adminsBody     = "<table border='1'>";

            adminsBody += "<tr><td>Hotel Name: </td><td>" + objData.sHotelName + "</td>";
            adminsBody += "<tr><td>Star Category: </td><td>" + objData.iStarCategory + "</td>";
            adminsBody += "<tr><td>Address: </td><td>" + objData.sHotelAddress + "</td>";
            adminsBody += "<tr><td>Your Negotiation Amount: </td><td>" + objData.dNegotiationAmount + "</td>";
            adminsBody += "<tr><td>Advanced Paid: </td><td>" + objData.dAdvancePaid + "</td>";
            adminsBody += "<tr><td>Balance Payment: </td><td>" + objData.dBalancePayment + "</td>";
            adminsBody += "<tr><td colspna='2'><a href='onefinerate.azurewebsites.net'>Click To Pay Balance Amount</a> </td>";
            adminsBody += "</table>";

            MailComponent.SendEmail(adminEmail, adminsCcEmail, adminsBCcEmail, adminsSubject, adminsBody, null, null, true, null, null);
            TempData["msg"] = "Link sent to customer successfully";

            return(RedirectToAction("UnfinishedBalanceToBePaid", objData));
        }
示例#11
0
        public string ProvideFinalOffer(int BookingId, int FinalOffer, int Convert)
        {
            try
            {
                string s = BL_Booking.ProvideFinalOffer(BookingId, FinalOffer, ((OneFineRateBLL.BL_Login.UserDetails)Session["UserDetails"]).iUserId, Convert);
                if (s == "")
                {
                    var bookingDetails = BL_Booking.GetBookingModifyDetails_Notifications(BookingId);
                    var model          = new NegotiationEmailTempleteModel();
                    model.Status = "Progress! You have received a  counter offer! Please check the details by clicking the link below: ";

                    bookingDetails.dTaxes = System.Convert.ToDecimal(bookingDetails.sExtra2);
                    model.BookingModify   = bookingDetails;

                    var websiteBaseUrl = ConfigurationManager.AppSettings["OFRBaseUrl"].ToString();
                    model.CallbackUrl = websiteBaseUrl + "Negotiation/NegotiationStatus?bookingId=" + clsUtils.Encode(BookingId.ToString());

                    model.CallbackUrl = clsUtils.Shorten(model.CallbackUrl);
                    // string notifySMS_User = model.Status + Environment.NewLine + "<a href=\"" + model.CallbackUrl + "\"></a>";

                    var html      = this.RenderViewToString("_EmailTemplete", model);
                    var testEmail = "";

                    Task.Run(() => clsUtils.sendSMS(bookingDetails.MobileOFR, model.Status + model.CallbackUrl));
                    Task.Run(() => MailComponent.SendEmail(bookingDetails.EmailOFR, testEmail, "", "Bargain Status", html, null, null, true, null, null));

                    return("{ \"st\" : 1 , \"Status\" : \"Final offer provided successfully.\" }");
                }
                else
                {
                    return("{ \"st\" : 0 , \"Status\" : \"" + s + "\" }");
                }
            }
            catch (Exception)
            {
                return("{ \"st\" : 0 , \"Status\" : \"Please try again.\" }");
            }
        }
示例#12
0
        static void Main(string[] args)
        {
            try
            {
                string body = "", subject = "";
                // Gets Data from tblBookingTripAdvisorReviewTx
                DataSet dt = SqlHelper.ExecuteDataset(ConfigurationManager.AppSettings["ConnectionString"].ToString(), CommandType.StoredProcedure, "[uspTripAdvisorMonthlyReport]");
                if (dt != null && dt.Tables.Count > 0 && dt.Tables[0] != null && dt.Tables[0].Rows.Count > 0)
                {
                    string path = AppDomain.CurrentDomain.BaseDirectory + "TripAdvisorMonthlyReport";
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }


                    body = "Hello,<br/><br/>Attached herewith the Monthly report (" + dt.Tables[1].Rows[0]["MonthYear"].ToString() + ") for review solicitation of OneFineRate.<br/><br/>Thank you,<br/>OneFineRate Team";
                    //subject = string.Format("Monthly report ({0}, {1})  for review solicitation of OneFineRate.", string.Format("{0:MMM}", DateTime.Now), string.Format("{0:yy}", DateTime.Now));
                    subject = "Monthly report (" + dt.Tables[1].Rows[0]["MonthYear"].ToString() + ") for review solicitation of OneFineRate.";
                    ExportDatasetToExcel(dt);
                    var            fileStream  = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "TripAdvisorMonthlyReport/MonthlyReport.xlsx", FileMode.Open, FileAccess.Read);
                    var            displayName = "TripAdvisorMonthlyReport.xlsx";
                    var            attachment  = new Attachment(fileStream, displayName);
                    SqlParameter[] MyParam     = new SqlParameter[1];
                    MyParam[0] = new SqlParameter("@sModule", "TripAdvisor");
                    DataSet dataset = SqlHelper.ExecuteDataset(ConfigurationManager.AppSettings["ConnectionString"].ToString(), CommandType.StoredProcedure, "[GetEmailByModule]", MyParam);
                    if (dataset.Tables[0] != null && dataset.Tables[0].Rows.Count > 0)
                    {
                        MailComponent.SendEmail(dataset.Tables[0].Rows[0]["Email"].ToString(), "", "", subject, body, attachment, null, true, fileStream, displayName);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#13
0
        private Task SendInformation(string statusType, long bookingId)
        {
            try
            {
                //var bookingDetails = BL_Booking.GetBooking(bookingId);
                var bookingModel = BL_Booking.GetBookingModifyDetails_Notifications(bookingId);

                var    model = new NegotiationEmailTempleteModel();
                string notificationSMS_User = string.Empty;
                bool   Accepted             = true;
                switch (statusType) // Notification mail/SMS to customer. Conserve commission checked and managed.
                {
                case "HR":          // Hotel has rejected the negotiation. Conserve commission not applied.
                    var websiteBaseUrl1 = ConfigurationManager.AppSettings["OFRBaseUrl"].ToString();

                    string negoStatusUrl = websiteBaseUrl1 + "Negotiation/NegotiationStatus?bookingId=" + clsUtils.Encode(bookingId.ToString());

                    model.Status         = "Sorry! Your offer is rejected. Please Check the related offer details by clicking the link below:";
                    notificationSMS_User = "******";
                    Accepted             = false;
                    break;

                case "CO":     // Hotel has countered the negotiation.
                case "RR":     // Rate reduced for "Original rate" through conserve commission.
                case "CR":     // Rate reduced for Counter offer through conserve commission.
                    model.Status         = "Progress! You have received a  counter offer ! Please check the details by clicking the link below:";
                    notificationSMS_User = model.Status;
                    Accepted             = false;
                    break;

                case "BP":     // Hotel has accepted the negotiation.
                case "RA":     // Negotiation accepted by reducing conserve commission on "Original rate".
                case "CA":     // Negotiation accepted by reducing conserve commission on counter offer.
                    model.Status         = "Congratulations! Your offer is accepted! Please Check the details by clicking the link below:";
                    notificationSMS_User = model.Status;
                    break;
                }

                //bookingModel.dTaxes = Convert.ToDecimal(bookingModel.sExtra2);

                model.BookingModify = bookingModel;

                var websiteBaseUrl = ConfigurationManager.AppSettings["OFRBaseUrl"].ToString();
                if (!Accepted)
                {
                    model.CallbackUrl = websiteBaseUrl + "Negotiation/NegotiationStatus?bookingId=" + clsUtils.Encode(bookingId.ToString());
                }
                else
                {
                    model.CallbackUrl = websiteBaseUrl + "NegoConfirmed/" + clsUtils.Encode(bookingId.ToString());
                }


                var html = this.RenderViewToString("_EmailTemplete", model);

                var shortUrl = clsUtils.Shorten(model.CallbackUrl);

                var message = notificationSMS_User + shortUrl;

                //Task.Run(() => clsUtils.sendSMS("9560439101", model.Status + Environment.NewLine + model.CallbackUrl));
                clsUtils.sendSMS(bookingModel.MobileOFR, message);

                return(Task.Run(() => MailComponent.SendEmail(bookingModel.EmailOFR, "", "", "Offer from OneFineRate Confirmation No: " + bookingModel.BookingId, html, null, null, true, null, null)));
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#14
0
        public int SendMailToRevenueManager(int bookingId)
        {
            try
            {
                var customerModel = new NegotiationEmailTempleteModel();
                // Added to show hotel Information in email template
                var bookingModel = BL_Booking.GetBookingModifyDetails_Notifications(bookingId);
                customerModel.BookingModify = bookingModel;


                Decimal?ExchangeRate = 1;
                // get from tblEmailSetting
                var revenueManagerDetail = BL_tblEmailSettingsM.GetRecord("RevenueManager");

                // get from propertyEdit page
                var pRevenueManager = BL_PropDetails.GetEmail_PhoneByPropId(bookingModel.PropId);

                string sPrimaryContactEmail;
                string sConfirmationContactEmail;
                string sRevenueManagerEmail;
                string sRevenueManagerContact;

                pRevenueManager.TryGetValue("sPrimaryContactEmail", out sPrimaryContactEmail);
                pRevenueManager.TryGetValue("sConfirmationContactEmail", out sConfirmationContactEmail);
                pRevenueManager.TryGetValue("sRevenueManagerEmail", out sRevenueManagerEmail);
                pRevenueManager.TryGetValue("sRevenueManagerContact", out sRevenueManagerContact);

                string emails = sRevenueManagerEmail + "," + sConfirmationContactEmail + "," + sPrimaryContactEmail;


                customerModel = new NegotiationEmailTempleteModel();
                customerModel.BookingModify = bookingModel;
                //customerModel.Status = "Thanks " + bookingModel.Booker + "! We have recieved your negotiation." + Environment.NewLine + "We will get back to you within 3 hours.";
                customerModel.Status = "Thank you " + bookingModel.Booker + "! We have recieved your bargain." + Environment.NewLine + bookingModel.sMessage;

                var revenuManagerModel = new NegotiationEmailTempleteModel();
                //revenuManagerModel.Status = "Hi " + revenueManageName +", Please take action for the following Negotiation Request.";
                revenuManagerModel.Status = "Hi, Please take action for the following bargain Request.";
                revenuManagerModel.IsRevenueManagerFormat = true;


                if (bookingModel.sCurrencyCode != "INR")
                {
                    etblExchangeRatesM objExchange = BL_ExchangeRate.GetSingleRecordById("INR", bookingModel.sCurrencyCode);
                    if (objExchange.dRate != null)
                    {
                        ExchangeRate = 1 / objExchange.dRate;
                    }
                }
                bookingModel.dTotalNegotiateAmount = bookingModel.dTotalNegotiateAmount * ExchangeRate;
                bookingModel.dTaxes = Convert.ToDecimal(bookingModel.Tax) * Convert.ToDecimal(ExchangeRate);
                revenuManagerModel.BookingModify = bookingModel;

                string extranetUrl = Request.Url.GetLeftPart(UriPartial.Authority) + "Account/Login?sPropId=" + clsUtils.Encode(bookingModel.PropId.ToString());

                string shortExtranetUrl = clsUtils.Shorten(extranetUrl);

                string notificationMsg_RevenueMgr = "You have received a new bargain offer. The guest has chosen your hotel! Click " + shortExtranetUrl + " to view the offer and process yet another reservation from OFR. This offer is valid for the next three hours.";

                var html_RevenueManager = this.RenderViewToString("_NegotiationEmailTemplete", revenuManagerModel);

                Task.Run(() => clsUtils.sendSMS(sRevenueManagerContact, notificationMsg_RevenueMgr));

                Task.Run(() => MailComponent.SendEmail(sRevenueManagerEmail, revenueManagerDetail.sEmail, "", "Reminder - New Bargain", html_RevenueManager, null, null, true, null, null));

                return(1);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
示例#15
0
        public int SendCustAcceptReminderEmail(int bookingId)
        {
            try
            {
                string notificationSMS_User = string.Empty;
                var    bookingDetails       = BL_Booking.GetBookingModifyDetails(bookingId);
                string statusType           = bookingDetails.cBookingStatus;
                var    model = new NegotiationEmailTempleteModel();
                model.BookingModify = bookingDetails;
                var    websiteBaseUrl = ConfigurationManager.AppSettings["OFRBaseUrl"].ToString();
                string negoStatusUrl  = websiteBaseUrl + "Negotiation/NegotiationStatus?bookingId=" + clsUtils.Encode(bookingId.ToString());

                string shortNegoStatusUrl = clsUtils.Shorten(negoStatusUrl);

                //bool Accepted = true;
                switch (statusType) // Notification mail/SMS to customer. Conserve commission checked and managed.
                {
                case "HR":          // Hotel has rejected the negotiation. Conserve commission not applied.
                    //model.Status = "Sorry! Your Negotiation is Rejected. Please Check the related offer details by clicking the link below";
                    notificationSMS_User = "******" + shortNegoStatusUrl;
                    model.Status         = notificationSMS_User;
                    //Accepted = false;
                    break;

                case "CO":     // Hotel has countered the negotiation.
                case "RR":     // Rate reduced for "Original rate" through conserve commission.
                case "CR":     // Rate reduced for Counter offer through conserve commission.
                case "FO":     // Final Offer given.
                    model.Status         = "Progress! You have received a  counter offer ! Please check the details by clicking the link below: ";
                    notificationSMS_User = model.Status;
                    //Accepted = false;
                    break;

                case "BP":     // Hotel has accepted the negotiation.
                case "RA":     // Negotiation accepted by reducing conserve commission on "Original rate".
                case "NA":     // Negotiation accepted.
                    model.Status         = "Congratulations! Your offer is accepted! Please Check the details by clicking the link below: ";
                    notificationSMS_User = model.Status;
                    break;

                case "CA":     //  counter offer accepted.
                case "FA":     //  Final offer accepted.
                    model.Status         = "Counter offer was accepted by you! Please Check the details by clicking the link below: ";
                    notificationSMS_User = model.Status;
                    break;

                case "OA":     //  counter offer accepted.
                case "NS":     //  counter offer accepted.
                    model.Status         = "Please Check the details by clicking the link below: ";
                    notificationSMS_User = model.Status;
                    break;
                }

                // if (!Accepted)
                //  model.CallbackUrl = websiteBaseUrl + "Negotiation/NegotiationStatus?bookingId=" + clsUtils.Encode(bookingId.ToString());
                model.CallbackUrl = shortNegoStatusUrl;
                //else
                //  model.CallbackUrl = websiteBaseUrl + "NegoConfirmed/" + clsUtils.Encode(bookingId.ToString());

                var html = this.RenderViewToString("_EmailTemplete", model);

                Task.Run(() => clsUtils.sendSMS(bookingDetails.MobileOFR, notificationSMS_User + model.CallbackUrl));

                Task.Run(() => MailComponent.SendEmail(bookingDetails.EmailOFR, "", "", "Bargain Status", html, null, null, true, null, null));

                return(1);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
示例#16
0
 public void SendMail(string body)
 {
     Task.Run(() => { MailComponent.SendEmail(this.sErrorEmails, "", "", "TravelGuru Sync Status", body, null, null, false); });
 }
示例#17
0
        static void Main(string[] args)
        {
            string result = "", userid = "", passwd = "", url = "";

            url    = ConfigurationManager.AppSettings["SMSurl"].ToString() + "?method=sendMessage&send_to=";
            userid = AESEncryption.DecryptData(ConfigurationManager.AppSettings["UIDSMS"], "HR$2pIjHR$2pIj12");
            passwd = AESEncryption.DecryptData(ConfigurationManager.AppSettings["PWDSMS"], "HR$2pIjHR$2pIj12");

            string sErrorEmail = "[email protected],[email protected]";

            try
            {
                sErrorEmail = SqlHelper.ExecuteScalar(ConfigurationManager.ConnectionStrings["OFR_DataContext"].ToString(), CommandType.Text, "SELECT TOP 1 sEmail FROM tblEmailSettingsM WHERE sModule = 'TripAdvisor'").ToString();
            }
            catch (Exception)
            {
            }

            try
            {
                ///////////RUN DAILY SCHEDULER FOR  to set Extranet Dashboard data and clear historical data from tblLookUp table
                DataSet ds1 = SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings["ConnectionString"].ToString(), CommandType.StoredProcedure, "uspDailyScheduler");
                /////////SMS and an email will be sent to the guest one month and 15 days before the expiry of points.
                DataSet ds = SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings["ConnectionString"].ToString(), CommandType.StoredProcedure, "uspGetExpiringPointsToSendReminder");
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    StringBuilder sbEmail;
                    for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
                    {
                        if (ds.Tables[0].Rows[i]["Name"].ToString() == "15")
                        {
                            sbEmail = new StringBuilder();
                            sbEmail.Append("<html> <body style='FONT-SIZE: 11pt; FONT-FAMILY: Calibri;'><font color=navy>Hi " + ds.Tables[0].Rows[i]["Name"].ToString() + ",");
                            sbEmail.Append("<p>Your OFR loyalty points (" + ds.Tables[0].Rows[i]["RemPoints"].ToString() + ") are going to expire in 15 days.");
                            sbEmail.Append("Please visit <a href='" + ConfigurationSettings.AppSettings["WebSiteUrl"].ToString() + "'>OneFineRate</a> to use your points as soon as possible. </p>");
                            sbEmail.Append("<p>Thank You,<br/>Team OneFineRate</p></font></body> </html>");

                            /////////////////SEND SMS---------------------

                            System.Net.WebRequest      request  = null;
                            System.Net.HttpWebResponse response = null;

                            try
                            {
                                url     = url + ds.Tables[0].Rows[i]["PhoneNumber"].ToString() + "&v=1.1&msg=Your OFR loyalty points (" + ds.Tables[0].Rows[i]["RemPoints"].ToString() + ") are going to expire in 1 month.&userid=" + ConfigurationSettings.AppSettings["UIDSMS"].ToString() + "&password="******"PWDSMS"].ToString() + "&msg_type=text&auth_scheme=PLAIN";
                                request = System.Net.WebRequest.Create(url);

                                response = (System.Net.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();
                            }
                            catch (Exception exp)
                            {
                                throw exp;
                            }
                            finally
                            {
                                if (response != null)
                                {
                                    response.Close();
                                }
                            }
                        }
                        else
                        {
                            sbEmail = new StringBuilder();
                            sbEmail.Append("<html> <body style='FONT-SIZE: 11pt; FONT-FAMILY: Calibri;'><font color=navy>Hi " + ds.Tables[0].Rows[i]["Name"].ToString() + ",");
                            sbEmail.Append("<p>Your OFR loyalty points (" + ds.Tables[0].Rows[i]["RemPoints"].ToString() + ") are going to expire in 1 month.");
                            sbEmail.Append("Please visit <a href='" + ConfigurationSettings.AppSettings["WebSiteUrl"].ToString() + "'>OneFineRate</a> to use your points as soon as possible. </p>");
                            sbEmail.Append("<p>Thank You,<br/>Team OneFineRate</p></font></body> </html>");

                            /////////////////SEND SMS---------------------

                            System.Net.WebRequest      request  = null;
                            System.Net.HttpWebResponse response = null;

                            try
                            {
                                url     = url + ds.Tables[0].Rows[i]["PhoneNumber"].ToString() + "&v=1.1&msg=Your OFR loyalty points (" + ds.Tables[0].Rows[i]["RemPoints"].ToString() + ") are going to expire in 1 month.&userid=" + ConfigurationSettings.AppSettings["UIDSMS"].ToString() + "&password="******"PWDSMS"].ToString() + "&msg_type=text&auth_scheme=PLAIN";
                                request = System.Net.WebRequest.Create(url);

                                response = (System.Net.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();
                            }
                            catch (Exception exp)
                            {
                                throw exp;
                            }
                            finally
                            {
                                if (response != null)
                                {
                                    response.Close();
                                }
                            }
                        }
                        MailComponent.SendEmail(ds.Tables[0].Rows[i]["Email"].ToString(), "", "", "OneFineRate- Loyalty Points Expiring", sbEmail.ToString(), null, null, true, null, null);

                        //Write code to send SMS
                        // ds.Tables[0].Rows[i]["PhoneNumber"].ToString() for SMS
                    }


                    // MailComponent.SendEmail(sErrorEmail, "", "", "TravelGuru Sync Error", "body", null, null, false);
                }

                // TripAdvisor Code
                #region Getting user who has not given reviews after checkout after 3 days(feedback) and 8 days (Reminder)
                DataTable  BookingTripAdvisorReview = new DataTable();
                DataColumn col3 = null;
                col3 = new DataColumn("[BookingId]", typeof(Int32));
                BookingTripAdvisorReview.Columns.Add(col3);
                col3 = new DataColumn("[ReviewEmailDate]", typeof(DateTime));
                BookingTripAdvisorReview.Columns.Add(col3);
                col3 = new DataColumn("[ReviewLinkClicked]", typeof(bool));
                BookingTripAdvisorReview.Columns.Add(col3);
                col3 = new DataColumn("[dtReviewLinkClicked]", typeof(DateTime));
                BookingTripAdvisorReview.Columns.Add(col3);
                col3 = new DataColumn("[EmailSent]", typeof(String));
                BookingTripAdvisorReview.Columns.Add(col3);
                DataSet        dt1   = SqlHelper.ExecuteDataset(ConfigurationManager.AppSettings["ConnectionString"].ToString(), CommandType.StoredProcedure, "uspGetBookingsForTripAdvisorReview");
                SqlParameter[] Param = new SqlParameter[1];
                Param[0] = new SqlParameter("@sModule", "TripAdvisor");
                DataSet dataset = SqlHelper.ExecuteDataset(ConfigurationManager.AppSettings["ConnectionString"].ToString(), CommandType.StoredProcedure, "[dbo].[GetEmailByModule]", Param);
                var     Bcc     = Convert.ToString(dataset.Tables[0].Rows[0]["Email"]);
                foreach (DataRow row in dt1.Tables[0].Rows)
                {
                    var feedBackHtml = RenderViewToString("FeedBackView.Html");
                    //feedBackHtml = feedBackHtml.Replace("{{FeedbackLink}}", string.Format("" + ConfigurationSettings.AppSettings["WebSiteUrl"].ToString() + "/Feedback/Index?bookingId={0}&customerEmail={1}", clsUtils.Encode(Convert.ToString(row["iBookingId"])), clsUtils.Encode(Convert.ToString(row["sCustomerEmail"]))));
                    var BlobUrl    = ConfigurationManager.AppSettings["BlobUrl"].ToString();
                    var WebSiteUrl = ConfigurationManager.AppSettings["WebSiteUrl"].ToString();
                    feedBackHtml = feedBackHtml.Replace("{{Name}}", Convert.ToString(row["sCustomerName"]));
                    feedBackHtml = feedBackHtml.Replace("{{Hotel}}", Convert.ToString(row["sHotelName"]));
                    feedBackHtml = feedBackHtml.Replace("{{CITY}}", Convert.ToString(row["sCity"]));
                    feedBackHtml = feedBackHtml.Replace("{{HotelImage}}", (!string.IsNullOrEmpty(Convert.ToString(row["sImgUrl"])) ? Convert.ToString(row["sImgUrl"]) : WebSiteUrl + "/images/noimage.jpg"));
                    feedBackHtml = feedBackHtml.Replace("{{ClickReviewImage}}", BlobUrl + "currency/clickreview.gif");
                    feedBackHtml = feedBackHtml.Replace("{{OneFineRateLogoImage}}", WebSiteUrl + "/images/logoNew.png");
                    //feedBackHtml = feedBackHtml.Replace("{{FeedbackLink}}", string.Format("http://*****:*****@BookingTripAdvisorReview", BookingTripAdvisorReview);
                    MyParam[0].TypeName = "[dbo].[BookingTripAdvisorReview]";
                    SqlHelper.ExecuteDataset(ConfigurationManager.AppSettings["ConnectionString"].ToString(), CommandType.StoredProcedure, "[UpdateBookingTripAdvisorReview]", MyParam);
                }

                #endregion
                #region Getting TripAdvisorData For TripAdvisorLocId and saving

                #region TripAdvisorDataTable
                DataTable  TripAdvisorData = new DataTable();
                DataColumn col             = null;
                col = new DataColumn("iPropId", typeof(Int32));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("iTripAdvisorLOCID", typeof(Int32));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("sRatingImageURL", typeof(String));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("iRating", typeof(Decimal));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("iRanking", typeof(int));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("sRankingString", typeof(String));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("iReviewsCount", typeof(Int32));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("sWebURL", typeof(String));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("iLocationRating", typeof(Decimal));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("sLocationRatingURL", typeof(String));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("iSleepQualityRating", typeof(Decimal));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("sSleepQualityRatingURL", typeof(String));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("iRoomsRating", typeof(Decimal));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("sRoomsRatingURL", typeof(String));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("iServiceRating", typeof(Decimal));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("sServiceRatingURL", typeof(String));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("iValueRating", typeof(Decimal));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("sValueRatingURL", typeof(String));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("iCleanlinessRating", typeof(Decimal));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("sCleanlinessRatingURL", typeof(String));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("review_rating1_count", typeof(long));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("review_rating2_count", typeof(long));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("review_rating3_count", typeof(long));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("review_rating4_count", typeof(long));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("review_rating5_count", typeof(long));
                TripAdvisorData.Columns.Add(col);
                col = new DataColumn("write_review", typeof(String));
                TripAdvisorData.Columns.Add(col);
                #endregion


                #region TripAdvisorReviewsDataTable
                DataTable  TripAdvisorReviews = new DataTable();
                DataColumn col1 = null;
                col1 = new DataColumn("iTripAdvisorLOCID", typeof(Int32));
                TripAdvisorReviews.Columns.Add(col1);
                col1 = new DataColumn("iReviewId", typeof(Int32));
                TripAdvisorReviews.Columns.Add(col1);
                col1 = new DataColumn("sTitle", typeof(String));
                TripAdvisorReviews.Columns.Add(col1);
                col1 = new DataColumn("sText", typeof(String));
                TripAdvisorReviews.Columns.Add(col1);
                col1 = new DataColumn("sReviewer", typeof(String));
                TripAdvisorReviews.Columns.Add(col1);
                col1 = new DataColumn("iRating", typeof(Decimal));
                TripAdvisorReviews.Columns.Add(col1);
                col1 = new DataColumn("sRatingImageURL", typeof(String));
                TripAdvisorReviews.Columns.Add(col1);
                col1 = new DataColumn("sReviewURL", typeof(String));
                TripAdvisorReviews.Columns.Add(col1);
                col1 = new DataColumn("dtReviewDate", typeof(DateTime));
                TripAdvisorReviews.Columns.Add(col1);
                col1 = new DataColumn("dtTravelDate", typeof(DateTime));
                TripAdvisorReviews.Columns.Add(col1);
                col1 = new DataColumn("sTripType", typeof(String));
                TripAdvisorReviews.Columns.Add(col1);
                col1 = new DataColumn("sUserLocation", typeof(String));
                TripAdvisorReviews.Columns.Add(col1);
                #endregion

                #region TripAdvisorAwardsDataTable

                DataTable  TripAdvisorAwards = new DataTable();
                DataColumn col2 = null;
                col2 = new DataColumn("iTripAdvisorLOCID", typeof(Int32));
                TripAdvisorAwards.Columns.Add(col2);
                col2 = new DataColumn("sAwardType", typeof(String));
                TripAdvisorAwards.Columns.Add(col2);
                col2 = new DataColumn("sDisplayName", typeof(String));
                TripAdvisorAwards.Columns.Add(col2);
                col2 = new DataColumn("iYear", typeof(Int32));
                TripAdvisorAwards.Columns.Add(col2);
                col2 = new DataColumn("sTinyImg", typeof(String));
                TripAdvisorAwards.Columns.Add(col2);
                col2 = new DataColumn("sSmallImg", typeof(String));
                TripAdvisorAwards.Columns.Add(col2);
                col2 = new DataColumn("sLargeImg", typeof(String));
                TripAdvisorAwards.Columns.Add(col2);
                col2 = new DataColumn("sCategories", typeof(String));
                TripAdvisorAwards.Columns.Add(col2);
                #endregion
                #region Getting and Adding data into datatables
                // Gets iTripAdvisor Id and Property Id from tblPropertyTripAdvisorM
                DataSet dt = SqlHelper.ExecuteDataset(ConfigurationManager.AppSettings["ConnectionString"].ToString(), CommandType.StoredProcedure, "uspGetPropertyTripAdvisorId");
                if (dt.Tables[0].Rows.Count > 0)
                {
                    var tripAdvisorKey = ConfigurationManager.AppSettings["TripAdvisorKey"].ToString();

                    foreach (DataRow drow in dt.Tables[0].Rows)
                    {
                        string TripAdvisorId = drow["iTripAdvisorLOCID"].ToString();
                        string TA_url        = "http://api.tripadvisor.com/api/partner/2.0/location/" + TripAdvisorId + "?key=" + tripAdvisorKey;
                        //string TA_url = "http://api.tripadvisor.com/api/partner/2.0/location/1759051?key=6F988E410E334D3CBCEBC86A6DAA4788";
                        using (WebClient wc = new WebClient())
                        {
                            string json = string.Empty;

                            try
                            {
                                json = wc.DownloadString(TA_url);
                                // This class would need to be updated when Awards are also fetched, as they most of the time appear as null.
                                TA_JSON data = JsonConvert.DeserializeObject <TA_JSON>(json);

                                DataRow drTripAdvisorData = TripAdvisorData.NewRow();
                                drTripAdvisorData["iPropId"] = Convert.ToInt32(drow["iPropId"]);
                                //drTripAdvisorData["iPropId"] = 43086;
                                drTripAdvisorData["iTripAdvisorLOCID"] = Convert.ToInt32(drow["iTripAdvisorLOCID"]);
                                //drTripAdvisorData["iTripAdvisorLOCID"] = 1759051;
                                drTripAdvisorData["sRatingImageURL"] = data.rating_image_url;
                                drTripAdvisorData["iRating"]         = Convert.ToDecimal(data.rating);

                                drTripAdvisorData["sRankingString"] = data.ranking_data == null ? null : data.ranking_data.ranking_string;
                                drTripAdvisorData["iReviewsCount"]  = Convert.ToInt32(data.num_reviews);
                                drTripAdvisorData["sWebURL"]        = data.web_url;
                                drTripAdvisorData["write_review"]   = data.write_review;
                                if (data.ranking_data == null)
                                {
                                    drTripAdvisorData["iRanking"] = DBNull.Value;
                                }
                                else
                                {
                                    drTripAdvisorData["iRanking"] = Convert.ToInt32(data.ranking_data.ranking);
                                }
                                if (data.review_rating_count != null)
                                {
                                    foreach (KeyValuePair <string, string> item in data.review_rating_count)
                                    {
                                        if (item.Key == "1")
                                        {
                                            drTripAdvisorData["review_rating1_count"] = Convert.ToInt64(item.Value);
                                        }
                                        else if (item.Key == "2")
                                        {
                                            drTripAdvisorData["review_rating2_count"] = Convert.ToInt64(item.Value);
                                        }
                                        else if (item.Key == "3")
                                        {
                                            drTripAdvisorData["review_rating3_count"] = Convert.ToInt64(item.Value);
                                        }
                                        else if (item.Key == "4")
                                        {
                                            drTripAdvisorData["review_rating4_count"] = Convert.ToInt64(item.Value);
                                        }
                                        else if (item.Key == "5")
                                        {
                                            drTripAdvisorData["review_rating5_count"] = Convert.ToInt64(item.Value);
                                        }
                                    }
                                }

                                foreach (var item in data.subratings)
                                {
                                    if (item.name == "rate_location")
                                    {
                                        drTripAdvisorData["iLocationRating"]    = Convert.ToDecimal(item.value);
                                        drTripAdvisorData["sLocationRatingURL"] = item.rating_image_url;
                                    }
                                    else if (item.name == "rate_room")
                                    {
                                        drTripAdvisorData["iRoomsRating"]    = Convert.ToDecimal(item.value);
                                        drTripAdvisorData["sRoomsRatingURL"] = item.rating_image_url;
                                    }
                                    else if (item.name == "rate_service")
                                    {
                                        drTripAdvisorData["iServiceRating"]    = Convert.ToDecimal(item.value);
                                        drTripAdvisorData["sServiceRatingURL"] = item.rating_image_url;
                                    }
                                    else if (item.name == "rate_value")
                                    {
                                        drTripAdvisorData["iValueRating"]    = Convert.ToDecimal(item.value);
                                        drTripAdvisorData["sValueRatingURL"] = item.rating_image_url;
                                    }
                                    else if (item.name == "rate_cleanliness")
                                    {
                                        drTripAdvisorData["iCleanlinessRating"]    = Convert.ToDecimal(item.value);
                                        drTripAdvisorData["sCleanlinessRatingURL"] = item.rating_image_url;
                                    }
                                    else if (item.name == "rate_sleep")
                                    {
                                        drTripAdvisorData["iSleepQualityRating"]    = Convert.ToDecimal(item.value);
                                        drTripAdvisorData["sSleepQualityRatingURL"] = item.rating_image_url;
                                    }
                                }

                                TripAdvisorData.Rows.Add(drTripAdvisorData);

                                foreach (var item in data.reviews)
                                {
                                    DateTime temp;
                                    if (!DateTime.TryParse(item.travel_date, out temp))
                                    {
                                        continue;
                                    }
                                    DataRow drTripAdvisorReviews = TripAdvisorReviews.NewRow();
                                    drTripAdvisorReviews["iTripAdvisorLOCID"] = Convert.ToInt32(drow["iTripAdvisorLOCID"]);
                                    drTripAdvisorReviews["iReviewId"]         = Convert.ToInt32(item.id);
                                    drTripAdvisorReviews["sTitle"]            = item.title;
                                    drTripAdvisorReviews["sText"]             = item.text;
                                    drTripAdvisorReviews["sReviewer"]         = item.user.username;
                                    drTripAdvisorReviews["iRating"]           = Convert.ToDecimal(item.rating);
                                    drTripAdvisorReviews["sRatingImageURL"]   = item.rating_image_url;
                                    drTripAdvisorReviews["sReviewURL"]        = item.url;
                                    drTripAdvisorReviews["dtReviewDate"]      = item.published_date;
                                    if (item.travel_date == null)
                                    {
                                        drTripAdvisorReviews["dtTravelDate"] = DBNull.Value;
                                    }
                                    else
                                    {
                                        drTripAdvisorReviews["dtTravelDate"] = temp;
                                    }

                                    drTripAdvisorReviews["sTripType"]     = item.trip_type;
                                    drTripAdvisorReviews["sUserLocation"] = item.user.user_location.name;
                                    TripAdvisorReviews.Rows.Add(drTripAdvisorReviews);
                                }
                                foreach (var item in data.awards)
                                {
                                    DataRow drTripAdvisorAwards = TripAdvisorAwards.NewRow();
                                    drTripAdvisorAwards["iTripAdvisorLOCID"] = Convert.ToInt32(drow["iTripAdvisorLOCID"]);
                                    drTripAdvisorAwards["sAwardType"]        = item.award_type;
                                    drTripAdvisorAwards["sDisplayName"]      = item.display_name;
                                    drTripAdvisorAwards["iYear"]             = item.year;
                                    drTripAdvisorAwards["sTinyImg"]          = item.images.tiny;
                                    drTripAdvisorAwards["sSmallImg"]         = item.images.small;
                                    drTripAdvisorAwards["sLargeImg"]         = item.images.large;
                                    if (item.categories != null && item.categories.Count > 0)
                                    {
                                        drTripAdvisorAwards["sCategories"] = string.Join(";", item.categories);
                                    }
                                    TripAdvisorAwards.Rows.Add(drTripAdvisorAwards);
                                }
                            }
                            catch (WebException ex)
                            {
                                Debug.WriteLine(ex.ToString());
                            }
                        }
                    }
                }
                #endregion
                #region Updating Data for Tripadvisor

                if (dt.Tables[1] != null && dt.Tables[1].Rows.Count > 0 && TripAdvisorData.Rows.Count > 0)
                {
                    SqlParameter[] MyParam = new SqlParameter[4];
                    MyParam[0]          = new SqlParameter("@TripAdvisorData", TripAdvisorData);
                    MyParam[0].TypeName = "[dbo].[TripAdvisorData]";
                    MyParam[1]          = new SqlParameter("@TripAdvisorReviews", TripAdvisorReviews);
                    MyParam[1].TypeName = "[dbo].[TripAdvisorReviews]";
                    MyParam[2]          = new SqlParameter("@LastUpdatedRecord", dt.Tables[1].Rows[0]["LastUpdatedRecord"]);
                    MyParam[3]          = new SqlParameter("@TripAdvisorAwards", TripAdvisorAwards);
                    MyParam[3].TypeName = "[dbo].[TripAdvisorAwards]";
                    SqlHelper.ExecuteDataset(ConfigurationManager.AppSettings["ConnectionString"].ToString(), CommandType.StoredProcedure, "uspUpdateTripAdvisorData", MyParam);
                }
                #endregion
                #endregion
            }
            catch (Exception ex)
            {
                MailComponent.SendEmail(sErrorEmail, "", "", "Loyalty points email sending error", ex.ToString(), null, null, false, null, null);
            }
        }
示例#18
0
        public ActionResult Index(etblHotelPartnerM model)
        {
            if (ModelState.IsValid)
            {
                if (model.bIsAgree == true)
                {
                    model.dtActionDate = DateTime.Now;
                    model.iID          = 1;
                    int result = BL_tblHotelPartner.AddRecord(model);
                    if (result == 1)
                    {
                        TempData["msg"] = "Submitted Successfully";

                        string sToEmail  = model.sEmail;
                        string sCcEmail  = "";
                        string sBCcEmail = "";
                        string sSubject  = "Hotel Partner  Application Submitted Successfully";
                        string sBody     = "Your application has been submitted successfully. Thank you.";
                        MailComponent.SendEmail(sToEmail, sCcEmail, sBCcEmail, sSubject, sBody, null, null, true, null, null);

                        string adminEmail     = BL_tblHotelPartner.GetPartnerEmailId();
                        string adminsCcEmail  = "*****@*****.**";
                        string adminsBCcEmail = "";
                        string adminsSubject  = "Hotel Partner  Application Submitted Successfully";
                        string adminsBody     = "<table border='1'>";
                        adminsBody += "<tr><td>Hotel Name: </td><td>" + model.sHotelName + "</td>";
                        adminsBody += "<tr><td>Star Category: </td><td>" + model.iStarCategory + "</td>";
                        adminsBody += "<tr><td>Hotel Website: </td><td>" + model.sWebsiteUrl + "</td>";
                        adminsBody += "<tr><td>Address: </td><td>" + model.sAddress + "</td>";
                        adminsBody += "<tr><td>City: </td><td>" + model.sCity + "</td>";
                        adminsBody += "<tr><td>State : </td><td>" + model.sState + "</td>";
                        adminsBody += "<tr><td>Country : </td><td>" + model.sCountry + "</td>";
                        adminsBody += "<tr><td>Pin Code: </td><td>" + model.sPIN + "</td>";
                        adminsBody += "<tr><td>Board line Number: </td><td>" + model.sBoardLineNumber + "</td>";
                        adminsBody += "<tr><td>First Name: </td><td>" + model.sFirstName + "</td>";
                        adminsBody += "<tr><td>Last Name: </td><td>" + model.sLastName + "</td>";
                        adminsBody += "<tr><td>Designation: </td><td>" + model.sDesignation + "</td>";
                        adminsBody += "<tr><td>Email Address: </td><td>" + model.sEmail + "</td>";
                        adminsBody += "<tr><td>Mobile Number: </td><td>" + model.sMobile + "</td>";
                        adminsBody += "</table>";
                        MailComponent.SendEmail(adminEmail, adminsCcEmail, adminsBCcEmail, adminsSubject, adminsBody, null, null, true, null, null);
                        return(RedirectToAction("Index"));
                    }
                    else if (result == 2)
                    {
                        TempData["Error"] = "Hotel with same Email Id already exists.";
                        return(View(model));
                    }
                }
                else
                {
                    TempData["Error"] = "Please read and agree on Terms and Conditions.";
                    return(View(model));
                }
            }

            foreach (ModelState modelState in ViewData.ModelState.Values)
            {
                foreach (ModelError error in modelState.Errors)
                {
                    TempData["Error"] = error.ErrorMessage;
                }
            }

            return(View(model));
        }
示例#19
0
        public async Task OTA_HotelResNotifRQ()
        {
            string sErrorEmail = "*****@*****.**";

            try
            {
                sErrorEmail = SqlHelper.ExecuteScalar(ConfigurationManager.AppSettings["ConnectionString"].ToString(), CommandType.Text, "SELECT TOP 1 sEmail FROM tblEmailSettingsM WHERE sModule = 'ChannelMgrError'").ToString();
            }
            catch (Exception)
            { }

            StringBuilder sb = new StringBuilder();

            try
            {
                DataSet dsBooking = SqlHelper.ExecuteDataset(ConfigurationManager.AppSettings["ConnectionString"].ToString(), CommandType.StoredProcedure, "uspGetBookingsToSyncWithChannelMgr");

                if (dsBooking != null && dsBooking.Tables.Count > 0 && dsBooking.Tables[0].Rows.Count > 0)
                {
                    for (int r = 0; r < dsBooking.Tables[0].Rows.Count; r++)
                    {
                        SqlParameter[] MyParam = new SqlParameter[1];
                        MyParam[0] = new SqlParameter("@iBookingId", dsBooking.Tables[0].Rows[r]["iBookingId"].ToString());

                        DataSet ds = SqlHelper.ExecuteDataset(ConfigurationManager.AppSettings["ConnectionString"].ToString(), CommandType.StoredProcedure, "uspHotelResNotif", MyParam);

                        if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                        {
                            if (ds.Tables[0].Rows[0]["iChannelMgr"].ToString() == "1") //Rate Gain
                            {
                                if (ds.Tables[1] != null && ds.Tables[1].Rows.Count > 0)
                                {
                                    sb.Append("<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:a=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\"");
                                    sb.Append(" xmlns:u=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\"> <s:Header>");
                                    sb.Append("<a:Action s:mustUnderstand=\"1\">http://cgbridge.rategain.com/2011A/ReservationService/HotelResNotif</a:Action>");
                                    //  sb.Append("<a:MessageID>urn:uuid:8deae80c-5d3d-4269-9f0a-6d25a217ef1c</a:MessageID>");
                                    //  sb.Append("<a:ReplyTo> <a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address> </a:ReplyTo>");
                                    sb.Append("<a:To s:mustUnderstand=\"1\">" + ConfigurationManager.AppSettings["ReservationNotificationURL"].ToString() + "</a:To>");
                                    sb.Append("<o:Security s:mustUnderstand=\"1\" xmlns:o=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">");
                                    sb.Append("<o:UsernameToken u:Id=\"uuid-c698aabc-c710-42f9-881c-0dfe3fdcaa4f-2\">");
                                    sb.Append("<o:Username>" + ConfigurationManager.AppSettings["RateGainUserName"].ToString() + "</o:Username>");
                                    sb.Append("<o:Password o:Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText\">" + ConfigurationManager.AppSettings["RateGainPassword"].ToString() + "</o:Password>");
                                    sb.Append("</o:UsernameToken> </o:Security> </s:Header>");
                                    sb.Append("<s:Body>");
                                    // sb.Append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
                                    // sb.Append(" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">");
                                    sb.Append("<OTA_HotelResNotifRQ xmlns=\"http://www.opentravel.org/OTA/2003/05\" TimeStamp=\"" + ds.Tables[0].Rows[0]["dtTimeStamp"].ToString() + "\" Target=\"Production\" Version=\"4\" ResStatus=\"" + dsBooking.Tables[0].Rows[r]["BookingType"].ToString() + "\">");
                                    sb.Append("<POS> <Source> <RequestorID Type=\"13\" ID=\"473\" /> <BookingChannel Type=\"7\" Primary=\"true\">");
                                    sb.Append("<CompanyName Code=\"" + ConfigurationManager.AppSettings["RateGainCode"].ToString() + "\">OneFineRate</CompanyName> </BookingChannel> </Source> </POS>");
                                    sb.Append("<HotelReservations> <HotelReservation CreateDateTime=\"" + ds.Tables[0].Rows[0]["dtReservationDate"].ToString() + "\" LastModifyDateTime=\"" + ds.Tables[0].Rows[0]["dtReservationDate"].ToString() + "\" ResStatus=\"" + dsBooking.Tables[0].Rows[r]["BookingType"].ToString() + "\" >");

                                    sb.Append("<RoomStays>");

                                    foreach (DataRow dr in ds.Tables[1].Rows)
                                    {
                                        sb.Append("<RoomStay RoomStayStatus=\"Book\">");
                                        sb.Append("<ResGuestRPHs>" + dr["ResGuestRPHs"].ToString() + "</ResGuestRPHs>"); // # persons
                                        sb.Append("<RoomTypes>");
                                        sb.Append("<RoomType RoomTypeCode=\"" + dr["iRoomId"].ToString() + "\" NumberOfUnits=\"" + dr["NumberOfUnits"].ToString() + "\">");
                                        sb.Append("<RoomDescription Name=\"" + dr["sRoomName"].ToString() + "\"></RoomDescription>");
                                        sb.Append("</RoomType>");
                                        sb.Append("</RoomTypes>");

                                        sb.Append("<RatePlans>");
                                        sb.Append("<RatePlan RatePlanCode=\"" + dr["iRPId"].ToString() + "\">");
                                        //<MealsIncluded Breakfast="true" /> NOT REQUIRED
                                        sb.Append("</RatePlan>");

                                        sb.Append("</RatePlans>");
                                        sb.Append("<RoomRates>");

                                        sb.Append("<RoomRate RatePlanCode=\"" + dr["iRPId"].ToString() + "\" RoomTypeCode=\"" + dr["iRoomId"].ToString() + "\" NumberOfUnits=\"" + dr["NumberOfUnits"].ToString() + "\">");
                                        sb.Append("<Rates>");

                                        foreach (DataRow dr1 in ds.Tables[2].Rows)
                                        {
                                            if (dr["iRPId"].ToString() == dr1["iRPId"].ToString() && dr["iRoomId"].ToString() == dr1["iRoomId"].ToString())
                                            {
                                                sb.Append("<Rate EffectiveDate=\"" + dr1["dtEffectiveDate"].ToString() + "\" ExpireDate=\"" + dr1["dtExpireDate"].ToString() + "\">");
                                                sb.Append("<Base AmountBeforeTax=\"" + dr1["dAmountBeforeTax"].ToString() + "\" AmountAfterTax=\"" + dr1["dAmountAfterTax"].ToString() + "\" CurrencyCode=\"" + ds.Tables[0].Rows[0]["sCurrencyCode"].ToString() + "\"/>");
                                                sb.Append("</Rate>");
                                            }
                                        }

                                        sb.Append("</Rates>");
                                        sb.Append("</RoomRate>");

                                        sb.Append("</RoomRates>");

                                        //foreach (DataRow dr3 in ds.Tables[1].Rows)
                                        //{
                                        //if (dr["iRPId"].ToString() == dr3["iRPId"].ToString() && dr["iRoomId"].ToString() == dr3["iRoomId"].ToString())
                                        //{
                                        sb.Append("<GuestCounts>");
                                        sb.Append("<GuestCount AgeQualifyingCode=\"10\" Count=\"" + dr["iAdults"].ToString() + "\" />");
                                        sb.Append("<GuestCount AgeQualifyingCode=\"8\" Count=\"" + dr["iChildren"].ToString() + "\" />");
                                        sb.Append("</GuestCounts>");

                                        sb.Append("<TimeSpan Start=\"" + ds.Tables[0].Rows[0]["dtCheckIn"].ToString() + "\" End=\"" + ds.Tables[0].Rows[0]["dtCheckOut"].ToString() + "\" /> ");
                                        sb.Append("<Total AmountBeforeTax=\"" + dr["dAmountBeforeTax"].ToString() + "\" AmountAfterTax=\"" + dr["dAmountAfterTax"].ToString() + "\" CurrencyCode=\"" + ds.Tables[0].Rows[0]["sCurrencyCode"].ToString() + "\" > ");
                                        sb.Append("<Taxes>");
                                        sb.Append("<Tax Amount=\"" + dr["dTaxes"].ToString() + "\" CurrencyCode=\"" + ds.Tables[0].Rows[0]["sCurrencyCode"].ToString() + "\" /> ");
                                        sb.Append("</Taxes>");
                                        sb.Append("</Total>");
                                        sb.Append("<BasicPropertyInfo HotelCode=\"" + ds.Tables[0].Rows[0]["iPropId"].ToString() + "\" HotelName=\"" + ds.Tables[0].Rows[0]["HoteName"].ToString() + "\">");
                                        sb.Append("</BasicPropertyInfo>");
                                        //    }
                                        //}
                                        sb.Append("</RoomStay>");
                                    }
                                    sb.Append("</RoomStays>");
                                    sb.Append("<ResGuests>");


                                    foreach (DataRow dr in ds.Tables[3].Rows)
                                    {
                                        if (dr["bIsPrimary"].ToString() == "true")
                                        {
                                            sb.Append("<ResGuest ResGuestRPH=\"" + dr["ResGuestRPHs"].ToString() + "\" PrimaryIndicator=\"" + dr["bIsPrimary"].ToString() + "\">");
                                        }
                                        else
                                        {
                                            sb.Append("<ResGuest ResGuestRPH=\"" + dr["ResGuestRPHs"].ToString() + "\">");
                                        }

                                        sb.Append("<Profiles>");
                                        sb.Append("<ProfileInfo>");
                                        sb.Append("<Profile ProfileType=\"1\" StatusCode=\"\">");
                                        sb.Append("<Customer>");
                                        sb.Append("<PersonName>");
                                        sb.Append("<GivenName>" + dr["FirstName"].ToString() + "</GivenName>");
                                        sb.Append("<Surname>" + dr["LastName"].ToString() + "</Surname>");
                                        sb.Append("</PersonName>");
                                        sb.Append("<Telephone PhoneTechType=\"1\" PhoneNumber=\"" + dr["sGuestMobile"].ToString() + "\" DefaultInd=\"true\" FormattedInd=\"false\" />");
                                        sb.Append("<Email EmailType=\"1\" DefaultInd=\"true\">" + dr["sGuestEmail"].ToString() + "</Email>");
                                        sb.Append("</Customer>");
                                        sb.Append("<CompanyInfo />");
                                        sb.Append("</Profile>");
                                        sb.Append("</ProfileInfo>");
                                        sb.Append("</Profiles>");
                                        sb.Append("</ResGuest>");
                                    }
                                    foreach (DataRow dr in ds.Tables[4].Rows)
                                    {
                                        sb.Append("<ResGuest PrimaryIndicator=\"" + dr["bIsPrimary"].ToString() + "\">");

                                        sb.Append("<Profiles>");
                                        sb.Append("<ProfileInfo>");
                                        sb.Append("<Profile ProfileType=\"18\" StatusCode=\"\">");
                                        sb.Append("<Customer>");
                                        sb.Append("<PersonName>");
                                        sb.Append("<GivenName>" + dr["FirstName"].ToString() + "</GivenName>");
                                        sb.Append("<Surname>" + dr["LastName"].ToString() + "</Surname>");
                                        sb.Append("</PersonName>");
                                        sb.Append("<Telephone PhoneTechType=\"1\" PhoneNumber=\"" + dr["sGuestMobile"].ToString() + "\" DefaultInd=\"true\" FormattedInd=\"false\" />");
                                        sb.Append("<Email EmailType=\"1\" DefaultInd=\"true\">" + dr["sGuestEmail"].ToString() + "</Email>");
                                        sb.Append("</Customer>");
                                        sb.Append("<CompanyInfo />");
                                        sb.Append("</Profile>");
                                        sb.Append("</ProfileInfo>");
                                        sb.Append("</Profiles>");
                                        sb.Append("</ResGuest>");
                                    }
                                    sb.Append("</ResGuests>");
                                    sb.Append("<ResGlobalInfo>");
                                    sb.Append("<SpecialRequests>");
                                    sb.Append("<SpecialRequest>");
                                    sb.Append("<Text>" + ds.Tables[0].Rows[0]["sSpecialRequests"].ToString() + "</Text>");
                                    sb.Append("</SpecialRequest>");
                                    sb.Append("</SpecialRequests>");
                                    sb.Append("<TimeSpan Start=\"" + ds.Tables[0].Rows[0]["dtCheckIn"].ToString() + "\" End=\"" + ds.Tables[0].Rows[0]["dtCheckOut"].ToString() + "\" Duration=\"" + ds.Tables[0].Rows[0]["Duration"].ToString() + "\" /> ");
                                    sb.Append("<Total CurrencyCode=\"" + ds.Tables[0].Rows[0]["sCurrencyCode"].ToString() + "\" AmountBeforeTax=\"" + ds.Tables[0].Rows[0]["TotalAmountBeforeTax"].ToString() + "\" AmountAfterTax=\"" + ds.Tables[0].Rows[0]["TotalAmountAfterTax"].ToString() + "\">");
                                    sb.Append("<Taxes>");
                                    sb.Append("<Tax Amount=\"" + ds.Tables[0].Rows[0]["dTaxes"].ToString() + "\" CurrencyCode=\"" + ds.Tables[0].Rows[0]["sCurrencyCode"].ToString() + "\" /> ");
                                    sb.Append("</Taxes> ");
                                    sb.Append("</Total> ");
                                    sb.Append("<HotelReservationIDs> ");
                                    sb.Append("<HotelReservationID ResID_Type=\"14\" ResID_Value=\"" + ds.Tables[0].Rows[0]["ResID"].ToString() + "\"/> ");
                                    sb.Append("</HotelReservationIDs> ");
                                    sb.Append("</ResGlobalInfo> ");
                                    sb.Append("</HotelReservation> </HotelReservations> </OTA_HotelResNotifRQ>");
                                    sb.Append("</s:Body>");
                                    sb.Append("</s:Envelope>");

                                    //------------------------SEND REQUEST to Channel Manager

                                    string responseXml = "";
                                    try
                                    {
                                        // string url = "https://rzbetal4.rategain.com/RZL4PREPRODYieldGainWS/Reservation.svc";
                                        string     url        = ConfigurationManager.AppSettings["ReservationNotificationURL"].ToString(); // "https://rzintghospidev.rategain.com/RezYieldGainWS/Reservation.svc";
                                        HttpClient httpClient = new HttpClient();
                                        httpClient.Timeout = TimeSpan.FromMilliseconds(40000);
                                        HttpContent         httpContent = new StringContent(sb.ToString());
                                        HttpResponseMessage response;

                                        HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Post, url);

                                        req.Headers.Add("SOAPAction", "http://cgbridge.rategain.com/2011A/ReservationService/HotelResNotif");
                                        req.Method  = HttpMethod.Post;
                                        req.Content = httpContent;
                                        req.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("text/xml; charset=utf-8");
                                        response = await httpClient.SendAsync(req);

                                        var responseXml1 = await response.Content.ReadAsStringAsync();

                                        responseXml = responseXml1;

                                        /*
                                         * var httpClient = new HttpClient();
                                         *
                                         * var content = new StringContent(sb.ToString(), Encoding.UTF8, "application/xml");
                                         *
                                         * var response = await httpClient.PostAsync("http://rzbetal4.rategain.com/RZL4PREPRODYieldGainWS/Reservation.svc", content);
                                         * response.EnsureSuccessStatusCode();
                                         *
                                         * var responseXml1 = await response.Content.ReadAsStringAsync();
                                         * responseXml = responseXml1;
                                         */
                                        InsertTracker(dsBooking.Tables[0].Rows[r]["iBookingId"].ToString(), "S", sb.ToString(), "");
                                        sb.Clear();
                                    }
                                    catch (Exception ex)
                                    {
                                        InsertTracker(dsBooking.Tables[0].Rows[r]["iBookingId"].ToString(), "F", sb.ToString(), ex.Message);
                                        sb.Clear();
                                        MailComponent.SendEmail(sErrorEmail, "", "", "RateGain - Error while sync reservation to channel manager.", ex.Message, null, null, false, null, null);
                                        break;
                                    }

                                    var xmlDoc = new XmlDocument();
                                    try
                                    {
                                        responseXml = responseXml.Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", "").Replace("<?xml version=\"1.0\" encoding=\"utf-16\"?>", "");
                                        MemoryStream stream = new MemoryStream();
                                        StreamWriter writer = new StreamWriter(stream);
                                        writer.Write(responseXml);
                                        writer.Flush();
                                        stream.Position = 0;
                                        xmlDoc.Load(stream);

                                        if (xmlDoc.GetElementsByTagName("Success") != null)//Success
                                        {
                                            //Update bSyncToChannelMgr = 1
                                            SqlParameter[] MyParam1 = new SqlParameter[1];
                                            MyParam1[0] = new SqlParameter("@iBookingId", dsBooking.Tables[0].Rows[r]["iBookingId"].ToString());

                                            SqlHelper.ExecuteNonQuery(ConfigurationManager.AppSettings["ConnectionString"].ToString(), CommandType.StoredProcedure, "uspUpdateBookingSyncStatusChannelMgr", MyParam1);
                                        }
                                        else//Error
                                        {
                                            XmlNodeList xmlnode;
                                            xmlnode = xmlDoc.GetElementsByTagName("Errors");

                                            for (int i = 0; i <= xmlnode[0].ChildNodes.Count - 1; i++)
                                            {
                                                if (xmlnode[0].ChildNodes[i].Attributes["ShortText"] != null)
                                                {
                                                    MailComponent.SendEmail(sErrorEmail, "", "", "RateGain -Error while reading response received from channel manager for reservation sync.", xmlnode[0].ChildNodes[i].Attributes["ShortText"].Value, null, null, false, null, null);
                                                }
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        MailComponent.SendEmail(sErrorEmail, "", "", "RateGain -Error while reading response received from channel manager for reservation sync.", ex.Message, null, null, false, null, null);
                                    }
                                }
                            }
                            else //-------------------------------Maximojo-------------------------------------------------------------
                            {
                                if (ds.Tables[1] != null && ds.Tables[1].Rows.Count > 0)
                                {
                                    string EchoToken = generateUniqueNumbers();

                                    sb.Append("<OTA_HotelResNotifRQ xmlns=\"http://www.opentravel.org/OTA/2003/05\" EchoToken=\"" + EchoToken + "\" ResStatus=\"" + dsBooking.Tables[0].Rows[r]["BookingType"].ToString() + "\" Timestamp=\"" + ds.Tables[0].Rows[0]["dtTimeStamp"].ToString() + "\"  Version=\"1.0\">");
                                    sb.Append("<POS> <Source> <RequestorID ID=\"" + ConfigurationManager.AppSettings["RequestorID_ID"].ToString() + "\" ID_Context=\"" + ConfigurationManager.AppSettings["RequestorID_ID_Context"].ToString() + "\" MessagePassword=\"" + ConfigurationManager.AppSettings["RequestorID_MessagePassword"].ToString() + "\" Type=\"" + ConfigurationManager.AppSettings["RequestorID_Type"].ToString() + "\" />");
                                    sb.Append("<BookingChannel Type=\"" + ConfigurationManager.AppSettings["BookingChannel_Type_MM"].ToString() + "\" Primary=\"true\">");
                                    sb.Append("<CompanyName Code=\"" + ConfigurationManager.AppSettings["Code_MM"].ToString() + "\" CompanyShortName=\"" + ConfigurationManager.AppSettings["CompanyName_MM"].ToString() + "\"/>");
                                    sb.Append("</BookingChannel> </Source> </POS>");
                                    sb.Append("<HotelReservations> <HotelReservation CreateDateTime=\"" + ds.Tables[0].Rows[0]["dtReservationDate"].ToString() + "\" LastModifyDateTime=\"" + ds.Tables[0].Rows[0]["dtReservationDate"].ToString() + "\" CreatorID=\"" + ConfigurationManager.AppSettings["RequestorID_ID_Context"].ToString() + "\" >");
                                    sb.Append("<UniqueID ID=\"" + dsBooking.Tables[0].Rows[r]["iBookingId"].ToString() + "\" Type=\"14\" />");
                                    sb.Append("<RoomStays>");

                                    foreach (DataRow dr in ds.Tables[1].Rows)
                                    {
                                        sb.Append("<RoomStay SourceOfBusiness=\"" + ConfigurationManager.AppSettings["RequestorID_ID_Context"].ToString() + "\">");
                                        sb.Append("<RoomRates>");

                                        sb.Append("<RoomRate RatePlanCode=\"" + dr["iRPId"].ToString() + "\" RoomTypeCode=\"" + dr["iRoomId"].ToString() + "\" NumberOfUnits=\"" + dr["NumberOfUnits"].ToString() + "\">");
                                        sb.Append("<Rates>");

                                        foreach (DataRow dr1 in ds.Tables[2].Rows)
                                        {
                                            if (dr["iRPId"].ToString() == dr1["iRPId"].ToString() && dr["iRoomId"].ToString() == dr1["iRoomId"].ToString())
                                            {
                                                sb.Append("<Rate EffectiveDate=\"" + dr1["dtEffectiveDate"].ToString() + "\" ExpireDate=\"" + dr1["dtExpireDate"].ToString() + "\" RateTimeUnit=\"Day\" UnitMultiplier=\"1\">");
                                                sb.Append("<Base AmountBeforeTax=\"" + dr1["dAmountBeforeTax"].ToString() + "\" AmountAfterTax=\"" + dr1["dAmountAfterTax"].ToString() + "\" CurrencyCode=\"" + ds.Tables[0].Rows[0]["sCurrencyCode"].ToString() + "\"/>");
                                                //Remove AmountAfterTax if not required for Maximojo
                                                sb.Append("</Rate>");
                                            }
                                        }

                                        sb.Append("</Rates>");
                                        sb.Append("</RoomRate>");

                                        sb.Append("</RoomRates>");

                                        sb.Append("<GuestCounts IsPerRoom=\"true\">");
                                        sb.Append("<GuestCount AgeQualifyingCode=\"10\" Count=\"" + dr["iAdults"].ToString() + "\" />");
                                        sb.Append("<GuestCount AgeQualifyingCode=\"8\" Count=\"" + dr["iChildren"].ToString() + "\" />");
                                        //Remove ROW GuestCount AgeQualifyingCode=\"8\" if not required for Maximojo
                                        sb.Append("</GuestCounts>");

                                        sb.Append("<TimeSpan Start=\"" + ds.Tables[0].Rows[0]["dtCheckIn"].ToString() + "\" End=\"" + ds.Tables[0].Rows[0]["dtCheckOut"].ToString() + "\" /> ");
                                        sb.Append("<Total AmountBeforeTax=\"" + dr["dAmountBeforeTax"].ToString() + "\" AmountAfterTax=\"" + dr["dAmountAfterTax"].ToString() + "\" CurrencyCode=\"" + ds.Tables[0].Rows[0]["sCurrencyCode"].ToString() + "\" > ");
                                        //Remove AmountAfterTax if not required for Maximojo
                                        sb.Append("<Taxes>");
                                        sb.Append("<Tax Amount=\"" + dr["dTaxes"].ToString() + "\" CurrencyCode=\"" + ds.Tables[0].Rows[0]["sCurrencyCode"].ToString() + "\" /> ");
                                        sb.Append("</Taxes>");
                                        sb.Append("</Total>");
                                        sb.Append("<BasicPropertyInfo HotelCode=\"" + ds.Tables[0].Rows[0]["iPropId"].ToString() + "\" HotelName=\"" + ds.Tables[0].Rows[0]["HoteName"].ToString() + "\">");
                                        sb.Append("</BasicPropertyInfo>");
                                        sb.Append("<ResGuestRPHs> <ResGuestRPH RPH=\"" + dr["ResGuestRPHs"].ToString() + "\" /></ResGuestRPHs>"); // # persons

                                        //foreach (DataRow dr3 in ds.Tables[2].Rows)
                                        //{
                                        //    if (dr["iRPId"].ToString() == dr3["iRPId"].ToString() && dr["iRoomId"].ToString() == dr3["iRoomId"].ToString())
                                        //    {
                                        //        sb.Append("<GuestCounts IsPerRoom=\"true\">");
                                        //        sb.Append("<GuestCount AgeQualifyingCode=\"10\" Count=\"" + dr3["iAdults"].ToString() + "\" />");
                                        //        sb.Append("<GuestCount AgeQualifyingCode=\"8\" Count=\"" + dr3["iChildren"].ToString() + "\" />");
                                        //        //Remove ROW GuestCount AgeQualifyingCode=\"8\" if not required for Maximojo
                                        //        sb.Append("</GuestCounts>");

                                        //        sb.Append("<TimeSpan Start=\"" + ds.Tables[0].Rows[0]["dtCheckIn"].ToString() + "\" End=\"" + ds.Tables[0].Rows[0]["dtCheckOut"].ToString() + "\" /> ");
                                        //        sb.Append("<Total AmountBeforeTax=\"" + ds.Tables[0].Rows[0]["TotalAmountBeforeTax"].ToString() + "\" AmountAfterTax=\"" + ds.Tables[0].Rows[0]["TotalAmountAfterTax"].ToString() + "\" CurrencyCode=\"" + ds.Tables[0].Rows[0]["sCurrencyCode"].ToString() + "\" > ");
                                        //        //Remove AmountAfterTax if not required for Maximojo
                                        //        sb.Append("<Taxes Amount=\"" + ds.Tables[0].Rows[0]["dTaxes"].ToString() + "\" CurrencyCode=\"" + ds.Tables[0].Rows[0]["sCurrencyCode"].ToString() + "\" /> ");
                                        //        /*
                                        //        sb.Append("<Taxes>");
                                        //        sb.Append("<Tax Amount=\"" + ds.Tables[0].Rows[0]["dTaxes"].ToString() + "\" CurrencyCode=\"" + ds.Tables[0].Rows[0]["sCurrencyCode"].ToString() + "\" /> ");
                                        //        sb.Append("</Taxes>");
                                        //         * */
                                        //        sb.Append("</Total>");
                                        //        sb.Append("<BasicPropertyInfo HotelCode=\"" + ds.Tables[0].Rows[0]["iPropId"].ToString() + "\" HotelName=\"" + ds.Tables[0].Rows[0]["HoteName"].ToString() + "\">");
                                        //        //Remove HotelName if not required for Maximojo
                                        //        sb.Append("</BasicPropertyInfo>");
                                        //        sb.Append("<ResGuestRPHs> <ResGuestRPH RPH=\"" + dr["ResGuestRPHs"].ToString() + "\" /></ResGuestRPHs>"); // # persons
                                        //    }
                                        //}

                                        sb.Append("</RoomStay>");
                                    }
                                    sb.Append("</RoomStays>");
                                    sb.Append("<ResGuests>");

                                    foreach (DataRow dr in ds.Tables[3].Rows)
                                    {
                                        if (dr["bIsPrimary"].ToString() == "true")
                                        {
                                            sb.Append("<ResGuest ResGuestRPH=\"" + dr["ResGuestRPHs"].ToString() + "\" PrimaryIndicator=\"" + dr["bIsPrimary"].ToString() + "\">");
                                        }
                                        else
                                        {
                                            sb.Append("<ResGuest ResGuestRPH=\"" + dr["ResGuestRPHs"].ToString() + "\">");
                                        }

                                        sb.Append("<Profiles>");
                                        sb.Append("<ProfileInfo>");
                                        sb.Append("<Profile ProfileType=\"1\">");
                                        sb.Append("<Customer>");
                                        sb.Append("<PersonName>");
                                        sb.Append("<GivenName>" + dr["FirstName"].ToString() + "</GivenName>");
                                        sb.Append("<Surname>" + dr["LastName"].ToString() + "</Surname>");
                                        sb.Append("</PersonName>");
                                        sb.Append("<Telephone PhoneTechType=\"1\" PhoneNumber=\"" + dr["sGuestMobile"].ToString() + "\" DefaultInd=\"true\" FormattedInd=\"false\" />");
                                        sb.Append("<Email EmailType=\"1\" DefaultInd=\"true\">" + dr["sGuestEmail"].ToString() + "</Email>");
                                        sb.Append("</Customer>");
                                        sb.Append("<CompanyInfo />");
                                        sb.Append("</Profile>");
                                        sb.Append("</ProfileInfo>");
                                        sb.Append("</Profiles>");
                                        sb.Append("</ResGuest>");
                                    }
                                    sb.Append("</ResGuests>");
                                    sb.Append("<ResGlobalInfo>");
                                    // NOT REQUIRED FOR MAXIMOJO sb.Append("<TimeSpan Start=\"" + ds.Tables[0].Rows[0]["dtTimeStamp"].ToString() + "\" End=\"" + ds.Tables[0].Rows[0]["dtCheckOut"].ToString() + "\" Duration=\"" + ds.Tables[0].Rows[0]["Duration"].ToString() + "\" /> ");
                                    sb.Append("<Total CurrencyCode=\"" + ds.Tables[0].Rows[0]["sCurrencyCode"].ToString() + "\" AmountBeforeTax=\"" + ds.Tables[0].Rows[0]["TotalAmountBeforeTax"].ToString() + "\" AmountAfterTax=\"" + ds.Tables[0].Rows[0]["TotalAmountAfterTax"].ToString() + "\">");
                                    //Remove AmountAfterTax if not required for Maximojo

                                    /* NOT REQUIRED FOR MAXIMOJO
                                     * sb.Append("<Taxes>");
                                     * sb.Append("<Tax Amount=\"" + ds.Tables[0].Rows[0]["dTaxes"].ToString() + "\" CurrencyCode=\"" + ds.Tables[0].Rows[0]["sCurrencyCode"].ToString() + "\" /> ");
                                     * sb.Append("</Taxes> ");
                                     * */
                                    sb.Append("</Total> ");
                                    sb.Append("<HotelReservationIDs> ");
                                    sb.Append("<HotelReservationID ResID_Type=\"14\" ResID_Value=\"" + ds.Tables[0].Rows[0]["ResID"].ToString() + "\"/> ");
                                    sb.Append("</HotelReservationIDs> ");
                                    sb.Append("</ResGlobalInfo> ");
                                    sb.Append("</HotelReservation> </HotelReservations> </OTA_HotelResNotifRQ>");

                                    /*
                                     * byte[] byteArray = Encoding.UTF8.GetBytes(sb.ToString());
                                     * //byte[] byteArray = Encoding.ASCII.GetBytes(contents);
                                     * MemoryStream stream = new MemoryStream(byteArray);
                                     * Maximojo.ServerClient obj = new Maximojo.ServerClient();
                                     * var response = await obj.PostAsync(stream);
                                     */
                                    /////////////////////////////////Method-1/////////////////////////////////////////////

                                    /*
                                     * var httpClient = new HttpClient();
                                     * var response = await httpClient.PostAsync("http://staging.platform.maximojo.com/HTNG/Server.svc/std/post", new StringContent(sb.ToString()));
                                     *
                                     * response.EnsureSuccessStatusCode();
                                     *
                                     * string content = await response.Content.ReadAsStringAsync();
                                     */
                                    //////////////////////////////////////////////////////////////////////////////
                                    ////////////////////////////////////Method-2- Working//////////////////////////////////////////
                                    string responseXml = "";
                                    try
                                    {
                                        var httpClient = new HttpClient();

                                        var content = new StringContent(sb.ToString(), Encoding.UTF8, "application/xml");

                                        var response = await httpClient.PostAsync("http://staging.platform.maximojo.com/HTNG/Server.svc/std/post", content);

                                        response.EnsureSuccessStatusCode();

                                        var responseXml1 = await response.Content.ReadAsStringAsync();

                                        responseXml = responseXml1;
                                        InsertTracker(dsBooking.Tables[0].Rows[r]["iBookingId"].ToString(), "S", sb.ToString(), "");
                                    }
                                    catch (Exception ex)
                                    {
                                        InsertTracker(dsBooking.Tables[0].Rows[r]["iBookingId"].ToString(), "F", sb.ToString(), ex.Message);
                                        sb.Clear();
                                        MailComponent.SendEmail(sErrorEmail, "", "", "Maximojo - Error while sync reservation to channel manager.", ex.Message, null, null, false, null, null);
                                        break;
                                    }


                                    //////////////////////////////////////////////////////////////////////////////
                                    ////////////////////////////////////Method-3//////////////////////////////////////////

                                    /*
                                     * Uri uri = new Uri("http://staging.platform.maximojo.com/HTNG/Server.svc/std/post");
                                     *
                                     * HttpWebRequest Request = (HttpWebRequest)HttpWebRequest.Create(uri);
                                     * byte[] RequestBytes = Encoding.UTF8.GetBytes(sb.ToString());
                                     * Request.ContentLength = RequestBytes.Length;
                                     * Request.Method = "POST";
                                     * Request.ContentType = "application/xml;charset=UTF-8";
                                     *
                                     * Stream RequestStream = Request.GetRequestStream();
                                     * RequestStream.Write(RequestBytes, 0, RequestBytes.Length);
                                     * RequestStream.Close();
                                     *
                                     * HttpWebResponse response = (HttpWebResponse)Request.GetResponse();
                                     * StreamReader reader = new StreamReader(response.GetResponseStream());
                                     * string ResponseMessage = reader.ReadToEnd();
                                     * response.Close();
                                     */
                                    //check success status
                                    var xmlDoc = new XmlDocument();
                                    try
                                    {
                                        responseXml = responseXml.Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", "").Replace("<?xml version=\"1.0\" encoding=\"utf-16\"?>", "");
                                        MemoryStream stream = new MemoryStream();
                                        StreamWriter writer = new StreamWriter(stream);
                                        writer.Write(responseXml);
                                        writer.Flush();
                                        stream.Position = 0;
                                        xmlDoc.Load(stream);
                                        string EchoToken_MM = "";
                                        if (xmlDoc.GetElementsByTagName("OTA_HotelResNotifRS")[0].Attributes["EchoToken"] != null)
                                        {
                                            EchoToken_MM = xmlDoc.GetElementsByTagName("OTA_HotelResNotifRS")[0].Attributes["EchoToken"].Value;
                                        }

                                        if (EchoToken == EchoToken_MM)                                                                                                             //Authentic response
                                        {
                                            if (xmlDoc.GetElementsByTagName("Success") != null)                                                                                    //Success
                                            {
                                                if (xmlDoc.GetElementsByTagName("UniqueID")[0].Attributes["ID"] != null)                                                           //Success
                                                {
                                                    if (xmlDoc.GetElementsByTagName("UniqueID")[0].Attributes["ID"].Value == dsBooking.Tables[0].Rows[r]["iBookingId"].ToString()) //Success
                                                    {
                                                        //Update bSyncToChannelMgr = 1
                                                        SqlParameter[] MyParam1 = new SqlParameter[1];
                                                        MyParam1[0] = new SqlParameter("@iBookingId", dsBooking.Tables[0].Rows[r]["iBookingId"].ToString());

                                                        SqlHelper.ExecuteNonQuery(ConfigurationManager.AppSettings["ConnectionString"].ToString(), CommandType.StoredProcedure, "uspUpdateBookingSyncStatusChannelMgr", MyParam1);
                                                        sb.Clear();
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        sb.Clear();
                                        MailComponent.SendEmail(sErrorEmail, "", "", "Maximojo -Error while reading response received from channel manager for reservation sync.", ex.Message, null, null, false, null, null);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                sb.Clear();
                MailComponent.SendEmail(sErrorEmail, "", "", "Maximojo -Error while sync reservation to channel manager.", ex.Message, null, null, false, null, null);
            }
        }