Exemplo n.º 1
0
        public ActionResult Register()
        {
            User user = new User();
            if(null != user){
                user.UserName = Request.QueryString["uname"];
                user.Password = Request.QueryString["pwd"];
                user.Email = Request.QueryString["email"];
                user.sex = Request.QueryString["sex"];
                user.RegisterTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            }
            //非空判断
            if (string.IsNullOrWhiteSpace(user.UserName)) { return RedirectToAction("Login"); }
            if (string.IsNullOrWhiteSpace(user.Password)) { return RedirectToAction("Login"); }
            if (string.IsNullOrWhiteSpace(user.Email)) { return RedirectToAction("Login"); }
            if (string.IsNullOrWhiteSpace(user.RegisterTime)) { return RedirectToAction("Login"); }

            WeiBoDataServices services = new WeiBoDataServices();
            int result = services.getServices().Register(user);
            if (result > 0)
            {
                //注册成功自动登录
                int uid = services.getServices().Login(user.UserName, user.Password);
                Session["uid"] = uid;
                Session["uname"] = user.UserName;
                return RedirectToAction("../Detail/More");
            }
            else
            {
                return RedirectToAction("Login");
            }
        }
Exemplo n.º 2
0
 public static string GenerateAt(string user)
 {
     WeiBoDataServices services = new WeiBoDataServices();
     CharEnumerator e = user.GetEnumerator();
     List<string> unames = new List<string>();
     string uname = "@";
     int uid = 00000000;
     while (e.MoveNext())
     {
         if (e.Current.Equals('@'))
         {
             while (e.MoveNext())
             {
                 uname += e.Current;
                 if (e.Current.Equals(' '))
                 {
                     unames.Add(uname);
                     uname = "@";
                     break;
                 }
             }
         }
     }
     foreach (string item in unames)
     {
         string temp = item.Substring(1,item.Length-1);
         uid = services.getServices().GetUidByName(temp);
         user = user.Replace(item, "<a href='"+uid+"'>" + item + "</a>");
     }
     return user;
 }
Exemplo n.º 3
0
        public ActionResult DoLogin()
        {
            string uname = Request.QueryString["Username"];
            string pwd = Request.QueryString["Password"];

            if(uname.Equals(string.Empty)){
                ViewData["errormsg"] = "用户名不能为空";
                return RedirectToAction("Login");
            }
            if(pwd.Equals(string.Empty)){
                ViewData["errormsg"] = "密码不能为空";
                return RedirectToAction("Login");
            }

            int result = new WeiBoDataServices().getServices().Login(uname, pwd);
            if (result != 0)
            {
                Session["uname"] = uname;
                Session["uid"] = result;
                return RedirectToAction("../index");
            }
            else
            {
                ViewData["errormsg"] = "用户名或密码错误";
                return RedirectToAction("Login");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 处理登录
        /// </summary>
        /// <returns></returns>
        public ActionResult DoLogin()
        {
            string uname = Request.QueryString["Username"];
            string pwd = Request.QueryString["Password"];
            string remember = Request.QueryString["remember"];

            if (uname.Equals(string.Empty)) { return RedirectToAction("Login"); }
            if (pwd.Equals(string.Empty)) { return RedirectToAction("Login"); }

            int result = new WeiBoDataServices().getServices().Login(uname, pwd);
            if (result != 0)
            {
                Session["uname"] = uname;
                Session["uid"] = result;
                if (null != remember && remember.Equals("on"))
                {
                    string cookie_value = string.Format("{0},{1}", uname, result);
                    Helper.SetCookie("LoginInfo", cookie_value, 7, Response);
                }
                return RedirectToAction("../index");
            }
            else
            {
                Session["error"]= "用户名或密码错误";
                return RedirectToAction("Login");
            }
        }
Exemplo n.º 5
0
 public void Del()
 {
     Request.ContentType = "test/plain";
     Response.ContentType = "text/plain";
     int id = int.Parse(Request.QueryString["id"]);
     int result = new WeiBoDataServices().getServices().DelWeibo(id);
     if(result>0) Response.Write(result);
 }
Exemplo n.º 6
0
 public ActionResult Add(string you,string he)
 {
     string url = Request.UrlReferrer.ToString();
     if(!string.IsNullOrWhiteSpace(he) && !string.IsNullOrWhiteSpace(you)){
         int vyou = int.Parse(you);
         int vhe = int.Parse(he);
         int result = new WeiBoDataServices().getServices().add(vyou, vhe);
     }
     return Redirect(url);
 }
Exemplo n.º 7
0
 public ActionResult More()
 {
     if (null == Session["uid"])
     {
         return Redirect("../Account/Login");
     }
     com.weibo.entity.User u = new WeiBoDataServices().getServices().getUserById((int)Session["uid"]);
     ViewBag.user = u;
     //ViewBag.provinces = new SelectList(provinces,"id","name");
     //ViewBag.cities = new SelectList(cities, "id", "name");
     return View();
 }
Exemplo n.º 8
0
 public JsonResult Card()
 {
     Request.ContentType = "test/plain";
     Response.ContentType = "text/plain";
     string foo = string.Empty;
     using (StreamReader dr= new StreamReader (Request.InputStream))
     {
         foo = dr.ReadToEnd();
     }
     int uid = int.Parse(foo);
     User user = new WeiBoDataServices().getServices().getUserById(uid);
     return Json(user);
 }
Exemplo n.º 9
0
 public JsonResult Comment()
 {
     Request.ContentType = "test/plain";
     Response.ContentType = "text/plain";
     string content = string.Empty;
     using (StreamReader r = new StreamReader(Request.InputStream))
     {
         content = r.ReadToEnd();
     }
     int weiboID = int.Parse(content);
     List<Comment> comments = new WeiBoDataServices().getServices().getComment(weiboID);
     return Json(comments);
 }
Exemplo n.º 10
0
 public ActionResult Follows(string foo)
 {
     if (!string.IsNullOrWhiteSpace(foo))
     {
         int id = int.Parse(foo);
         List<Fans_Follow_UserInfo> follows = new WeiBoDataServices().getServices().GetFollows(id);
         ViewBag.follows = follows;
         ViewBag.id = id;
         return View();
     }
     else
     {
         return RedirectToAction("Index");
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// 粉丝页面
 /// </summary>
 /// <param name="foo"></param>
 /// <returns></returns>
 public ActionResult Fans(string foo)
 {
     if (!string.IsNullOrWhiteSpace(foo))
     {
         if (null != Session["uname"] && null != Session["uid"])
         {
             int id = 0;
             try
             {
                 int.TryParse(foo, out id);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.Message);
                 return View("Error");
             }
             List<Fans_Follow_UserInfo> fans = new WeiBoDataServices().getServices().GetFans(id);
             ViewBag.fans = fans;
             ViewBag.id = id;
             return View();
         }
         else if (Helper.IsCookie(Session, Request))
         {
             int id = 0;
             try
             {
                 int.TryParse(foo, out id);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.Message);
                 return View("Error");
             }
             List<Fans_Follow_UserInfo> fans = new WeiBoDataServices().getServices().GetFans(id);
             ViewBag.fans = fans;
             ViewBag.id = id;
             return View();
         }
         return RedirectToAction("../Account/Login");
     }
     else
     {
         return RedirectToAction("Index");
     }
 }
Exemplo n.º 12
0
        public ActionResult HomePage(string id)
        {
            //string value = Request.RequestContext.RouteData.Values["id"].ToString();
            //当请求路径为index时转向
            if(id.Equals("index"))
            {
                return RedirectToAction("Index");
            }
            //当请求为search时转向
            if (id.Equals("search"))
            {
                return RedirectToAction("Search");
            }
            if (!id.Equals("favicon.ico"))
            {
                int uid = int.Parse(id);
                int m_id = 0;
                if (null != Session["uid"])
                {
                    m_id = (int)Session["uid"];
                }
                WeiBoDataServices services = new WeiBoDataServices ();
                if (!id.Equals(string.Empty))
                {
                    List<WeiBo> weibos = services.getServices().getWeiboForUser(uid);
                    foreach (WeiBo item in weibos)
                    {
                        item.Weibo = Helper.GenerateAt(item.Weibo);
                    }
                    UserSimpleInfo user = services.getServices().getUserInfoById(m_id,uid);
                    ViewBag.weibos = weibos;
                    ViewBag.user = user;
                    ViewBag.id = id;
                }
                return View("HomePage");
            }

            return null;
        }
Exemplo n.º 13
0
        public void SendComment()
        {
            Request.ContentType = "test/plain";
            Response.ContentType = "text/plain";

            string content = Request.QueryString["_comment"];
            string S_wid = Request.QueryString["weibo_id"];
            string s_uid = Request.QueryString["uid"];
            int wid = int.Parse(S_wid);
            int uid = int.Parse(s_uid);

            int result = new WeiBoDataServices().getServices().sendComment(content,DateTime.Now.ToString(),wid,uid);

            if (result > 0)
            {
                Response.Write("1");
            }
            else
            {
                Response.Write("0");
            }
        }
Exemplo n.º 14
0
 public ActionResult Recommend()
 {
     if (null != Session["uid"])
     {
         int id = (int)Session["uid"];
         List<Fans_Follow_UserInfo> users = new WeiBoDataServices().getServices().Recommend(id);
         ViewBag.recommend = users;
         return View();
     }
     return RedirectToAction("../Account/Login");
 }
Exemplo n.º 15
0
        /// <summary>
        /// 个人主页页面
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult HomePage(string id)
        {
            //string value = Request.RequestContext.RouteData.Values["id"].ToString();
            //当请求路径为index时转向
            if (id.Equals("index"))
            {
                return RedirectToAction("Index");
            }
            //当请求为search时转向
            if (id.Equals("search"))
            {
                return RedirectToAction("Search");
            }
            //如果存在Cookie就加入session
            if (null == Session["uid"] && null == Session["uname"])
            {
                Helper.IsCookie(Session, Request);
            }
            if (!id.Equals("favicon.ico"))
            {
                int uid = 0;
                try
                {
                    int.TryParse(id, out uid);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    return View("Error");
                }
                int m_id = 0;
                if (null != Session["uid"])
                {
                    m_id = (int)Session["uid"];
                }
                WeiBoDataServices services = new WeiBoDataServices();
                if (!id.Equals(string.Empty))
                {
                    if (uid == 0) { return View("Error"); }
                    List<WeiBo> weibos = services.getServices().getWeiboForUser(uid);
                    foreach (WeiBo item in weibos)
                    {
                        item.Weibo = Helper.GenerateAt(item.Weibo);
                    }
                    UserSimpleInfo user = services.getServices().getUserInfoById(m_id, uid);
                    ViewBag.weibos = weibos;
                    ViewBag.user = user;
                    ViewBag.id = id;
                }
                return View("HomePage");
            }

            return null;
        }
Exemplo n.º 16
0
 public JsonResult GetProvinces()
 {
     List<Province> provinces = new WeiBoDataServices().getServices().GetAllprivinces();
     return Json(provinces);
 }
Exemplo n.º 17
0
 public JsonResult GetCities()
 {
     int id = int.Parse(Request.QueryString["id"]);
     List<City> cities = new WeiBoDataServices().getServices().GetCityByProvinceID(id);
     return Json(cities,JsonRequestBehavior.AllowGet);
 }
Exemplo n.º 18
0
        public void sendWeibo()
        {
            Request.ContentType = "test/plain";
            Response.ContentType = "text/plain";
            string content = Request.QueryString["content"];
            int uid = int.Parse(Request.QueryString["id"]);

            //非空非零判断
            if (string.IsNullOrWhiteSpace(content)) { Response.Write("0"); return; }
            if (uid == 0) { Response.Write("0"); return; }

            int result = new WeiBoDataServices().getServices().sendWeibo(uid,content);
            if (result > 0)
            {
                Response.Write("1");
            }
            else
            {
                Response.Write("0");
            }
        }
Exemplo n.º 19
0
 public void upLoadImage()
 {
     HttpPostedFileBase upImg = Request.Files["userImage"];
     string filename = Path.GetFileName(upImg.FileName);
     string filepath = Server.MapPath("~/Content/Image/UserImage/");
     string UrlReferrer = Request.UrlReferrer.ToString();
     try
     {
         upImg.SaveAs(filepath+filename);
         int result = new WeiBoDataServices().getServices().updateUserImage(filename,(int)Session["uid"]);
         if (result > 0)
         {
             Response.Redirect(UrlReferrer);
         }
     }catch(Exception ex)
     {
         Response.Write(ex.Message);
     }
 }
Exemplo n.º 20
0
        public void sendRepost()
        {
            Request.ContentType = "test/plain";
            Response.ContentType = "text/plain";

            string content = Request.QueryString["content"];
            int uid = int.Parse(Request.QueryString["id"]);
            int weibo_id = int.Parse(Request.QueryString["weibo_id"]);

            //非空非零判断
            if (string.IsNullOrWhiteSpace(content)) { Response.Write("0"); return;}
            if (uid == 0) { Response.Write("0"); return; }
            if (weibo_id == 0) { Response.Write("0"); return; }

            WeiBoDataServices service = new WeiBoDataServices();
            StringBuilder sb = new StringBuilder();

            string weibo = service.getServices().get_A_WeiboByID(weibo_id);
            string weibo_name = service.getServices().getUserNameByWeiboID(weibo_id);
            int weibo_userid = service.getServices().getUserIDByWeiboID(weibo_id);

            if (string.IsNullOrWhiteSpace(weibo)) { Response.Write("0"); return; }
            if (string.IsNullOrWhiteSpace(weibo_name)) { Response.Write("0"); return; }
            if (weibo_userid == 0) { Response.Write("0"); return; }

            sb.AppendFormat("{0} // @{1} :{2}", content, weibo_name, weibo);
            string repost_weibo = sb.ToString();
            if (string.IsNullOrWhiteSpace(repost_weibo)) { Response.Write("0"); return; }
            //..

            int result = service.getServices().sendRopost(weibo_id, uid, repost_weibo, DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
            if (result > 0)
            {
                Response.Write("1");
            }
            else
            {
                Response.Write("0");
            }
        }
Exemplo n.º 21
0
        public JsonResult search()
        {
            string value = string.Empty;
            //value = Request.QueryString["kw"];
            List<UserSimpleInfo> infos = null;
            using (StreamReader r = new StreamReader(Request.InputStream))
            {
                value = r.ReadToEnd();
            }
            if (null != Session["uid"])
            {
                int uid = (int)Session["uid"];
                 infos= new WeiBoDataServices().getServices().SearchFriend(value, uid);
            }
            else
            {
                 infos = new WeiBoDataServices().getServices().SearchFriend(value, 0);
            }

            return Json(infos);
        }
Exemplo n.º 22
0
 public ActionResult Index()
 {
     if (null != Session["uid"] && null != Session["uname"])
     {
         int uid = (int)Session["uid"];
         List<WeiBo> weibos = new WeiBoDataServices().getServices().getWeibo(uid);
         string userImage = new WeiBoDataServices().getServices().getUserImageById(uid);
         foreach(WeiBo item in weibos)
         {
             item.Weibo =  Helper.GenerateAt(item.Weibo);
         }
         ViewBag.weibos = weibos;
         ViewBag.userImage = userImage;
         return View("Index");
     }
     else
     {
         return RedirectToAction("../Account/Login");
     }
 }
Exemplo n.º 23
0
 public void update()
 {
     WeiBoDataServices s = new WeiBoDataServices();
     com.weibo.entity.User u = new com.weibo.entity.User();
     string UrlReferrer = Request.UrlReferrer.ToString();
     int no_province = int.Parse(Request.QueryString["Provinces"]);
     int no_city = int.Parse(Request.QueryString["Cities"]);
     string no_sex = Request.QueryString["sex"];
     string introduce = Request.QueryString["introduce"];
     string[] pc = s.getServices().GetProvinceAndCityById(no_province, no_city);
     u.ID = (int)Session["uid"];
     u.Address = pc[0] + "," + pc[1];
     u.sex = no_sex;
     u.Introduce = introduce;
     int result = s.getServices().updateUser(u);
     if (result > 0)
     {
         Response.Redirect(UrlReferrer);
     }
     else
     {
         Response.Redirect(UrlReferrer);
     }
 }