Exemple #1
0
        public JsonResult SelectImgJson()
        {
            String            id   = Request["id"];
            List <ImageModel> list = new List <ImageModel>();

            if (!(id == null || id.Equals("")))
            {
                list.Add(ImgService.selectImgById(Convert.ToInt64(id)));
            }

            else
            {
                DefaultConfig config = setConfig();
                if (Request["limit"] != null)
                {
                    config.limit = Convert.ToInt32(Request["limit"]);
                }
                if (config.order == StaticVal.Order.ORDER_BY_RANDOM)
                {
                    list.AddRange(ImgService.random(config));
                }
                else
                {
                    list.Add(ImgService.selectImg(config));
                }
            }
            DataTool.addHis("json", IPAddress(), list);
            return(Json(list, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        public void SelectImgPng( )
        {
            DefaultConfig config = new DefaultConfig();
            String        id     = Request["id"];

            List <ImageModel> list = new List <ImageModel>();

            if (!(id == null || id.Equals("")))
            {
                list.Add(ImgService.selectImgById(Convert.ToInt64(id)));
            }
            else
            {
                config = setConfig();
                if (config.order == StaticVal.Order.ORDER_BY_RANDOM)
                {
                    list.AddRange(ImgService.random(config));
                }
                else
                {
                    list.Add(ImgService.selectImg(config));
                }
            }
            DataTool.addHis("png", IPAddress(), list[0].Kid);
            string     pathh = "C:\\Onedrive\\OneDrive - ITBYCX\\pmcdn\\" + Convert.ToInt32(list[0].Kid) / 1000 + "\\" + list[0].Kid + getExt(list[0].File_url);
            FileStream fs    = new FileStream(pathh, FileMode.Open);//可以是其他重载方法

            byte[] byData = new byte[fs.Length];
            fs.Read(byData, 0, byData.Length);
            fs.Close();

            if (getExt(list[0].File_url).Equals(".png"))
            {
                Response.ContentType = "image/png";
                Response.BinaryWrite(byData);
            }
            else
            {
                Response.ContentType = "image/jpeg";
                Response.BinaryWrite(byData);
            }
        }