示例#1
0
        public ActionResult GetPhotos()
        {
            Validation  vld          = new Validation();
            string      sCategoryIDs = vld.Get("categoryIDs", false, "请至少选择一个类别", regex: @"^\d+(\.\d+)*$", regexText: "类别参数错误");
            IList <int> categoryIDs;

            if (string.IsNullOrEmpty(sCategoryIDs))
            {
                categoryIDs = null;
            }
            else
            {
                string[] aCategoryIDs = sCategoryIDs.Split(',');
                categoryIDs = new List <int>();
                for (int i = 0; i < aCategoryIDs.Length; i++)
                {
                    categoryIDs.Add(int.Parse(aCategoryIDs[i]));
                }
            }
            string keywords = vld.Get("keywords");
            int    page     = vld.GetInt("page", defaultValue: 1);
            int    pageSize = vld.GetInt("pageSize", defaultValue: 10);

            PhotoBLL photoBLL = new PhotoBLL();
            int      total;
            var      res = photoBLL.GetPhotos(categoryIDs, keywords, page, pageSize, out total);

            return(Json(new { success = true, data = res, total = total }));
        }
示例#2
0
        public ActionResult PotoT1XML(int id)
        {
            StringBuilder sb = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n");

            sb.AppendLine("<root>");

            PhotoBLL  photoBLL = new PhotoBLL();
            JsonArray res      = photoBLL.GetPhotos(new List <int>()
            {
                id
            });

            if (res != null)
            {
                for (var i = 0; i < res.Count; i++)
                {
                    sb.Append("<list id=\"")
                    .Append(res[i]["PhotoID"])
                    .Append("\" pic=\"")
                    .Append(Config.MediaServer)
                    .Append(res[i]["Pic"])
                    .Append("\" name=\"")
                    .Append(res[i]["Name"] == null ? null : HttpUtility.HtmlEncode((string)res[i]["Name"]))
                    .Append("\" info=\"")
                    .Append(res[i]["Info"] == null ? null : HttpUtility.HtmlEncode((string)res[i]["Info"]))
                    .AppendLine("\" />");
                }
            }

            sb.Append("</root>");
            return(Content(sb.ToString(), "text/xml"));
        }