Esempio n. 1
0
 public int UpdateResourceRequest(ReSourceRequest model)
 {
     if (model == null || string.IsNullOrWhiteSpace(model.Content))
     {
         return(0);
     }
     return(dal.UpdateResourceRequest(model));
 }
Esempio n. 2
0
 public int UpdateResourceRequest(ReSourceRequest model)
 {
     cmdstr = GenneralSqlFromConfig(DBCommand.UpdateResourceRequest);
     SqlParameter[] spam =
     {
         new SqlParameter("@Content",    model.Content),
         new SqlParameter("@Contact",    model.Contact),
         new SqlParameter("@UpdateTime", DateTime.Now),
         new SqlParameter("@RId",        model.Id)
     };
     return(sqlhelper.ExecuteNonQuery(constr, text, cmdstr, spam));
 }
Esempio n. 3
0
 public string NewResourceRequest(ReSourceRequest model)
 {
     if (model == null || string.IsNullOrWhiteSpace(model.Content))
     {
         return(null);
     }
     model.IPAddr = HttpHelper.GetClientIP();
     #region 验证IP的每天发送量是否超标,暂定为10次/天
     if (GetTimesByIP(model.IPAddr) >= 10)
     {
         return("请求次数超过限制,请明天再来,谢谢!");
     }
     #endregion
     return(dal.NewResourceRequest(model).ToString());
 }
Esempio n. 4
0
        public List <ReSourceRequest> GetListResourceRequest(ViewType type)
        {
            string[] spam = null;
            string where = string.Empty;
            switch (type.ToString())
            {
            case "Hot":
                where = " order by useful,AddTime";
                break;

            default:
            case "Fresh":
                where = " order by AddTime desc";
                break;

            case "My":
                where   = " where OpenId={0} order by AddTime Desc";
                spam[0] = CookieHelper.GetCookieValue("OpenId");
                break;
            }
            DataTable dt = dal.GetListResourceRequest(where, spam);

            if (dt == null || dt.Rows.Count <= 0)
            {
                return(null);
            }
            List <int> mylist = new List <int>();

            foreach (DataRow dr in dt.Rows)
            {
                mylist.Add(int.Parse(dr["Id"].ToString()));
            }
            List <ReSourceRequest> list = new List <ReSourceRequest>();

            foreach (int RId in mylist)
            {
                ReSourceRequest model = GenneralT <ReSourceRequest>(dal.GetSingleResourceRequest(RId));
                list.Add(model);
            }
            return(list);
        }
        public ActionResult AddRequest()
        {
            ReSourceRequest model   = new ReSourceRequest();
            string          content = Request["content"] == null ? "" : Request["content"].ToString();
            string          contact = Request["contact"] == null ? "" : Request["contact"].ToString();
            string          Code    = Request["code"] == null ? "" : Request["code"].ToString();

            if (string.IsNullOrWhiteSpace(Code))
            {
                return(Content("验证码不能为空!"));
            }
            #region 处理验证码

            string CodeType  = CookieHelper.GetCookieValue("CodeType");
            string CodeValue = CookieHelper.GetCookieValue("CodeValue").Replace(" ", "");
            switch (CodeType)
            {
            case "Char":
                if (Code != CodeValue)
                {
                    return(Content("验证码输入错误"));
                }
                break;

            case "Num":
                switch (CodeValue.Length.ToString())
                {
                case "4":
                    int    num1   = int.Parse(CodeValue.Substring(0, 2));
                    int    num2   = int.Parse(CodeValue.Substring(3, 1));
                    string type   = CodeValue.Substring(2, 1);
                    int    result = 0;
                    switch (type)
                    {
                    case "+":
                        result = num1 + num2;
                        break;

                    case "-":
                        result = num1 - num2;
                        break;

                    case "x":
                        result = num1 * num2;
                        break;
                    }
                    if (Code != result.ToString())
                    {
                        return(Content("验证码输入错误"));
                    }
                    break;

                case "5":
                    int    num3    = int.Parse(CodeValue.Substring(0, 2));
                    int    num4    = int.Parse(CodeValue.Substring(3, 2));
                    string type2   = CodeValue.Substring(2, 1);
                    int    result2 = 0;
                    switch (type2)
                    {
                    case "+":
                        result2 = num3 + num4;
                        break;

                    case "-":
                        result2 = num3 - num4;
                        break;

                    case "x":
                        result2 = num3 * num4;
                        break;
                    }
                    if (Code != result2.ToString())
                    {
                        return(Content("验证码输入错误"));
                    }
                    break;
                }
                break;
            }
            #endregion
            model.Content = content;
            model.Contact = contact;
            return(Content(RRBL.NewResourceRequest(model)));
        }