/// <summary>
 /// This method used to update status of tribute
 /// </summary>
 /// <param name="intNumberOfDays"></param>
 /// <param name="DeleteTribute"></param>
 public void SetTributeStatus()
 {
     ResourceAccess objResouce = new ResourceAccess();
     objResouce.GetDataSet("usp_ChangeTributeStatus", null);
     objResouce = null;
 }
        /// <summary>
        /// This method used for AutoRenewal for One Year
        /// </summary>
        public void AutoRenewalForOneYearPackage()
        {
            DataSet dsMailerList = new DataSet();
            DataSet dsMailerList1 = new DataSet();//vchange line added
            bool _transaction = true;
            PaymentGateWay objPay = new PaymentGateWay();
            ResourceAccess objResouce = new ResourceAccess();
            EmailMessages objEmail = EmailMessages.Instance;
            string _EmailBody=string.Empty;
            string confirmationId = string.Empty;//vchange line added
            string amount = string.Empty;//vchange line added
             object[] objParam = new object[3];
             object[] objParam2 = { null };
             try
             {

             dsMailerList = objResouce.GetDataSet("usp_AutoRenewalCustomerList", null);

                 if (dsMailerList.Tables[0].Rows.Count > 0)
                 {
                     for (int i = 0; i <= dsMailerList.Tables[0].Rows.Count - 1; i++)
                     {
                         //This code will execute on server
                         /*_transaction = objPay.PayYourBill(dsMailerList.Tables[0].Rows[i]["CreditCardNo"].ToString(), dsMailerList.Tables[0].Rows[i]["CVC"].ToString(),
                             int.Parse(DateTime.Now.Month.ToString()), int.Parse(DateTime.Now.Year.ToString()),
                             "20.00", SelectCreditCardType(dsMailerList.Tables[0].Rows[i]["CreditCardType"].ToString()),
                             dsMailerList.Tables[0].Rows[i]["FirstName"].ToString(), dsMailerList.Tables[0].Rows[i]["Lastname"].ToString(), "TimelessTribute BackOffice",
                         dsMailerList.Tables[0].Rows[i]["City"].ToString(), StateV1.CA, CountryV1.US, dsMailerList.Tables[0].Rows[i]["Zip"].ToString(),
                         dsMailerList.Tables[0].Rows[i]["Telephone"].ToString(), dsMailerList.Tables[0].Rows[i]["Email"].ToString(),
                         Environment.MachineName.ToString());*/
                         //This code will execute on local
                         /* _transaction = true;*/

                         //vchange added satarted
                         try
                         {
                             int Couponamount = 0;

                             amount = ConfigurationSettings.AppSettings["OneyearAmount"];
                             Couponamount = Convert.ToInt32(amount.Substring(1, amount.Length - 1));

                             _transaction = objPay.PayYourBill(TributePortalSecurity.Security.DecryptSymmetric(dsMailerList.Tables[0].Rows[i]["CreditCardNo"].ToString()), TributePortalSecurity.Security.DecryptSymmetric(dsMailerList.Tables[0].Rows[i]["CVC"].ToString()),
                               Convert.ToInt32(dsMailerList.Tables[0].Rows[i]["ExpiryMonth"]), Convert.ToInt32(dsMailerList.Tables[0].Rows[i]["ExpiryYear"]),
                               Couponamount.ToString(), SelectCreditCardType(dsMailerList.Tables[0].Rows[i]["CreditCardType"].ToString()),
                               dsMailerList.Tables[0].Rows[i]["FirstName"].ToString(), dsMailerList.Tables[0].Rows[i]["Lastname"].ToString(), dsMailerList.Tables[0].Rows[i]["Address"].ToString().Replace(ConfigurationSettings.AppSettings["AddressSeparator"],ConfigurationSettings.AppSettings["AddressSeparatorDisplay"]),
                           dsMailerList.Tables[0].Rows[i]["City"].ToString(), StateV1.CA, CountryV1.US, dsMailerList.Tables[0].Rows[i]["Zip"].ToString(),
                           dsMailerList.Tables[0].Rows[i]["Telephone"].ToString(), dsMailerList.Tables[0].Rows[i]["Email"].ToString(),
                           Environment.MachineName.ToString(), out confirmationId);

                          //   _transaction = objPay.PayYourBill(dsMailerList.Tables[0].Rows[i]["CreditCardNo"].ToString(), dsMailerList.Tables[0].Rows[i]["CVC"].ToString(),
                          //    int.Parse(DateTime.Now.Month.ToString()), int.Parse(DateTime.Now.Year.ToString()),
                          //    Couponamount.ToString(), SelectCreditCardType(dsMailerList.Tables[0].Rows[i]["CreditCardType"].ToString()),
                          //    dsMailerList.Tables[0].Rows[i]["FirstName"].ToString(), dsMailerList.Tables[0].Rows[i]["Lastname"].ToString(), "TimelessTribute BackOffice",
                          //dsMailerList.Tables[0].Rows[i]["City"].ToString(), StateV1.CA, CountryV1.US, dsMailerList.Tables[0].Rows[i]["Zip"].ToString(),
                          //dsMailerList.Tables[0].Rows[i]["Telephone"].ToString(), dsMailerList.Tables[0].Rows[i]["Email"].ToString(),
                          //Environment.MachineName.ToString(), out confirmationId);
                             //vchange added end
                             if (_transaction)
                             {
                                 EventLog.WriteEntry("Payment Recived");
                                 objParam[0] = dsMailerList.Tables[0].Rows[i]["TributePackageId"].ToString();
                                 objParam[1] = Couponamount.ToString();// vchnage "20";
                                 objParam[2] = confirmationId.Length == 0 ? 0 : int.Parse(confirmationId);

                                 //objResouce.GetDataSet("usp_RenewTributePackage", objParam);
                                 //vchnage code added satrt
                                 dsMailerList1 = objResouce.GetDataSet("usp_RenewTributePackage", objParam);
                                 if (dsMailerList1.Tables[0].Rows.Count > 0)
                                 {
                                         //vchnage code added end
                                         objEmail = EmailMessages.Instance;
                                         _EmailBody = ConfigurationSettings.AppSettings["MailAfterRenewal"];

                                         _EmailBody = _EmailBody.Replace("#FirstName", dsMailerList.Tables[0].Rows[i]["FirstName"].ToString());
                                         _EmailBody = _EmailBody.Replace("#LastName", dsMailerList.Tables[0].Rows[i]["LastName"].ToString());
                                         _EmailBody = _EmailBody.Replace("#TributeName", dsMailerList.Tables[0].Rows[i]["TributeName"].ToString());
                                         _EmailBody = _EmailBody.Replace("#TributeUrl", dsMailerList.Tables[0].Rows[i]["TributeUrl"].ToString());
                                         _EmailBody = _EmailBody.Replace("#RenewalDate", DateTime.Parse(dsMailerList.Tables[0].Rows[i]["EndDate"].ToString()).ToString("MMMM dd, yyyy"));
                                         _EmailBody = _EmailBody.Replace("#TributeType", dsMailerList.Tables[0].Rows[i]["TributeTypeName"].ToString().ToLower());
                                         objEmail.SendMessages("Your Tribute<*****@*****.**>", dsMailerList.Tables[0].Rows[i]["Email"].ToString(), "The " + dsMailerList.Tables[0].Rows[i]["TributeName"].ToString() + " Tribute renewed.", _EmailBody, EmailMessages.TextFormat.Html.ToString());

                                         ///vchnage code added start
                                         object[] param ={ dsMailerList1.Tables[0].Rows[0][0].ToString() };
                                         GetTransactionDetails(param);

                                 }
                             }
                             else
                             {
                                 //NotifyRenwealFailed()
                                 EventLog.WriteEntry("Payment not recevied");
                                 objEmail = EmailMessages.Instance;
                                 _EmailBody = ConfigurationSettings.AppSettings["MailRenewalFailed"];
                                 _EmailBody = _EmailBody.Replace("#FirstName", dsMailerList.Tables[0].Rows[i]["FirstName"].ToString());
                                 _EmailBody = _EmailBody.Replace("#LastName", dsMailerList.Tables[0].Rows[i]["LastName"].ToString());
                                 _EmailBody = _EmailBody.Replace("#TributeName", dsMailerList.Tables[0].Rows[i]["TributeName"].ToString());
                                 _EmailBody = _EmailBody.Replace("#TributeUrl", dsMailerList.Tables[0].Rows[i]["TributeUrl"].ToString());
                                 _EmailBody = _EmailBody.Replace("#TributeType", dsMailerList.Tables[0].Rows[i]["TributeTypeName"].ToString().ToLower());
                                 objEmail.SendMessages("Your Tribute<*****@*****.**>", dsMailerList.Tables[0].Rows[i]["Email"].ToString(), "Auto-Renewal of the " + dsMailerList.Tables[0].Rows[i]["TributeName"].ToString() + " Tribute has failed...", _EmailBody, EmailMessages.TextFormat.Html.ToString());
                             }
                         }
                         catch
                         {
                             // NotifyRenwealFailed()
                             EventLog.WriteEntry("Exception occured,Payment not recevied");
                             objEmail = EmailMessages.Instance;
                             _EmailBody = ConfigurationSettings.AppSettings["MailRenewalFailed"];
                             _EmailBody = _EmailBody.Replace("#FirstName", dsMailerList.Tables[0].Rows[i]["FirstName"].ToString());
                             _EmailBody = _EmailBody.Replace("#LastName", dsMailerList.Tables[0].Rows[i]["LastName"].ToString());
                             _EmailBody = _EmailBody.Replace("#TributeName", dsMailerList.Tables[0].Rows[i]["TributeName"].ToString());
                             _EmailBody = _EmailBody.Replace("#TributeUrl", dsMailerList.Tables[0].Rows[i]["TributeUrl"].ToString());
                             _EmailBody = _EmailBody.Replace("#TributeType", dsMailerList.Tables[0].Rows[i]["TributeTypeName"].ToString().ToLower());
                             objEmail.SendMessages("Your Tribute<*****@*****.**>", dsMailerList.Tables[0].Rows[i]["Email"].ToString(), "Auto-Renewal of the " + dsMailerList.Tables[0].Rows[i]["TributeName"].ToString() + " Tribute has failed...", _EmailBody, EmailMessages.TextFormat.Html.ToString());
                             ///vchnage code added end
                         }

                         objEmail = null;
                     }
                 }
             }
             catch (Exception ex)
             {
                 EventLog.WriteEntry(ex.Message.ToString());
             }
        }
        //vchnage code added end
        /// <summary>
        /// This Method used to send email to users for credit card exipration 
        /// </summary>
        public void NotifyCreditCardExpirationDate(int intNumberOfDays)
        {
            DataSet dsMailerList = new DataSet();
            ResourceAccess objResouce = new ResourceAccess();

            object[] objParam = { intNumberOfDays };
            dsMailerList = objResouce.GetDataSet("usp_CreditCardExpiredCustomerList", objParam);

            if (dsMailerList.Tables[0].Rows.Count > 0)
            {
                //EventLog.WriteEntry(dsMailerList.Tables[0].Rows[0][0].ToString() + "-Record Found");

                EmailMessages objEmail = EmailMessages.Instance;
                string _EmailBody = string.Empty;
                for (int i = 0; i <= dsMailerList.Tables[0].Rows.Count - 1; i++)
                {
                    _EmailBody = _EmailBody = ConfigurationSettings.AppSettings["CreditCardExpiryReminder"];
                    _EmailBody = _EmailBody.Replace("#FirstName", dsMailerList.Tables[0].Rows[i]["FirstName"].ToString());
                    _EmailBody = _EmailBody.Replace("#LastName", dsMailerList.Tables[0].Rows[i]["LastName"].ToString());
                    _EmailBody = _EmailBody.Replace("#TributeName", dsMailerList.Tables[0].Rows[i]["TributeName"].ToString());
                    _EmailBody = _EmailBody.Replace("#TributeUrl", dsMailerList.Tables[0].Rows[i]["TributeUrl"].ToString());
                    _EmailBody = _EmailBody.Replace("#ExpireDate",DateTime.Parse(dsMailerList.Tables[0].Rows[i]["EndDate"].ToString()).ToString("MMMM dd, yyyy"));
                    _EmailBody = _EmailBody.Replace("#TributeType", dsMailerList.Tables[0].Rows[i]["TributeTypeName"].ToString().ToLower());
                    _EmailBody = _EmailBody.Replace("#CCExpireReminder", Convert.ToString(intNumberOfDays));
                    objEmail.SendMessages("Your Tribute<*****@*****.**>", dsMailerList.Tables[0].Rows[i]["Email"].ToString(), "The " + dsMailerList.Tables[0].Rows[i]["TributeName"].ToString() + " Your Tribute CC Expiry Notice", _EmailBody, EmailMessages.TextFormat.Html.ToString());
                }
                objEmail = null;
            }
            EventLog.WriteEntry("My simple service Ended.");
        }
        /// <summary>
        /// This Method used for Tribute expiry
        /// </summary>
        /// <param name="intNumberOfDays"></param>
        public void NotifyTributeExpiryToUsersOneYear(int intNumberOfDays)
        {
            DataSet dsMailerList = new DataSet();
            ResourceAccess objResouce = new ResourceAccess();

            object[] objParam = { intNumberOfDays, 2 };
            dsMailerList = objResouce.GetDataSet("usp_GetTributeOwnerMailerList", objParam);

            if (dsMailerList.Tables[0].Rows.Count > 0)
            {
                //EventLog.WriteEntry(dsMailerList.Tables[0].Rows[0][0].ToString() + "-Record Found");

                EmailMessages objEmail = EmailMessages.Instance;
                string _EmailBody = string.Empty;
                int packageid = 0;//vchange line added
                for (int i = 0; i <= dsMailerList.Tables[0].Rows.Count - 1; i++)
                {
                    _EmailBody = ConfigurationSettings.AppSettings["ExpiryReminder"];
                    // vchange block added srart
                    packageid = Convert.ToInt32(dsMailerList.Tables[0].Rows[i]["packageid"]);
                    if (packageid == 3)
                    {
                        _EmailBody = _EmailBody.Replace("#FreeTrialPackage", "The free trial for");
                    }
                    else
                    {
                        _EmailBody = _EmailBody.Replace("#FreeTrialPackage", "The");
                    }
                    // vchange block added end
                    _EmailBody = _EmailBody.Replace("#FirstName", dsMailerList.Tables[0].Rows[i]["FirstName"].ToString());
                    _EmailBody = _EmailBody.Replace("#LastName", dsMailerList.Tables[0].Rows[i]["LastName"].ToString());
                    _EmailBody = _EmailBody.Replace("#TributeName", dsMailerList.Tables[0].Rows[i]["TributeName"].ToString());
                    _EmailBody = _EmailBody.Replace("#TributeUrl", dsMailerList.Tables[0].Rows[i]["TributeUrl"].ToString());
                    _EmailBody = _EmailBody.Replace("#ExpireDate", DateTime.Parse(dsMailerList.Tables[0].Rows[i]["EndDate"].ToString()).ToString("MMMM dd, yyyy"));
                    _EmailBody = _EmailBody.Replace("#TributeType", dsMailerList.Tables[0].Rows[i]["TributeTypeName"].ToString().ToLower().Replace("new baby", "newbaby"));
                    objEmail.SendMessages("Your Tribute<*****@*****.**>", dsMailerList.Tables[0].Rows[i]["Email"].ToString(), "The " + dsMailerList.Tables[0].Rows[i]["TributeName"].ToString().ToLower() + " Tribute expires soon...", _EmailBody, EmailMessages.TextFormat.Html.ToString());
                }
                objEmail = null;
            }
            EventLog.WriteEntry("My simple service Ended.");
        }
 /// <summary>
 /// Method to get the Transaction details for the payment
 /// </summary>
 /// <param name="objValue">Package Id</param>
 /// <returns>Get the details of transaction.</returns>
 public PaymentReceipt GetTransactionDetail(object[] objValue)
 {
     ResourceAccess objResouce = new ResourceAccess();
     PaymentReceipt objPaymentReceipt = new PaymentReceipt();
     //PaymentReceipt objpay = null;
     try
     {
         DataSet ds = objResouce.GetDataSet("usp_GetTransactionDetails", objValue);
         if (ds.Tables[0].Rows.Count > 0)
         {
             for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
             {
                 objPaymentReceipt = (new PaymentReceipt(int.Parse(ds.Tables[0].Rows[i]["TransactionId"].ToString()),
                                                          ds.Tables[0].Rows[i]["Tributename"].ToString(),
                                                          ds.Tables[0].Rows[i]["TypeDescription"].ToString(),
                                                          ds.Tables[0].Rows[i]["Packagename"].ToString(),
                                                          (ds.Tables[0].Rows[i]["Enddate"].ToString().Length != 0 ? Convert.ToDateTime(ds.Tables[0].Rows[i]["Enddate"]).ToString("MMMM dd, yyyy") : "Never"),
                     //,
                                                          ds.Tables[0].Rows[i]["CardholdersName"].ToString(),
                                                          ds.Tables[0].Rows[i]["Address"].ToString(),
                                                          ds.Tables[0].Rows[i]["City"].ToString(),
                                                          ds.Tables[0].Rows[i]["State"].ToString(),
                                                          ds.Tables[0].Rows[i]["Country"].ToString(),
                                                          ds.Tables[0].Rows[i]["Zip"].ToString(),
                                                          ds.Tables[0].Rows[i]["Telephone"].ToString(),
                                                          DateTime.Parse(ds.Tables[0].Rows[i]["StartDate"].ToString()),
                                                          ds.Tables[0].Rows[i]["CreditCardType"].ToString(),
                                                          ds.Tables[0].Rows[i]["CreditCardNo"].ToString(),
                                                          int.Parse(ds.Tables[0].Rows[i]["AmountPaid"].ToString()),
                                                          ds.Tables[0].Rows[i]["SponsorEmailAddress"].ToString(),
                                                          Convert.ToBoolean(ds.Tables[0].Rows[i]["IsAutomaticRenew"].ToString())));
             }
         }
         return objPaymentReceipt;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }