예제 #1
0
        /// <summary>
        /// Update User Password
        ///<param name="userID">userID</param>
        ///<param name="Pwd">Pwd</param>
        /// </summary>
        /// <returns>Affected rows</returns>
        public String UpdatePassword(String userID, String Pwd, Int32 Type)
        {
            String     msg = "";
            SqlCommand cmd = new SqlCommand();

            try
            {
                cmd.CommandText = "Sbsp_ResetPassword";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@userID", SqlDbType.VarChar).Value      = userID;
                cmd.Parameters.Add("@Password", SqlDbType.Binary, 16).Value = MppUtility.EncryptPassword(Pwd);
                cmd.Parameters.Add("@Code", SqlDbType.VarChar).Value        = null;
                cmd.Parameters.Add("@Type", SqlDbType.Int).Value            = Type;
                cmd.Parameters.Add("@ModifiedOn", SqlDbType.DateTime).Value = DateTime.Now;
                DataAccess.ExecuteCommand(cmd);
            }
            catch (SqlException ex)
            {
                msg = ex.Message;
                LogFile.WriteLog(msg);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                LogFile.WriteLog(msg);
            }
            finally
            {
                if (cmd != null)
                {
                    cmd.Dispose();
                }
            }
            return(msg);
        }
예제 #2
0
        public void ProcessRequest(HttpContext context)
        {
            Int32  userid        = SessionData.UserID;
            String uploadFileDir = ConfigurationManager.AppSettings["UploadFolderPath"];

            System.Web.HttpRequest request = System.Web.HttpContext.Current.Request;
            string startDate      = request.QueryString["startDate"];
            string endDate        = request.QueryString["endDate"];
            string uploadfilepath = MppUtility.GetFilelocation(userid, uploadFileDir, "bulk");
            string fileName       = ConfigurationManager.AppSettings["filename"];
            string fileName1      = fileName.PadRight(29) + MppUtility.DateFormat(Convert.ToDateTime(startDate), 2) + "-" + MppUtility.DateFormat(Convert.ToDateTime(endDate), 2) + ".csv";
            string filePath       = Path.Combine(uploadfilepath, fileName1);
            bool   test           = System.IO.File.Exists(filePath);

            System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
            if (System.IO.File.Exists(filePath))
            {
                response.ClearContent();
                response.Clear();
                byte[] Content = System.IO.File.ReadAllBytes(filePath);
                response.ContentType = "text/csv";
                response.AddHeader("content-disposition", "attachment; filename=" + fileName1 + ".csv");
                response.BufferOutput = true;
                response.Cache.SetCacheability(HttpCacheability.NoCache);
                response.OutputStream.Write(Content, 0, Content.Length);
                response.Flush();
                response.End();
            }
            else
            {
                response.Redirect("ShowStatus.html");
            }
        }
예제 #3
0
        /// <summary>
        /// User Admin login vaildation
        ///<param name="UserID">AdminID</param>
        ///<param name="Password">Password</param>
        /// </summary>
        /// <returns></returns>
        public String CheckAdminUserLogin(Int32 AdminID, String Password)
        {
            String     res = "";
            SqlCommand cmd = new SqlCommand();

            try
            {
                cmd.CommandText = "Sbsp_VerifyAdminUserLogin";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@AdminID", SqlDbType.VarChar, 50).Value = AdminID;
                cmd.Parameters.Add("@Password", SqlDbType.Binary, 16).Value = MppUtility.EncryptPassword(Password);
                DataAccess.ExecuteCommand(cmd);
            }
            catch (SqlException ex)
            {
                res = ex.Message;
                LogFile.WriteLog(res);
            }
            catch (Exception ex)
            {
                res = ex.Message;
                LogFile.WriteLog(res);
            }
            finally
            {
                if (cmd != null)
                {
                    cmd.Dispose();
                }
            }
            return(res);
        }
예제 #4
0
 public HomeController()
 {
     _version         = MppUtility.ReadConfig("ApiVersion");
     _api             = MppUtility.ReadConfig("Url");
     _clientkey       = MppUtility.ReadConfig("ClientKey");
     _clientSecretkey = MppUtility.ReadConfig("ClientSecretKey");
 }
예제 #5
0
        /// <summary>
        /// User Activation code
        ///<param name="userID">userID</param>
        ///<param name="ActivationCode">ActivationCode</param>
        /// </summary>
        /// <returns>Affected rows</returns>
        public String UpdatePassword(Int32 userID, String oldPwd, String newPwd)
        {
            String     msg = "";
            SqlCommand cmd = new SqlCommand();

            try
            {
                cmd.CommandText = "Sbsp_UpdatePassword";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@userID", SqlDbType.Int).Value             = userID;
                cmd.Parameters.Add("@oldPassword", SqlDbType.Binary, 16).Value = MppUtility.EncryptPassword(oldPwd);
                cmd.Parameters.Add("@newPassword", SqlDbType.Binary, 16).Value = MppUtility.EncryptPassword(newPwd);
                cmd.Parameters.Add("@date", SqlDbType.DateTime).Value          = DateTime.Now;
                msg = Convert.ToString(DataAccess.GetDataValue(cmd));
            }
            catch (SqlException ex)
            {
                msg = ex.Message;
                LogFile.WriteLog("Update Password - " + userID + ": " + msg);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                LogFile.WriteLog("Update Password - " + userID + ": " + msg);
            }
            finally
            {
                if (cmd != null)
                {
                    cmd.Dispose();
                }
            }
            return(msg);
        }
예제 #6
0
        /// <summary>
        /// Download File
        ///<param name="strtdate">strtdate</param>
        ///<param name="enddate">enddate</param>
        /// </summary>
        /// <returns></returns>


        /// <summary>
        /// Upload File
        ///<param name="strtdate">strtdate</param>
        ///<param name="enddate">enddate</param>
        /// </summary>
        /// <returns></returns>
        public String UploadFileData(String strtdate, String enddate)
        {
            String msg = "";

            try
            {
                Int32  userid         = SessionData.UserID;
                String uploadFileDir  = ConfigurationManager.AppSettings["UploadFolderPath"];
                string uploadfilepath = MppUtility.GetFilelocation(userid, uploadFileDir, "bulk");
                string fileName       = ConfigurationManager.AppSettings["filename"];
                string fileName1      = fileName.PadRight(29) + strtdate + "-" + enddate + ".csv";
                string filePath       = Path.Combine(uploadfilepath, fileName1);
                if (File.Exists(filePath) == true)
                {
                    HttpContext context = HttpContext.Current;
                    context.Response.Clear();
                    context.Response.ContentType = "text/csv";
                    context.Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName1);
                    context.Response.WriteFile(filePath);
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
            return(msg);
        }
예제 #7
0
 public AccountController()
 {
     this.userregistrationData = new AccountData();
     _version         = MppUtility.ReadConfig("ApiVersion");
     _api             = MppUtility.ReadConfig("Url");
     _returnUri       = MppUtility.ReadConfig("ReturnUrl");
     _clientkey       = MppUtility.ReadConfig("ClientKey");
     _clientSecretkey = MppUtility.ReadConfig("ClientSecretKey");
 }
예제 #8
0
        /// <summary>
        /// Get the path of folder to save log file
        /// </summary>
        /// <returns>returns the path of log directory</returns>
        private static String getLogDir()
        {
            String logFileDir = MppUtility.ReadConfig("LogFolderPath");

            if (logFileDir.EndsWith("\\") == false)
            {
                logFileDir += "\\";
            }
            return(logFileDir);
        }
예제 #9
0
 public Log ConvertToCampLog(DataRow row)
 {
     return(new Log()
     {
         LogID = row.Field <Int32>("CampaignLogID"),
         ModifiedOn = MppUtility.FullDateString(row.Field <DateTime>("ModifiedOn")),
         ModifiedField = row.Field <String>("ModifiedField"),
         OldValue = row.Field <String>("OldValue"),
         NewValue = row.Field <String>("NewValue"),
         Time = MppUtility.TimeToString(row.Field <DateTime>("ModifiedOn")),
     });
 }
예제 #10
0
        public void Configuration(IAppBuilder app)
        {
            string ConnStr = MppUtility.ReadConfig("PPCConnStr");

            GlobalConfiguration.Configuration.UseSqlServerStorage(ConnStr);

            app.UseHangfireDashboard();
            app.UseHangfireServer();

            //JOB: Set Reports (Snapshot, Inventory), run every 3 minutes
            //RecurringJob.AddOrUpdate("Missing Out Punch Alerts", () => ReportsAPI.ProcessSetProductsSnapShot(), "20/30 * * * *", TimeZoneInfo.Local);
        }
예제 #11
0
        public void ProcessRequest(HttpContext context)
        {
            var response = System.Web.HttpContext.Current.Response;

            if (HttpContext.Current.Session["AdminUserID"] != null)
            {
                var           adata = new AdminData();
                var           dtbl  = adata.GetActiveUsersData();
                StringBuilder sb    = new StringBuilder();

                if (dtbl.Rows.Count > 0)
                {
                    //headers
                    foreach (DataColumn dc in dtbl.Columns)
                    {
                        sb.Append(MppUtility.FormatCSV(dc.ColumnName.ToString()) + ",");
                    }
                    sb.Remove(sb.Length - 1, 1);
                    sb.Append(Environment.NewLine);
                    foreach (DataRow dr in dtbl.Rows)
                    {
                        foreach (DataColumn dc in dtbl.Columns)
                        {
                            sb.Append(MppUtility.FormatCSV(dr[dc.ColumnName].ToString()) + ",");
                        }
                        sb.Remove(sb.Length - 1, 1);
                        sb.Append(Environment.NewLine);
                    }

                    response.ClearContent();
                    response.Clear();
                    response.ContentType = "text/csv";
                    response.AddHeader("content-disposition", "attachment; filename= MyPPCPal_ActiveUsers.csv");
                    response.BufferOutput = true;
                    response.Cache.SetCacheability(HttpCacheability.NoCache);
                    response.Write(sb.ToString());
                    response.Flush();
                    response.End();
                }
                else
                {
                    response.Write("Active users were not found");
                }
            }
            else
            {
                response.Redirect("admin/account/login");
            }
        }
예제 #12
0
        private Log ConvertToOptimizedData(DataRow row, int type)
        {
            return(new Log()
            {
                CampID = (type == 0) ? row.Field <Int64>("CiD") : 0,
                CampaignName = (type == 0) ? row.Field <String>("campaign") : "",
                KeywordName = (type == 1) ? row.Field <String>("Keyword") : "",
                MatchType = (type != 0) ? row.Field <String>("MatchType") : "",
                ModifiedField = (type != 0) ? row.Field <String>("ModifiedField") : "",
                ModifiedOn = MppUtility.FullDateString(row.Field <DateTime>("Date")),
                OldValue = (type != 0) ? row.Field <String>("OldValue") : "",
                NewValue = (type != 0) ? row.Field <String>("NewValue") : "",

                //ReportID = (type != 0) ? row.Field<Int32>("ReportID"):0,
                ReasonID = (type != 0) ? row.Field <Int32>("ReasonID") : 0,



                //AdGroupName = (type != 0) ? row.Field<String>("AdGroupName"):"",
                //Reason = (type != 0) ? row.Field<String>("Reasondesc"):""
            });
        }
예제 #13
0
 public Log ConvertToKeyLog(DataRow row, int type)
 {
     return(new Log()
     {
         RevertStatus = (type != 1)? row.Field <Int32>("RevertStatus"): 0,
         PopUpID = row.Field <Int32>("PopUpID"),
         ModifiedOn = MppUtility.FullDateString(row.Field <DateTime>("ModifiedOn")),
         ModifiedOn1 = row.Field <DateTime>("ModifiedOn").ToString("yyyy-MM-dd"),
         MatchType = (type != 1) ? row.Field <String>("MatchType"): "",
         ModifiedField = row.Field <String>("ModifiedField"),
         OldValue = row.Field <String>("OldValue"),
         NewValue = row.Field <String>("NewValue"),
         KeywordID = (type != 1) ? row.Field <Int64>("KeywordID"): 0,
         ReportID = (type != 1) ? row.Field <Int32>("ReportID"): 0,
         ReasonID = (type != 1) ? row.Field <Int32>("ReasonID"): 0,
         CampID = (type != 1) ? row.Field <Int64>("CampaignID"): 0,
         AdGroupID = (type != 1) ? row.Field <Int64>("AdgroupID"): 0,
         KeywordName = row.Field <String>("KeyName"),
         AdGroupName = row.Field <String>("AdGroupName"),
         Reason = row.Field <String>("Reasondesc")
     });
 }
예제 #14
0
        /// <summary>
        /// User Registration
        ///<param name="firstName">firstName</param>
        /// </summary>
        /// <returns>ID</returns>
        public String InsertUpdateUser(String firstName, String lastName, String email, String password, String activecode)
        {
            String     res = "";
            SqlCommand cmd = new SqlCommand();

            try
            {
                cmd.CommandText = @"Sbsp_InsertUser";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@Email", SqlDbType.VarChar, 150).Value         = email;
                cmd.Parameters.Add("@SbPassword", SqlDbType.Binary, 16).Value      = MppUtility.EncryptPassword(password);
                cmd.Parameters.Add("@FirstName", SqlDbType.VarChar).Value          = firstName;
                cmd.Parameters.Add("@LastName", SqlDbType.VarChar).Value           = lastName;
                cmd.Parameters.Add("@StartDate", SqlDbType.SmallDateTime).Value    = DateTime.Now.Date;
                cmd.Parameters.Add("@TrailEndDate", SqlDbType.SmallDateTime).Value = DateTime.Now.Date.AddDays(30);
                cmd.Parameters.Add("@ActivationCode", SqlDbType.VarChar).Value     = activecode;
                cmd.Parameters.Add("@CreatedOn", SqlDbType.DateTime).Value         = DateTime.Now;

                DataAccess.ExecuteCommand(cmd);
            }
            catch (SqlException ex)
            {
                res = ex.Message;
                LogFile.WriteLog(res);
            }
            catch (Exception ex)
            {
                res = ex.Message;
                LogFile.WriteLog(res);
            }
            finally
            {
                if (cmd != null)
                {
                    cmd.Dispose();
                }
            }
            return(res);
        }
예제 #15
0
        /// <summary>
        /// Admin User Registration
        ///<param name="firstName">firstName</param>
        /// </summary>
        /// <returns>ID</returns>
        public String AddUpdateAdminUser(String firstName, String lastName, String email, String password, String code, int type)
        {
            String     msg = "";
            SqlCommand cmd = new SqlCommand();

            try
            {
                cmd.CommandText = "Sbsp_InsertAdminUser";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@Email", SqlDbType.VarChar, 500).Value  = email;
                cmd.Parameters.Add("@Password", SqlDbType.Binary, 16).Value = MppUtility.EncryptPassword(password);
                cmd.Parameters.Add("@FirstName", SqlDbType.VarChar).Value   = firstName;
                cmd.Parameters.Add("@LastName", SqlDbType.VarChar).Value    = lastName;
                cmd.Parameters.Add("@Code", SqlDbType.VarChar).Value        = code;
                cmd.Parameters.Add("@CreatedOn", SqlDbType.DateTime).Value  = DateTime.Now;
                cmd.Parameters.Add("@type", SqlDbType.Int).Value            = type;
                DataAccess.ExecuteCommand(cmd);
            }
            catch (SqlException ex)
            {
                msg = ex.Message;
                LogFile.WriteLog("Insert AdminUser : "******"Insert AdminUser : " + msg);
            }
            finally
            {
                if (cmd != null)
                {
                    cmd.Dispose();
                }
            }
            return(msg);
        }
예제 #16
0
        public void DownloadFileData(DateTime startDate, DateTime endDate)
        {
            String msg = "";

            try
            {
                Int32  userid         = SessionData.UserID;
                String downloaddir    = ConfigurationManager.AppSettings["DownloadFolderPath"];
                string uploadfilepath = MppUtility.GetFilelocation(userid, downloaddir, "bulk");
                string fileName       = ConfigurationManager.AppSettings["filename"];
                string fileName1      = fileName.PadRight(29) + MppUtility.DateFormat(startDate, 2).PadRight(11) + "-" + MppUtility.DateFormat(endDate, 2).PadLeft(11) + ".csv";
                string filePath       = Path.Combine(uploadfilepath, fileName1);
                bool   test           = System.IO.File.Exists(filePath);
                if (System.IO.File.Exists(filePath))
                {
                    Response.ClearHeaders();
                    Response.Clear();
                    //context.Response.ContentType = "application/octet-stream";
                    //context.Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName1);
                    //context.Response.WriteFile(filePath);
                    //context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                    byte[] Content = System.IO.File.ReadAllBytes(filePath);
                    Response.ContentType = "text/csv";
                    Response.AddHeader("content-disposition", "attachment; filename=" + fileName1 + ".csv");
                    Response.BufferOutput = true;
                    Response.Cache.SetCacheability(HttpCacheability.NoCache);
                    Response.OutputStream.Write(Content, 0, Content.Length);
                    Response.End();
                    Response.Close();
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
        }
예제 #17
0
 static DataAccess()
 {
     ConnStr = MppUtility.ReadConfig("PPCConnStr");
 }
예제 #18
0
        public HttpStatusCode WebHook()
        {
            try
            {
                var    paymentAlertStatus = 0;
                string secret             = MppUtility.ReadConfig("MS_WebHookReceiverSecret_Custom");
                var    postdata           = new StreamReader(HttpContext.Request.InputStream).ReadToEnd();
                var    emailboday         = "";
                var    signature          = Request.Headers["Stripe-Signature"];
                var    stripeEvent        = StripeEventUtility.ConstructEvent(postdata, signature, secret);
                var    eventid            = stripeEvent.Id;
                var    eventdata          = StripeHelper.GetStripeEvent(eventid);
                var    data   = JObject.Parse(postdata);
                var    custid = data["data"].First().First["customer"].ToString();
                var    msg    = "";

                if (eventdata != null && (eventdata.Type == "invoice.payment_succeeded" || eventdata.Type == "invoice.payment_failed"))
                {
                    String coupon_id    = null;
                    var    list         = data["data"].First().First["lines"];
                    var    Amount       = ((double)list["data"].First["amount"]) / 100;
                    var    Amount_off   = ((double)data["data"].First().First["amount_due"]) / 100;
                    var    Discount     = data["data"].First().First["discount"];
                    var    start        = (double)list["data"].First["period"]["start"];
                    var    end          = (double)list["data"].First["period"]["end"];
                    var    startperiod  = MppUtility.UnixTimeStampToDateTime(start);
                    var    endperiod    = MppUtility.UnixTimeStampToDateTime(end);
                    var    discount     = Math.Round(Amount - Amount_off, 2, MidpointRounding.AwayFromZero);
                    var    customerdata = StripeHelper.GetStripeCustomer(custid);
                    var    email        = customerdata.Email;
                    var    last4        = "";
                    var    carddetails  = StripeHelper.GetCard(custid);
                    foreach (var card in carddetails)
                    {
                        last4 = card.Last4;
                    }

                    if (Discount.Count() > 0)
                    {
                        coupon_id = Discount["coupon"]["id"].ToString();
                    }

                    switch (eventdata.Type)
                    {
                    case "invoice.payment_succeeded":
                        msg                = AccountData.UpdatePaymentStatus(custid, Amount, Amount_off, coupon_id, discount, startperiod, endperiod, 1);
                        emailboday         = "A payment of $" + Amount_off + " was made using your card on file ending with <b> " + last4 + " </b>";
                        paymentAlertStatus = 1;
                        break;

                    case "invoice.payment_failed":
                        msg = AccountData.UpdatePaymentStatus(custid, Amount, Amount_off, coupon_id, discount, startperiod, endperiod, 0);
                        upData.UpdatePlanData(custid, 0);
                        StripeHelper.UnSubscribe(custid);
                        emailboday         = @"A payment $" + Amount_off + " failed from your card ending with <b> " + last4 + " </b>" + "Please check your card details or add new card.";
                        paymentAlertStatus = 2;
                        break;
                    }
                    if (msg == "" && Amount_off != 0)
                    {
                        var respo = EmailAlert.PaymentAlertMail(email, emailboday);
                        if (respo == "success")
                        {
                            sellerData.UpdatePaymentAlert(paymentAlertStatus, custid);
                        }
                    }
                }
                else if (stripeEvent.Type == "charge.failed")
                {
                    var Amount          = ((double)data["data"].First().First["amount"]) / 100;
                    var failure_message = data["data"].First().First["failure_message"].ToString();
                    // msg = AccountData.UpdatePaymentStatus(custid, Amount, Amount, 0, 0.00, startperiod, endperiod, 0);
                    if (Amount > 1)//Card verification charge
                    {
                        upData.UpdatePlanData(custid, 0);
                        StripeHelper.UnSubscribe(custid);
                    }
                    var last4        = "";
                    var carddetails  = StripeHelper.GetCard(custid);
                    var customerdata = StripeHelper.GetStripeCustomer(custid);
                    var email        = customerdata.Email;
                    foreach (var card in carddetails)
                    {
                        last4 = card.Last4;
                    }
                    emailboday = @"A payment $" + Amount + " failed from your card ending with <b> " + last4 + " </b>" + "Please check your card details or add new card.</b>Possible reason:" + failure_message;
                    var respo = EmailAlert.PaymentAlertMail(email, emailboday);
                    if (respo == "success" && Amount > 1)
                    {
                        sellerData.UpdatePaymentAlert(2, custid);
                    }
                }
            }
            catch (Exception ex)
            {
                String msg = ex.Message;
                LogFile.WriteLog(msg);
            }
            return(HttpStatusCode.OK);
        }
예제 #19
0
        public JsonResult Uploadfile(DateTime startDate, DateTime endDate)
        {
            var res = rdata.UploadFileData(MppUtility.DateFormat(startDate, 2), MppUtility.DateFormat(endDate, 2));

            return(Json(res, JsonRequestBehavior.AllowGet));
        }
예제 #20
0
        public void WebHook()
        {
            try
            {
                var paymentAlertStatus = 0;
                var postdata           = new StreamReader(HttpContext.Request.InputStream).ReadToEnd();
                var data       = JObject.Parse(postdata);
                var signature  = Request.Headers["Stripe-Signature"];
                var eventid    = data["id"].ToString();
                var custid     = data["data"].First().First["customer"].ToString();
                var msg        = "";
                var emailboday = "";
                var eventdata  = StripeHelper.GetStripeEvent(eventid);

                if (eventdata != null && (eventdata.Type == "invoice.payment_succeeded" || eventdata.Type == "invoice.payment_failed"))
                {
                    String coupon_id    = null;
                    var    list         = data["data"].First().First["lines"];
                    var    Amount       = ((double)list["data"].First["amount"]) / 100;
                    var    Amount_off   = ((double)data["data"].First().First["amount_due"]) / 100;
                    var    Discount     = data["data"].First().First["discount"];
                    var    start        = (double)list["data"].First["period"]["start"];
                    var    end          = (double)list["data"].First["period"]["end"];
                    var    startperiod  = MppUtility.UnixTimeStampToDateTime(start);
                    var    endperiod    = MppUtility.UnixTimeStampToDateTime(end);
                    var    discount     = Math.Round(Amount - Amount_off, 2, MidpointRounding.AwayFromZero);
                    var    customerdata = StripeHelper.GetStripeCustomer(custid);
                    var    email        = customerdata.Email;
                    var    last4        = "";
                    var    carddetails  = StripeHelper.GetCard(custid);
                    foreach (var card in carddetails)
                    {
                        last4 = card.Last4;
                    }

                    if (Discount.Count() > 0)
                    {
                        coupon_id = Discount["coupon"]["id"].ToString();
                    }

                    switch (eventdata.Type)
                    {
                    case "invoice.payment_succeeded":
                        msg                = AccountData.UpdatePaymentStatus(custid, Amount, Amount_off, coupon_id, discount, startperiod, endperiod, 1);
                        emailboday         = "Payment Success. A payment of $" + Amount_off + " was made using your card on file ending with <b> " + last4 + " </b>";
                        paymentAlertStatus = 1;
                        break;

                    case "invoice.payment_failed":
                        msg                = AccountData.UpdatePaymentStatus(custid, Amount, Amount_off, coupon_id, discount, startperiod, endperiod, 0);
                        emailboday         = "Payment failed.Payment $" + Amount_off + " failed from your card ending with <b> " + last4 + " </b> ";
                        paymentAlertStatus = 2;
                        break;
                    }
                    if (msg == "" && Amount_off != 0)
                    {
                        var respo = EmailAlert.PaymentAlertMail(email, emailboday);
                        if (respo == "success")
                        {
                            sellerData.UpdatePaymentAlert(paymentAlertStatus, custid);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                String msg = ex.Message;
            }
        }
예제 #21
0
        private void KeywordSearchTermReportGenerator(DataSet dataset, out StringBuilder sb)
        {
            sb = new StringBuilder();
            var dtbl    = dataset.Tables[0];
            var dtTotal = dataset.Tables[1];

            //headers
            foreach (DataColumn dc in dtbl.Columns)
            {
                sb.Append(MppUtility.FormatCSV(dc.ColumnName.ToString().Replace('_', ' ')) + ",");
            }
            sb.Remove(sb.Length - 1, 1);
            sb.Append(Environment.NewLine);

            // var flag = false;
            var i = 1;

            foreach (DataRow dr in dtbl.Rows)
            {
                var nextKey      = "";
                var nextQuery    = "";
                var CurrentKey   = dr["Keyword"].ToString().ToLower().Replace(" ", "_");
                var currentQuery = dr["Search_Term"].ToString().ToLower().Replace(" ", "_");
                if (i < dtbl.Rows.Count)
                {
                    nextKey   = dtbl.Rows[i]["Keyword"].ToString().ToLower().Replace(" ", "_");
                    nextQuery = dtbl.Rows[i]["Search_Term"].ToString().ToLower().Replace(" ", "_");
                }
                if (CurrentKey == nextKey && currentQuery == nextQuery)
                {
                    foreach (DataColumn dc in dtbl.Columns)
                    {
                        sb.Append(MppUtility.FormatCSV(dr[dc.ColumnName].ToString()) + ",");
                    }
                    sb.Remove(sb.Length - 1, 1);
                    sb.Append(Environment.NewLine);
                    //  flag = true;
                    i++;
                    continue;
                }
                else if (nextKey != "" && nextQuery != "")
                {
                    try
                    {
                        foreach (DataColumn dc in dtbl.Columns)
                        {
                            sb.Append(MppUtility.FormatCSV(dr[dc.ColumnName].ToString()) + ",");
                        }
                        sb.Remove(sb.Length - 1, 1);
                        sb.Append(Environment.NewLine);
                        // if (flag)
                        // {

                        var CurrentRow = (from row in dtTotal.AsEnumerable()
                                          where row.Field <string>("Keyword").ToLower().Replace(" ", "_") == CurrentKey &&
                                          row.Field <string>("Search_Term").ToLower().Replace(" ", "_") == currentQuery
                                          select row).FirstOrDefault();
                        foreach (DataColumn dc in dtbl.Columns)
                        {
                            var columnName = dc.ColumnName == "Campaign_Name" ? "Total" : null;
                            if (dtTotal.Columns.IndexOf(dc.ColumnName) < 0)
                            {
                                sb.Append(MppUtility.FormatCSV(columnName) + ",");
                            }
                            else
                            {
                                sb.Append(MppUtility.FormatCSV(CurrentRow[dc.ColumnName].ToString()) + ",");
                            }
                        }
                        sb.Remove(sb.Length - 1, 1);
                        sb.Append(Environment.NewLine);

                        // flag = false;

                        //   }
                        i++;
                    }
                    catch (Exception ex)
                    {
                    }
                }
                else
                {
                    foreach (DataColumn dc in dtbl.Columns)
                    {
                        sb.Append(MppUtility.FormatCSV(dr[dc.ColumnName].ToString()) + ",");
                    }
                    sb.Remove(sb.Length - 1, 1);
                    sb.Append(Environment.NewLine);

                    //if (flag)
                    // {
                    var CurrentRow = (from row in dtTotal.AsEnumerable()
                                      where row.Field <string>("Keyword").ToLower().Replace(" ", "_") == CurrentKey &&
                                      row.Field <string>("Search_Term").ToLower().Replace(" ", "_") == currentQuery
                                      select row).FirstOrDefault();
                    foreach (DataColumn dc in dtbl.Columns)
                    {
                        var columnName = dc.ColumnName == "Campaign_Name" ? "Total" : null;
                        if (dtTotal.Columns.IndexOf(dc.ColumnName) < 0)
                        {
                            sb.Append(MppUtility.FormatCSV(columnName) + ",");
                        }
                        else
                        {
                            sb.Append(MppUtility.FormatCSV(CurrentRow[dc.ColumnName].ToString()) + ",");
                        }
                    }
                    sb.Remove(sb.Length - 1, 1);
                    sb.Append(Environment.NewLine);
                    //  }
                    // flag = false;
                }
            }
        }