示例#1
0
        public void allRequirementList(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            List <Requirement>          list       = requirementService.getAllRequirementListWithoutBanned();
            StringBuilder               jsonString = new StringBuilder();
            Dictionary <String, Object> dictionary = new Dictionary <string, object>();

            jsonString.Append("[");
            int i = 1;

            foreach (Requirement requirement in list)
            {
                string         imgPath        = "defaultImg.jpg";
                RequirementImg requirementImg = requirementService.getRequirementFirstImg(requirement.Id);
                if (requirementImg.ImgPath != null && requirementImg.ImgPath != "")
                {
                    imgPath = System.IO.Path.GetFileName(requirementImg.ImgPath);
                }
                dictionary.Add("Id", requirement.Id);
                dictionary.Add("Name", requirement.RequirementName);
                dictionary.Add("Desc", requirement.RequirementDesc);
                dictionary.Add("categoryId", requirement.RequirementCategory.Id);
                dictionary.Add("priority", requirement.Priority);
                dictionary.Add("userId", requirement.User.Id);
                dictionary.Add("nickName", requirement.User.NickName);
                dictionary.Add("teleNumber", requirement.User.TeleNumber);
                dictionary.Add("createTime", requirement.CreateTime);
                dictionary.Add("modifyTime", requirement.ModifyTime);
                dictionary.Add("Status", requirement.RequirementStatus);
                dictionary.Add("FirstImgPath", imgPath);
                dictionary.Add("success", "true");
                jsonString.Append(JsonUtil.toJson(dictionary));
                if (i < list.Count)
                {
                    jsonString.Append(",");
                }
                i++;
                dictionary.Clear();
            }
            jsonString.Append("]");
            context.Response.Write(jsonString.ToString());
        }