Beispiel #1
0
        /// <summary>
        /// 获取图片
        /// </summary>
        /// <param name="keyValue">主键</param>
        public void GetImg(string keyValue)
        {
            ArticleEntity entity = GetEntity(keyValue);
            string        img    = "";

            if (entity != null && !string.IsNullOrEmpty(entity.F_Img))
            {
                ImgEntity imgEntity = imgIBLL.GetEntity(entity.F_Img);

                if (imgEntity != null && !string.IsNullOrEmpty(imgEntity.F_Content))
                {
                    FileDownHelper.DownLoadBase64(imgEntity.F_Content, imgEntity.F_Name);
                    return;
                }
            }
            else
            {
                img = "/Content/images/plhome/banner_df.jpg";
            }

            if (string.IsNullOrEmpty(img))
            {
                img = "/Content/images/plhome/banner_df.jpg";
            }
            FileDownHelper.DownLoad(img);
        }
Beispiel #2
0
        /// <summary>
        /// 获取图片
        /// </summary>
        /// <param name="keyValue">主键</param>
        public void GetImg(string keyValue)
        {
            DTImgEntity entity = GetEntity(keyValue);
            string      img    = "";

            if (entity != null)
            {
                if (!string.IsNullOrEmpty(entity.F_FileName))
                {
                    string fileHeadImg = Config.GetValue("fileAppDTImg");
                    string fileImg     = string.Format("{0}/{1}{2}", fileHeadImg, entity.F_Id, entity.F_FileName);
                    if (DirFileHelper.IsExistFile(fileImg))
                    {
                        img = fileImg;
                        FileDownHelper.DownLoadnew(img);
                        return;
                    }
                }
            }
            else
            {
                img = "/Content/images/add.jpg";
            }
            if (string.IsNullOrEmpty(img))
            {
                img = "/Content/images/add.jpg";
            }
            FileDownHelper.DownLoad(img);
        }
Beispiel #3
0
        /// <summary>
        /// 获取图片
        /// </summary>
        /// <param name="type">类型</param>
        public void GetImg(string type)
        {
            HomeConfigEntity entity = GetEntityByType(type);
            string           img    = "";

            if (entity != null && !string.IsNullOrEmpty(entity.F_Img))
            {
                ImgEntity imgEntity = imgIBLL.GetEntity(entity.F_Img);

                if (imgEntity != null && !string.IsNullOrEmpty(imgEntity.F_Content))
                {
                    FileDownHelper.DownLoadBase64(imgEntity.F_Content, imgEntity.F_Name);
                    return;
                }
            }
            else
            {
                img = "/Content/images/plhome/addImg.png";
            }

            if (string.IsNullOrEmpty(img))
            {
                img = "/Content/images/plhome/addImg.png";
            }
            FileDownHelper.DownLoad(img);
        }
Beispiel #4
0
        /// <summary>
        /// 获取图片
        /// </summary>
        /// <param name="keyValue">主键</param>
        public void GetImg(string keyValue)
        {
            string img = "";

            if (!string.IsNullOrEmpty(keyValue))
            {
                string fileHeadImg = Config.GetValue("fileHealthImg"); //Config.GetValue("fileAppDTImg");
                string fileImg     = string.Format("{0}/{1}{2}", fileHeadImg, keyValue, ".jpg");
                if (DirFileHelper.IsExistFile(fileImg))
                {
                    img = fileImg;
                    FileDownHelper.DownLoadnew(img);
                    return;
                }
            }
            else
            {
                img = "/Content/images/add.jpg";
            }
            if (string.IsNullOrEmpty(img))
            {
                img = "/Content/images/add.jpg";
            }
            FileDownHelper.DownLoad(img);
        }
        public IActionResult Download(string aid)
        {
            var downloadResult = _ArticleService.ClientDownLoad(aid);

            if (downloadResult.Success && downloadResult.Data != null && !downloadResult.Data.Attachment.IsEmpty())
            {
                byte[] fileBytes;
                var    files        = downloadResult.Data.Attachment.Split(',');
                var    contentType  = FileHelper.GetContentType("zip");
                var    resourceType = "zip";

                if (files.Length == 1)
                {
                    resourceType = downloadResult.Data.ResourceType ?? FileHelper.GetExtension(FileHelper.MapFilePath(files[0]));
                    contentType  = FileHelper.GetContentType(resourceType);
                    fileBytes    = FileDownHelper.DownLoad(files[0]);
                }
                else
                {
                    fileBytes = FileDownHelper.DownloadZip(files.ToDictionary(k => k, v => v));
                }
                return(File(fileBytes, contentType, $"{downloadResult.Data.Title}.{resourceType}"));
            }
            return(ErrorPage(downloadResult.Message ?? "下载失败!"));
        }
Beispiel #6
0
        /// <summary>
        /// 获取图片
        /// </summary>
        /// <param name="keyValue">主键</param>
        public void GetImg(string keyValue)
        {
            //首先获取实体
            LR_StampManageEntity entity = GetEntity(keyValue);
            string img = "";

            //实体是否存在
            if (entity != null && !string.IsNullOrEmpty(entity.F_ImgFile))
            {
                ImgEntity imgEntity = imgIBLL.GetEntity(entity.F_ImgFile);

                if (imgEntity != null && !string.IsNullOrEmpty(imgEntity.F_Content))
                {
                    FileDownHelper.DownLoadBase64(imgEntity.F_Content, imgEntity.F_Name);
                    return;
                }
            }
            else
            {
                img = "/Content/images/add.jpg";
            }
            if (string.IsNullOrEmpty(img))
            {
                img = "/Content/images/add.jpg";
            }
            FileDownHelper.DownLoad(img);
        }
Beispiel #7
0
        /// <summary>
        /// 导出PDF
        /// </summary>
        /// <param name="html">html页面字串</param>
        public void ExportPDF(string html)
        {
            SynchronizedPechkin sc = new SynchronizedPechkin(new GlobalConfig().SetMargins(new System.Drawing.Printing.Margins(100, 100, 100, 100)));

            byte[] buf = sc.Convert(new ObjectConfig(), html);

            var ms = new MemoryStream(buf);

            FileDownHelper.DownLoad(ms, "报价单.pdf");
            ms.Close();
        }
        public ActionResult GenerateFile(string ext = "json")
        {
            string jsonStr = GetJsonDataByNewTon();                             //使用递归获取,利用litjson生成json字符串

            FileHelper.CreateDir("File");                                       //判断文件是否存在,如果不存在则创建文件夹
            string VirtualPath  = @"/File/Dictionary." + ext;                   //虚拟路径
            string PhysicalPath = Server.MapPath(VirtualPath);                  //实际的物理路径

            if (ext == "json")                                                  //如果是要生成json格式
            {
                FileHelper.WriteText(PhysicalPath, jsonStr, UTF8Encoding.UTF8); //将文件存入服务器
            }
            else//如果是要生成xml格式
            {
                XmlDocument xdoc = Newtonsoft.Json.JsonConvert.DeserializeXmlNode(jsonStr, "DictionaryJsonV1"); //首先将json装xml
                xdoc.Save(PhysicalPath);                                                                        //将文件存入服务器
            }
            FileDownHelper.DownLoad(VirtualPath);                                                               //从服务器下载文件至本地
            return(Success("下载成功!"));                                                                           //下载成功
        }