public void Execute(BasePage Context)
        {
            JavaScriptSerializer        jsSerializer = new JavaScriptSerializer();
            Dictionary <String, Object> jsonPictures = new Dictionary <string, Object>();
            String ImageIds = WebHelper.GetStringParam(Context.Request, "Images", "");

            if (!String.IsNullOrEmpty(ImageIds))
            {
                QueryParam qp = new QueryParam();
                qp.Orderfld = Playngo_ClientZone_Files._.ID;

                qp.PageIndex = WebHelper.GetIntParam(Context.Request, "PageIndex", 1);
                qp.PageSize  = WebHelper.GetIntParam(Context.Request, "PageSize", Int32.MaxValue);
                qp.Where.Add(new SearchParam(Playngo_ClientZone_Files._.Status, (Int32)EnumFileStatus.Approved, SearchType.Equal));
                qp.Where.Add(new SearchParam(Playngo_ClientZone_Files._.PortalId, Context.PortalId, SearchType.Equal));
                qp.Where.Add(new SearchParam(Playngo_ClientZone_Files._.ID, ImageIds.Trim(','), SearchType.In));


                int RecordCount = 0;
                List <Playngo_ClientZone_Files> fileList = Playngo_ClientZone_Files.FindAll(qp, out RecordCount);



                TemplateFormat xf = new TemplateFormat();



                foreach (var fileItem in fileList)
                {
                    int index = fileList.IndexOf(fileItem); //index 为索引值

                    Dictionary <String, Object> jsonPicture = new Dictionary <String, Object>();

                    jsonPicture.Add("Pages", qp.Pages);


                    jsonPicture.Add("ID", fileItem.ID);

                    jsonPicture.Add("CreateTime", fileItem.LastTime);

                    jsonPicture.Add("Name", WebHelper.leftx(fileItem.Name, 20, "..."));
                    jsonPicture.Add("Extension", fileItem.FileExtension);


                    String ThumbnailUrl = Context.ViewLinkUrl(String.Format("MediaID={0}", fileItem.ID));
                    jsonPicture.Add("ThumbnailUrl", ThumbnailUrl);
                    jsonPicture.Add("FileUrl", Context.GetPhotoPath(fileItem.FilePath));

                    jsonPicture.Add("Thumbnail", String.Format("<img style=\"border-width:0px; max-height:60px;max-width:80px;\"  src=\"{0}\"  /> ", ThumbnailUrl));
                    //判断当前文件是否为图片
                    if (!String.IsNullOrEmpty(fileItem.FileExtension) && ("gif,jpg,jpeg,bmp,png").IndexOf(fileItem.FileExtension, StringComparison.CurrentCultureIgnoreCase) >= 0)
                    {
                        jsonPicture.Add("IsVideo", false);
                        jsonPicture.Add("IsPicture", true);
                    }
                    else if (!String.IsNullOrEmpty(fileItem.FileExtension) && ("mp4,mkv,avi,ogv,webm,m4v").IndexOf(fileItem.FileExtension, StringComparison.CurrentCultureIgnoreCase) >= 0)
                    {
                        jsonPicture.Add("IsVideo", true);
                        jsonPicture.Add("IsPicture", false);


                        switch (fileItem.FileExtension)
                        {
                        case "mp4": jsonPicture.Add("IsMp4", true); break;

                        case "m4v": jsonPicture.Add("IsM4v", true); break;

                        case "ogv": jsonPicture.Add("IsOgv", true); break;

                        case "webm": jsonPicture.Add("IsWebm", true); break;

                        default: break;
                        }
                    }
                    else if (!String.IsNullOrEmpty(fileItem.FileExtension) && ("flv,swf").IndexOf(fileItem.FileExtension, StringComparison.CurrentCultureIgnoreCase) >= 0)
                    {
                        jsonPicture.Add("IsFlash", true);
                        jsonPicture.Add("IsPicture", false);
                        jsonPicture.Add("Guid", Guid.NewGuid().ToString());
                    }
                    else
                    {
                        jsonPicture.Add("IsVideo", false);
                        jsonPicture.Add("IsPicture", false);
                    }

                    jsonPicture.Add("Json", jsSerializer.Serialize(jsonPicture));

                    jsonPictures.Add(index.ToString(), jsonPicture);
                }

                jsonPictures.Add("ResultCount", jsonPictures.Count);
                jsonPictures.Add("Result", "success");
            }
            else
            {
                jsonPictures.Add("ResultCount", 0);
                jsonPictures.Add("Result", "error");
            }


            //转换数据为json

            ResponseString = jsSerializer.Serialize(jsonPictures);
        }
예제 #2
0
        public void Execute(BasePage Context)
        {
            Dictionary <String, Object> jsonPicture = new Dictionary <String, Object>();

            Int32 MediaID = WebHelper.GetIntParam(Context.Request, "MediaID", 0);

            if (MediaID > 0)
            {
                Playngo_ClientZone_Files PictureItem = Playngo_ClientZone_Files.FindByKeyForEdit(MediaID);
                if (PictureItem != null && PictureItem.ID > 0)
                {
                    jsonPicture.Add("ID", PictureItem.ID);
                    jsonPicture.Add("CreateTime", PictureItem.LastTime);
                    jsonPicture.Add("Name", PictureItem.Name);
                    jsonPicture.Add("Extension", PictureItem.FileExtension);
                    String ThumbnailUrl = Context.ViewLinkUrl(String.Format("MediaID={0}", PictureItem.ID));
                    jsonPicture.Add("ThumbnailUrl", ThumbnailUrl);
                    jsonPicture.Add("FileUrl", Context.GetPhotoPath(PictureItem.FilePath));


                    jsonPicture.Add("Thumbnail", String.Format("<img style=\"border-width:0px; max-height:60px;max-width:80px;\"  src=\"{0}\"  /> ", ThumbnailUrl));

                    //判断当前文件是否为图片
                    if (!String.IsNullOrEmpty(PictureItem.FileExtension) && ("gif,jpg,jpeg,bmp,png").IndexOf(PictureItem.FileExtension, StringComparison.CurrentCultureIgnoreCase) >= 0)
                    {
                        jsonPicture.Add("IsVideo", false);
                        jsonPicture.Add("IsPicture", true);
                    }
                    else if (!String.IsNullOrEmpty(PictureItem.FileExtension) && ("mp4,mkv,avi,ogv,webm,m4v").IndexOf(PictureItem.FileExtension, StringComparison.CurrentCultureIgnoreCase) >= 0)
                    {
                        jsonPicture.Add("IsVideo", true);
                        jsonPicture.Add("IsPicture", false);


                        switch (PictureItem.FileExtension)
                        {
                        case "mp4": jsonPicture.Add("IsMp4", true); break;

                        case "m4v": jsonPicture.Add("IsM4v", true); break;

                        case "ogv": jsonPicture.Add("IsOgv", true); break;

                        case "webm": jsonPicture.Add("IsWebm", true); break;

                        default: break;
                        }
                    }
                    else if (!String.IsNullOrEmpty(PictureItem.FileExtension) && ("flv,swf").IndexOf(PictureItem.FileExtension, StringComparison.CurrentCultureIgnoreCase) >= 0)
                    {
                        jsonPicture.Add("IsFlash", true);
                        jsonPicture.Add("IsPicture", false);
                        jsonPicture.Add("Guid", Guid.NewGuid().ToString());
                    }
                    else
                    {
                        jsonPicture.Add("IsVideo", false);
                        jsonPicture.Add("IsPicture", false);
                    }
                }
            }

            //转换数据为json
            JavaScriptSerializer jsSerializer = new JavaScriptSerializer();

            ResponseString = jsSerializer.Serialize(jsonPicture);
        }