/// <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_PowerForms_Files PictureItem = DNNGo_PowerForms_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();
        }
Esempio n. 2
0
        /// <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 (FileType >= 0)
            {
                Where = DNNGo_PowerForms_Files.ByType(Where, FileType);
            }


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



            return(Where);
        }
Esempio n. 3
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_PowerForms_Files Multimedia = DNNGo_PowerForms_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);
            }
        }
Esempio n. 4
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_PowerForms_Files Multimedia = DNNGo_PowerForms_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);
            }
        }
Esempio n. 5
0
        public String ViewPicture(DNNGo_PowerForms_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);
        }
Esempio n. 6
0
        /// <summary>
        /// 获取图片的路径
        /// </summary>
        /// <param name="media">媒体文件的实体</param>
        /// <returns></returns>
        public String GetPhotoPath(DNNGo_PowerForms_Files media)
        {
            String PhotoPath = String.Empty;

            if (media != null && media.ID > 0)
            {
                PhotoPath = GetPhotoPath(media.FilePath);
            }
            return(PhotoPath);
        }
        /// <summary>
        /// 推送图片列表数据
        /// </summary>
        public void PushPictureList()
        {
            QueryParam qp = new QueryParam();

            qp.Orderfld = DNNGo_PowerForms_Files._.ID;

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


            int RecordCount = 0;
            List <DNNGo_PowerForms_Files> fileList = DNNGo_PowerForms_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("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));


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

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

            //转换数据为json

            Response.Clear();
            Response.Write(jsSerializer.Serialize(jsonLayers));
            Response.End();
        }
Esempio n. 8
0
 private void SetValues(DNNGo_PowerForms_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";
 }
Esempio n. 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_PowerForms_Files._.ID;
            }

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


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


            #endregion

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

            List <DNNGo_PowerForms_Files> Comments = DNNGo_PowerForms_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"));



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


            //ctlPagingControl.TotalRecords = RecordCount;

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

            //}

            gvCommentList.DataSource = Comments;
            gvCommentList.DataBind();
            BindGridViewEmpty <DNNGo_PowerForms_Files>(gvCommentList, new DNNGo_PowerForms_Files());
        }
        /// <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)
                    {
                        DNNGo_PowerForms_Files Multimedia = DNNGo_PowerForms_Files.FindByID(MediaID);
                        if (Multimedia != null && Multimedia.ID > 0)
                        {
                            if (IsPhotoExtension)
                            {
                                DefaultValue = Server.UrlPathEncode(GetPhotoExtension(Multimedia.FileExtension, Multimedia.FilePath));// String.Format("{0}{1}", bpm.PowerForms_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);
        }
Esempio n. 11
0
        private void DeliverFile(HttpContext context)
        {
            DNNGo_PowerForms_Files DataItem = DNNGo_PowerForms_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;
        }
Esempio n. 12
0
        // Delete file from the server
        private void DeleteFile(HttpContext context)
        {
            Int32 PhotoID = WebHelper.GetIntParam(context.Request, "ID", 0);
            DNNGo_PowerForms_Files PhotoItem = DNNGo_PowerForms_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();
            }
        }
Esempio n. 13
0
        public Int32 SynchronizeAllFiles(FileInfo SynchronizeFile)
        {
            Int32 SynchronizeFileCount = 0;


            DNNGo_PowerForms_Files PhotoItem = new DNNGo_PowerForms_Files();

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


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

            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 = PhotoItem.FileName; //文件名称
            String WebPath  = String.Format("PowerForms/uploads/{0}/{1}/{2}/", xUserTime.UtcTime().Year, xUserTime.UtcTime().Month, xUserTime.UtcTime().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 = DNNGo_PowerForms_Files._.Sort;
            qp.OrderType    = 1;
            qp.Where.Add(new SearchParam(DNNGo_PowerForms_Files._.PortalId, PhotoItem.PortalId, SearchType.Equal));
            PhotoItem.Sort = Convert.ToInt32(DNNGo_PowerForms_Files.FindScalar(qp)) + 2;
            Int32 PhotoId = PhotoItem.Insert();

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


            return(SynchronizeFileCount);
        }
Esempio n. 14
0
 public Resource_FilesStatus(DNNGo_PowerForms_Files PhotoItem, int fileLength, PortalSettings ps, String ModulePath)
 {
     SetValues(PhotoItem, fileLength, ps, ModulePath);
 }
Esempio n. 15
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)
                    {
                        DNNGo_PowerForms_Files PhotoItem = new DNNGo_PowerForms_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 = FileSystemUtils.GetContentType(Path.GetExtension(PhotoItem.FileName).Replace(".", ""));

                        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 = System.IO.Path.GetFileName(file.FileName).Replace("." + PhotoItem.FileExtension, ""); //文件名称
                        String WebPath  = String.Format("PowerForms/uploads/{0}/{1}/{2}/", xUserTime.UtcTime().Year, xUserTime.UtcTime().Month, xUserTime.UtcTime().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}DNNGo_PhotoAlbums/{0}/{1}/"), String.Format("{0}DNNGo_PhotoAlbums/{0}/{1}/"), (int)DotNetNuke.Services.FileSystem.FolderController.StorageLocationTypes.InsecureFileSystem);
                            }

                            //构造指定存储路径
                            file.SaveAs(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_PowerForms_Files._.Sort;
                        qp.OrderType    = 1;
                        qp.Where.Add(new SearchParam(DNNGo_PowerForms_Files._.PortalId, PhotoItem.PortalId, SearchType.Equal));
                        PhotoItem.Sort = Convert.ToInt32(DNNGo_PowerForms_Files.FindScalar(qp)) + 2;
                        Int32 PhotoId = PhotoItem.Insert();



                        statuses.Add(new Resource_FilesStatus(PhotoItem, PortalSettings, ModulePath));
                    }
                }
            }
        }
Esempio n. 16
0
 public String ThumbnailUrl(DNNGo_PowerForms_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));
 }
Esempio n. 17
0
 public Resource_FilesStatus(DNNGo_PowerForms_Files PhotoItem, PortalSettings ps, String ModulePath)
 {
     SetValues(PhotoItem, PhotoItem.FileSize, ps, ModulePath);
 }
Esempio n. 18
0
        /// <summary>
        /// 列表行绑定
        /// </summary>
        protected void gvCommentList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //还原出数据
                DNNGo_PowerForms_Files Media = e.Row.DataItem as DNNGo_PowerForms_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);
                    }
                }
            }
        }