114 lines
3.8 KiB
C#
114 lines
3.8 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.ComponentModel;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Drawing;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Windows.Forms;
|
|||
|
|
using System.IO;
|
|||
|
|
using System.Reflection;
|
|||
|
|
using SOH.JianYan;
|
|||
|
|
using ICSharpCode.SharpZipLib;
|
|||
|
|
using ICSharpCode.SharpZipLib.Core;
|
|||
|
|
using ICSharpCode.SharpZipLib.Zip;
|
|||
|
|
|
|||
|
|
namespace SOH.LIS.Packing
|
|||
|
|
{
|
|||
|
|
public partial class Main : Form
|
|||
|
|
{
|
|||
|
|
public Main()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btn_xz_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (fbd_lis.ShowDialog() == DialogResult.OK)
|
|||
|
|
{
|
|||
|
|
txt_forderpath.Text = fbd_lis.SelectedPath;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btn_db_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
string lisfoder = "";
|
|||
|
|
if (txt_forderpath.Text.Trim() == "")
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("请先选择要打包的文件夹!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
lisfoder = txt_forderpath.Text.Trim();
|
|||
|
|
}
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (!Directory.Exists(lisfoder))
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("请先选择要打包的文件夹!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("请先选择要打包的文件夹!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
string[] lisfiles = Directory.GetFiles(lisfoder);
|
|||
|
|
var lisdecs = lisfiles.Where(t => t.Replace(lisfoder + "\\", "").StartsWith("SOH.JianYan.DEC") && t.EndsWith(".exe")).ToArray();
|
|||
|
|
if (lisdecs.Length > 1)
|
|||
|
|
{
|
|||
|
|
txt_forderpath.Text = "你选择的文件夹有多个解码程序无法打包!";
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
else if (lisdecs.Length == 0)
|
|||
|
|
{
|
|||
|
|
txt_forderpath.Text = "你选择的文件夹没有解码程序无法打包!";
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
var lisdecfile = lisdecs[0];
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
var dectype = Assembly.LoadFile(lisdecfile);
|
|||
|
|
var jyattrs = dectype.GetCustomAttributes(typeof(JianYanAttribute), false);
|
|||
|
|
if (jyattrs.Count() == 0)
|
|||
|
|
{
|
|||
|
|
txt_forderpath.Text = "你选择的解码文件夹有问题!解码程序不正确!";
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
JianYanAttribute jyattr = jyattrs[0] as JianYanAttribute;
|
|||
|
|
if (MessageBox.Show("你要打包的解决程序是:" + jyattr.YQ + "("+jyattr.YQMC+"),你确定要打包吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
|
|||
|
|
{
|
|||
|
|
jyattr = null;
|
|||
|
|
dectype = null;
|
|||
|
|
jyattrs = null;
|
|||
|
|
GC.Collect();
|
|||
|
|
GC.Collect(1);
|
|||
|
|
string savepath = "";
|
|||
|
|
if(sfd_db.ShowDialog()==DialogResult.OK)
|
|||
|
|
{
|
|||
|
|
savepath = sfd_db.FileName;
|
|||
|
|
}
|
|||
|
|
//FileStream fs = new FileStream(savepath, FileMode.Create, FileAccess.ReadWrite, FileShare.None);
|
|||
|
|
//ZipOutputStream zs = new ZipOutputStream(fs);
|
|||
|
|
////soh.lis.yq
|
|||
|
|
//zs.Password = "69c64c3356fcb8b3";
|
|||
|
|
if (ZipHelper.ZipDirectory(lisfoder, savepath, "69c64c33"))
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("打包成功!");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
txt_forderpath.Text = "你选择的解码文件夹有问题!解码程序不正确!";
|
|||
|
|
MessageBox.Show(ex.Message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|