/// <summary>
        /// 显示图片文件的大小 kb/mb
        /// </summary>
        /// <param name="DataItem"></param>
        /// <param name="FieldName"></param>
        /// <returns></returns>
        public String PictureSize(DNNGo_DNNGalleryPro_Layer DataItem, String FieldName)
        {
            String _PictureSize = "0kb";
            String _PictureUrl  = Convert.ToString(ViewLayerSetting(DataItem, FieldName, ""));

            if (!String.IsNullOrEmpty(_PictureUrl) && _PictureUrl.IndexOf("MediaID=", StringComparison.CurrentCultureIgnoreCase) >= 0)
            {
                int MediaID = 0;
                if (int.TryParse(_PictureUrl.Replace("MediaID=", ""), out MediaID) && MediaID > 0)
                {
                    DNNGo_DNNGalleryPro_Files Multimedia = DNNGo_DNNGalleryPro_Files.FindByID(MediaID);
                    if (Multimedia != null && Multimedia.ID > 0 && Multimedia.FileSize > 0)
                    {
                        if (Multimedia.FileSize > (1024 * 1024))
                        {
                            _PictureSize = String.Format("{0:N}gb", Convert.ToSingle(Multimedia.FileSize) / (1024 * 1024));
                        }
                        else if (Multimedia.FileSize > 1024)
                        {
                            _PictureSize = String.Format("{0:N}mb", Convert.ToSingle(Multimedia.FileSize) / Convert.ToSingle(1024));
                        }
                        else
                        {
                            _PictureSize = String.Format("{0}kb", Multimedia.FileSize);
                        }
                    }
                }
            }
            return(_PictureSize);
        }
Exemple #2
0
        /// <summary>
        /// 绑定查询的方法
        /// </summary>
        private List <SearchParam> BindSearch()
        {
            List <SearchParam> Where = new List <SearchParam>();

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


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


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



            return(Where);
        }
Exemple #3
0
        /// <summary>
        /// 推送图片列表数据
        /// </summary>
        public void PushPictureItem()
        {
            JavaScriptSerializer        jsSerializer = new JavaScriptSerializer();
            Dictionary <String, Object> jsonLayer    = new Dictionary <String, Object>();

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

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


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

            //转换数据为json
            Response.Clear();
            Response.Write(jsSerializer.Serialize(jsonLayer));
            Response.End();
        }
Exemple #4
0
        /// <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))
                        {
                            DNNGo_DNNGalleryPro_Files Multimedia = DNNGo_DNNGalleryPro_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);
            }
        }
Exemple #5
0
        /// <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;

                    DNNGo_DNNGalleryPro_Files Multimedia = DNNGo_DNNGalleryPro_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);
            }
        }
Exemple #6
0
        public String ViewPicture(DNNGo_DNNGalleryPro_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);
        }
Exemple #7
0
        /// <summary>
        /// 获取图片的路径
        /// </summary>
        /// <param name="media">媒体文件的实体</param>
        /// <returns></returns>
        public String GetPhotoPath(DNNGo_DNNGalleryPro_Files media, PortalSettings ps)
        {
            String PhotoPath = String.Empty;

            if (media != null && media.ID > 0)
            {
                PhotoPath = GetPhotoPath(media.FilePath, ps);
            }
            return(PhotoPath);
        }
Exemple #8
0
 private void SetValues(DNNGo_DNNGalleryPro_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   = "POST";
 }
Exemple #9
0
        /// <summary>
        /// 绑定列表
        /// </summary>
        private void BindDataList()
        {
            QueryParam qp = new QueryParam();

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

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


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


            #endregion

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

            List <DNNGo_DNNGalleryPro_Files> Comments = DNNGo_DNNGalleryPro_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"));


            Int32 ByPortalID = Settings_PortalID;
            hlFileMateAll.Text   = String.Format("{1} ({0})", DNNGo_DNNGalleryPro_Files.FindCountByType(ByPortalID, -1), ViewResourceText("hlFileMateAll", "All"));
            hlFileMateImage.Text = String.Format("{1} ({0})", DNNGo_DNNGalleryPro_Files.FindCountByType(ByPortalID, (Int32)EnumFileMate.Image), ViewResourceText("hlFileMateImage", "Image"));
            hlFileMateZip.Text   = String.Format("{1} ({0})", DNNGo_DNNGalleryPro_Files.FindCountByType(ByPortalID, (Int32)EnumFileMate.Zip), ViewResourceText("hlFileMateZip", "Zip"));
            hlFileMateVideo.Text = String.Format("{1} ({0})", DNNGo_DNNGalleryPro_Files.FindCountByType(ByPortalID, (Int32)EnumFileMate.Video), ViewResourceText("hlFileMateVideo", "Video"));
            hlFileMateDoc.Text   = String.Format("{1} ({0})", DNNGo_DNNGalleryPro_Files.FindCountByType(ByPortalID, (Int32)EnumFileMate.Doc), ViewResourceText("hlFileMateDoc", "Doc"));


            //ctlPagingControl.TotalRecords = RecordCount;

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

            //}

            gvCommentList.DataSource = Comments;
            gvCommentList.DataBind();
            BindGridViewEmpty <DNNGo_DNNGalleryPro_Files>(gvCommentList, new DNNGo_DNNGalleryPro_Files());
        }
Exemple #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}", DNNGalleryPro_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)
                    {
                        DNNGo_DNNGalleryPro_Files Multimedia = DNNGo_DNNGalleryPro_Files.FindByID(MediaID);
                        if (Multimedia != null && Multimedia.ID > 0)
                        {
                            if (IsPhotoExtension)
                            {
                                DefaultValue = Server.UrlPathEncode(GetPhotoExtension(Multimedia.FileExtension, Multimedia.FilePath));// String.Format("{0}{1}", bpm.DNNGalleryPro_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, DNNGalleryPro_PortalSettings, Null.NullString, "", "");
                }
                else
                {
                    DefaultValue = UrlValue;
                }
            }
            return(DefaultValue);
        }
        /// <summary>
        /// 绑定列表
        /// </summary>
        private void BindDataList()
        {
            QueryParam qp = new QueryParam();

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

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


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


            #endregion

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

            List <DNNGo_DNNGalleryPro_Files> Articles = DNNGo_DNNGalleryPro_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"));



            //ctlPagingControl.TotalRecords = RecordCount;

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

            //}

            gvArticleList.DataSource = Articles;
            gvArticleList.DataBind();
            BindGridViewEmpty <DNNGo_DNNGalleryPro_Files>(gvArticleList, new DNNGo_DNNGalleryPro_Files());
        }
Exemple #12
0
        /// <summary>
        /// 转换URL链接
        /// </summary>
        /// <param name="UrlValue"></param>
        /// <returns></returns>
        public String ViewLinkUrl(String UrlValue)
        {
            String DefaultValue = String.Empty;

            if (!String.IsNullOrEmpty(UrlValue))
            {
                if (UrlValue.IndexOf("FileID=", StringComparison.CurrentCultureIgnoreCase) == 0)
                {
                    var fi = DotNetNuke.Services.FileSystem.FileManager.Instance.GetFile(Convert.ToInt32(UrlValue.Replace("FileID=", "")));
                    DefaultValue = string.Format("{0}{1}{2}", DNNGalleryPro_PortalSettings.HomeDirectory, fi.Folder, HttpContext.Current.Server.UrlPathEncode(fi.FileName));
                    //DefaultValue = string.Format("{0}{1}{2}", bpm.PortalSettings.HomeDirectory, fi.Folder, fi.FileName);
                }
                else if (UrlValue.IndexOf("TabID=", StringComparison.CurrentCultureIgnoreCase) == 0)
                {
                    DefaultValue = Globals.NavigateURL(Convert.ToInt32(UrlValue.Replace("TabID=", "")), false, DNNGalleryPro_PortalSettings, Null.NullString, "", "");
                }
                else if (UrlValue.IndexOf("MediaID=", StringComparison.CurrentCultureIgnoreCase) == 0)
                {
                    int MediaID = 0;
                    if (int.TryParse(UrlValue.Replace("MediaID=", ""), out MediaID) && MediaID > 0)
                    {
                        DNNGo_DNNGalleryPro_Files Multimedia = DNNGo_DNNGalleryPro_Files.FindByID(MediaID);
                        if (Multimedia != null && Multimedia.ID > 0)
                        {
                            DefaultValue = HttpContext.Current.Server.UrlPathEncode(String.Format("{0}{1}", DNNGalleryPro_PortalSettings.HomeDirectory, Multimedia.FilePath));// String.Format("{0}{1}", bpm.DNNGalleryPro_PortalSettings.HomeDirectory, Multimedia.FilePath);
                        }

                        if (!String.IsNullOrEmpty(DefaultValue))
                        {
                            if (DefaultValue.ToLower().IndexOf("http://") < 0)
                            {
                                DefaultValue = string.Format("http://{0}{1}", WebHelper.GetHomeUrl(), DefaultValue);
                            }
                        }
                    }
                }
                else
                {
                    DefaultValue = UrlValue;
                }
            }
            return(DefaultValue);
        }
 /// <summary>
 /// 显示URL控件存放的值
 /// </summary>
 /// <param name="UrlValue"></param>
 /// <returns></returns>
 public String ViewLinkUrl(String UrlValue, String DefaultValue, int PortalId)
 {
     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 = FileManager.Instance.GetFile(FileID);
                 if (fi != null && fi.FileId > 0)
                 {
                     DefaultValue = string.Format("{0}{1}{2}", bpm.DNNGalleryPro_PortalSettings.HomeDirectory, fi.Folder, bpm.Server.UrlPathEncode(fi.FileName));
                 }
             }
         }
         else if (UrlValue.IndexOf("MediaID=", StringComparison.CurrentCultureIgnoreCase) == 0)
         {
             int MediaID = 0;
             if (int.TryParse(UrlValue.Replace("MediaID=", ""), out MediaID) && MediaID > 0)
             {
                 DNNGo_DNNGalleryPro_Files Multimedia = DNNGo_DNNGalleryPro_Files.FindByID(MediaID);
                 if (Multimedia != null && Multimedia.ID > 0)
                 {
                     DefaultValue = bpm.Server.UrlPathEncode(bpm.GetPhotoPath(Multimedia.FilePath)); // String.Format("{0}{1}", bpm.DNNGalleryPro_PortalSettings.HomeDirectory, Multimedia.FilePath);
                 }
             }
         }
         else if (UrlValue.IndexOf("TabID=", StringComparison.CurrentCultureIgnoreCase) == 0)
         {
             DefaultValue = Globals.NavigateURL(Convert.ToInt32(UrlValue.Replace("TabID=", "")), false, bpm.DNNGalleryPro_PortalSettings, Null.NullString, "", "");
         }
         else
         {
             DefaultValue = UrlValue;
         }
     }
     return(bpm.FullPortalUrl(DefaultValue));
 }
        private void DeliverFile(HttpContext context)
        {
            DNNGo_DNNGalleryPro_Files DataItem = DNNGo_DNNGalleryPro_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;
        }
        // Delete file from the server
        private void DeleteFile(HttpContext context)
        {
            Int32 PhotoID = WebHelper.GetIntParam(context.Request, "ID", 0);
            DNNGo_DNNGalleryPro_Files PhotoItem = DNNGo_DNNGalleryPro_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();
            }
        }
Exemple #16
0
        /// <summary>
        /// 列表行绑定
        /// </summary>
        protected void gvCommentList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //还原出数据
                DNNGo_DNNGalleryPro_Files Media = e.Row.DataItem as DNNGo_DNNGalleryPro_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;
                    lblSize.Text = Common.ConvertFileSize(Media.FileSize);
                }
            }
        }
Exemple #17
0
 public String ThumbnailUrl(DNNGo_DNNGalleryPro_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));
 }
Exemple #18
0
        /// <summary>
        /// 推送图片列表数据
        /// </summary>
        public void PushPictureList()
        {
            QueryParam qp = new QueryParam();

            qp.Orderfld  = DNNGo_DNNGalleryPro_Layer._.ID;
            qp.OrderType = 1;

            qp.PageIndex = WebHelper.GetIntParam(Request, "PageIndex", 1);
            qp.PageSize  = WebHelper.GetIntParam(Request, "PageSize", Int32.MaxValue);
            qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Files._.Status, (Int32)EnumStatus.Activated, SearchType.Equal));
            qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Files._.PortalId, PortalId, SearchType.Equal));


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

            Dictionary <String, Object> jsonLayers = new Dictionary <string, Object>();

            TemplateFormat xf = new TemplateFormat();

            JavaScriptSerializer jsSerializer = new JavaScriptSerializer();

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

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

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


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

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

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


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

                jsonLayer.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)
                {
                    jsonLayer.Add("IsPicture", true);
                }
                else
                {
                    jsonLayer.Add("IsPicture", false);
                }



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

                jsonLayers.Add(index.ToString(), jsonLayer);
            }

            //转换数据为json

            Response.Clear();
            Response.Write(jsSerializer.Serialize(jsonLayers));
            Response.End();
        }
Exemple #19
0
 public Resource_FilesStatus(DNNGo_DNNGalleryPro_Files PhotoItem, int fileLength, PortalSettings ps, String ModulePath)
 {
     SetValues(PhotoItem, fileLength, ps, ModulePath);
 }
Exemple #20
0
 public Resource_FilesStatus(DNNGo_DNNGalleryPro_Files PhotoItem, PortalSettings ps, String ModulePath)
 {
     SetValues(PhotoItem, PhotoItem.FileSize, ps, ModulePath);
 }
        /// <summary>
        /// 列表行绑定
        /// </summary>
        protected void gvArticleList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //还原出数据
                DNNGo_DNNGalleryPro_Files Media = e.Row.DataItem as DNNGo_DNNGalleryPro_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 hlAdditional = e.Row.FindControl("hlAdditional") as HyperLink;

                    switch (File_Type.ToLower())
                    {
                    case "media": hlAdditional.Attributes.Add("onclick", String.Format("ReturnHtmlPicture('{0}','MediaID={1}');", GetPhotoExtension(Media.FileExtension, Media.FilePath), Media.ID));; break;

                    case "thumbnail": hlAdditional.Attributes.Add("onclick", String.Format("ReturnThumbnail('{0}','MediaID={1}');", GetPhotoExtension(Media.FileExtension, Media.FilePath), Media.ID)); break;

                    case "urllink": hlAdditional.Attributes.Add("onclick", String.Format("ReturnUrlLink('{0}','MediaID={1}');", GetPhotoExtension(Media.FileExtension, Media.FilePath), Media.ID)); break;

                    default: hlAdditional.Attributes.Add("onclick", String.Format("Return{2}('{0}','MediaID={1}');", GetPhotoExtension(Media.FileExtension, Media.FilePath), Media.ID, File_Type)); break;
                    }

                    //if (InsertType)
                    //{
                    //    //插入到文章内容
                    //    hlAdditional.Attributes.Add("onclick", String.Format("ReturnHtmlPicture('{0}',{1});", GetPhotoExtension(Media.FileExtension, Media.FilePath), Media.ID));
                    //}
                    //else
                    //{
                    //    hlAdditional.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));
                }
            }
        }
        // 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)
                {
                    //验证后缀名是否符合
                    bool Valid = FileSystemUtils.CheckValidFileName(file.FileName);
                    if (Valid)
                    {
                        DNNGo_DNNGalleryPro_Files PhotoItem = new DNNGo_DNNGalleryPro_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;


                        //将文件存储的路径整理好
                        String fileName = FileSystemUtils.HandleFileName(System.IO.Path.GetFileName(file.FileName).Replace("." + PhotoItem.FileExtension, ""));  //文件名称
                        String WebPath  = String.Format("DNNGalleryPro/uploads/{0}/{1}/{2}/", PhotoItem.LastTime.Year, PhotoItem.LastTime.Month, PhotoItem.LastTime.Day);
                        //检测文件存储路径是否有相关的文件
                        System.IO.FileInfo fInfo = new System.IO.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}", FileSystemUtils.HandleFileName(PhotoItem.Name), j);
                                fInfo    = new System.IO.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}DNNGo_PhotoAlbums/{0}/{1}/"), String.Format("{0}DNNGo_PhotoAlbums/{0}/{1}/"), (int)DotNetNuke.Services.FileSystem.FolderController.StorageLocationTypes.InsecureFileSystem);
                            }

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

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



                        statuses.Add(new Resource_FilesStatus(PhotoItem, PortalSettings, ModulePath));
                    }
                    else
                    {
                        throw new HttpRequestValidationException("Following file was imported/uploaded, but is not an authorized filetype: " + file.FileName);
                    }
                }
            }
        }
Exemple #23
0
        public Int32 SynchronizeAllFiles(System.IO.FileInfo SynchronizeFile)
        {
            Int32 SynchronizeFileCount = 0;


            DNNGo_DNNGalleryPro_Files PhotoItem = new DNNGo_DNNGalleryPro_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;

            //将文件存储的路径整理好
            String fileName = FileSystemUtils.HandleFileName(PhotoItem.Name); //文件名称
            String WebPath  = String.Format("DNNGalleryPro/uploads/{0}/{1}/{2}/", PhotoItem.LastTime.Year, PhotoItem.LastTime.Month, PhotoItem.LastTime.Day);

            //检测文件存储路径是否有相关的文件
            System.IO.FileInfo fInfo = new System.IO.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}", FileSystemUtils.HandleFileName(PhotoItem.Name), j);
                    fInfo    = new System.IO.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 = DNNGo_DNNGalleryPro_Files._.Sort;
            qp.OrderType    = 1;
            qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Files._.PortalId, PhotoItem.PortalId, SearchType.Equal));
            PhotoItem.Sort = Convert.ToInt32(DNNGo_DNNGalleryPro_Files.FindScalar(qp)) + 2;
            Int32 PhotoId = PhotoItem.Insert();

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


            return(SynchronizeFileCount);
        }
Exemple #24
0
        /// <summary>
        /// 导入图片到媒体库
        /// </summary>
        /// <param name="PictureUrl">图片地址</param>
        /// <returns></returns>
        public String ImportPicture(String PictureUrl)
        {
            String Picture = "";

            if (!String.IsNullOrEmpty(PictureUrl))
            {
                //查看该图片是否已经存在过
                KeyValueEntity PictureTemp = ImportPictureList.Find(r1 => r1.Key == PictureUrl);
                if (PictureTemp != null && !String.IsNullOrEmpty(PictureTemp.Key))
                {
                    Picture = PictureTemp.Value.ToString();
                }
                else
                {
                    DNNGo_DNNGalleryPro_Files PhotoItem = new DNNGo_DNNGalleryPro_Files();

                    //将图片的URL转换为相应的文件名,文件后缀等内容
                    PhotoItem.FileName = System.IO.Path.GetFileName(PictureUrl);//文件名 “Default.aspx”

                    if (!String.IsNullOrEmpty(PhotoItem.FileName) && PhotoItem.FileName.IndexOf(".") > 0)
                    {
                        PhotoItem.FileExtension = System.IO.Path.GetExtension(PhotoItem.FileName).Replace(".", "");
                        PhotoItem.Name          = PhotoItem.FileName.Replace(System.IO.Path.GetExtension(PictureUrl), "");

                        //判断哪些文件需要被下载
                        if (NeedExtension(PhotoItem.FileExtension))
                        {
                            String   FullFile = String.Format("{0}DNNGalleryPro\\uploads\\{1}\\{2}\\{3}\\{4}", DNNGalleryPro_PortalSettings.HomeDirectoryMapPath, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, PhotoItem.FileName);
                            FileInfo file     = new FileInfo(FullFile);

                            int ExistsCount = 1;
                            //如果有重复的文件,需要改变文件名
                            while (file.Exists)
                            {
                                PhotoItem.FileName = String.Format("{0}_{1}.{2}", PhotoItem.Name, ExistsCount, PhotoItem.FileExtension);
                                FullFile           = String.Format("{0}DNNGalleryPro\\uploads\\{1}\\{2}\\{3}\\{4}", DNNGalleryPro_PortalSettings.HomeDirectoryMapPath, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, PhotoItem.FileName);
                                file = new FileInfo(FullFile);
                                ExistsCount++;
                            }

                            try
                            {
                                if (!file.Directory.Exists)
                                {
                                    file.Directory.Create();
                                }

                                //下载图片
                                WebClientX web = new WebClientX();
                                web.DownloadFile(new Uri(PictureUrl), FullFile);

                                file = new FileInfo(FullFile);
                                if (file.Exists)
                                {
                                    PhotoItem.ModuleId = ModuleID;
                                    PhotoItem.PortalId = DNNGalleryPro_PortalSettings.PortalId;
                                    PhotoItem.FileSize = Convert.ToInt32(file.Length / 1024);
                                    PhotoItem.FileMate = FileSystemUtils.GetContentType(Path.GetExtension(PhotoItem.FileName).Replace(".", ""));
                                    PhotoItem.Status   = (Int32)EnumFileStatus.Approved;
                                    PhotoItem.FilePath = String.Format("DNNGalleryPro/uploads/{0}/{1}/{2}/{3}", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, PhotoItem.FileName);


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

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

                                    PhotoItem.LastTime = DateTime.Now;
                                    PhotoItem.LastIP   = WebHelper.UserHost;
                                    //PhotoItem.LastUser = DNNGalleryPro_PortalSettings.UserInfo.UserID;
                                    PhotoItem.ID = PhotoItem.Insert();

                                    //返回图片的路径
                                    Picture = String.Format("MediaID={0}", PhotoItem.ID);
                                    ImportPictureList.Add(new KeyValueEntity(PictureUrl, Picture));
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                        else
                        {
                            Picture = PictureUrl;
                        }
                    }
                    else
                    {
                        Picture = PictureUrl;
                    }
                }
            }


            return(Picture);
        }