Пример #1
0
        public ActionResult AddYTMembers(YTMembers ytmember)
        {
            if (TryUpdateModel(ytmember, new string[] { "YT_Account", "YT_Password", "Youtubelink", "YT_Name", "Isenable", "Productid" }) && ModelState.IsValid)
            {
                ytmember.YTMemberid = Guid.NewGuid();
                ytmember.YT_Account = Regex.Replace(ytmember.YT_Account, @"[^a-z||A-Z||@||.||0-9]", "");         // 保留A-Z、a-z、0-9、小老鼠、小數點,其餘取代空值
                ytmember.Createdate = dt_tw();
                ytmember.Updatedate = dt_tw();
                ytmember.Lastdate   = ((int)(dt_tw() - new DateTime(1970, 1, 1)).TotalSeconds) - 28800;    // 總秒數
                ytmember.Isenable   = 1;
                /*** 隨機抓取Useragent ***/
                int         useragentCount = useragentService.Get().Count();
                Useragent[] useragent      = useragentService.Get().ToArray();
                Random      crand          = new Random();
                int         rand           = crand.Next(0, useragentCount - 1);
                ytmember.Useragent = useragent[rand].User_agent;
                /**** 將會員寫進會員登入紀錄裡,預設狀態為0 【0 : 未驗證 , 1 : 已驗證 , 2 : 需驗證】 ****/
                YTMembersLoginlog ytmembersloginlog = new YTMembersLoginlog();
                ytmembersloginlog.YTMemberid = ytmember.YTMemberid;
                ytmembersloginlog.Createdate = dt_tw();
                ytmembersloginlog.Status     = 0;
                ytmember.YTMembersLoginlog.Add(ytmembersloginlog);
                /**** End Memberloginrecord ****/
                ytmembersService.Create(ytmember);
                ytmembersService.SaveChanges();
            }

            return(RedirectToAction("YTMembers"));
        }
Пример #2
0
        public ActionResult EditYTOrder(Guid YTOrderid)
        {
            YTOrder ytorder = ytorderService.GetByID(YTOrderid);

            if (TryUpdateModel(ytorder, new string[] { "Url", "Count", "Productid", "YTOrderStatus", "Categoryid", "Istest" }) && ModelState.IsValid)
            {
                /*** 訂單不是進行中,將完成名單的會員Docker關閉 ****/
                if (ytorder.YTOrderStatus != 1)
                {
                    IEnumerable <YTMembers>   YTMembers   = ytmembersService.Get();
                    IEnumerable <YTOrderlist> YTOrderlist = ytorderlistService.Get().Where(a => a.YTOrderid == YTOrderid);
                    foreach (YTOrderlist list in YTOrderlist)
                    {
                        foreach (YTMembers YTMember in YTMembers)
                        {
                            if (YTMember.YTMemberid == list.YTMemberid)
                            {
                                YTMember.Isdocker = 0;  // 關閉Docker 【0 : 關閉, 1 : 開啟】
                                ytmembersService.SpecificUpdate(YTMember, new string[] { "Isdocker" });
                            }
                        }
                    }
                    ytmembersService.SaveChanges();
                }
                ytorderService.Update(ytorder);
                ytorderService.SaveChanges();
            }
            return(RedirectToAction("YTOrder"));
        }
Пример #3
0
        /*** 批量刪除YT會員 ****/
        public JsonResult AjaxDeleteYTMembersChecked(Guid[] YTMemberid)
        {
            if (YTMemberid != null)
            {
                foreach (Guid thismemberid in YTMemberid)
                {
                    YTMembers ytmember = ytmembersService.GetByID(thismemberid);
                    ytmember.Isenable = 0;
                    ytmembersService.SpecificUpdate(ytmember, new string[] { "Isenable" });
                }
                ytmembersService.SaveChanges();
            }

            return(this.Json("Success"));
        }