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")); }
public ActionResult EditYTMembers(int p, Guid YTMemberid) { ViewBag.pageNumber = p; YTMembers ytmember = ytmembersService.GetByID(YTMemberid); /**** YT 產品選單 ***/ YTProductDropDownList(ytmember); return(View(ytmember)); }
public ActionResult DeleteYTMembers(Guid YTMemberid, int p) { YTMembers ytmember = ytmembersService.GetByID(YTMemberid); ytmember.Isenable = 0; ytmembersService.SpecificUpdate(ytmember, new string[] { "Isenable" }); ytmembersService.SaveChanges(); return(RedirectToAction("YTMembers")); }
public void import_YTMemberstoSQL(string path) { IWorkbook workBook; using (var fs = new FileStream(path, FileMode.Open, FileAccess.ReadWrite)) { workBook = new XSSFWorkbook(fs); } var sheet = workBook.GetSheet("工作表1"); for (var i = 1; i <= sheet.LastRowNum; i++) { var j = sheet.LastRowNum; if (sheet.GetRow(i) != null) { YTMembers ytmember = new YTMembers(); if (sheet.GetRow(i).GetCell(0).ToString() != "" && sheet.GetRow(i).GetCell(0).ToString() != null) { var test = sheet.GetRow(i).GetCell(3).ToString(); ytmember.YT_Account = Regex.Replace(sheet.GetRow(i).GetCell(0).ToString(), @"[^a-z||A-Z||@||.||0-9]", ""); // 保留A-Z、a-z、0-9、小老鼠、小數點,其餘取代空值 ytmember.YT_Password = sheet.GetRow(i).GetCell(1).ToString(); ytmember.YT_Name = sheet.GetRow(i).GetCell(2).ToString(); ytmember.Youtubelink = sheet.GetRow(i).GetCell(3).ToString(); ytmember.Cookie = sheet.GetRow(i).GetCell(4).ToString(); ytmember.YTMemberid = Guid.NewGuid(); ytmember.Createdate = dt_tw(); ytmember.Updatedate = dt_tw(); ytmember.Isenable = 1; ytmember.Lastdate = ((int)(dt_tw() - new DateTime(1970, 1, 1)).TotalSeconds) - 28800; /*** 隨機指派手機版Useragent ***/ int useragent_phone = useragentService.Get().Count(); Useragent[] useragent = useragentService.Get().ToArray(); Random rnd = new Random(); int rnd_useragent = rnd.Next(1, useragent_phone - 1); /*** End Useragent ***/ ytmember.Useragent = useragent[rnd_useragent].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 LoginLog ****/ ytmembersService.Create(ytmember); } } } ytmembersService.SaveChanges(); }
/*** 批量刪除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")); }
public ActionResult EditYTMembers(Guid YTMemberid, int Status) { YTMembersLoginlog ytmembersloginlog = new YTMembersLoginlog(); YTMembers ytmember = ytmembersService.GetByID(YTMemberid); if (TryUpdateModel(ytmember, new string[] { "YT_Account", "YT_Password", "Youtubelink", "YT_Name", "Productid" }) && ModelState.IsValid) { ytmember.YT_Account = Regex.Replace(ytmember.YT_Account, @"[^a-z||A-Z||@||.||0-9]", ""); // 保留A-Z、a-z、0-9、小老鼠、小數點,其餘取代空值 ytmembersService.Update(ytmember); ytmembersService.SaveChanges(); ytmembersloginlog.YTMemberid = YTMemberid; ytmembersloginlog.Status = Status; ytmembersloginlog.Createdate = DateTime.Now; ytmembersloginlogService.Create(ytmembersloginlog); ytmembersloginlogService.SaveChanges(); } return(RedirectToAction("YTMembers")); }
public IResult SpecificUpdate(YTMembers entity, string[] Includeproperties) { if (entity == null) { throw new ArgumentNullException(); } IResult result = new Result(false); try { this.repository.SpecificUpdate(entity, Includeproperties); result.Success = true; } catch (Exception ex) { result.Exception = ex; } return(result); }
public IResult Update(YTMembers entity) { if (entity == null) { throw new ArgumentNullException(); } IResult result = new Result(false); try { this.repository.Update(entity); result.Success = true; } catch (Exception ex) { result.Exception = ex; } return(result); }
public IResult Delete(YTMembers entity) { IResult result = new Result(false); if (entity == null) { result.Message = "找不到資料"; } try { this.repository.Delete(entity); result.Success = true; } catch (Exception ex) { result.Exception = ex; } return(result); }
public JsonResult UpdateYTRegainMember(string Id, string YTOrdernumber, string Memberid, string Cookie, int AccountStatus) { if (Id == "CloudControl_order") { YTOrder ytorder = ytorderService.Get().Where(a => a.YTOrdernumber == YTOrdernumber).FirstOrDefault(); YTMembers ytmembers = ytmembersService.GetByID(Guid.Parse(Memberid)); /*** 0 : 帳號需驗證,1 : 帳密輸入錯誤 or 密碼更改,2 : 成功執行,3 : 找不到讚的位置***/ if (AccountStatus == 0) { /**** 寫入TXT檔 *****/ using (StreamWriter sw = new StreamWriter(txt_filepath, true)) { sw.Write("CloudControl訂單問題回報 訂單編號:" + ytorder.YTOrdernumber + "會員帳號:" + ytmembers.YT_Account + "登入有問題(帳號需驗證)"); sw.Write(Environment.NewLine); sw.Write(dt_tw()); sw.Write(Environment.NewLine); } return(this.Json("Success")); } else if (AccountStatus == 1) { /**** 寫入TXT檔 *****/ using (StreamWriter sw = new StreamWriter(txt_filepath, true)) { sw.Write("CloudControl訂單問題回報 訂單編號:" + ytorder.YTOrdernumber + "會員帳號:" + ytmembers.YT_Account + "登入有問題(密碼更改or帳密錯誤)"); sw.Write(Environment.NewLine); sw.Write(dt_tw()); sw.Write(Environment.NewLine); } return(this.Json("Success")); } else if (AccountStatus == 2) { /**** 寫入TXT檔 *****/ using (StreamWriter sw = new StreamWriter(txt_filepath, true)) { sw.Write("CloudControl訂單問題回報 訂單編號:" + ytorder.YTOrdernumber + "會員帳號:" + ytmembers.YT_Account + "執行成功"); sw.Write(Environment.NewLine); sw.Write(dt_tw()); sw.Write(Environment.NewLine); } return(this.Json("Success")); } else { /**** 寫入TXT檔 *****/ using (StreamWriter sw = new StreamWriter(txt_filepath, true)) { sw.Write("CloudControl訂單問題回報 訂單編號:" + ytorder.YTOrdernumber + " 會員帳號:" + ytmembers.YT_Account + "找不到執行的位置"); sw.Write(Environment.NewLine); sw.Write(dt_tw()); sw.Write(Environment.NewLine); } return(this.Json("Success")); } } else { return(this.Json("Error", JsonRequestBehavior.AllowGet)); } }
public JsonResult UpdateYTMember(string Id, string YTOrdernumber, string Memberid, string Cookie, int AccountStatus) { if (Id == "CloudControl_order") { YTOrder ytorder = ytorderService.Get().Where(a => a.YTOrdernumber == YTOrdernumber).FirstOrDefault(); YTMembers ytmembers = ytmembersService.GetByID(Guid.Parse(Memberid)); /*** 0 : 帳號需驗證,1 : 帳密輸入錯誤 or 密碼更改,2 : 成功執行,3 : 找不到讚的位置***/ if (AccountStatus == 0) { /*** 將會員寫入會員紀錄裡 ***/ YTMembersLoginlog ytmembersloginlog = new YTMembersLoginlog(); ytmembersloginlog.Createdate = dt_tw(); ytmembersloginlog.YTMemberid = Guid.Parse(Memberid); ytmembersloginlog.Status = 2; // 【 0:未驗證 , 1:已驗證 , 2:需驗證 】 ytmembersloginlogService.Create(ytmembersloginlog); ytmembersloginlogService.SaveChanges(); /**** 寫入TXT檔 *****/ using (StreamWriter sw = new StreamWriter(txt_filepath, true)) { sw.Write("CloudControl訂單問題回報 訂單編號:" + ytorder.YTOrdernumber + "會員帳號:" + ytmembers.YT_Account + "登入有問題(帳號需驗證)"); sw.Write(Environment.NewLine); sw.Write(dt_tw()); sw.Write(Environment.NewLine); } return(this.Json("Success")); } else if (AccountStatus == 1) { /**** 寫入TXT檔 *****/ using (StreamWriter sw = new StreamWriter(txt_filepath, true)) { sw.Write("CloudControl訂單問題回報 訂單編號:" + ytorder.YTOrdernumber + "會員帳號:" + ytmembers.YT_Account + "登入有問題(密碼更改or帳密錯誤)"); sw.Write(Environment.NewLine); sw.Write(dt_tw()); sw.Write(Environment.NewLine); } return(this.Json("Success")); } else if (AccountStatus == 2) { /*** 更新該會員的Cookie *****/ ytmembers.Cookie = Cookie; ytmembersService.SpecificUpdate(ytmembers, new string[] { "Cookie" }); ytmembersService.SaveChanges(); /**** 寫入登入表裡 ***/ YTMembersLoginlog ytmembersloginlog = new YTMembersLoginlog(); ytmembersloginlog.YTMemberid = Guid.Parse(Memberid); ytmembersloginlog.Createdate = dt_tw(); ytmembersloginlog.Status = 1; ytmembersloginlogService.Create(ytmembersloginlog); ytmembersloginlogService.SaveChanges(); /*** 改訂單剩餘人數 ***/ ytorder.Remains -= 1; ytorderService.SpecificUpdate(ytorder, new string[] { "Remains", "Cookie" }); ytorderService.SaveChanges(); YTOrderlist ytorderlist = new YTOrderlist(); ytorderlist.YTOrderlistid = Guid.NewGuid(); ytorderlist.YTMemberid = Guid.Parse(Memberid); ytorderlist.YTAccount = ytmembers.YT_Account; ytorderlist.YTOrderid = ytorder.YTOrderid; ytorderlist.Createdate = dt_tw(); ytorderlist.Updatedate = dt_tw(); ytorderlistService.Create(ytorderlist); ytorderlistService.SaveChanges(); return(this.Json("Success")); } else { /**** 寫入TXT檔 *****/ using (StreamWriter sw = new StreamWriter(txt_filepath, true)) { sw.Write("CloudControl訂單問題回報 訂單編號:" + ytorder.YTOrdernumber + " 會員帳號:" + ytmembers.YT_Account + "找不到執行的位置"); sw.Write(Environment.NewLine); sw.Write(dt_tw()); sw.Write(Environment.NewLine); } return(this.Json("Success")); } } else { return(this.Json("Error", JsonRequestBehavior.AllowGet)); } }
public JsonResult GetYTMember(string Id, int number, string YTOrdernumber) { if (Id == "CloudControl_order") { YTOrder ytorder = ytorderService.Get().Where(a => a.YTOrdernumber == YTOrdernumber).FirstOrDefault(); // 撈該訂單 IEnumerable <YTOrderlist> ytorderlist = ytorderlistService.Get().Where(a => a.YTOrder.YTOrdernumber == YTOrdernumber); // 撈該訂單的完成列表 IEnumerable <YTOrder> old_ytorders = ytorderService.Get().Where(c => c.Productid == ytorder.Productid).Where(a => a.YTOrdernumber != YTOrdernumber).Where(x => x.Url == ytorder.Url); // 撈所有訂單裡網址為此訂單及產品為此訂單的資料 Product product = productService.GetByID(ytorder.Productid); // 撈此訂單所需的產品 List <get_old_member> MemberList = new List <get_old_member>(); /**** 先排除這張訂單的完成訂單裡的人 ****/ if (ytorderlist != null) { foreach (YTOrderlist list in ytorderlist) { string Account = Regex.Replace(list.YTMembers.YT_Account, @"[^a-z||A-Z||@||.||0-9]", "").Replace(" ", ""); // 保留A-Z、a-z、0-9、小老鼠、小數點,其餘取代空值 MemberList.Add( new get_old_member { Account = Account }); } } /*** 將同網址的訂單的完成訂單裡的人排除掉 ****/ if (old_ytorders != null) { foreach (YTOrder old_ytorder in old_ytorders) { IEnumerable <YTOrderlist> old_ytorderlists = ytorderlistService.Get().Where(a => a.YTOrderid == old_ytorder.YTOrderid); foreach (YTOrderlist old_ytorderlist in old_ytorderlists) { string Account = Regex.Replace(old_ytorderlist.YTMembers.YT_Account, @"[^a-z||A-Z||@||.||0-9]", "").Replace(" ", ""); // 保留A-Z、a-z、0-9、小老鼠、小數點,其餘取代空值 MemberList.Add( new get_old_member { Account = Account }); } } } List <get_member> AccountList = new List <get_member>(); IEnumerable <YTMembers> YTMembers = ytmembersService.Get().Where(a => a.Lastdate <= Now).Where(x => x.YTMembersLoginlog.OrderByDescending(c => c.Createdate).FirstOrDefault().Status != 2).OrderBy(o => o.Lastdate); // 撈可用時間小於現在以及驗證狀態不是需驗證的會員 if (YTMembers != null) { foreach (YTMembers Member in YTMembers) { bool used = false; int loop; for (loop = 0; loop < MemberList.Count(); loop++) { if (Member.YT_Account == MemberList[loop].Account) { used = true; } } if (used == false) { string Cookie = ""; if (Member.Cookie != null) { Cookie = Member.Cookie.Replace("True", "true").Replace("False", "false").Replace("name", "Name").Replace("value", "Value").Replace("path", "Path").Replace("domain", "Domain").Replace("secure", "Secure").Replace("httpOnly", "IsHttpOnly").Replace("expiry", "Expiry"); Cookie = Cookie.Replace("'", @""""); // 將' 取代成 " } /**** 判斷這張單是否是留言訂單 ****/ if (product.Productid == Guid.Parse("205548ac-b02c-42a1-8e43-1ce78f451dd8")) { /**** 撈取該訂單的留言類別 ****/ Guid CategortMessageid = categorymessageService.GetByID(ytorder.Categoryid).Categoryid; /*** 撈取該留言類別底下的留言 ***/ int messageConunt = messageService.Get().Where(a => a.Categoryid == ytorder.Categoryid).Count(); // 該留言類別底下的留言數量 Message[] message = messageService.Get().Where(a => a.Categoryid == ytorder.Categoryid).ToArray(); Random crandom = new Random(); int rand = crandom.Next(0, messageConunt - 1); AccountList.Add( new get_member { Memberid = Member.YTMemberid, Account = Member.YT_Account, Password = Member.YT_Password, Useragent_phone = Member.Useragent, Cookie = Cookie, Message = message[rand].MessageName } ); used = true; } else { AccountList.Add( new get_member { Memberid = Member.YTMemberid, Account = Member.YT_Account, Password = Member.YT_Password, Useragent_phone = Member.Useragent, Cookie = Cookie, } ); used = true; } } } /*** 可用人數小於該訂單所需人數 ****/ if (AccountList.Count() < number) { return(this.Json("數量不足", JsonRequestBehavior.AllowGet)); } else { foreach (get_member entity in AccountList.Take(number)) { /*** 將此會員更新下次互惠時間 ****/ YTMembers Member = ytmembersService.GetByID(entity.Memberid); Member.Lastdate = Now + 120; ytmembersService.SpecificUpdate(Member, new string[] { "Lastdate" }); } ytmembersService.SaveChanges(); return(this.Json(AccountList.Take(number), JsonRequestBehavior.AllowGet)); } } else { return(this.Json("數量不足", JsonRequestBehavior.AllowGet)); } } else { return(this.Json("Error", JsonRequestBehavior.AllowGet)); } }