Ejemplo n.º 1
0
        public ActionResult AddFBMembers(FBMembers fbmember)
        {
            Guid    FBAccountCostid      = Guid.Parse("bfc0aa6b-91e9-4c1e-ba33-853ce7e92880"); // FB帳號成本ID
            Product FBAccountCostProduct = productService.GetByID(FBAccountCostid);            // FB帳號成本

            if (TryUpdateModel(fbmember, new string[] { "FB_Account", "FB_Password", "Facebooklink", "FB_Name", "Isenable", "Productid" }) && ModelState.IsValid)
            {
                fbmember.FBMemberid  = Guid.NewGuid();
                fbmember.FB_Account  = Regex.Replace(fbmember.FB_Account, @"[^a-z||A-Z||@||.||0-9]", "").Replace(" ", "").Trim();        // 保留A-Z、a-z、0-9、小老鼠、小數點,其餘取代空值,清除頭尾空白
                fbmember.Createdate  = dt_tw();
                fbmember.Updatedate  = dt_tw();
                fbmember.Lastdate    = ((int)(dt_tw() - new DateTime(1970, 1, 1)).TotalSeconds) - 28800; // 總秒數
                fbmember.AccountCost = FBAccountCostProduct.Cost;                                        // 帳號成本為當前的帳號成本
                fbmember.Isenable    = 1;
                /*** 隨機抓取Useragent ***/
                int         useragentCount = useragentService.Get().Count();
                Useragent[] useragent      = useragentService.Get().ToArray();
                Random      crand          = new Random();
                int         rand           = crand.Next(0, useragentCount - 1);
                fbmember.Useragent = useragent[rand].User_agent;
                /**** 將會員寫進會員登入紀錄裡,預設狀態為0 【0 : 未驗證 , 1 : 已驗證 , 2 : 需驗證】 ****/
                FBMembersLoginlog fbmembersloginlog = new FBMembersLoginlog();
                fbmembersloginlog.FBMemberid = fbmember.FBMemberid;
                fbmembersloginlog.Createdate = fbmember.Createdate;
                fbmembersloginlog.Status     = 0;
                fbmember.FBMembersLoginlog.Add(fbmembersloginlog);
                /**** End Memberloginrecord ****/
                fbmembersService.Create(fbmember);
                fbmembersService.SaveChanges();
            }

            return(RedirectToAction("FBMembers"));
        }
Ejemplo n.º 2
0
        public ActionResult EditFBMembers(int p, Guid FBMemberid)
        {
            ViewBag.pageNumber = p;
            FBMembers fbmember = fbmembersService.GetByID(FBMemberid);

            /**** FB 產品選單 ***/
            FBProductDropDownList(fbmember);
            return(View(fbmember));
        }
Ejemplo n.º 3
0
        public ActionResult DeleteFBMembers(Guid FBMemberid, int p)
        {
            FBMembers fbmember = fbmembersService.GetByID(FBMemberid);

            fbmember.Isenable = 0;
            fbmembersService.SpecificUpdate(fbmember, new string[] { "Isenable" });
            fbmembersService.SaveChanges();
            return(RedirectToAction("FBMembers"));
        }
Ejemplo n.º 4
0
        /*** 批量FB會員轉正式 ****/
        public JsonResult AjaxToOfficialFBMembersChecked(Guid[] FBMemberid)
        {
            if (FBMemberid != null)
            {
                foreach (Guid thismemberid in FBMemberid)
                {
                    FBMembers fbmember = fbmembersService.GetByID(thismemberid);
                    fbmember.Isenable = 1;
                    fbmembersService.SpecificUpdate(fbmember, new string[] { "Isenable" });
                }
                fbmembersService.SaveChanges();
            }

            return(this.Json("Success"));
        }
Ejemplo n.º 5
0
        /****** 設定FB會員產品 *****/
        public JsonResult AjaxSetFBMembersProduct(Guid[] FBMemberid, Guid Productid)
        {
            if (FBMemberid != null && Productid != null)
            {
                foreach (Guid thismemberid in FBMemberid)
                {
                    FBMembers fbmember = fbmembersService.GetByID(thismemberid);
                    fbmember.Productid = Productid;
                    fbmembersService.SpecificUpdate(fbmember, new string[] { "Productid" });
                }
                fbmembersService.SaveChanges();
            }

            return(this.Json("Success"));
        }
Ejemplo n.º 6
0
        public IResult SpecificUpdate(FBMembers 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);
        }
Ejemplo n.º 7
0
        public IResult Update(FBMembers 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);
        }
Ejemplo n.º 8
0
        public IResult Delete(FBMembers 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);
        }
Ejemplo n.º 9
0
        public ActionResult EditFBMembers(Guid FBMemberid, int Status)
        {
            FBMembersLoginlog fbmembersloginlog = new FBMembersLoginlog();
            FBMembers         fbmember          = fbmembersService.GetByID(FBMemberid);

            if (TryUpdateModel(fbmember, new string[] { "FB_Account", "FB_Password", "Facebooklink", "FB_Name", "Productid" }) && ModelState.IsValid)
            {
                fbmember.FB_Account = Regex.Replace(fbmember.FB_Account, @"[^a-z||A-Z||@||.||0-9]", "").Replace(" ", "").Trim();         // 保留A-Z、a-z、0-9、小老鼠、小數點,其餘取代空值,清除頭尾空白
                fbmembersService.Update(fbmember);
                fbmembersService.SaveChanges();

                fbmembersloginlog.Status     = Status;
                fbmembersloginlog.FBMemberid = FBMemberid;
                fbmembersloginlog.Createdate = DateTime.Now;
                fbmembersloginlogService.Create(fbmembersloginlog);
                fbmembersloginlogService.SaveChanges();
            }

            return(RedirectToAction("FBMembers"));
        }
Ejemplo n.º 10
0
        public void import_FBMemberstoSQL(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)
                {
                    FBMembers fbmember = new FBMembers();
                    if (sheet.GetRow(i).GetCell(0).ToString() != "" && sheet.GetRow(i).GetCell(0).ToString() != null)
                    {
                        Guid    FBAccountCostid      = Guid.Parse("bfc0aa6b-91e9-4c1e-ba33-853ce7e92880"); // FB帳號成本ID
                        Product FBAccountCostProduct = productService.GetByID(FBAccountCostid);            // FB帳號成本

                        var test = sheet.GetRow(i).GetCell(3).ToString();
                        fbmember.FB_Account  = Regex.Replace(sheet.GetRow(i).GetCell(0).ToString(), @"[^a-z||A-Z||@||.||0-9]", "").Replace(" ", "").Trim();        // 保留A-Z、a-z、0-9、小老鼠、小數點,其餘取代空值,清除頭尾空白
                        fbmember.FB_Password = sheet.GetRow(i).GetCell(1).ToString();
                        fbmember.FB_Name     = sheet.GetRow(i).GetCell(2).ToString();
                        if (sheet.GetRow(i).GetCell(3).ToString() != "null")
                        {
                            fbmember.Facebooklink = sheet.GetRow(i).GetCell(3).ToString();
                        }
                        if (sheet.GetRow(i).GetCell(4).ToString() != "null")
                        {
                            fbmember.Cookie = sheet.GetRow(i).GetCell(4).ToString();
                        }
                        switch (sheet.GetRow(i).GetCell(5).ToString())
                        {
                        case "1":
                            fbmember.Productid = Guid.Parse("0c020482-d76a-4213-b021-f8db0fe96489");
                            break;

                        case "2":
                            fbmember.Productid = Guid.Parse("6c5425d0-5362-4fa9-8c6e-dfb929877b93");
                            break;

                        case "3":
                            fbmember.Productid = Guid.Parse("f9dd03ee-ecd7-4514-94c6-2ea7d72d931c");
                            break;

                        case "4":
                            fbmember.Productid = Guid.Parse("6b1e8bd2-8dbb-4282-89df-b509be5ff361");
                            break;

                        case "5":
                            fbmember.Productid = Guid.Parse("e592d2a8-a1a7-4471-a648-0547c7a46cdd");
                            break;

                        case "6":
                            fbmember.Productid = Guid.Parse("bffb9389-46f0-4bf4-a6ab-d4dcf77435c7");
                            break;

                        case "7":
                            fbmember.Productid = Guid.Parse("f686d184-884c-4aa7-9f26-f8118ba7f990");
                            break;

                        case "8":
                            fbmember.Productid = Guid.Parse("07408390-5f81-451a-9193-a93faaed1825");
                            break;

                        case "9":
                            fbmember.Productid = Guid.Parse("b93e5ee4-f946-4bb0-ad6a-8f379e704802");
                            break;

                        case "10":
                            fbmember.Productid = Guid.Parse("e16dfe59-2789-4598-9310-6334e5e7803c");
                            break;

                        default:
                            fbmember.Productid = Guid.Parse("78da7b19-f424-4efa-9691-45268100188d");
                            break;
                        }

                        if (sheet.GetRow(i).GetCell(6).ToString() == "1")
                        {
                            fbmember.Isenable = 1;
                        }
                        else if (sheet.GetRow(i).GetCell(6).ToString() == "2")
                        {
                            fbmember.Isenable = 2;
                        }

                        fbmember.FBMemberid = Guid.NewGuid();
                        fbmember.Createdate = dt_tw();
                        fbmember.Updatedate = dt_tw();
                        //fbmember.Lastdate = ((int)(dt_tw() - new DateTime(1970, 1, 1)).TotalSeconds) - 28800;
                        //fbmember.Isnew = 0; // 是否新Cookie【0:舊Cookie 1: 新Cookie】
                        /**** 測試 ****/
                        fbmember.Lastdate = 0;                            // 測試
                        fbmember.Isnew    = 1;                            // 測試

                        fbmember.AccountCost = FBAccountCostProduct.Cost; // 帳號成本為當前的帳號成本
                        /*** 隨機指派手機版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 ***/
                        fbmember.Useragent = useragent[rnd_useragent].User_agent;
                        /*** 將帳號寫入登入紀錄裡,預設狀態為0 【0 : 未驗證 , 1 : 已驗證 , 2 : 需驗證】 ***/
                        FBMembersLoginlog fbmembersloginlog = new FBMembersLoginlog();
                        fbmembersloginlog.FBMemberid = fbmember.FBMemberid;
                        fbmembersloginlog.Createdate = dt_tw();
                        fbmembersloginlog.Status     = 0;
                        fbmember.FBMembersLoginlog.Add(fbmembersloginlog);
                        /*** End LoginLog ***/
                        fbmembersService.Create(fbmember);
                    }
                }
            }
            fbmembersService.SaveChanges();
        }