修改同步文件删除
This commit is contained in:
@@ -206,6 +206,14 @@ public partial class supplierBuildFile : System.Web.UI.Page
|
|||||||
upStatus = 2;
|
upStatus = 2;
|
||||||
updateSql += string.Format("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where ctid in ({0}) ;", string.Join(",", tids), (int)OrderState.下单完成, 0, "下载设计文件");
|
updateSql += string.Format("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where ctid in ({0}) ;", string.Join(",", tids), (int)OrderState.下单完成, 0, "下载设计文件");
|
||||||
updateSql += string.Format("update ce_erptradecell set UpdateTime=getdate() where ctid in ({0}) ;", string.Join(",", tids));
|
updateSql += string.Format("update ce_erptradecell set UpdateTime=getdate() where ctid in ({0}) ;", string.Join(",", tids));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Delete(zipFilePath);
|
||||||
|
}
|
||||||
|
catch (Exception delEx)
|
||||||
|
{
|
||||||
|
writeLog("删除临时文件失败: " + delEx.Message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+46
-8
@@ -87,6 +87,8 @@ public partial class xhyOrderFile : System.Web.UI.Page
|
|||||||
static string pCheckUrl = "http://test.new-only.com:54444/shopPlat/front/needlogin/erp/checkOrderParam.do";
|
static string pCheckUrl = "http://test.new-only.com:54444/shopPlat/front/needlogin/erp/checkOrderParam.do";
|
||||||
static string userName = "18959023975";
|
static string userName = "18959023975";
|
||||||
static string passWord = "lt50510";
|
static string passWord = "lt50510";
|
||||||
|
|
||||||
|
private static string tempUpPath = ConfigurationManager.AppSettings["curPath"] + "\\tempUp";
|
||||||
private void downloadMore()
|
private void downloadMore()
|
||||||
{
|
{
|
||||||
if (running)
|
if (running)
|
||||||
@@ -115,26 +117,26 @@ public partial class xhyOrderFile : System.Web.UI.Page
|
|||||||
string ctid = dr["ctid"].ToString();
|
string ctid = dr["ctid"].ToString();
|
||||||
string post_url = dr["url"].ToString();
|
string post_url = dr["url"].ToString();
|
||||||
string id = dr["id"].ToString();
|
string id = dr["id"].ToString();
|
||||||
|
string filePath = "";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CeErpTradeCell itemData = CeErpTradeCell.GetByCtid(ctid);
|
CeErpTradeCell itemData = CeErpTradeCell.GetByCtid(ctid);
|
||||||
List<string> files = new List<string>();
|
List<string> files = new List<string>();
|
||||||
List<string> tids = new List<string>();
|
List<string> tids = new List<string>();
|
||||||
string filePath = "";
|
|
||||||
string finishDesignTime = getDesignTime(itemData.FinishDesignTime);
|
string finishDesignTime = getDesignTime(itemData.FinishDesignTime);
|
||||||
string df_name = upPath + "\\" + finishDesignTime + "\\" + formatMemo(itemData.seller_memo);
|
string df_name = upPath + "\\" + finishDesignTime + "\\" + formatMemo(itemData.seller_memo);
|
||||||
string ext = getCanDownFile(df_name);
|
string ext = getCanDownFile(df_name);
|
||||||
if (string.IsNullOrEmpty(ext))
|
if (string.IsNullOrEmpty(ext))
|
||||||
{
|
{
|
||||||
updateSql = string.Format("update CE_ErpXhyOrderInfo set message = '文件不存在!',type=2,sendtime = GETDATE() where id= {0};", id);
|
updateSql = string.Format("update CE_ErpXhyOrderInfo set message = '文件不存在!{1}',type=2,sendtime = GETDATE() where id= {0};", id, df_name);
|
||||||
CeErpTradeLog.ExecuteNonQuery(updateSql);
|
CeErpTradeLog.ExecuteNonQuery(updateSql);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
string fname = df_name + ext;
|
string fname = df_name + ext;
|
||||||
string rname = formatMemo(itemData.seller_memo) + ext;
|
string rname = formatMemo(itemData.seller_memo) + ext;
|
||||||
|
|
||||||
if (itemData.OrderState != 6)
|
if (itemData.OrderState != 5)
|
||||||
{
|
{
|
||||||
updateSql = string.Format("update CE_ErpXhyOrderInfo set message = '订单状态不正确!',type=2,sendtime = GETDATE() where id= {0};", id);
|
updateSql = string.Format("update CE_ErpXhyOrderInfo set message = '订单状态不正确!',type=2,sendtime = GETDATE() where id= {0};", id);
|
||||||
CeErpTradeLog.ExecuteNonQuery(updateSql);
|
CeErpTradeLog.ExecuteNonQuery(updateSql);
|
||||||
@@ -185,6 +187,7 @@ public partial class xhyOrderFile : System.Web.UI.Page
|
|||||||
string url = pUrl + "?" + ToUrlParams(param);
|
string url = pUrl + "?" + ToUrlParams(param);
|
||||||
|
|
||||||
filePath = copyFile(getDesignDate(itemData.FinishDesignTime), "XHY", fname, rname);
|
filePath = copyFile(getDesignDate(itemData.FinishDesignTime), "XHY", fname, rname);
|
||||||
|
// filePath = copyTempFile(fname, rname);
|
||||||
|
|
||||||
writeLog("XHY复制文件!:" + fname);
|
writeLog("XHY复制文件!:" + fname);
|
||||||
writeLog("XHY复制文件!地址:" + filePath);
|
writeLog("XHY复制文件!地址:" + filePath);
|
||||||
@@ -195,7 +198,16 @@ public partial class xhyOrderFile : System.Web.UI.Page
|
|||||||
postVars.Add(new StringContent(json), "json");
|
postVars.Add(new StringContent(json), "json");
|
||||||
if (filePath != null)
|
if (filePath != null)
|
||||||
{
|
{
|
||||||
postVars.Add(new ByteArrayContent(File.ReadAllBytes(filePath)), "file", Path.GetFileName(filePath));
|
// 使用 FileStream 打开文件,并包装为 StreamContent
|
||||||
|
var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||||
|
var streamContent = new StreamContent(fileStream);
|
||||||
|
// 设置 Content-Disposition,需要手动指定文件名
|
||||||
|
streamContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data")
|
||||||
|
{
|
||||||
|
Name = "file",
|
||||||
|
FileName = Path.GetFileName(filePath)
|
||||||
|
};
|
||||||
|
postVars.Add(streamContent);
|
||||||
}
|
}
|
||||||
var request = new HttpRequestMessage
|
var request = new HttpRequestMessage
|
||||||
{
|
{
|
||||||
@@ -208,7 +220,7 @@ public partial class xhyOrderFile : System.Web.UI.Page
|
|||||||
};
|
};
|
||||||
request.Content = postVars;
|
request.Content = postVars;
|
||||||
|
|
||||||
using (var response = await client.SendAsync(request))
|
using (var response = client.SendAsync(request).GetAwaiter().GetResult())
|
||||||
{
|
{
|
||||||
string responseBody = await response.Content.ReadAsStringAsync();
|
string responseBody = await response.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
@@ -218,7 +230,7 @@ public partial class xhyOrderFile : System.Web.UI.Page
|
|||||||
if (xhyResponse.code == 200)
|
if (xhyResponse.code == 200)
|
||||||
{
|
{
|
||||||
updateSql = string.Format("update CE_ErpXhyOrderInfo set message = '{1}',type=1,sendtime = GETDATE() where id= {0};", id, xhyResponse.message);
|
updateSql = string.Format("update CE_ErpXhyOrderInfo set message = '{1}',type=1,sendtime = GETDATE() where id= {0};", id, xhyResponse.message);
|
||||||
updateSql += string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid ='{0}' and OrderState=5 and IsVerifyToSupplier=2;", itemData.ctid);
|
// updateSql += string.Format("update CE_ErpTradeCell set OrderState=6,IsHaveNewOrder=0 where ctid ='{0}' and OrderState=5 and IsHaveNewOrder=3;", itemData.ctid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -231,10 +243,24 @@ public partial class xhyOrderFile : System.Web.UI.Page
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
writeLog("Xh复制文件出错!" + ex.Message);
|
writeLog("Xh复制文件出错!" + ex);
|
||||||
updateSql = string.Format("update CE_ErpXhyOrderInfo set message = '复制文件出错!{1}' ,type=2,sendtime = GETDATE() where id= {0};", id, ex.Message);
|
updateSql = string.Format("update CE_ErpXhyOrderInfo set message = '复制文件出错!{1}' ,type=2,sendtime = GETDATE() where id= {0};", id, ex.Message);
|
||||||
CeErpTradeLog.ExecuteNonQuery(updateSql);
|
CeErpTradeLog.ExecuteNonQuery(updateSql);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(filePath) && File.Exists(filePath))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// File.Delete(filePath);
|
||||||
|
}
|
||||||
|
catch (Exception delEx)
|
||||||
|
{
|
||||||
|
writeLog("删除临时文件失败: " + delEx.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -305,6 +331,18 @@ public partial class xhyOrderFile : System.Web.UI.Page
|
|||||||
}
|
}
|
||||||
return path + "\\" + rname;
|
return path + "\\" + rname;
|
||||||
}
|
}
|
||||||
|
private string copyTempFile(string file, string rname)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!Directory.Exists(tempUpPath)) Directory.CreateDirectory(tempUpPath);
|
||||||
|
string fname = Path.GetFileName(file);
|
||||||
|
File.Copy(file, tempUpPath + "\\" + rname, true);
|
||||||
|
if (!File.Exists(tempUpPath + "\\" + rname))
|
||||||
|
{
|
||||||
|
File.Copy(file, tempUpPath + "\\" + rname, true);
|
||||||
|
}
|
||||||
|
return tempUpPath + "\\" + rname;
|
||||||
|
}
|
||||||
|
|
||||||
private string getCopyPath(string date, string supplier, string zipName = "")
|
private string getCopyPath(string date, string supplier, string zipName = "")
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user