Example #1
0
 /**** 加入黑名單 ****/
 public JsonResult AjaxBlackChecked(Guid[] Memberid)
 {
     if (Memberid != null)
     {
         foreach (Guid thismemberid in Memberid)
         {
             Memberblacklist Memberblacklist = new Memberblacklist();
             Members         Members         = membersService.GetByID(thismemberid);
             Memberblacklist.Memberid   = Members.Memberid;
             Memberblacklist.Account    = Members.Account;
             Memberblacklist.Useragent  = Members.Useragent_phone;
             Memberblacklist.Createdate = DateTime.Now;
             memberblacklistService.Create(Memberblacklist);
         }
         memberblacklistService.SaveChanges();
     }
     return(this.Json("Success"));
 }
Example #2
0
        public ActionResult Feedbackrecord(Feedbackrecord feedbackrecord)
        {
            Guid            Memberid  = Guid.Parse(Session["Memberid"].ToString());
            Memberblacklist blacklist = new Memberblacklist();
            string          ipaddress;

            ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (ipaddress == "" || ipaddress == null)
            {
                ipaddress = Request.ServerVariables["REMOTE_ADDR"];
            }
            Members Member = membersService.GetByID(Memberid);
            RegexStringValidator myRegexValidator = new RegexStringValidator(@"/^[0 - 9] *$/");

            if (feedbackrecord.Money > Member.Feedbackmoney || feedbackrecord.Money <= 0 || myRegexValidator.CanValidate(feedbackrecord.Money.GetType()))
            {
                blacklist.Account   = Member.Account;
                blacklist.Memberid  = Guid.Parse(Session["Memberid"].ToString());
                blacklist.Useragent = Request.UserAgent;
                blacklist.IP_Addr   = ipaddress;
                memberblacklistService.Create(blacklist);
                memberblacklistService.SaveChanges();
                Session.RemoveAll();
                return(RedirectToAction("Home", "HomeMs"));
            }
            /*** 金額不得小於500 ***/
            if (feedbackrecord.Money < 500)
            {
                return(RedirectToAction("Feedbackrecord"));
            }
            IEnumerable <Feedbackrecord> old_data = feedbackrecordService.Get().Where(a => a.Memberid == Memberid).OrderByDescending(o => o.Createdate);
            int count = old_data.Count();

            if (count == 0)
            {
                Session["Remains"] = Member.Feedbackmoney;
            }
            else
            {
                Session["Remains"] = old_data.FirstOrDefault().Remains;
            }
            Session["Money"] = feedbackrecord.Money;
            return(RedirectToAction("Feedbacktransfer"));
        }
Example #3
0
        public ActionResult Order(Order order)
        {
            int Now = (int)(DateTime.Now - new DateTime(1970, 1, 1)).TotalSeconds - 28800;      // 目前時間的總秒數
            //Guid Vipid = memberlevelService.Get().Where(a => a.Levelname == "VIP").FirstOrDefault().Levelid;    // VIPID

            int membersCount = membersService.Get().Where(x => x.Logindate >= Now).Where(b => b.Memberloginrecord.OrderByDescending(x => x.Createdate).FirstOrDefault().Status == 1).Count();    // 扣除Vip會員的所有可用人數

            if (order.Count > membersCount)
            {
                ViewBag.TotalNumber = membersService.Get().Count();         // 會員總人數
                Setting Setting = settingService.Get().FirstOrDefault();
                ViewBag.Max         = Setting.Max;
                ViewBag.Min         = Setting.Min;
                TempData["message"] = "數量錯誤,請重新下單!" + membersCount;
                return(RedirectToAction("Order", "OrderMs"));
            }
            Members         member    = membersService.GetByID(Session["Memberid"]);
            Memberblacklist blacklist = new Memberblacklist();
            string          ipaddress;

            ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (ipaddress == "" || ipaddress == null)
            {
                ipaddress = Request.ServerVariables["REMOTE_ADDR"];
            }
            if (order.Url.IndexOf("facebook.com") != -1 && order.Count != null)
            {
                if (order.Url.IndexOf("photos") != -1 || order.Url.IndexOf("posts") != -1 || order.Url.IndexOf("video") != -1 || order.Url.IndexOf("permalink") != -1 || order.Url.IndexOf("photo") != -1)
                {
                    string Url            = order.Url.Replace(" ", "");                                           // 將訂單的空白字元砍掉
                    Guid   Memberid       = Guid.Parse(Session["Memberid"].ToString());
                    int?   MemberCooldown = member.Memberlevel.Memberlevelcooldown.FirstOrDefault().Cooldowntime; // 該會員的冷卻時間(一般/VIP)

                    if (member.Isreal == true)
                    {
                        Guid Realid           = memberlevelService.Get().Where(a => a.Levelname == "真人").FirstOrDefault().Levelid;              // 取得真人ID
                        int? RealCooldowntime = memberlevelcooldownService.Get().Where(a => a.Levelid == Realid).FirstOrDefault().Cooldowntime; // 取得真人的冷卻時間
                        if (MemberCooldown > RealCooldowntime)
                        {
                            Cooldowntime = RealCooldowntime;
                        }
                        else
                        {
                            Cooldowntime = MemberCooldown;
                        }
                    }
                    else
                    {
                        Cooldowntime = MemberCooldown;
                    }
                    IEnumerable <Order> old_order = orderService.Get().Where(a => a.Memberid == Memberid).OrderByDescending(o => o.Createdate);
                    if (old_order.ToList().Count() == 0)
                    {
                        if (TryUpdateModel(order, new string[] { "Count" }) && ModelState.IsValid)
                        {
                            order.Orderid          = Guid.NewGuid();
                            order.Createdate       = DateTime.Now;
                            order.Updatedate       = DateTime.Now;
                            order.Memberid         = Memberid;
                            order.Remains          = order.Count;
                            order.Url              = Url;
                            order.Ordernumber      = "heo" + DateTime.Now.ToString("HHmmssfff");
                            Session["OrderNumber"] = order.Ordernumber;
                            order.Service          = "讚";
                            orderService.Create(order);
                            orderService.SaveChanges();
                        }
                        return(RedirectToAction("OrderResult"));
                    }
                    else
                    {
                        DateTime date = old_order.FirstOrDefault().Createdate.AddSeconds(Convert.ToDouble(Cooldowntime));

                        if (DateTime.Now > date)
                        {
                            if (TryUpdateModel(order, new string[] { "Count", }) && ModelState.IsValid)
                            {
                                order.Orderid          = Guid.NewGuid();
                                order.Createdate       = DateTime.Now;
                                order.Updatedate       = DateTime.Now;
                                order.Memberid         = Memberid;
                                order.Remains          = order.Count;
                                order.Url              = Url;
                                order.Ordernumber      = "heo" + DateTime.Now.ToString("HHmmssfff");
                                Session["OrderNumber"] = order.Ordernumber;
                                order.Service          = "讚";
                                orderService.Create(order);
                                orderService.SaveChanges();
                            }
                            return(RedirectToAction("OrderResult"));
                        }
                        else
                        {
                            double time = ((date - DateTime.Now).TotalSeconds);
                            Session["Date"] = Convert.ToInt16(time);
                            return(RedirectToAction("OrderCooldown"));
                        }
                    }
                }
                else
                {
                    ViewBag.TotalNumber = membersService.Get().Count();         // 會員總人數
                    Setting Setting = settingService.Get().FirstOrDefault();
                    ViewBag.Max         = Setting.Max;
                    ViewBag.Min         = Setting.Min;
                    TempData["message"] = "網址輸入錯誤,請重新下單!!!";
                    return(RedirectToAction("Order", "OrderMs"));
                }
            }
            else if (order.Url.Contains("'") || order.Url.Contains("\"") || order.Count == null)     // 亂輸入者,則被寫到黑名單的表裡面,並記載IP、Useragent、MemberId
            {
                blacklist.Account   = member.Account;
                blacklist.Memberid  = Guid.Parse(Session["Memberid"].ToString());
                blacklist.Useragent = Request.UserAgent;
                blacklist.IP_Addr   = ipaddress;
                memberblacklistService.Create(blacklist);
                memberblacklistService.SaveChanges();
                Session.RemoveAll();
                return(RedirectToAction("Home", "HomeMs"));
            }
            blacklist.Account   = member.Account;
            blacklist.Memberid  = Guid.Parse(Session["Memberid"].ToString());
            blacklist.Useragent = Request.UserAgent;
            blacklist.IP_Addr   = ipaddress;
            memberblacklistService.Create(blacklist);
            memberblacklistService.SaveChanges();
            Session.RemoveAll();
            return(RedirectToAction("Home", "HomeMs"));
        }