예제 #1
0
        // Delete file from the server
        private void DeleteFile(HttpContext context)
        {
            Int32 PhotoID = WebHelper.GetIntParam(context.Request, "ID", 0);
            Playngo_ClientZone_Files PhotoItem = Playngo_ClientZone_Files.FindByKeyForEdit(PhotoID);

            if (PhotoItem != null && PhotoItem.ID > 0)
            {
                //要删除实际的文件
                String DeletePath = HttpContext.Current.Server.MapPath(GetPhotoPath(PhotoItem.FilePath));



                //删除文件
                if (File.Exists(DeletePath))
                {
                    try
                    {
                        File.Delete(DeletePath);
                    }
                    catch { }
                }
                //删除记录
                PhotoItem.Delete();
            }
        }
        /// <summary>
        /// 状态应用按钮事件
        /// </summary>
        protected void btnApply_Click(object sender, EventArgs e)
        {
            try
            {
                Int32 Status = WebHelper.GetIntParam(Request, ddlStatus.UniqueID, -1);

                if (Status >= 0)
                {
                    string   Checkbox_Value       = WebHelper.GetStringParam(Request, "Checkbox", "");
                    string[] Checkbox_Value_Array = Checkbox_Value.Split(',');
                    Int32    IDX = 0;
                    mTips.IsPostBack = true;
                    for (int i = 0; i < Checkbox_Value_Array.Length; i++)
                    {
                        if (Int32.TryParse(Checkbox_Value_Array[i], out IDX))
                        {
                            Playngo_ClientZone_Files Multimedia = Playngo_ClientZone_Files.FindByKeyForEdit(IDX);
                            if (Multimedia != null && Multimedia.ID > 0)
                            {
                                //if (Multimedia.Status == (Int32)EnumFileStatus.Recycle && Status == (Int32)EnumFileStatus.Recycle)
                                //{
                                //要删除实际的文件
                                String DeletePath = Server.MapPath(GetPhotoPath(Multimedia.FilePath));
                                if (Multimedia.Delete() > 0)
                                {
                                    //删除文件
                                    if (File.Exists(DeletePath))
                                    {
                                        File.Delete(DeletePath);
                                    }

                                    //操作成功
                                    mTips.LoadMessage("DeleteMediaLibrarySuccess", EnumTips.Success, this, new String[] { Multimedia.FileName });
                                }
                                else
                                {
                                    //操作失败
                                    mTips.LoadMessage("DeleteMediaLibraryError", EnumTips.Success, this, new String[] { Multimedia.FileName });
                                }

                                //}
                                //else
                                //{
                                //    Multimedia.Status = Status;
                                //    if (Multimedia.Update() > 0)
                                //    {
                                //    }
                                //}
                            }
                        }
                    }
                    BindDataList();
                }
            }
            catch (Exception ex)
            {
                ProcessModuleLoadException(ex);
            }
        }
        /// <summary>
        /// 列表上的项删除事件
        /// </summary>
        protected void btnRemove_Click(object sender, EventArgs e)
        {
            try
            {
                LinkButton btnRemove = (LinkButton)sender;

                if (btnRemove != null && !String.IsNullOrEmpty(btnRemove.CommandArgument))
                {
                    mTips.IsPostBack = true;

                    Playngo_ClientZone_Files Multimedia = Playngo_ClientZone_Files.FindByKeyForEdit(btnRemove.CommandArgument);

                    if (Multimedia != null && Multimedia.ID > 0)
                    {
                        //if (Multimedia.Status == (Int32)EnumFileStatus.Recycle)
                        //{
                        //要删除实际的文件
                        String DeletePath = Server.MapPath(GetPhotoPath(Multimedia.FilePath));
                        if (Multimedia.Delete() > 0)
                        {
                            //删除文件
                            if (File.Exists(DeletePath))
                            {
                                File.Delete(DeletePath);
                            }

                            //操作成功
                            mTips.LoadMessage("DeleteMediaLibrarySuccess", EnumTips.Success, this, new String[] { Multimedia.FileName });
                        }
                        else
                        {
                            //操作失败
                            mTips.LoadMessage("DeleteMediaLibraryError", EnumTips.Success, this, new String[] { Multimedia.FileName });
                        }
                        //}
                        //else
                        //{
                        //    Multimedia.Status = (Int32)EnumFileStatus.Recycle;
                        //    if (Multimedia.Update() > 0)
                        //    {
                        //        //移动到回收站操作成功
                        //        mTips.LoadMessage("DeleteCommentSuccess", EnumTips.Success, this, new String[] { Multimedia.FileName });
                        //    }
                        //    else
                        //    {
                        //        //移动到回收站操作失败
                        //        mTips.LoadMessage("DeleteCommentError", EnumTips.Success, this, new String[] { Multimedia.FileName });
                        //    }
                        //}
                        BindDataList();
                    }
                }
            }
            catch (Exception ex)
            {
                ProcessModuleLoadException(ex);
            }
        }
예제 #4
0
        public void Execute(BasePage Context)
        {
            Int32 FileId = WebHelper.GetIntParam(Context.Request, "FileId", 0);

            if (FileId > 0)
            {
                var FileItem = Playngo_ClientZone_DownloadFile.FindByKeyForEdit(FileId);
                if (FileItem != null && FileItem.ID > 0 && !String.IsNullOrEmpty(FileItem.Options))
                {
                    if (Context.IsPreRoleView(FileItem.Per_AllUsers, FileItem.Per_Roles) && Context.IsPreJurisdictionView(FileItem.Per_AllJurisdictions, FileItem.Per_Jurisdictions))
                    {
                        var FileItemOptions = ConvertTo.Deserialize <List <KeyValueEntity> >(FileItem.Options);
                        if (FileItemOptions != null)
                        {
                            TemplateFormat           xf         = new TemplateFormat(Context);
                            Playngo_ClientZone_Files Multimedia = new Playngo_ClientZone_Files();
                            String UploadFile = xf.GetFilePath(xf.ViewItemSettingT <String>(FileItem.Options, "UploadFile", ""), Context, out Multimedia);
                            if (!String.IsNullOrEmpty(UploadFile))
                            {
                                UploadFile = Context.Server.MapPath(UploadFile);
                                if (File.Exists(UploadFile))
                                {
                                    String FileName = String.Format("{0}.{1}", Multimedia.Name, Multimedia.FileExtension);
                                    //FileSystemUtils.DownloadFile(UploadFile,String.Format("{0}_{1}{2}", FileItem.Title, FileItem.Version,  Path.GetExtension(UploadFile)));
                                    //FileSystemUtils.DownloadFile(UploadFile);

                                    FileManager file = new FileManager();

                                    file.WriteFileToResponse(new System.IO.FileInfo(UploadFile), ContentDisposition.Attachment);
                                    IsResponseWrite = false;
                                }
                            }
                            else
                            {
                                //当前文件找不到
                            }
                        }
                        else
                        {
                            //没有添加文件
                        }
                    }
                    else
                    {
                        //没有权限下载
                    }
                }
                else
                {
                    ResponseString = "没找到数据怎么搞";
                }
            }
            else
            {
                ResponseString = "传过来的文件编号都不对";
            }
        }
예제 #5
0
        public String ViewPicture(Playngo_ClientZone_Files DataItem, PortalSettings ps, String ModulePath)
        {
            String Picture = String.Format("{0}Resource/images/DefaultPhoto.png", ModulePath);

            if (DataItem != null && DataItem.ID > 0)
            {
                Picture = GetPhotoPath(DataItem, ps);
            }
            return(Picture);
        }
예제 #6
0
        /// <summary>
        /// 获取图片的路径
        /// </summary>
        /// <param name="media">媒体文件的实体</param>
        /// <returns></returns>
        public String GetPhotoPath(Playngo_ClientZone_Files media)
        {
            String PhotoPath = String.Empty;

            if (media != null && media.ID > 0)
            {
                PhotoPath = GetPhotoPath(media.FilePath);
            }
            return(PhotoPath);
        }
예제 #7
0
 private void SetValues(Playngo_ClientZone_Files PhotoItem, int fileLength, PortalSettings ps, String ModulePath)
 {
     name          = WebHelper.leftx(PhotoItem.Name, 35, "...");
     type          = "image/png";
     size          = PhotoItem.FileSize * 1024;
     progress      = "1.0";
     url           = ViewPicture(PhotoItem, ps, ModulePath);
     thumbnail_url = GetPhotoExtension(PhotoItem.FileExtension, PhotoItem.FilePath, ps, ModulePath);
     delete_url    = String.Format("{2}Resource_jQueryFileUpload.ashx?ID={0}&type=DELETE&{1}", PhotoItem.ID, WebHelper.GetScriptNameQueryString, ModulePath);
     delete_type   = "Event";
 }
        /// <summary>
        /// 绑定列表
        /// </summary>
        private void BindDataList()
        {
            QueryParam qp = new QueryParam();

            qp.OrderType = OrderType;
            if (!String.IsNullOrEmpty(Orderfld))
            {
                qp.Orderfld = Orderfld;
            }
            else
            {
                qp.Orderfld = Playngo_ClientZone_Files._.ID;
            }

            #region "分页的一系列代码"


            int RecordCount = 0;
            int pagesize    = qp.PageSize = Settings_General_ManagerPerPage;
            qp.PageIndex = PageIndex;


            #endregion

            //查询的方法
            qp.Where = BindSearch();

            List <Playngo_ClientZone_Files> Comments = Playngo_ClientZone_Files.FindAll(qp, out RecordCount);
            qp.RecordCount      = RecordCount;
            RecordPages         = qp.Pages;
            lblRecordCount.Text = String.Format("{0} {2} / {1} {3}", RecordCount, RecordPages, ViewResourceText("Title_Items", "Items"), ViewResourceText("Title_Pages", "Pages"));

            Boolean is_admin = !IsAdministrator && !IsAdmin;

            hlFileMateAll.Text   = String.Format("{1} ({0})", Playngo_ClientZone_Files.FindCountByType(PortalId, Visibility, -1, is_admin, UserId), ViewResourceText("hlFileMateAll", "All"));
            hlFileMateImage.Text = String.Format("{1} ({0})", Playngo_ClientZone_Files.FindCountByType(PortalId, Visibility, (Int32)EnumFileMate.Image, is_admin, UserId), ViewResourceText("hlFileMateImage", "Image"));
            hlFileMateZip.Text   = String.Format("{1} ({0})", Playngo_ClientZone_Files.FindCountByType(PortalId, Visibility, (Int32)EnumFileMate.Zip, is_admin, UserId), ViewResourceText("hlFileMateZip", "Zip"));
            hlFileMateVideo.Text = String.Format("{1} ({0})", Playngo_ClientZone_Files.FindCountByType(PortalId, Visibility, (Int32)EnumFileMate.Video, is_admin, UserId), ViewResourceText("hlFileMateVideo", "Video"));
            hlFileMateDoc.Text   = String.Format("{1} ({0})", Playngo_ClientZone_Files.FindCountByType(PortalId, Visibility, (Int32)EnumFileMate.Doc, is_admin, UserId), ViewResourceText("hlFileMateDoc", "Doc"));


            //ctlPagingControl.TotalRecords = RecordCount;

            //if (RecordCount <= pagesize)
            //{
            //    ctlPagingControl.Visible = false;

            //}

            gvCommentList.DataSource = Comments;
            gvCommentList.DataBind();
            BindGridViewEmpty <Playngo_ClientZone_Files>(gvCommentList, new Playngo_ClientZone_Files());
        }
예제 #9
0
        /// <summary>
        /// 列表行绑定
        /// </summary>
        protected void gvEventList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //还原出数据
                Playngo_ClientZone_Files Media = e.Row.DataItem as Playngo_ClientZone_Files;

                if (Media != null && Media.ID > 0)
                {
                    Label lblFileExtension = e.Row.FindControl("lblFileExtension") as Label;
                    lblFileExtension.Text = Media.FileExtension;

                    Image imgFileName = e.Row.FindControl("imgFileName") as Image;

                    HyperLink hlFileName = e.Row.FindControl("hlFileName") as HyperLink;
                    hlFileName.Text        = Media.FileName.Replace("." + Media.FileExtension, "");
                    imgFileName.ImageUrl   = GetPhotoExtension(Media.FileExtension, Media.FilePath);
                    hlFileName.NavigateUrl = GetPhotoPath(Media.FilePath);

                    HyperLink hlAdd = e.Row.FindControl("hlAdd") as HyperLink;

                    if (InsertType)
                    {
                        //插入到文章内容
                        hlAdd.Attributes.Add("onclick", String.Format("ReturnHtmlPicture('{0}',{1});", GetPhotoExtension(Media.FileExtension, Media.FilePath), Media.ID));
                    }
                    else
                    {
                        hlAdd.Attributes.Add("onclick", String.Format("ReturnPicture('{0}',{1});", GetPhotoExtension(Media.FileExtension, Media.FilePath), Media.ID));
                    }

                    //发布者信息
                    e.Row.Cells[1].Text = "--";
                    if (Media.LastUser > 0)
                    {
                        UserInfo uInfo = UserController.GetUserById(PortalId, Media.LastUser);
                        if (uInfo != null && uInfo.UserID > 0)
                        {
                            e.Row.Cells[1].Text = String.Format("{0}<br />{1}", uInfo.Username, uInfo.DisplayName);
                        }
                    }


                    //发布时间
                    e.Row.Cells[2].Text = Media.LastTime.ToShortDateString();

                    //状态
                    e.Row.Cells[3].Text = EnumHelper.GetEnumTextVal(Media.Status, typeof(EnumFileStatus));
                }
            }
        }
예제 #10
0
        /// <summary>
        /// 显示URL控件存放的值
        /// </summary>
        /// <param name="UrlValue"></param>
        /// <param name="IsPhotoExtension">是否显示扩展名图片</param>
        /// <returns></returns>
        public String ViewLinkUrl(String UrlValue, Boolean IsPhotoExtension)
        {
            String DefaultValue = String.Empty;

            if (!String.IsNullOrEmpty(UrlValue) && UrlValue != "0")
            {
                if (UrlValue.IndexOf("FileID=", StringComparison.CurrentCultureIgnoreCase) >= 0)
                {
                    int FileID = 0;
                    if (int.TryParse(UrlValue.Replace("FileID=", ""), out FileID) && FileID > 0)
                    {
                        var fi = DotNetNuke.Services.FileSystem.FileManager.Instance.GetFile(FileID);
                        if (fi != null && fi.FileId > 0)
                        {
                            DefaultValue = string.Format("{0}{1}{2}", PortalSettings.HomeDirectory, fi.Folder, Server.UrlPathEncode(fi.FileName));
                        }
                    }
                }
                else if (UrlValue.IndexOf("MediaID=", StringComparison.CurrentCultureIgnoreCase) >= 0)
                {
                    DefaultValue = String.Format("{0}Resource/images/no_image.png", ModulePath);

                    int MediaID = 0;
                    if (int.TryParse(UrlValue.Replace("MediaID=", ""), out MediaID) && MediaID > 0)
                    {
                        Playngo_ClientZone_Files Multimedia = Playngo_ClientZone_Files.FindByID(MediaID);
                        if (Multimedia != null && Multimedia.ID > 0)
                        {
                            if (IsPhotoExtension)
                            {
                                DefaultValue = Server.UrlPathEncode(GetPhotoExtension(Multimedia.FileExtension, Multimedia.FilePath));// String.Format("{0}{1}", bpm.ClientZone_PortalSettings.HomeDirectory, Multimedia.FilePath);
                            }
                            else
                            {
                                DefaultValue = Server.UrlPathEncode(GetPhotoPath(Multimedia.FilePath));
                            }
                        }
                    }
                }
                else if (UrlValue.IndexOf("TabID=", StringComparison.CurrentCultureIgnoreCase) >= 0)
                {
                    DefaultValue = Globals.NavigateURL(Convert.ToInt32(UrlValue.Replace("TabID=", "")), false, PortalSettings, Null.NullString, "", "");
                }
                else
                {
                    DefaultValue = UrlValue;
                }
            }
            return(DefaultValue);
        }
예제 #11
0
        /// <summary>
        /// 绑定列表
        /// </summary>
        private void BindDataList()
        {
            QueryParam qp = new QueryParam();

            qp.OrderType = OrderType;
            if (!String.IsNullOrEmpty(Orderfld))
            {
                qp.Orderfld = Orderfld;
            }
            else
            {
                qp.Orderfld = Playngo_ClientZone_Files._.ID;
            }

            #region "分页的一系列代码"


            int RecordCount = 0;
            int pagesize    = qp.PageSize = 10;
            qp.PageIndex = PageIndex;


            #endregion

            //查询的方法
            qp.Where = BindSearch();

            List <Playngo_ClientZone_Files> Events = Playngo_ClientZone_Files.FindAll(qp, out RecordCount);
            qp.RecordCount      = RecordCount;
            RecordPages         = qp.Pages;
            lblRecordCount.Text = String.Format("{0} {2} / {1} {3}", RecordCount, RecordPages, ViewResourceText("Title_Items", "Items"), ViewResourceText("Title_Pages", "Pages"));


            //Boolean is_admin = !IsAdministrator && !IsAdmin;



            //ctlPagingControl.TotalRecords = RecordCount;

            //if (RecordCount <= pagesize)
            //{
            //    ctlPagingControl.Visible = false;

            //}

            gvEventList.DataSource = Events;
            gvEventList.DataBind();
            BindGridViewEmpty <Playngo_ClientZone_Files>(gvEventList, new Playngo_ClientZone_Files());
        }
        /// <summary>
        /// 批量改名
        /// 由于之前导入文件会把多加一个.zip的名称
        /// 暂时不删除
        /// </summary>
        public void BatchReNames()
        {
            Int32 ReName = WebHelper.GetIntParam(Request, "rename", 0);

            if (ReName > 0)
            {
                Int32      RecordCount = 0;
                QueryParam qp          = new QueryParam();
                if (Visibility >= 0)
                {
                    qp.Where.Add(new SearchParam(Playngo_ClientZone_Files._.Extension1, Visibility, SearchType.Equal));
                }

                qp.Where.Add(new SearchParam(Playngo_ClientZone_Files._.FileName, ".zip.zip", SearchType.Like));


                List <Playngo_ClientZone_Files> Files = Playngo_ClientZone_Files.FindAll(qp, out RecordCount);
                if (Files != null && Files.Count > 0)
                {
                    foreach (var file in Files)
                    {
                        //得到新的文件名称和路径
                        String NewFileName = Common.ReplaceNoCase(file.FileName, ".zip.zip", ".zip");
                        String NewFilePath = Common.ReplaceNoCase(file.FilePath, ".zip.zip", ".zip");
                        var    NewFileInfo = new FileInfo(MapPath(String.Format("{0}{1}", PortalSettings.HomeDirectory, NewFilePath)));

                        //得到老的文件路径
                        var OldFileInfo = new FileInfo(MapPath(String.Format("{0}{1}", PortalSettings.HomeDirectory, file.FilePath)));

                        //需要将存储的文件更名
                        OldFileInfo.MoveTo(NewFileInfo.FullName);

                        //需要移除掉重复的文件名
                        file.FileName = NewFileName;

                        //需要移除掉路径中重复的文件名
                        file.FilePath = NewFilePath;

                        //保存当前的修改
                        file.Update();
                    }
                }
            }
        }
        /// <summary>
        /// 绑定查询的方法
        /// </summary>
        private List <SearchParam> BindSearch()
        {
            List <SearchParam> Where = new List <SearchParam>();

            Where.Add(new SearchParam("PortalId", PortalId, SearchType.Equal));
            //Where.Add(new SearchParam("ModuleId", ModuleId, SearchType.Equal));

            //不是管理员,只能看到自己发布文章的评论
            if (!IsAdministrator && !IsAdmin)
            {
                Where.Add(new SearchParam(Playngo_ClientZone_Files._.LastUser, UserId, SearchType.Equal));
            }
            //else if (ViewSettingT<string>("General.MediaLibrary", "public") == "private")
            //{
            //    Where.Add(new SearchParam(Playngo_ClientZone_Files._.LastUser, UserId, SearchType.Equal));
            //}


            //筛选文章的状态
            if (FileType >= 0)
            {
                Where = Playngo_ClientZone_Files.ByType(Where, FileType);
            }


            if (!String.IsNullOrEmpty(Search_Title))
            {
                txtSearch.Text = HttpUtility.UrlDecode(Search_Title);
                Where.Add(new SearchParam(Playngo_ClientZone_Files._.Name, HttpUtility.UrlDecode(Search_Title), SearchType.Like));
            }



            if (Visibility >= 0)
            {
                Where.Add(new SearchParam(Playngo_ClientZone_Files._.Extension1, Visibility, SearchType.Equal));
            }


            return(Where);
        }
예제 #14
0
        private void DeliverFile(HttpContext context)
        {
            Playngo_ClientZone_Files DataItem = Playngo_ClientZone_Files.FindByKeyForEdit(WebHelper.GetStringParam(context.Request, "PhotoID", "0"));

            if (DataItem != null && DataItem.ID > 0)
            {
                String Picture = GetPhotoPath(DataItem);

                if (!String.IsNullOrEmpty(Picture) && File.Exists(context.Server.MapPath(Picture)))
                {
                    context.Response.AddHeader("Content-Disposition", "attachment; filename=\"" + DataItem.FileName + "\"");
                    context.Response.ContentType = "application/octet-stream";
                    context.Response.ClearContent();
                    context.Response.WriteFile(context.Server.MapPath(Picture));
                }
                else
                {
                    context.Response.StatusCode = 404;
                }
            }
            else
            {
                context.Response.StatusCode = 404;
            }



            //var filename = context.Request["PhotoID"];
            //var filePath = StorageRoot + filename;

            //if (File.Exists(filePath)) {
            //    context.Response.AddHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
            //    context.Response.ContentType = "application/octet-stream";
            //    context.Response.ClearContent();
            //    context.Response.WriteFile(filePath);
            //} else
            //    context.Response.StatusCode = 404;
        }
        public void Execute(BasePage Context)
        {
            //根据ID查询出缩略的方式
            Int32  PhotoID = WebHelper.GetIntParam(Context.Request, "ID", 0);
            Int32  Width   = WebHelper.GetIntParam(Context.Request, "width", 200);
            Int32  height  = WebHelper.GetIntParam(Context.Request, "height", 200);
            String Mode    = WebHelper.GetStringParam(Context.Request, "mode", "AUTO");


            String ImagePath = Context.MapPath(String.Format("{0}/Resource/images/no_image.png", Context.TemplateSourceDirectory));

            Boolean isPush = false;

            if (PhotoID > 0)
            {
                Playngo_ClientZone_Files PhotoItem = Playngo_ClientZone_Files.FindByID(PhotoID);
                if (PhotoItem != null && PhotoItem.ID > 0)
                {
                    //拼接图片的地址
                    //ImagePath = String.Format("{0}ClientZone\\{1}\\{2}\\{3}", PortalSettings.HomeDirectoryMapPath, PhotoItem.ModuleId, PhotoItem.AlbumID, PhotoItem.FileName);
                    ImagePath = Context.MapPath(String.Format("{0}{1}", Context.PortalSettings.HomeDirectory, PhotoItem.FilePath));


                    String ThumbnailPath = String.Format("{0}ClientZone\\thumbnails\\{1}\\{2}_{3}_{4}_{5}.{6}", Context.PortalSettings.HomeDirectoryMapPath, PhotoItem.ModuleId, PhotoItem.ID, Width, height, Mode, PhotoItem.FileExtension);

                    FileInfo ThumbnailFile = new FileInfo(ThumbnailPath);

                    if (!ThumbnailFile.Directory.Exists)
                    {
                        ThumbnailFile.Directory.Create();
                    }


                    isPush = true;

                    if (ThumbnailFile.Exists)
                    {
                        Context.Response.Clear();
                        Context.Response.AddHeader("content-disposition", "attachment;filename=" + Context.Server.UrlEncode(ThumbnailFile.Name));
                        Context.Response.AddHeader("content-length", ThumbnailFile.Length.ToString());
                        Context.Response.ContentType     = PhotoItem.FileMate;
                        Context.Response.Charset         = "utf-8";
                        Context.Response.ContentEncoding = Encoding.UTF8;
                        Context.Response.WriteFile(ThumbnailFile.FullName);
                        Context.Response.Flush();
                        Context.Response.End();
                    }
                    else
                    {
                        GenerateThumbnail.PushThumbnail(ImagePath, ThumbnailPath, Width, height, Mode);
                    }
                }
            }


            if (!isPush)
            {
                FileInfo NoFile = new FileInfo(ImagePath);

                Context.Response.Clear();
                Context.Response.AddHeader("content-disposition", "attachment;filename=" + Context.Server.UrlEncode(NoFile.Name));
                Context.Response.AddHeader("content-length", NoFile.Length.ToString());
                Context.Response.ContentType     = FileSystemUtils.GetContentType(NoFile.Extension.Replace(".", ""));
                Context.Response.Charset         = "utf-8";
                Context.Response.ContentEncoding = Encoding.UTF8;
                Context.Response.WriteFile(NoFile.FullName);
                Context.Response.Flush();
                Context.Response.End();
            }
        }
예제 #16
0
        public Int32 SynchronizeAllFiles(FileInfo SynchronizeFile)
        {
            Int32 SynchronizeFileCount = 0;


            Playngo_ClientZone_Files PhotoItem = new Playngo_ClientZone_Files();

            PhotoItem.ModuleId = ModuleId;
            PhotoItem.PortalId = PortalId;


            PhotoItem.FileName = SynchronizeFile.Name;
            PhotoItem.FileSize = Convert.ToInt32(SynchronizeFile.Length / 1024);
            PhotoItem.FileMate = WebHelper.leftx(FileSystemUtils.GetContentType(Path.GetExtension(PhotoItem.FileName).Replace(".", "")), 30);

            PhotoItem.FileExtension = System.IO.Path.GetExtension(PhotoItem.FileName).Replace(".", "");
            PhotoItem.Name          = System.IO.Path.GetFileName(PhotoItem.FileName).Replace(Path.GetExtension(PhotoItem.FileName), "");

            PhotoItem.Status = (Int32)EnumFileStatus.Approved;

            try
            {
                if (("png,gif,jpg,jpeg,bmp").IndexOf(PhotoItem.FileExtension) >= 0)
                {
                    //图片的流
                    System.Drawing.Image image = System.Drawing.Image.FromFile(SynchronizeFile.FullName);
                    PhotoItem.ImageWidth  = image.Width;
                    PhotoItem.ImageHeight = image.Height;

                    PhotoItem.Exif = Common.Serialize <EXIFMetaData.Metadata>(new EXIFMetaData().GetEXIFMetaData(image));
                }
            }
            catch
            {
            }

            PhotoItem.LastTime = xUserTime.UtcTime();
            PhotoItem.LastIP   = WebHelper.UserHost;
            PhotoItem.LastUser = UserInfo.UserID;


            PhotoItem.Extension1 = Visibility;


            //根据菜单来选择导入的文件夹
            String SaveDirPath = "uploads";

            if (Visibility == 1)
            {
                SaveDirPath = "downloads";
            }



            //将文件存储的路径整理好
            String fileName = PhotoItem.Name; //文件名称
            String WebPath  = String.Format("ClientZone/{0}/{1}/{2}/{3}/", SaveDirPath, PhotoItem.LastTime.Year, PhotoItem.LastTime.Month, PhotoItem.LastTime.Day);
            //检测文件存储路径是否有相关的文件
            FileInfo fInfo = new FileInfo(HttpContext.Current.Server.MapPath(String.Format("{0}{1}{2}.{3}", PortalSettings.HomeDirectory, WebPath, fileName, PhotoItem.FileExtension)));

            //检测文件夹是否存在
            if (!System.IO.Directory.Exists(fInfo.Directory.FullName))
            {
                System.IO.Directory.CreateDirectory(fInfo.Directory.FullName);
            }
            else
            {
                Int32 j = 1;
                while (fInfo.Exists)
                {
                    //文件已经存在了
                    fileName = String.Format("{0}_{1}", PhotoItem.Name, j);
                    fInfo    = new FileInfo(HttpContext.Current.Server.MapPath(String.Format("{0}{1}{2}.{3}", PortalSettings.HomeDirectory, WebPath, fileName, PhotoItem.FileExtension)));
                    j++;
                }
            }

            PhotoItem.FilePath = String.Format("{0}{1}.{2}", WebPath, fileName, PhotoItem.FileExtension);
            PhotoItem.FileName = String.Format("{0}.{1}", fileName, PhotoItem.FileExtension);

            try
            {
                if (!fInfo.Directory.Exists)
                {
                    fInfo.Directory.Create();
                }
                //异步移动文件到文件夹中
                List <String> SynchronizeFileQueue = new List <string>();
                SynchronizeFileQueue.Add(SynchronizeFile.FullName);
                SynchronizeFileQueue.Add(fInfo.FullName);
                ManagedThreadPool.QueueUserWorkItem(new WaitCallback(ThreadMoveTo), SynchronizeFileQueue);
            }
            catch (Exception ex)
            {
            }

            //给上传的相片设置初始的顺序
            QueryParam qp = new QueryParam();

            qp.ReturnFields = qp.Orderfld = Playngo_ClientZone_Files._.Sort;
            qp.OrderType    = 1;
            qp.Where.Add(new SearchParam(Playngo_ClientZone_Files._.PortalId, PhotoItem.PortalId, SearchType.Equal));
            PhotoItem.Sort = Convert.ToInt32(Playngo_ClientZone_Files.FindScalar(qp)) + 2;
            Int32 PhotoId = PhotoItem.Insert();

            if (PhotoId > 0)
            {
                SynchronizeFileCount++;
            }


            return(SynchronizeFileCount);
        }
        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);
        }
예제 #18
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);
        }
예제 #19
0
        // Upload entire file
        private void UploadWholeFile(HttpContext context, List <Resource_FilesStatus> statuses)
        {
            for (int i = 0; i < context.Request.Files.Count; i++)
            {
                var file = context.Request.Files[i];

                if (file != null && !String.IsNullOrEmpty(file.FileName) && file.ContentLength > 0)
                {
                    //To verify that if the suffix name of the uploaded files meets the DNN HOST requirements
                    Boolean retValue = FileSystemUtils.CheckValidFileName(file.FileName);
                    if (retValue)
                    {
                        Playngo_ClientZone_Files PhotoItem = new Playngo_ClientZone_Files();

                        PhotoItem.ModuleId = WebHelper.GetIntParam(context.Request, "ModuleId", 0);
                        PhotoItem.PortalId = WebHelper.GetIntParam(context.Request, "PortalId", 0);


                        PhotoItem.FileName = file.FileName;
                        PhotoItem.FileSize = file.ContentLength / 1024;
                        PhotoItem.FileMate = WebHelper.leftx(FileSystemUtils.GetContentType(Path.GetExtension(PhotoItem.FileName).Replace(".", "")), 30);

                        PhotoItem.FileExtension = System.IO.Path.GetExtension(PhotoItem.FileName).Replace(".", "");
                        PhotoItem.Name          = System.IO.Path.GetFileName(file.FileName).Replace(Path.GetExtension(PhotoItem.FileName), "");
                        PhotoItem.Status        = (Int32)EnumFileStatus.Approved;

                        try
                        {
                            if (("png,gif,jpg,jpeg,bmp").IndexOf(PhotoItem.FileExtension) >= 0)
                            {
                                //图片的流
                                Image image = Image.FromStream(file.InputStream);
                                PhotoItem.ImageWidth  = image.Width;
                                PhotoItem.ImageHeight = image.Height;

                                PhotoItem.Exif = Common.Serialize <EXIFMetaData.Metadata>(new EXIFMetaData().GetEXIFMetaData(image));
                            }
                        }
                        catch
                        {
                        }

                        PhotoItem.LastTime   = xUserTime.UtcTime();
                        PhotoItem.LastIP     = WebHelper.UserHost;
                        PhotoItem.LastUser   = UserInfo.UserID;
                        PhotoItem.Extension1 = Visibility;

                        String SaveDirPath = "uploads";

                        if (Visibility == 1)
                        {
                            SaveDirPath = "downloads";
                        }

                        //将文件存储的路径整理好
                        String fileName = System.IO.Path.GetFileName(file.FileName).Replace("." + PhotoItem.FileExtension, ""); //文件名称
                        String WebPath  = String.Format("ClientZone/{0}/{1}/{2}/{3}/", SaveDirPath, DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day);
                        //检测文件存储路径是否有相关的文件
                        FileInfo fInfo = new FileInfo(HttpContext.Current.Server.MapPath(String.Format("{0}{1}{2}.{3}", PortalSettings.HomeDirectory, WebPath, fileName, PhotoItem.FileExtension)));

                        //检测文件夹是否存在
                        if (!System.IO.Directory.Exists(fInfo.Directory.FullName))
                        {
                            System.IO.Directory.CreateDirectory(fInfo.Directory.FullName);
                        }
                        else
                        {
                            Int32 j = 1;
                            while (fInfo.Exists)
                            {
                                //文件已经存在了
                                fileName = String.Format("{0}_{1}", PhotoItem.Name, j);
                                fInfo    = new FileInfo(HttpContext.Current.Server.MapPath(String.Format("{0}{1}{2}.{3}", PortalSettings.HomeDirectory, WebPath, fileName, PhotoItem.FileExtension)));
                                j++;
                            }
                        }

                        PhotoItem.FilePath = String.Format("{0}{1}.{2}", WebPath, fileName, PhotoItem.FileExtension);
                        PhotoItem.FileName = String.Format("{0}.{1}", fileName, PhotoItem.FileExtension);
                        try
                        {
                            if (!fInfo.Directory.Exists)
                            {
                                fInfo.Directory.Create();

                                // FileSystemUtils.AddFolder(PortalSettings, String.Format("{0}Playngo_PhotoAlbums/{0}/{1}/"), String.Format("{0}Playngo_PhotoAlbums/{0}/{1}/"), (int)DotNetNuke.Services.FileSystem.FolderController.StorageLocationTypes.InsecureFileSystem);
                            }

                            //构造指定存储路径
                            file.SaveAs(fInfo.FullName);
                            //FileSystemUtils.AddFile(PhotoItem.FileName, PhotoItem.PortalId, String.Format("Playngo_PhotoAlbums\\{0}\\{1}\\", PhotoItem.ModuleId, PhotoItem.AlbumID), PortalSettings.HomeDirectoryMapPath, PhotoItem.FileMeta);
                        }
                        catch (Exception ex)
                        {
                        }

                        //给上传的相片设置初始的顺序
                        QueryParam qp = new QueryParam();
                        qp.ReturnFields = qp.Orderfld = Playngo_ClientZone_Files._.Sort;
                        qp.OrderType    = 1;
                        qp.Where.Add(new SearchParam(Playngo_ClientZone_Files._.PortalId, PhotoItem.PortalId, SearchType.Equal));
                        PhotoItem.Sort = Convert.ToInt32(Playngo_ClientZone_Files.FindScalar(qp)) + 2;
                        Int32 PhotoId = PhotoItem.Insert();



                        statuses.Add(new Resource_FilesStatus(PhotoItem, PortalSettings, ModulePath));
                    }
                }
            }
        }
예제 #20
0
 public Resource_FilesStatus(Playngo_ClientZone_Files PhotoItem, int fileLength, PortalSettings ps, String ModulePath)
 {
     SetValues(PhotoItem, fileLength, ps, ModulePath);
 }
예제 #21
0
 public String ThumbnailUrl(Playngo_ClientZone_Files DataItem, PortalSettings ps, String ModulePath)
 {
     return(String.Format("{0}Resource_Service.aspx?Token=thumbnail&PortalId={1}&TabId={2}&ID={3}&width=40&height=40&mode=WH", ModulePath, ps.PortalId, ps.ActiveTab.TabID, DataItem.ID));
 }
예제 #22
0
 public Resource_FilesStatus(Playngo_ClientZone_Files PhotoItem, PortalSettings ps, String ModulePath)
 {
     SetValues(PhotoItem, PhotoItem.FileSize, ps, ModulePath);
 }
        /// <summary>
        /// 列表行绑定
        /// </summary>
        protected void gvCommentList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //还原出数据
                Playngo_ClientZone_Files Media = e.Row.DataItem as Playngo_ClientZone_Files;

                if (Media != null && Media.ID > 0)
                {
                    #region "编辑&删除按钮"
                    HyperLink  hlEdit          = e.Row.FindControl("hlEdit") as HyperLink;
                    HyperLink  hlMobileEdit    = e.Row.FindControl("hlMobileEdit") as HyperLink;
                    LinkButton btnRemove       = e.Row.FindControl("btnRemove") as LinkButton;
                    LinkButton btnMobileRemove = e.Row.FindControl("btnMobileRemove") as LinkButton;
                    //设置按钮的CommandArgument
                    btnRemove.CommandArgument = btnMobileRemove.CommandArgument = Media.ID.ToString();
                    //设置删除按钮的提示
                    //if (Media.Status == (Int32)EnumFileStatus.Recycle)
                    //{
                    btnRemove.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');");
                    btnMobileRemove.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');");
                    //}
                    //else
                    //{
                    //    btnRemove.Attributes.Add("onClick", "javascript:return confirm('" + ViewResourceText("DeleteRecycleItem", "Are you sure to move it to recycle bin?") + "');");
                    //    btnMobileRemove.Attributes.Add("onClick", "javascript:return confirm('" + ViewResourceText("DeleteRecycleItem", "Are you sure to move it to recycle bin?") + "');");
                    //}

                    hlEdit.NavigateUrl = hlMobileEdit.NavigateUrl = xUrl("ID", Media.ID.ToString(), "AddMedia");
                    #endregion

                    //发布者信息
                    e.Row.Cells[3].Text = "--";
                    if (Media.LastUser > 0)
                    {
                        UserInfo uInfo = UserController.GetUserById(PortalId, Media.LastUser);
                        if (uInfo != null && uInfo.UserID > 0)
                        {
                            e.Row.Cells[3].Text = String.Format("{0}<br />{1}", uInfo.Username, uInfo.DisplayName);
                        }
                    }


                    //发布时间
                    e.Row.Cells[4].Text = Media.LastTime.ToShortDateString();

                    //状态
                    e.Row.Cells[5].Text = EnumHelper.GetEnumTextVal(Media.Status, typeof(EnumFileStatus));

                    Label lblFileExtension = e.Row.FindControl("lblFileExtension") as Label;
                    lblFileExtension.Text = Media.FileExtension;

                    Image imgFileName = e.Row.FindControl("imgFileName") as Image;

                    HyperLink hlFileName = e.Row.FindControl("hlFileName") as HyperLink;
                    hlFileName.Text        = Media.FileName.Replace("." + Media.FileExtension, "");
                    imgFileName.ImageUrl   = GetPhotoExtension(Media.FileExtension, Media.FilePath);
                    hlFileName.NavigateUrl = GetPhotoPath(Media.FilePath);

                    Label lblSize = e.Row.FindControl("lblSize") as Label;
                    if (Media.FileSize > 1024)
                    {
                        lblSize.Text = String.Format("{0} MB", Media.FileSize / 1024);
                    }
                    else
                    {
                        lblSize.Text = String.Format("{0} KB", Media.FileSize);
                    }
                }
            }
        }