/// <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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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));
 }