diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Controllers/Ass_AssetsInfoItemController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Controllers/Ass_AssetsInfoItemController.cs index e02675f7b..e786f9c2d 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Controllers/Ass_AssetsInfoItemController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Controllers/Ass_AssetsInfoItemController.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Linq; using Learun.Application.Base.SystemModule; using Learun.Application.Organization; +using ZipOneCode.ZipProvider; namespace Learun.Application.Web.Areas.AssetManagementSystem.Controllers { @@ -368,6 +369,52 @@ namespace Learun.Application.Web.Areas.AssetManagementSystem.Controllers ass_AssetsInfoItemIBLL.SaveEntity(keyValue, entity); return Success("保存成功!"); } + + + /// + /// 生成二维码 + /// + /// + [HttpPost] + [AjaxOnly] + public ActionResult GetQRCode() + { + //TODO:文件夹压缩成zip + //var a = @"D:\Job\test\zip"; + //var aa = string.Format(@"{0}.zip", a); + //ZipHelper.CreateZip(a, aa); + + //TODO:生成带logo二维码 + //var resultImgPath = QRCodeHelper.ProcessRequest("demo", @"~\Content\images\img1.png"); + + //TODO:生成二维码,并打包 + var dArr = new List(); + for (int i = 0; i < 5; i++) + { + var d = QRCodeHelper.ProcessRequest("demo" + i, @"~\Content\images\img1.png", "demo" + i); + if (dArr.IndexOf(d) == -1) + { + dArr.Add(d); + } + } + foreach (var item in dArr) + { + ZipHelper.CreateZip(item, item + ".zip"); + } + + return Success("操作成功!", dArr); + + } + //todo:下载 + [HttpPost] + public void DownFile(string path) + { + path = string.Format(@"{0}{1}", path, ".zip"); + if (FileDownHelper.FileExists(path)) + { + FileDownHelper.DownLoadold(path, path.Substring(path.LastIndexOf(@"\") + 1)); + } + } #endregion } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Views/Ass_AssetsInfoItem/Index.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Views/Ass_AssetsInfoItem/Index.cshtml index f5448a3fe..3899e22b6 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Views/Ass_AssetsInfoItem/Index.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Views/Ass_AssetsInfoItem/Index.cshtml @@ -97,6 +97,9 @@  查看使用人员记录  导出 +
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Views/Ass_AssetsInfoItem/Index.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Views/Ass_AssetsInfoItem/Index.js index 15afab421..24f696895 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Views/Ass_AssetsInfoItem/Index.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Views/Ass_AssetsInfoItem/Index.js @@ -241,6 +241,21 @@ var bootstrap = function ($, learun) { $('#lr_exportexcel').on('click', function () { page.exportExcel(); }); + + + //生成二维码 + $('#lr_getqrcode').on('click', function () { + learun.postForm(top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/GetQRCode', { }, function (res) { + if (res && res.code == "200") { + //下载文件 + //只下载一个??? + //for (var i = 0; i < res.data.length; i++) { + // learun.download({ url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/DownFile', param: { path: res.data[i], __RequestVerificationToken: $.lrToken }, method: 'POST' }); + //} + } + }); + }); + }, // 初始化列表 initGird: function () { diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Content/images/img1.png b/Learun.Framework.Ultimate V7/Learun.Application.Web/Content/images/img1.png new file mode 100644 index 000000000..7db98a9ea Binary files /dev/null and b/Learun.Framework.Ultimate V7/Learun.Application.Web/Content/images/img1.png differ diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Website/Web.config b/Learun.Framework.Ultimate V7/Learun.Application.Website/Web.config index 65a84299c..77bf6316c 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Website/Web.config +++ b/Learun.Framework.Ultimate V7/Learun.Application.Website/Web.config @@ -69,6 +69,18 @@ + + + + + + + + + + + + diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Language/app.config b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Language/app.config index 739e9c9c8..899e22885 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Language/app.config +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Language/app.config @@ -6,6 +6,18 @@ + + + + + + + + + + + + diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/app.config b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/app.config index 739e9c9c8..899e22885 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/app.config +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/app.config @@ -6,6 +6,18 @@ + + + + + + + + + + + + diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Learun.Util.csproj b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Learun.Util.csproj index 6153a1661..dbaff6549 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Learun.Util.csproj +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Learun.Util.csproj @@ -81,6 +81,9 @@ + + ..\..\..\packages\ThoughtWorks.QRCode.1.1.0\lib\ThoughtWorks.QRCode.dll + ..\..\..\packages\YUICompressor.NET.2.7.0.0\lib\NET20\Yahoo.Yui.Compressor.dll @@ -128,8 +131,10 @@ + + diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Web/QRCodeHelper.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Web/QRCodeHelper.cs new file mode 100644 index 000000000..c3e30d2b0 --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Web/QRCodeHelper.cs @@ -0,0 +1,115 @@ +using System; +using System.Web; +using ThoughtWorks.QRCode.Codec; +using ThoughtWorks.QRCode.Codec.Data; +using ThoughtWorks.QRCode.Codec.Util; +using System.IO; +using System.Text; +using System.Drawing; +using System.Drawing.Drawing2D; + +namespace Learun.Util +{ + public class QRCodeHelper + { + /// + /// 生成带图片的二维码 + /// + /// 二维码内容 + /// 二维码上图片地址 + public static string ProcessRequest(string qrcodeText,string imagePath,string savePath) + { + //最终图片保存路径 + var resultImgPath = string.Empty; + if (!string.IsNullOrEmpty(qrcodeText)) + { + QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(); + qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE; + qrCodeEncoder.QRCodeScale = 4; + qrCodeEncoder.QRCodeVersion = 8; + qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M; + System.Drawing.Image image = qrCodeEncoder.Encode(qrcodeText); + System.IO.MemoryStream MStream = new System.IO.MemoryStream(); + image.Save(MStream, System.Drawing.Imaging.ImageFormat.Png); + System.IO.MemoryStream MStream1 = new System.IO.MemoryStream(); + CombinImage(image, HttpContext.Current.Server.MapPath(imagePath)).Save(MStream1, System.Drawing.Imaging.ImageFormat.Png); + //保存图片到本地文件夹 + System.Drawing.Image img = System.Drawing.Image.FromStream(MStream1); + //string imgPath = System.IO.Path.Combine(Config.GetValue("AnnexesFile"), "带logo图片二维码", DateTime.Now.ToString("yyyyMMddHHmm")); + string imgPath = System.IO.Path.Combine(Config.GetValue("AnnexesFile"), "带logo图片二维码", savePath); + if (!System.IO.Directory.Exists(imgPath)) + { + System.IO.Directory.CreateDirectory(imgPath); + } + img.Save(System.IO.Path.Combine(imgPath, qrcodeText+".png"), System.Drawing.Imaging.ImageFormat.Png); + resultImgPath = imgPath; + + //HttpContext.Current.Response.ClearContent(); + //HttpContext.Current.Response.ContentType = "image/png"; + //HttpContext.Current.Response.BinaryWrite(MStream1.ToArray()); + //image.Dispose(); + MStream.Dispose(); + MStream1.Dispose(); + + } + //HttpContext.Current.Response.Flush(); + //HttpContext.Current.Response.End(); + + return resultImgPath; + } + /// + /// 调用此函数后使此两种图片合并,类似相册,有个 + /// 背景图,中间贴自己的目标图片 + /// + /// 粘贴的源图片 + /// 粘贴的目标图片 + public static Image CombinImage(Image imgBack, string destImg) + { + Image img = Image.FromFile(destImg); //照片图片 + if (img.Height != 65 || img.Width != 65) + { + img = KiResizeImage(img, 65, 65, 0); + } + Graphics g = Graphics.FromImage(imgBack); + g.DrawImage(imgBack, 0, 0, imgBack.Width, imgBack.Height); + //g.DrawImage(imgBack, 0, 0, 相框宽, 相框高); + //g.FillRectangle(System.Drawing.Brushes.White, imgBack.Width / 2 - img.Width / 2 - 1, imgBack.Width / 2 - img.Width / 2 - 1,1,1);//相片四周刷一层黑色边框 + //g.DrawImage(img, 照片与相框的左边距, 照片与相框的上边距, 照片宽, 照片高); + g.DrawImage(img, imgBack.Width / 2 - img.Width / 2, imgBack.Width / 2 - img.Width / 2, img.Width, img.Height); + GC.Collect(); + return imgBack; + } + /// + /// Resize图片 + /// + /// 原始Bitmap + /// 新的宽度 + /// 新的高度 + /// 保留着,暂时未用 + /// 处理以后的图片 + public static Image KiResizeImage(Image bmp, int newW, int newH, int Mode) + { + try + { + Image b = new Bitmap(newW, newH); + Graphics g = Graphics.FromImage(b); + // 插值算法的质量 + g.InterpolationMode = InterpolationMode.HighQualityBicubic; + g.DrawImage(bmp, new Rectangle(0, 0, newW, newH), new Rectangle(0, 0, bmp.Width, bmp.Height), GraphicsUnit.Pixel); + g.Dispose(); + return b; + } + catch + { + return null; + } + } + public bool IsReusable + { + get + { + return false; + } + } + } +} \ No newline at end of file diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Web/ZipHelper.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Web/ZipHelper.cs new file mode 100644 index 000000000..e7f8be7b2 --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Web/ZipHelper.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; +using System.Diagnostics; +using ICSharpCode.SharpZipLib; +using ICSharpCode.SharpZipLib.Zip; +using ICSharpCode.SharpZipLib.Checksums; +using ICSharpCode.SharpZipLib.Core; + +namespace ZipOneCode.ZipProvider +{ + public class ZipHelper + { + /// + /// 压缩文件 + /// + /// + /// + public static void CreateZip(string sourceFilePath, string destinationZipFilePath) + { + if (sourceFilePath[sourceFilePath.Length - 1] != System.IO.Path.DirectorySeparatorChar) + sourceFilePath += System.IO.Path.DirectorySeparatorChar; + + ZipOutputStream zipStream = new ZipOutputStream(File.Create(destinationZipFilePath)); + zipStream.SetLevel(6); // 压缩级别 0-9 + CreateZipFiles(sourceFilePath, zipStream, sourceFilePath); + + zipStream.Finish(); + zipStream.Close(); + } + + /// + /// 递归压缩文件 + /// + /// 待压缩的文件或文件夹路径 + /// 打包结果的zip文件路径(类似 D:\WorkSpace\a.zip),全路径包括文件名和.zip扩展名 + /// + private static void CreateZipFiles(string sourceFilePath, ZipOutputStream zipStream, string staticFile) + { + Crc32 crc = new Crc32(); + string[] filesArray = Directory.GetFileSystemEntries(sourceFilePath); + foreach (string file in filesArray) + { + if (Directory.Exists(file)) //如果当前是文件夹,递归 + { + CreateZipFiles(file, zipStream, staticFile); + } + + else //如果是文件,开始压缩 + { + FileStream fileStream = File.OpenRead(file); + + byte[] buffer = new byte[fileStream.Length]; + fileStream.Read(buffer, 0, buffer.Length); + string tempFile = file.Substring(staticFile.LastIndexOf("\\") + 1); + ZipEntry entry = new ZipEntry(tempFile); + + entry.DateTime = DateTime.Now; + entry.Size = fileStream.Length; + fileStream.Close(); + crc.Reset(); + crc.Update(buffer); + entry.Crc = crc.Value; + zipStream.PutNextEntry(entry); + + zipStream.Write(buffer, 0, buffer.Length); + } + } + } + } +} \ No newline at end of file diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/packages.config b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/packages.config index 30bb78e68..e4fa9f5c3 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/packages.config +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/packages.config @@ -7,5 +7,6 @@ + \ No newline at end of file diff --git a/Learun.Framework.Ultimate V7/Quanjiang.DigitalSchool.Aspose/Quanjiang.DigitalSchool.Aspose.csproj b/Learun.Framework.Ultimate V7/Quanjiang.DigitalSchool.Aspose/Quanjiang.DigitalSchool.Aspose.csproj index abd9a6972..2053b563a 100644 --- a/Learun.Framework.Ultimate V7/Quanjiang.DigitalSchool.Aspose/Quanjiang.DigitalSchool.Aspose.csproj +++ b/Learun.Framework.Ultimate V7/Quanjiang.DigitalSchool.Aspose/Quanjiang.DigitalSchool.Aspose.csproj @@ -55,6 +55,7 @@ + diff --git a/Learun.Framework.Ultimate V7/Quanjiang.DigitalSchool.Aspose/app.config b/Learun.Framework.Ultimate V7/Quanjiang.DigitalSchool.Aspose/app.config new file mode 100644 index 000000000..e936cc132 --- /dev/null +++ b/Learun.Framework.Ultimate V7/Quanjiang.DigitalSchool.Aspose/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Learun.Framework.Ultimate V7/packages/ThoughtWorks.QRCode.1.1.0/.signature.p7s b/Learun.Framework.Ultimate V7/packages/ThoughtWorks.QRCode.1.1.0/.signature.p7s new file mode 100644 index 000000000..5920afe5e Binary files /dev/null and b/Learun.Framework.Ultimate V7/packages/ThoughtWorks.QRCode.1.1.0/.signature.p7s differ diff --git a/Learun.Framework.Ultimate V7/packages/ThoughtWorks.QRCode.1.1.0/ThoughtWorks.QRCode.1.1.0.nupkg b/Learun.Framework.Ultimate V7/packages/ThoughtWorks.QRCode.1.1.0/ThoughtWorks.QRCode.1.1.0.nupkg new file mode 100644 index 000000000..c7891604b Binary files /dev/null and b/Learun.Framework.Ultimate V7/packages/ThoughtWorks.QRCode.1.1.0/ThoughtWorks.QRCode.1.1.0.nupkg differ diff --git a/Learun.Framework.Ultimate V7/packages/ThoughtWorks.QRCode.1.1.0/lib/ThoughtWorks.QRCode.dll b/Learun.Framework.Ultimate V7/packages/ThoughtWorks.QRCode.1.1.0/lib/ThoughtWorks.QRCode.dll new file mode 100644 index 000000000..45b1b5267 Binary files /dev/null and b/Learun.Framework.Ultimate V7/packages/ThoughtWorks.QRCode.1.1.0/lib/ThoughtWorks.QRCode.dll differ