edit
此提交包含在:
+4
-4
@@ -288,13 +288,13 @@ public partial class copydownload : System.Web.UI.Page
|
|||||||
string fname = Path.GetFileName(file);
|
string fname = Path.GetFileName(file);
|
||||||
foreach (var rule in replaceRules)
|
foreach (var rule in replaceRules)
|
||||||
{
|
{
|
||||||
rname = rname.Replace(rule.Key, rule.Value);
|
fname = fname.Replace(rule.Key, rule.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
File.Copy(file, path + "\\" + rname, true);
|
File.Copy(file, path + "\\" + fname, true);
|
||||||
if (!File.Exists(path + "\\" + rname))
|
if (!File.Exists(path + "\\" + fname))
|
||||||
{
|
{
|
||||||
File.Copy(file, path + "\\" + rname, true);
|
File.Copy(file, path + "\\" + fname, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+153
-38
@@ -2,8 +2,10 @@
|
|||||||
using Aliyun.OSS.Common;
|
using Aliyun.OSS.Common;
|
||||||
using BizCom;
|
using BizCom;
|
||||||
using ICSharpCode.SharpZipLib.Zip;
|
using ICSharpCode.SharpZipLib.Zip;
|
||||||
|
using MSharp.Framework;
|
||||||
using NPOI.OpenXmlFormats.Dml.Diagram;
|
using NPOI.OpenXmlFormats.Dml.Diagram;
|
||||||
using NPOI.OpenXmlFormats.Shared;
|
using NPOI.OpenXmlFormats.Shared;
|
||||||
|
using NPOI.POIFS.Properties;
|
||||||
using SiteCore.Handler;
|
using SiteCore.Handler;
|
||||||
using SiteCore.Redis;
|
using SiteCore.Redis;
|
||||||
using System;
|
using System;
|
||||||
@@ -76,7 +78,7 @@ public partial class supplierBuildFile : System.Web.UI.Page
|
|||||||
string fname = fileName + ext;
|
string fname = fileName + ext;
|
||||||
if (File.Exists(fname))
|
if (File.Exists(fname))
|
||||||
{
|
{
|
||||||
return fname;
|
return ext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,28 +99,144 @@ public partial class supplierBuildFile : System.Web.UI.Page
|
|||||||
var principal = new WindowsPrincipal(identity);
|
var principal = new WindowsPrincipal(identity);
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
try
|
using (identity.Impersonate())
|
||||||
{
|
{
|
||||||
using (identity.Impersonate())
|
StringBuilder sql = new StringBuilder();
|
||||||
|
sql.AppendFormat("select * from CE_ErpPackData WITH(nolock) where upStatus = 0");
|
||||||
|
int userId = 1;
|
||||||
|
DataTable dt = CeErpTradeCell.ExecuteDataset(sql.ToString()).Tables[0];
|
||||||
|
string updateSql = "";
|
||||||
|
if (dt != null && dt.Rows.Count > 0)
|
||||||
{
|
{
|
||||||
|
foreach (DataRow dr in dt.Rows)
|
||||||
MemoryStream ms = new MemoryStream();
|
|
||||||
byte[] buffer = null;
|
|
||||||
List<string> addFiles = new List<string>();
|
|
||||||
List<string> addCtid = new List<string>();
|
|
||||||
using (ZipFile file = ZipFile.Create(ms))
|
|
||||||
{
|
{
|
||||||
|
string packId = dr["ID"].ToString();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CeErpTradeLog.ExecuteNonQuery(string.Format("update CE_ErpPackData set upStatus = 1 where ID= {0} ;", packId));
|
||||||
|
DataTable itemData = CeErpTradeCell.ExecuteDataset(string.Format("select ctid,seller_memo,FinishDesignTime,OrderState,SupplierName,OrderSn,tid from view_erptradecell where FinishDesignTime is not null and ctid in (SELECT ctid FROM CE_ErpPackDataItem WHERE packId = {0})", packId)).Tables[0];
|
||||||
|
List<string> files = new List<string>();
|
||||||
|
int upStatus = 3;
|
||||||
|
string url = "";
|
||||||
|
if (itemData != null && itemData.Rows.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (DataRow row in itemData.Rows)
|
||||||
|
{
|
||||||
|
string finishDesignTime = getDesignTime(row["FinishDesignTime"]);
|
||||||
|
string ctid = row["ctid"].ToString();
|
||||||
|
string df_name = upPath + "\\" + finishDesignTime + "\\" + formatMemo(row["seller_memo"]);
|
||||||
|
string ext = getCanDownFile(df_name);
|
||||||
|
if (string.IsNullOrEmpty(ext))
|
||||||
|
{
|
||||||
|
updateSql += string.Format("update CE_ErpPackDataItem set message = '文件不存在!' where packId= {0} and ctid='{1}' ;", packId, ctid);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
string fname = df_name + ext;
|
||||||
|
if (Convert.ToInt16(row["OrderState"]) != 6)
|
||||||
|
{
|
||||||
|
updateSql += string.Format("update CE_ErpPackDataItem set message = '订单状态不正确!' where packId= {0} and ctid='{1}' ;", packId, ctid);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int IsFileEncrypt = IsFileEncrypted(fname);
|
||||||
|
if (IsFileEncrypt == 1 && File.Exists(fname))
|
||||||
|
{
|
||||||
|
string key = "gBQnlxiBb7MthH9644V0W0pFwqYZgyy7";
|
||||||
|
var sb = new StringBuilder(key);
|
||||||
|
|
||||||
|
//Linux系统的接口要调用一次,Windows系统要调用两次
|
||||||
|
CreateUserKey(sb, key.Length);
|
||||||
|
CreateUserKey(sb, key.Length); //破解用dse生成的文件,需要调2次。
|
||||||
|
int result = InitAesKey(sb, sb.Length);
|
||||||
|
result = IsInitedAesKey();
|
||||||
|
if (result != 1)
|
||||||
|
{
|
||||||
|
addLog(ctid, userId, "初始化秘钥失败" + result, 0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
uint a = DecFile(fname);
|
||||||
|
if (a != 0)
|
||||||
|
{
|
||||||
|
addLog(ctid, userId, "解密失败" + a, 0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(fname))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
copyFile(getDesignDate(row["FinishDesignTime"]), row["SupplierName"].ToString(), fname);
|
||||||
|
files.Add(fname);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
writeLog("打包复制文件出错!" + ex.Message);
|
||||||
|
updateSql += string.Format("update CE_ErpPackDataItem set message = '复制文件出错!{2}' where packId= {0} and ctid='{1}' ;", packId, ctid, ex.Message);
|
||||||
|
files = new List<string>();//清空数据
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (files.Count == 0)
|
||||||
|
{
|
||||||
|
updateSql += string.Format("update CE_ErpPackData set upStatus = 3,message='没有可打包文件!' where ID= {0} ;", packId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
MemoryStream ms = new MemoryStream();
|
||||||
|
byte[] buffer = null;
|
||||||
|
using (ZipFile file = ZipFile.Create(ms))
|
||||||
|
{
|
||||||
|
|
||||||
|
file.BeginUpdate();
|
||||||
|
//file.NameTransform = new ZipNameTransform();
|
||||||
|
file.NameTransform = new MyNameTransfom();
|
||||||
|
for (int i = 0; i < files.Count; i++)
|
||||||
|
{
|
||||||
|
if (File.Exists(files[i]))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
file.Add(files[i]);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
file.CommitUpdate();
|
||||||
|
buffer = new byte[ms.Length];
|
||||||
|
ms.Position = 0;
|
||||||
|
ms.Read(buffer, 0, buffer.Length); //读取文件内容(1次读ms.Length/1024M)
|
||||||
|
ms.Flush();
|
||||||
|
ms.Close();
|
||||||
|
}
|
||||||
|
url = FileOssUp(buffer, dr["fileName"].ToString());
|
||||||
|
|
||||||
|
if (url != null)
|
||||||
|
{
|
||||||
|
upStatus = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
updateSql += string.Format("update CE_ErpPackData set upStatus = {1},fileUrl='{2}' where ID= {0} ;", packId, upStatus, url);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
writeLog("打包文件出错!" + ex.Message);
|
||||||
|
updateSql += string.Format("update CE_ErpPackData set upStatus = 3 where ID= {0} ;", packId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
CeErpTradeLog.ExecuteNonQuery(updateSql);
|
||||||
}
|
}
|
||||||
running = false;
|
running = false;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
running = false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
conSuc("运行结束!");
|
conSuc("运行结束!");
|
||||||
@@ -158,7 +276,7 @@ public partial class supplierBuildFile : System.Web.UI.Page
|
|||||||
return Convert.ToDateTime(v).ToString("yyyy-MM-dd");*/
|
return Convert.ToDateTime(v).ToString("yyyy-MM-dd");*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FileOssUp()
|
private string FileOssUp(byte[] buffer, string fileName)
|
||||||
{
|
{
|
||||||
// yourEndpoint填写Bucket所在地域对应的Endpoint。以华东1(杭州)为例,Endpoint填写为https://oss-cn-hangzhou.aliyuncs.com。
|
// yourEndpoint填写Bucket所在地域对应的Endpoint。以华东1(杭州)为例,Endpoint填写为https://oss-cn-hangzhou.aliyuncs.com。
|
||||||
var endpoint = "https://oss-cn-fuzhou.aliyuncs.com";
|
var endpoint = "https://oss-cn-fuzhou.aliyuncs.com";
|
||||||
@@ -168,7 +286,7 @@ public partial class supplierBuildFile : System.Web.UI.Page
|
|||||||
// 填写Bucket名称,例如examplebucket。
|
// 填写Bucket名称,例如examplebucket。
|
||||||
var bucketName = "dfdiyfile";
|
var bucketName = "dfdiyfile";
|
||||||
// 填写Object完整路径,完整路径中不能包含Bucket名称,例如exampledir/exampleobject.txt。
|
// 填写Object完整路径,完整路径中不能包含Bucket名称,例如exampledir/exampleobject.txt。
|
||||||
var objectName = "supplierFile/test.zip";
|
var objectName = "supplierFile/" + fileName;
|
||||||
|
|
||||||
// 填写Bucket所在地域对应的Region。以华东1(杭州)为例,Region填写为cn-hangzhou。
|
// 填写Bucket所在地域对应的Region。以华东1(杭州)为例,Region填写为cn-hangzhou。
|
||||||
string region = "cn-fuzhou";
|
string region = "cn-fuzhou";
|
||||||
@@ -184,37 +302,18 @@ public partial class supplierBuildFile : System.Web.UI.Page
|
|||||||
client.SetRegion(region);
|
client.SetRegion(region);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
MemoryStream ms = new MemoryStream();
|
|
||||||
byte[] buffer = null;
|
|
||||||
using (ZipFile file = ZipFile.Create(ms))
|
|
||||||
{
|
|
||||||
|
|
||||||
file.BeginUpdate();
|
|
||||||
//file.NameTransform = new ZipNameTransform();
|
|
||||||
file.NameTransform = new MyNameTransfom();
|
|
||||||
|
|
||||||
file.Add("C:\\Users\\231010\\Downloads\\setup.exe");
|
|
||||||
file.CommitUpdate();
|
|
||||||
buffer = new byte[ms.Length];
|
|
||||||
ms.Position = 0;
|
|
||||||
ms.Read(buffer, 0, buffer.Length); //读取文件内容(1次读ms.Length/1024M)
|
|
||||||
ms.Flush();
|
|
||||||
ms.Close();
|
|
||||||
|
|
||||||
}
|
|
||||||
MemoryStream requestContent = new MemoryStream(buffer);
|
MemoryStream requestContent = new MemoryStream(buffer);
|
||||||
// 上传文件。
|
// 上传文件。
|
||||||
client.PutObject(bucketName, objectName, requestContent);
|
client.PutObject(bucketName, objectName, requestContent);
|
||||||
Debug.WriteLine("Put object succeeded");
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("Put object failed" + ex.Message);
|
writeLog("打包文件上传oss出错!" + ex.Message);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return "https://dfdiyfile.oss-cn-fuzhou.aliyuncs.com/" + objectName;
|
||||||
conSuc("上传成功!");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
/// 批量进行多个文件压缩到一个文件
|
/// 批量进行多个文件压缩到一个文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -340,4 +439,20 @@ public partial class supplierBuildFile : System.Web.UI.Page
|
|||||||
log.OperateTime = DateTime.Now;
|
log.OperateTime = DateTime.Now;
|
||||||
log.Create();
|
log.Create();
|
||||||
}
|
}
|
||||||
|
private static string logPath = ConfigurationManager.AppSettings["curPath"] + "\\log";
|
||||||
|
private static object logFlag = new object();
|
||||||
|
public static void writeLog(string log)
|
||||||
|
{
|
||||||
|
lock (logFlag)
|
||||||
|
{
|
||||||
|
using (FileStream fileStream = new FileStream(logPath + "\\" + DateTime.Now.ToString("yy-MM-dd") + ".log", FileMode.Append, FileAccess.Write))
|
||||||
|
{
|
||||||
|
using (StreamWriter sw = new StreamWriter(fileStream, Encoding.Default))
|
||||||
|
{
|
||||||
|
sw.Write(log + " ------时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n");
|
||||||
|
sw.Flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+7
-6
@@ -303,15 +303,16 @@ public partial class supplierDownload : System.Web.UI.Page
|
|||||||
{
|
{
|
||||||
string path = copyPath + "\\" + date + "\\" + supplier + "\\" + "车间下载";
|
string path = copyPath + "\\" + date + "\\" + supplier + "\\" + "车间下载";
|
||||||
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
|
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
|
||||||
|
string fname = Path.GetFileName(file);
|
||||||
foreach (var rule in replaceRules)
|
foreach (var rule in replaceRules)
|
||||||
{
|
{
|
||||||
rname = rname.Replace(rule.Key, rule.Value);
|
fname = fname.Replace(rule.Key, rule.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
File.Copy(file, path + "\\" + rname, true);
|
File.Copy(file, path + "\\" + fname, true);
|
||||||
if (!File.Exists(path + "\\" + rname))
|
if (!File.Exists(path + "\\" + fname))
|
||||||
{
|
{
|
||||||
File.Copy(file, path + "\\" + rname, true);
|
File.Copy(file, path + "\\" + fname, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,7 +351,7 @@ public partial class supplierDownload : System.Web.UI.Page
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
file.Add(files[i], rnameList[i]);
|
file.Add(files[i]);
|
||||||
addFiles.Add(files[i]);
|
addFiles.Add(files[i]);
|
||||||
addCtid.Add(ctidLst[i]);
|
addCtid.Add(ctidLst[i]);
|
||||||
}
|
}
|
||||||
@@ -413,7 +414,7 @@ public partial class supplierDownload : System.Web.UI.Page
|
|||||||
//通知浏览器下载文件而不是打开\\fileDownload=true; path=/
|
//通知浏览器下载文件而不是打开\\fileDownload=true; path=/
|
||||||
Response.AddHeader("Set-Cookie", "fileDownload=true; path=/;");
|
Response.AddHeader("Set-Cookie", "fileDownload=true; path=/;");
|
||||||
//Response.AddHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
//Response.AddHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||||
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fname, System.Text.Encoding.UTF8));
|
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(dfile, System.Text.Encoding.UTF8));
|
||||||
Response.AddHeader("Content-Length", bytes.Length.ToString());
|
Response.AddHeader("Content-Length", bytes.Length.ToString());
|
||||||
Response.AddHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
Response.AddHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
||||||
Response.BinaryWrite(bytes);
|
Response.BinaryWrite(bytes);
|
||||||
|
|||||||
+1
-1
@@ -270,7 +270,7 @@ public partial class uploadFile : System.Web.UI.Page
|
|||||||
entity.FinishPlaceTime = DateTime.Now;
|
entity.FinishPlaceTime = DateTime.Now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (((entity.seller_memo.Contains("条幅彩色") && !entity.seller_memo.Contains("辽宁") && !entity.seller_memo.Contains("山东")) || entity.seller_memo.Contains("贡锻布") || entity.seller_memo.Contains("贡缎布") || entity.seller_memo.Contains("旗帜布")) && !entity.seller_memo.Contains("双喷"))
|
if ((((entity.seller_memo.Contains("条幅彩色") && !entity.seller_memo.Contains("辽宁") && !entity.seller_memo.Contains("山东")) || entity.seller_memo.Contains("贡锻布") || entity.seller_memo.Contains("贡缎布") || entity.seller_memo.Contains("旗帜布")) && !entity.seller_memo.Contains("双喷")) || entity.seller_memo.Contains("帆布"))
|
||||||
{
|
{
|
||||||
entity.IsVerifyToSupplier = true;
|
entity.IsVerifyToSupplier = true;
|
||||||
entity.SupplierId = 98;
|
entity.SupplierId = 98;
|
||||||
|
|||||||
新增問題並參考
封鎖使用者