Beispiel #1
0
        public ActionResult AuthMembers()
        {
            IEnumerable <Members> members = membersService.Get().Where(a => a.Memberloginrecord.OrderByDescending(x => x.Createdate).FirstOrDefault().Status != 2).ToList();

            foreach (Members auth_member in members)
            {
                string     url   = "http://cp4m.heohelp.com:8080/Check/BackendCkeckFacebook?Facebookid=" + auth_member.Facebookid;
                WebRequest myReq = WebRequest.Create(url);
                myReq.Method      = "GET";
                myReq.ContentType = "application/json; charset=UTF-8";
                UTF8Encoding enc = new UTF8Encoding();
                myReq.Headers.Remove("auth-token");
                WebResponse  wr            = myReq.GetResponse();
                Stream       receiveStream = wr.GetResponseStream();
                StreamReader reader        = new StreamReader(receiveStream, Encoding.UTF8);
                string       content       = reader.ReadToEnd();
                content = content.Replace("\"", "");
                if (content != "")          // 假設content不是空值時
                {
                    if (content == "已驗證")
                    {
                        Memberloginrecord loginrecord = new Memberloginrecord();
                        loginrecord.Status     = 1;
                        loginrecord.Memberid   = auth_member.Memberid;
                        loginrecord.Createdate = DateTime.Now;
                        memberloginrecordService.Create(loginrecord);
                    }
                    else
                    {
                        Memberloginrecord loginrecord = new Memberloginrecord();
                        loginrecord.Status     = 2;
                        loginrecord.Memberid   = auth_member.Memberid;
                        loginrecord.Createdate = DateTime.Now;
                        memberloginrecordService.Create(loginrecord);
                    }
                }
                else
                {
                    Memberloginrecord loginrecord = new Memberloginrecord();
                    loginrecord.Status     = 0;
                    loginrecord.Memberid   = auth_member.Memberid;
                    loginrecord.Createdate = DateTime.Now;
                    memberloginrecordService.Create(loginrecord);
                }
            }
            memberloginrecordService.SaveChanges();
            membersService.SaveChanges();
            TempData["message"] = "驗證已完成";
            return(RedirectToAction("Members"));
        }
Beispiel #2
0
 /***** 驗證帳號 ****/
 public JsonResult AjaxAuthMembers(Guid[] Memberid)
 {
     if (Memberid != null)
     {
         foreach (Guid thismemberid in Memberid)
         {
             Members    Members = membersService.GetByID(thismemberid);
             string     url     = "http://cp4m.heohelp.com:8080/Check/BackendCkeckFacebook?Facebookid=" + Members.Facebookid;
             WebRequest myReq   = WebRequest.Create(url);
             myReq.Method      = "GET";
             myReq.ContentType = "application/json; charset=UTF-8";
             UTF8Encoding enc = new UTF8Encoding();
             myReq.Headers.Remove("auth-token");
             WebResponse  wr            = myReq.GetResponse();
             Stream       receiveStream = wr.GetResponseStream();
             StreamReader reader        = new StreamReader(receiveStream, Encoding.UTF8);
             string       content       = reader.ReadToEnd();
             content = content.Replace("\"", "");
             if (content != "")       // 假設content不是空值時
             {
                 if (content == "已驗證")
                 {
                     Memberloginrecord loginrecord = new Memberloginrecord();
                     loginrecord.Status     = 1;
                     loginrecord.Memberid   = Members.Memberid;
                     loginrecord.Createdate = DateTime.Now;
                     memberloginrecordService.Create(loginrecord);
                 }
                 else
                 {
                     Memberloginrecord loginrecord = new Memberloginrecord();
                     loginrecord.Status     = 2;
                     loginrecord.Memberid   = Members.Memberid;
                     loginrecord.Createdate = DateTime.Now;
                     memberloginrecordService.Create(loginrecord);
                 }
             }
             else
             {
                 Memberloginrecord loginrecord = new Memberloginrecord();
                 loginrecord.Status     = 0;
                 loginrecord.Memberid   = Members.Memberid;
                 loginrecord.Createdate = DateTime.Now;
                 memberloginrecordService.Create(loginrecord);
             }
         }
         memberloginrecordService.SaveChanges();
         membersService.SaveChanges();
     }
     return(this.Json("Success"));
 }
Beispiel #3
0
        /*** 更新會員互惠列表 ***/
        public JsonResult UpdateAccount(string Id, string Ordernumber, string Memberid, string FacebookCookie, int AccountStatus, string Facebookid)
        {
            if (Id == "heo_order")
            {
                IEnumerable <Memberlevel> memberlevel = memberlevelService.Get().Where(a => a.Isenable == 1);                                              // 撈除了真人以外的層級
                Order           order           = orderService.Get().Where(a => a.Ordernumber == Ordernumber).FirstOrDefault();                            // 該訂單的詳細資料
                Members         member          = membersService.GetByID(Guid.Parse(Memberid));                                                            // 該會員的詳細資料
                Feedbackproduct feedbackproduct = feedbackproductService.Get().Where(a => a.Feedbackproductname.Contains(order.Service)).FirstOrDefault(); // 該訂單之產品資料
                if (AccountStatus == 0 || AccountStatus == 1)                                                                                              // 帳號需驗證、帳密錯誤、更改密碼
                {
                    /**** 將登入失敗寫入資料庫 ****/
                    Memberloginrecord Memberloginrecord = new Memberloginrecord();
                    Memberloginrecord.Memberid   = Guid.Parse(Memberid);
                    Memberloginrecord.Status     = 2;
                    Memberloginrecord.Createdate = DateTime.Now;
                    memberloginrecordService.Create(Memberloginrecord);
                    memberloginrecordService.SaveChanges();
                    /**** 寫入TXT檔 *****/
                    using (StreamWriter sw = new StreamWriter(@"C:\Users\wadmin\Desktop\HEO_order.txt", true))
                    {
                        sw.Write("HEO訂單問題回報 會員帳號:" + member.Account + "登入有問題(密碼更改or帳密錯誤)");
                        sw.Write(Environment.NewLine);
                        sw.Write(DateTime.Now);
                        sw.Write(Environment.NewLine);
                    }
                }
                else if (AccountStatus == 2)     // 按讚成功
                {
                    /*** 改訂單剩餘人數 ***/
                    order.Remains -= 1;
                    orderService.SpecificUpdate(order, new string[] { "Remains" });
                    orderService.SaveChanges();
                    /**** 將登入成功寫入資料庫 ****/
                    Memberloginrecord Memberloginrecord = new Memberloginrecord();
                    Memberloginrecord.Memberid   = Guid.Parse(Memberid);
                    Memberloginrecord.Status     = 1;
                    Memberloginrecord.Createdate = DateTime.Now;
                    memberloginrecordService.Create(Memberloginrecord);
                    memberloginrecordService.SaveChanges();
                }
                else if (AccountStatus == 3)    // 找不到讚的位置
                {
                    /***** 寄信給我 ****/
                    order.OrderStatus = 3;      //訂單改為失敗
                    orderService.SpecificUpdate(order, new string[] { "OrderStatus" });
                    orderService.SaveChanges();
                    /**** 寫入TXT檔 *****/
                    using (StreamWriter sw = new StreamWriter(@"C:\Users\wadmin\Desktop\HEO_order.txt", true))
                    {
                        sw.Write("HEO訂單問題回報 訂單編號:" + order.Ordernumber + "有問題," + member.Account + "(找不到讚的位置)");
                        sw.Write(Environment.NewLine);
                        sw.Write(DateTime.Now);
                        sw.Write(Environment.NewLine);
                    }
                }
                else    // 已按過讚
                {
                    /**** 寫入TXT檔 *****/
                    using (StreamWriter sw = new StreamWriter(@"C:\Users\wadmin\Desktop\HEO_order.txt", true))
                    {
                        sw.Write("HEO訂單問題回報 訂單編號:" + order.Ordernumber + "有問題," + member.Account + "(已按過讚)");
                        sw.Write(Environment.NewLine);
                        sw.Write(DateTime.Now);
                        sw.Write(Environment.NewLine);
                    }
                }
                if (order.Ordernumber.Contains("heo"))
                {
                    /*** HEO內部下單 ***/
                    /*** 更新會員的FacebookId ***/
                    member.Facebookid = Facebookid;
                    /*** 更新會員的Cookie *****/
                    member.Facebookcookie = FacebookCookie;
                    membersService.SpecificUpdate(member, new string[] { "Facebookcookie", "Facebookid" });
                    /*** 將會員寫到該訂單的互惠會員列表 ***/
                    Orderfaceooklist orderfacebooklist = new Orderfaceooklist();
                    orderfacebooklist.Memberid          = member.Memberid;
                    orderfacebooklist.Feedbackproductid = feedbackproduct.Feedbackproductid;
                    orderfacebooklist.Facebookaccount   = member.Account;
                    orderfacebooklist.Orderid           = order.Orderid;
                    orderfacebooklist.Createdate        = DateTime.Now;
                    orderfacebooklist.Updatedate        = DateTime.Now;
                    //orderfacebooklistService.Create(orderfacebooklist);
                    member.Orderfaceooklist.Add(orderfacebooklist);
                    membersService.SaveChanges();
                    return(this.Json("Success"));
                }
                else
                {
                    /**** HDZ餵來的訂單 ****/
                    /*** 更新訂單成本及判斷該會員的層級,並且撥對應的回饋金給該會員 ****/
                    if (member.Is_import == 0)           // 判斷該會員非後台匯入的會員
                    {
                        if (member.Isreal == true)       // 判斷該會員是否為真人
                        {
                            order.Cost           += 1.0 * Convert.ToDouble(feedbackproduct.Feedbackdetail.FirstOrDefault(a => a.Memberlevel.Levelname == "真人").Money);
                            member.Feedbackmoney += order.Cost;
                        }
                        else
                        {
                            foreach (Memberlevel level in memberlevel)
                            {
                                if (member.Memberlevel.Levelname == level.Levelname)
                                {
                                    order.Cost += 1.0 * Convert.ToDouble(feedbackproduct.Feedbackdetail.FirstOrDefault(a => a.Memberlevel.Levelname == level.Levelname).Money);
                                }
                            }
                        }
                    }

                    orderService.SpecificUpdate(order, new string[] { "Cost" });
                    /*** 將會員寫到該訂單的互惠會員列表 ***/
                    Orderfaceooklist orderfacebooklist = new Orderfaceooklist();
                    orderfacebooklist.Memberid          = member.Memberid;
                    orderfacebooklist.Feedbackproductid = feedbackproduct.Feedbackproductid;
                    orderfacebooklist.Facebookaccount   = member.Account;
                    orderfacebooklist.Orderid           = order.Orderid;
                    orderfacebooklist.Createdate        = DateTime.Now;
                    orderfacebooklist.Updatedate        = DateTime.Now;
                    order.Orderfaceooklist.Add(orderfacebooklist);
                    orderService.SaveChanges();
                    // orderfacebooklistService.Create(orderfacebooklist);
                    /*** 判斷該會員的層級,並且撥對應的回饋金給該會員 ***/
                    if (member.Is_import == 0)           // 判斷該會員非後台匯入的會員
                    {
                        if (member.Isreal == true)       // 判斷該會員是否為真人
                        {
                            member.Feedbackmoney += Convert.ToInt32(feedbackproduct.Feedbackdetail.FirstOrDefault(a => a.Memberlevel.Levelname == "真人").Money);
                        }
                        else
                        {
                            member.Feedbackmoney += Convert.ToInt32(feedbackproduct.Feedbackdetail.FirstOrDefault(a => a.Levelid == member.Levelid).Money);
                        }
                    }
                    /*** 更新該會員的FacebookId ***/
                    member.Facebookid = Facebookid;
                    /*** 更新該會員的Cookie *****/
                    member.Facebookcookie = FacebookCookie;
                    membersService.SpecificUpdate(member, new string[] { "Facebookcookie", "Feedbackmoney", "Facebookid" });
                    membersService.SaveChanges();
                    return(this.Json("Success"));
                }
            }
            else
            {
                string status = "Error";
                return(this.Json(status));
            }
        }
Beispiel #4
0
        public ActionResult Login(Members members)
        {
            string  Account         = Regex.Replace(members.Account, @"[^a-z||A-Z||@||.||0-9||_]", ""); // 保留A-Z、a-z、0-9、小老鼠、小數點,其餘取代空值
            Members thismember      = membersService.Get().Where(a => a.Account == members.Account).FirstOrDefault();
            string  useragent_phone = "";

            if (thismember != null)
            {
                useragent_phone = thismember.Useragent_phone;
            }
            else
            {
                /***** useragent *****/
                useragent_phone = "Mozilla/5.0 (iPhone; CPU iPhone OS 11_1_2 like Mac OS X) AppleWebKit/604.3.5 (KHTML, like Gecko) Version/11.0 Mobile/15B202 Safari/604.1";
            }

            /**** HTTP POST ****/
            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("http://heohelp.com:8080/Check/CheckFacebook");

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "POST";

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                string json = new JavaScriptSerializer().Serialize(new
                {
                    Account   = Account,
                    Password  = members.Password,
                    Useragent = useragent_phone
                });

                streamWriter.Write(json);
            }

            HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            string          result       = "";

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                result = streamReader.ReadToEnd();
            }
            //ViewBag.message = result;
            //return View();
            string[] status = result.Replace("\"", "").Split('#');
            ///**** 測試用 ****/
            //string[] status = new string[5];
            //status[0] = "成功登入!";
            //status[1] = "";
            //status[2] = "";
            //status[3] = "";
            //status[4] = "";
            if (status[0] == "成功登入!")
            {
                Session["Img"]          = status[2];
                Session["Facebookname"] = status[3];
                IEnumerable <Members> old_members = membersService.Get().ToList();
                Guid NormalLevelid = memberlevelService.Get().Where(a => a.Levelname == "一般").FirstOrDefault().Levelid;
                IEnumerable <Feedbackproduct> feedbackproduct = feedbackproductService.Get();
                foreach (Members old_member in old_members)
                {
                    if (old_member.Facebookid.Equals(status[1]))
                    {
                        if (Session["href"] == null)
                        {
                            if (old_member.Facebookstatus == 0)
                            {
                                Session["IsLogin"]  = true;
                                Session["Memberid"] = old_member.Memberid;

                                /**** 將會員成功登入寫進會員登入紀錄裡 ****/
                                Memberloginrecord memberloginrecord = new Memberloginrecord();
                                memberloginrecord.Memberid   = old_member.Memberid;
                                memberloginrecord.Createdate = DateTime.Now;
                                memberloginrecord.Status     = 1;
                                memberloginrecordService.Create(memberloginrecord);
                                memberloginrecordService.SaveChanges();
                                /**** End Memberloginrecord ****/
                                /**** 更新會員Facebooklink連結 *****/
                                old_member.Facebookid     = status[1];
                                old_member.Facebookcookie = status[4];
                                old_member.Password       = members.Password;                                                      // 更新密碼
                                old_member.Logindate      = ((int)(DateTime.Now - new DateTime(1970, 1, 1)).TotalSeconds - 28800); // 登入時間為現在時間的總秒數
                                membersService.SpecificUpdate(old_member, new string[] { "Facebookid", "Facebookcookie", "Logindate", "Password" });
                                membersService.SaveChanges();
                                /***** End Facebookid ****/
                                return(RedirectToAction("Certified"));
                            }
                            else
                            {
                                Session["IsLogin"]  = true;
                                Session["Memberid"] = old_member.Memberid;

                                /**** 將會員成功登入寫進會員登入紀錄裡 ****/
                                Memberloginrecord memberloginrecord = new Memberloginrecord();
                                memberloginrecord.Memberid   = old_member.Memberid;
                                memberloginrecord.Createdate = DateTime.Now;
                                memberloginrecord.Status     = 1;
                                memberloginrecordService.Create(memberloginrecord);
                                memberloginrecordService.SaveChanges();
                                /**** End Memberloginrecord ****/
                                /**** 更新會員Facebookid連結 *****/
                                old_member.Facebookid     = status[1];
                                old_member.Facebookcookie = status[4];
                                old_member.Password       = members.Password;                                                      // 更新密碼
                                old_member.Logindate      = ((int)(DateTime.Now - new DateTime(1970, 1, 1)).TotalSeconds - 28800); // 登入時間為現在時間的總秒數
                                membersService.SpecificUpdate(old_member, new string[] { "Facebookid", "Facebookcookie", "Logindate", "Password" });
                                membersService.SaveChanges();
                                /***** End Facebookid ****/
                                return(RedirectToAction("Order", "OrderMs"));
                            }
                        }
                        else
                        {
                            Session["IsLogin"]  = true;
                            Session["Memberid"] = old_member.Memberid;

                            /**** 將會員成功登入寫進會員登入紀錄裡 ****/
                            Memberloginrecord memberloginrecord = new Memberloginrecord();
                            memberloginrecord.Memberid   = old_member.Memberid;
                            memberloginrecord.Createdate = DateTime.Now;
                            memberloginrecord.Status     = 1;
                            memberloginrecordService.Create(memberloginrecord);
                            memberloginrecordService.SaveChanges();
                            /**** End Memberloginrecord ****/
                            /**** 更新會員Facebookid連結 *****/
                            old_member.Facebookid     = status[1];
                            old_member.Facebookcookie = status[4];
                            old_member.Password       = members.Password;                                                      // 更新密碼
                            old_member.Logindate      = ((int)(DateTime.Now - new DateTime(1970, 1, 1)).TotalSeconds - 28800); // 登入時間為現在時間的總秒數
                            membersService.SpecificUpdate(old_member, new string[] { "Facebookid", "Facebookcookie", "Logindate", "Password" });
                            membersService.SaveChanges();
                            /***** End Facebookid ****/
                            return(RedirectToAction("Deposit", "DepositMs"));
                        }
                    }
                }
                if (TryUpdateModel(members, new string[] { "Password" }))
                {
                    /*** 隨機抓取Useragent ***/
                    int         useragentCount = useragentService.Get().Count();
                    Useragent[] useragent      = useragentService.Get().ToArray();
                    Random      crand          = new Random();
                    int         rand           = crand.Next(0, useragentCount - 1);
                    /******* 新增會員 ********/
                    members.Memberid        = Guid.NewGuid();
                    members.Levelid         = NormalLevelid;
                    members.Isenable        = 1;
                    members.Is_import       = 0;        // 是否匯入【0: 前台登入 , 1 : 後台匯入 , 2 : 轉前台】
                    members.Account         = Account;
                    members.Createdate      = DateTime.Now;
                    members.Updatedate      = DateTime.Now;
                    members.Facebookcookie  = status[4];
                    members.Useragent_phone = useragent[rand].User_agent;
                    members.Lastdate        = (int)(DateTime.Now - new DateTime(1970, 1, 1)).TotalSeconds - 28800;
                    members.Logindate       = (int)(DateTime.Now - new DateTime(1970, 1, 1)).TotalSeconds - 28800;  // 紀錄目前登入時間
                    members.Name            = status[3];
                    members.Facebookid      = status[1];
                    /*** 預設將產品授權功能為fasle 【false:未授權 , true: 已授權】 ***/
                    foreach (Feedbackproduct feedbackproductlist in feedbackproduct)
                    {
                        Memberauthorization memberauthorization = new Memberauthorization();
                        memberauthorization.Id                = Guid.NewGuid();
                        memberauthorization.Memberid          = members.Memberid;
                        memberauthorization.Feedbackproductid = feedbackproductlist.Feedbackproductid;
                        memberauthorization.Checked           = false;
                        members.Memberauthorization.Add(memberauthorization);

                        //memberauthorizationService.Create(memberauthorization);
                    }
                    /**** 將會員成功登入寫進會員登入紀錄裡 ****/
                    Memberloginrecord memberloginrecord = new Memberloginrecord();
                    memberloginrecord.Memberid   = members.Memberid;
                    memberloginrecord.Createdate = members.Createdate;
                    memberloginrecord.Status     = 1;
                    members.Memberloginrecord.Add(memberloginrecord);
                    /**** End Memberloginrecord ****/
                    membersService.Create(members);
                    membersService.SaveChanges();
                }

                Session["IsLogin"]  = true;
                Session["Memberid"] = members.Memberid;
                if (Session["href"] == null)
                {
                    return(RedirectToAction("Certified"));
                }
                else
                {
                    return(RedirectToAction("Deposit", "DepositMs"));
                }
            }
            else
            {
                /*** 如果該會員有登過heo ***/
                if (thismember != null)
                {
                    /**** 將會員登入失敗寫進會員登入紀錄裡 ****/
                    Memberloginrecord memberloginrecord = new Memberloginrecord();
                    memberloginrecord.Memberid   = thismember.Memberid;
                    memberloginrecord.Createdate = DateTime.Now;
                    memberloginrecord.Status     = 2;
                    memberloginrecordService.Create(memberloginrecord);
                    memberloginrecordService.SaveChanges();
                    /**** End Memberloginrecord ****/
                }

                ViewBag.Status = status[0];
                return(View());
            }
        }