Ejemplo n.º 1
0
        public ActionResult Save(SpeechInfoEntity model)
        {
            try
            {

                SpeechInfoBLL bll = new SpeechInfoBLL();
                IPScaner objScan = new IPScaner();
                string ip = Request.UserHostAddress.ToString();
                objScan.DataPath = Server.MapPath("/App_data/qqwry.Dat");
                objScan.IP = WorkContext.IP;
                //"113.200.29.90";
                string addre = objScan.IPLocation();
                int IndexofA = addre.IndexOf("省") + 1;
                var ct = addre.Substring(0,IndexofA);
                var sourceaddr = addre;
               var citys= bll.GetCitys();
               if (citys.FirstOrDefault(s => s.CityName == ct) == null)
               {
                   ct = "重庆市";
               }
                model.SourceCity = sourceaddr;
                model.City = ct;
                model.FromUser = WorkContext.Uid;
                model.IsVip = Convert.ToByte(Guid.Empty.Equals(WorkContext.Uid) ? 0 : 1);
                model.SumbitTime = DateTime.Now;
                model.State = 1;//-1为删除状态,1表示正常

                if (bll.Insert(model, null))
                {
                    return AjaxResult("ok", "发送成功!", false);
                }
                else
                {
                    return AjaxResult("err", "发送失败!", false);

                }
            }
            catch (Exception ex)
            {
                return AjaxResult("err", "发送失败!" + ex.ToString(), false);
                throw;
            }
        }
Ejemplo n.º 2
0
        public ActionResult Save(SpeechInfoEntity model)
        {
            try
            {

                var city = "";
                //统计当前发言人的发言次数
                //if (Session["User"] != null)
                //{
                //    UsersEntity user = Session["User"] as UsersEntity;

                //    //获取当前这个人的这个小时发言的数量
                string uid = string.Empty;
                if (Session["User"] != null)
                {
                    UsersEntity user = Session["User"] as UsersEntity;
                    uid = user.Id.ToString();
                }
                else
                {
                    uid = ShopUtils.GetBSPCookie("bsp");
                    if (string.IsNullOrEmpty(uid.ToString()))
                    {
                        uid = Guid.NewGuid().ToString();
                        ShopUtils.SetBSPCookie("bsp", uid);
                    }

                }
                SpeechInfoBLL bll = new SpeechInfoBLL();
                IPScaner objScan = new IPScaner();
                string ip = Request.UserHostAddress.ToString();
                objScan.DataPath = Server.MapPath("/App_data/qqwry.Dat");
                objScan.IP = WorkContext.IP;
                //"113.200.29.90";
                string addre = objScan.IPLocation();
                int IndexofA = addre.IndexOf("省") + 1;
                var ct = addre.Substring(0,IndexofA);
                var sourceaddr = addre;
                var citys = bll.GetCitys();
                if (citys.FirstOrDefault(s => s.CityName == ct) == null)
                {
                    ct = "重庆市";
                }

                SpeechInfoBLL bill = new SpeechInfoBLL();
                if (!string.IsNullOrEmpty(uid))
                    {
                        int num = bill.GetSpeechCount(new Guid(uid));
                        if (num >= 3)
                        {
                            return AjaxResult("err", "发送失败一小时内最多能发3条!", false);
                        }
                    }
                    model.SourceCity = sourceaddr;
                    model.FromUser = new Guid(uid);
                    model.IsVip = Convert.ToByte(Guid.Empty.Equals(new Guid(uid)) ? 0 : 1);
                    model.SumbitTime = DateTime.Now;
                    model.State = 1; //-1为删除状态,1表示正常
                    model.City = ct;
                   // SpeechInfoBLL bll = new SpeechInfoBLL();
                    if (bll.Insert(model, null))
                    {
                        return AjaxResult("ok", "发送成功!", false);
                    }
                    else
                    {
                        return AjaxResult("ok", "发送失败!", false);

                    }
                //}

                //return AjaxResult("err", "请登陆后发信息!", false);

            }
            catch (Exception ex)
            {
                //return AjaxResult("err", "发送失败!" + ex.ToString(), false);
                throw;
            }
        }