From b7d3df951f77a2cd4ebc626f2a362eb5f7bae062 Mon Sep 17 00:00:00 2001
From: llj <132905093+newwwwwwtree@users.noreply.github.com>
Date: 星期二, 07 四月 2026 23:53:31 +0800
Subject: [PATCH] 1
---
WebAPI/Controllers/项目管理/工作任务/PM_WorkTaskBillController.cs | 390 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 377 insertions(+), 13 deletions(-)
diff --git "a/WebAPI/Controllers/\351\241\271\347\233\256\347\256\241\347\220\206/\345\267\245\344\275\234\344\273\273\345\212\241/PM_WorkTaskBillController.cs" "b/WebAPI/Controllers/\351\241\271\347\233\256\347\256\241\347\220\206/\345\267\245\344\275\234\344\273\273\345\212\241/PM_WorkTaskBillController.cs"
index 0660f8c..26e969c 100644
--- "a/WebAPI/Controllers/\351\241\271\347\233\256\347\256\241\347\220\206/\345\267\245\344\275\234\344\273\273\345\212\241/PM_WorkTaskBillController.cs"
+++ "b/WebAPI/Controllers/\351\241\271\347\233\256\347\256\241\347\220\206/\345\267\245\344\275\234\344\273\273\345\212\241/PM_WorkTaskBillController.cs"
@@ -10,6 +10,10 @@
using System.Web.Http;
using System.Windows.Forms;
using WebAPI.Models;
+using System.Threading.Tasks;
+using DLL;
+using SyntacticSugar.constant;
+using System.IO;
namespace WebAPI.Controllers.椤圭洰绠$悊.宸ヤ綔浠诲姟
{
@@ -62,6 +66,7 @@
public string HDeleteManDate;
public string HBackerDate;
public string HBackRemark;
+ public string HTaskType;
public int HMainSourceInterID;
public int HMainSourceEntryID;
@@ -182,6 +187,7 @@
string HDeleteManDate = mainList[0].HDeleteManDate;
string HBackerDate = mainList[0].HBackerDate;
string HBackRemark = mainList[0].HBackRemark;
+ string HTaskType = mainList[0].HTaskType;
int HMainSourceInterID = mainList[0].HMainSourceInterID;
int HMainSourceEntryID = mainList[0].HMainSourceEntryID;
string HMainSourceBillNo = mainList[0].HMainSourceBillNo;
@@ -209,7 +215,7 @@
{
string sql = "insert into PM_WorkTaskBillMain" +
"(HYear,HPeriod,HBillType,HBillSubType,HInterID,HBillNo,HProjectID,HProNumber,HProjectStageID,HName,HDate,HTaskNote,HPlanTimes" +
- ",HSelfTimes,HLastDate,HSendEmp,HReceiveEmp,HType,HCopyEmp,HRemark,HOrgID,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType,HOrderLevID,HTaskClassID)" +
+ ",HSelfTimes,HLastDate,HSendEmp,HReceiveEmp,HType,HCopyEmp,HRemark,HOrgID,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType,HOrderLevID,HTaskClassID,HTaskType)" +
"values(" +
"" + HYear +
"," + HPeriod +
@@ -240,6 +246,7 @@
"','" + HMainSourceBillType +
"','" + HOrderLevID +
"','"+ HTaskClassID+
+ "','"+ HTaskType +
"')";
//涓昏〃
@@ -278,6 +285,7 @@
"',HMainSourceBillType = '" + HMainSourceBillType +
"',HOrderLevID = '" + HOrderLevID +
"',HTaskClassID = '" + HTaskClassID +
+ "',HTaskType = '" + HTaskType +
"' where HInterID = " + HInterID;
oCN.RunProc(sql);
@@ -292,7 +300,7 @@
{
string sql = "insert into PM_WorkTaskBillMain" +
"(HYear,HPeriod,HBillType,HBillSubType,HInterID,HBillNo,HProjectID,HProNumber,HProjectStageID,HName,HDate,HTaskNote,HPlanTimes" +
- ",HSelfTimes,HLastDate,HSendEmp,HReceiveEmp,HType,HCopyEmp,HRemark,HOrgID,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType,HOrderLevID )" +
+ ",HSelfTimes,HLastDate,HSendEmp,HReceiveEmp,HType,HCopyEmp,HRemark,HOrgID,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType,HOrderLevID,HTaskType )" +
"values(" +
"" + HYear +
"," + HPeriod +
@@ -322,6 +330,7 @@
",'" + HMainSourceBillNo +
"','" + HMainSourceBillType +
"','" + HOrderLevID +
+ "','" + HTaskType +
"')";
//涓昏〃
oCN.RunProc(sql);
@@ -440,6 +449,62 @@
}
}
#endregion
+
+ #region 宸ヤ綔浠诲姟鍒楄〃鍒嗛〉鍒楄〃
+ [Route("PM_WorkTaskBill/page")]
+ [HttpGet]
+ public object PM_WorkTaskBillPage(string sWhere, string user, int page, int size)
+ {
+ DataSet ds;
+ try
+ {
+ List<object> columnNameList = new List<object>();
+ //鍒ゆ柇鏉冮檺
+ //if (!DBUtility.ClsPub.Security_Log("Cg_POInStockBillQuery", 1, false, user))
+ //{
+ // objJsonResult.code = CodeConstant.FAIL;
+ // objJsonResult.count = CountConstant.FAIL;
+ // objJsonResult.Message = "鎮ㄦ病鏈夎妯″潡鏉冮檺,璇蜂笌绠$悊鍛樿仈绯伙紒";
+ // objJsonResult.data = null;
+ // return objJsonResult;
+ //}
+
+ if (sWhere == null || sWhere.Equals(""))
+ {
+ ds = oCN.RunProcReturn("exec h_p_PM_WorkTaskBillList " + page + "," + size + ",''", "h_p_PM_WorkTaskBillList");
+ }
+ else
+ {
+ sWhere = sWhere.Replace("'", "''");
+ ds = oCN.RunProcReturn("exec h_p_PM_WorkTaskBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_PM_WorkTaskBillList");
+ }
+
+ //娣诲姞鍒楀悕
+ foreach (DataColumn col in ds.Tables[0].Columns)
+ {
+ Type dataType = col.DataType;
+ string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+ columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+ }
+
+ objJsonResult.code = CodeConstant.SUCCEED;
+ objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
+ objJsonResult.Message = "Sucess锛�";
+ objJsonResult.list = columnNameList;
+ objJsonResult.data = ds.Tables[0];
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
#region 宸ヤ綔浠诲姟鍒楄〃 涓嬫帹鏁版嵁鏌ヨ
/// <summary>
@@ -1228,6 +1293,7 @@
#region 浠诲姟姹囨姤 鏂板/缂栬緫-淇濆瓨
#region 浠诲姟姹囨姤 琛ㄥご鏁版嵁
+ string reportMan;
public class PM_WorkTaskReportBill_Main
{
public int HInterID;
@@ -1254,6 +1320,8 @@
public string HBackRemark;
public int HReportEmpID;
public string HReportEmpName;
+ public string HReceiveEmp;
+ public string HCopyEmp;
}
#endregion
#region 浠诲姟姹囨姤 瀛愯〃鏁版嵁
@@ -1275,7 +1343,10 @@
public int HSourceEntryID;
public string HSourceBillNo;
public string HSourceBillType;
- public bool HFinishFlag;
+ public bool HFinishFlag;
+ public string HWeekProDays; // 鏈懆娑堣�楀疄鏂戒汉澶�(绫婚噷闈娇鐢╯tring瀛橈紝鍚庨潰杞寲涓篸ecimal)
+ public string HWeekReportFileName; // 浜哄ぉ鍗曟枃浠跺悕绉�
+ public string HWeekReportFileAddr; // 浜哄ぉ鍗曟枃浠惰矾寰�
}
#endregion
#region 浠诲姟姹囨姤 鏂板/缂栬緫-淇濆瓨
@@ -1373,7 +1444,9 @@
string HReportEmpName = mainList[0].HReportEmpName;
string HUpdater = mainList[0].HUpdater;
string HUpdaterDate = mainList[0].HUpdaterDate;
-
+ string HReceiveEmp = mainList[0].HReceiveEmp;
+ string HCopyEmp = mainList[0].HCopyEmp;
+ reportMan = HReportEmpName;//鑾峰彇姹囨姤浜哄悕绉�
//淇濆瓨鍓嶆帶鍒�
DataSet BeforeDs = oCN.RunProcReturn("Exec h_p_PM_WorkTaskReportBill_BeforeSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "'," + OperationType.ToString(), "h_p_PM_WorkTaskReportBill_BeforeSaveCtrl");
if (BeforeDs == null || BeforeDs.Tables[0].Rows.Count == 0)
@@ -1401,7 +1474,7 @@
if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//鏂板
{
string sql = "insert into PM_WorkTaskReportBillMain" +
- "(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate,HBillNo,HBillStatus,HRemark,HMaker,HMakeDate,HOrgID,HReportEmpID) " +
+ "(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate,HBillNo,HBillStatus,HRemark,HMaker,HMakeDate,HOrgID,HReportEmpID,HReceiveEmp, HCopyEmp) " +
"values(" +
"" + HYear +
"," + HPeriod +
@@ -1416,8 +1489,10 @@
"','" + HMakerDate +
"'," + HOrgID +
"," + HReportEmpID +
- ")";
-
+ ",N'" + HReceiveEmp +
+ "',N'" + HCopyEmp +
+ "')";
+ LogService.Write(sql);
//涓昏〃
oCN.RunProc(sql);
LogService.Write("鐢ㄦ埛:" + user + ",鏃ユ湡:" + DateTime.Now + ",鏂板浠诲姟姹囨姤:" + HBillNo);
@@ -1438,8 +1513,9 @@
"',HUpdateDate = '" + HUpdaterDate +
"',HOrgID = " + HOrgID +
",HReportEmpID = " + HReportEmpID +
+ ",HReceiveEmp = N'" + HReceiveEmp + "'" +
+ ",HCopyEmp = N'" + HCopyEmp + "'" +
" where HInterID = " + HInterID;
-
oCN.RunProc(sql);
//鍒犻櫎瀛愯〃鏃� 鍥炲~宸ヤ綔浠诲姟鍗曞叧鑱旀暟閲忋�佸崟鎹姸鎬�
@@ -1511,7 +1587,7 @@
public json AddBillSub_WorkTaskReportBill(string msg3, long HInterID, string HBillNo, int OperationType)
{
List<PM_WorkTaskReportBill_Sub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PM_WorkTaskReportBill_Sub>>(msg3);
- int i = 0; //浣滀负瀛愯〃鍐呯爜
+ int i = 0; //浣滀负瀛愯〃鍐呯爜
foreach (PM_WorkTaskReportBill_Sub oSub in DetailColl)
{
i++; //鍚屼竴涓富琛ㄤ笅鐨勫瓙琛ㄧ殑鍐呯爜鑷
@@ -1532,7 +1608,9 @@
string HSourceBillNo = oSub.HSourceBillNo;
string HSourceBillType = oSub.HSourceBillType;
bool HFinishFlag = oSub.HFinishFlag;
-
+ string HWeekProDays = oSub.HWeekProDays;
+ string HWeekReportFileAddr = oSub.HWeekReportFileAddr;
+ string HWeekReportFileName = oSub.HWeekReportFileName;
if (HFinishFlag==true)
{
//鍒ゆ柇鍗曟嵁鏄惁瀛樺湪
@@ -1556,9 +1634,27 @@
oCN.RunProc(sql2);
}
}
-
+ //鏌ユ壘宸ヤ綔浠诲姟鑾峰彇娲惧崟浜哄拰鎶勯�佷汉
+ string sqlz = "select * from h_v_PM_WorkTaskBillList where HInterID = " + HSourceInterID;
+ ds = oCN.RunProcReturn(sqlz, "h_v_PM_WorkTaskBillList");
+ if (ds == null || ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ string HSendEmp = ds.Tables[0].Rows[0]["娲惧崟浜�"].ToString();//娲惧崟浜�
+ string HCopyEmp = ds.Tables[0].Rows[0]["鎶勯�佷汉"].ToString();//鎶勯�佷汉
+ string HWorkTaskDate = DateTime.Parse(ds.Tables[0].Rows[0]["鏃ユ湡"].ToString()).ToString("yyyy-MM-dd");//宸ヤ綔浠诲姟鍗曟嵁鏃堕棿
+ string HSelfTimes = ds.Tables[0].Rows[0]["鑷瘎宸ユ椂"].ToString();//鑷瘎宸ユ椂
+ string HProjectName = ds.Tables[0].Rows[0]["椤圭洰鍚嶇О"].ToString();//椤圭洰鍚嶇О
+ string HTaskDescription = ds.Tables[0].Rows[0]["浠诲姟鎻忚堪"].ToString();
+ //鎻掑叆瀛愯〃sql
string sql = "insert into PM_WorkTaskReportBillSub" +
- "(HInterID,HBillNo_bak,HEntryID,HRemark,HProjectID,HProNumber,HProjectStageID,HName,HTaskNote,HType,HRelTimes,HReportNote,HAdv,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo,HFinishFlag) " +
+ "(HInterID,HBillNo_bak,HEntryID,HRemark,HProjectID,HProNumber,HProjectStageID,HName,HTaskNote,HType,HRelTimes,HReportNote,HAdv,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo,HFinishFlag " +
+ ", HWeekProDays,HWeekReportFileName,HWeekReportFileAddr) " +
"values(" +
"" + HInterID +
",'" + HBillNo +
@@ -1578,9 +1674,11 @@
",'" + HSourceBillType +
"','" + HSourceBillNo +
"'," + DBUtility.ClsPub.BoolToString(HFinishFlag) +
+ $",CONVERT(MONEY, '{HWeekProDays}'), '{HWeekReportFileName}', '{HWeekReportFileAddr}'" +
")";
-
oCN.RunProc(sql);
+ string messageContext = "鍗曟嵁鏃ユ湡= " + HWorkTaskDate + ",姹囨姤浜�=" + reportMan + ",姹囨姤鍐呭=" + HReportNote +",浠诲姟鎻忚堪 ="+ HTaskDescription +",瀹屾垚鏍囪="+ (HFinishFlag?"鏄�":"鍚�") + ",鑷瘎宸ユ椂=" + HSelfTimes + "灏忔椂,鑰楃敤宸ユ椂=" + HRelTimes + "灏忔椂,浠诲姟鍚嶇О=" + HName + ",椤圭洰鍚嶇О=" + HProjectName; ;
+ _ = SendDingDingAsync(HSendEmp, messageContext, HCopyEmp);
}
//淇濆瓨鍚庢帶鍒�
@@ -1678,6 +1776,62 @@
}
}
#endregion
+
+ #region 浠诲姟姹囨姤鍒嗛〉鍒楄〃
+ [Route("PM_WorkTaskReportBill/page")]
+ [HttpGet]
+ public object PM_WorkTaskReportBillPage(string sWhere, string user, int page, int size)
+ {
+ DataSet ds;
+ try
+ {
+ List<object> columnNameList = new List<object>();
+ //鍒ゆ柇鏉冮檺
+ //if (!DBUtility.ClsPub.Security_Log("Cg_POInStockBillQuery", 1, false, user))
+ //{
+ // objJsonResult.code = CodeConstant.FAIL;
+ // objJsonResult.count = CountConstant.FAIL;
+ // objJsonResult.Message = "鎮ㄦ病鏈夎妯″潡鏉冮檺,璇蜂笌绠$悊鍛樿仈绯伙紒";
+ // objJsonResult.data = null;
+ // return objJsonResult;
+ //}
+
+ if (sWhere == null || sWhere.Equals(""))
+ {
+ ds = oCN.RunProcReturn("exec h_p_PM_WorkTaskReportBillList " + page + "," + size + ",''", "h_p_PM_WorkTaskReportBillList");
+ }
+ else
+ {
+ sWhere = sWhere.Replace("'", "''");
+ ds = oCN.RunProcReturn("exec h_p_PM_WorkTaskReportBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_PM_WorkTaskReportBillList");
+ }
+
+ //娣诲姞鍒楀悕
+ foreach (DataColumn col in ds.Tables[0].Columns)
+ {
+ Type dataType = col.DataType;
+ string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+ columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+ }
+
+ objJsonResult.code = CodeConstant.SUCCEED;
+ objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
+ objJsonResult.Message = "Sucess锛�";
+ objJsonResult.list = columnNameList;
+ objJsonResult.data = ds.Tables[0];
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
#region 浠诲姟姹囨姤 缂栬緫-椤甸潰璧嬪��
/// <summary>
@@ -4021,5 +4175,215 @@
#endregion
#endregion
+
+ #region 浠诲姟姹囨姤鍗曚繚瀛樺彂閫侀拤閽夋秷鎭�
+ /// <summary>
+ /// 浠诲姟姹囨姤鍗曚繚瀛樺彂閫侀拤閽夋秷鎭�
+ /// </summary>
+ /// <param name="HSendMan"></param>
+ /// <param name="HDescription">鏃ユ湡+姹囨姤浜�+姹囨姤鍐呭+宸ユ椂+ 椤圭洰鍚嶇О</param>
+ /// <param name="HCopyMan">鎶勯�佷汉</param>
+ /// <returns></returns>
+ public async Task<object> SendDingDingAsync(string HSendMan, string HDescription, string HCopyMan)
+ {
+ string concatenatedNames = "";
+ Cls_DDMsg msg = new Cls_DDMsg();
+ string appKey = "dingrsrzhdyn3mlaof95";
+ string appSecret = "RAqH6YtZnPLCpDbuqfaYQkKkVtVdS0wqfC8I26X6qiS-8eoCJCNrzx3fubGND4Sq";
+ //浠诲姟姹囨姤鍗曚繚瀛樺彂閫侀拤閽夋秷鎭繚瀛� 灏嗘秷鎭� 鍙戦�佺粰 鎺ユ敹浜�
+ //鑾峰彇鎺ラ�佷汉鐨勯拤閽塱d
+ string HReceiveMan = HSendMan;
+ string[] names = HCopyMan.Split(',');
+ string sqlNames = "";
+ foreach (string name in names)
+ {
+ sqlNames += "'" + name.Trim() + "',";
+ }
+ sqlNames = sqlNames.TrimEnd(',');
+ //鑾峰彇鎸囨淳澶勭悊浜�,鍙戦�佷汉鐨勯拤閽塱d
+ string sql1 = "select HDingDingUserID 閽夐拤id from Gy_Czygl where Czymc in ('" + HReceiveMan + "'," + sqlNames + ")";
+ ds = oCN.RunProcReturn(sql1, "Gy_Czygl");
+ List<string> HNames = new List<string>();
+ for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
+ {
+ string HName = ds.Tables[0].Rows[i]["閽夐拤id"].ToString();
+ HNames.Add(HName);
+ }
+ concatenatedNames = string.Join(",", HNames);//閽夐拤浜哄憳鐨刬d鍒楄〃
+ //鑾峰彇浼佷笟鐨刟ccess_token鐨勫��
+ string response = msg.GetAccessToken(appKey, appSecret);
+ JObject responseJson = JObject.Parse(response);
+ // 鑾峰彇access_token鐨勫��
+ string accessToken = responseJson["accessToken"].ToString();
+
+ //璋冪敤鏂规硶鍙戦�佹秷鎭�
+ string agentId = "3118119317";//閽夐拤鍚庡彴寤虹珛鐨勫皬绋嬪簭id
+ string userIdList = concatenatedNames;//閽夐拤浜哄憳鐨刬d
+ string deptIdList = "0"; // 绌哄瓧绗︿覆琛ㄧず涓嶆寚瀹氶儴闂�
+ string toAllUser = "false";
+ string message = HDescription;
+ response = await msg.SendTextMessage(accessToken, agentId, userIdList, deptIdList, toAllUser, message);
+ Console.WriteLine(response);
+ return response;
+ }
+ #endregion
+
+
+
+ //#region 鑷姩鍔犺浇椤甸潰琛ㄥご
+ ///// <summary>
+ ///// 杩斿洖椤圭洰闃舵鍒楄〃
+ /////鍙傛暟锛歴tring sql銆�
+ /////杩斿洖鍊硷細object銆�
+ ///// </summary>
+ //[Route("Xt_DefineBillMainSet/getDefineBillMainSet")]
+ //[HttpGet]
+ //public object getDefineBillMainSet(string HModName, string user)
+ //{
+ // try
+ // {
+ // string sql = "select * from h_v_Xt_DefineBillMainSet_AutoLoadList where HModName ='" + HModName + "' and HUser ='" + user + "' order by HArrangeOrder,HArrangeOrderSub";
+ // ds = oCN.RunProcReturn(sql, "Xt_DefineBillMainSet");
+
+ // if(ds!=null && ds.Tables[0].Rows.Count == 0)
+ // {
+ // sql = "select * from h_v_Xt_DefineBillMainSet_AutoLoadList where HModName ='" + HModName + "' and HUser ='admin' order by HArrangeOrder,HArrangeOrderSub";
+ // ds = oCN.RunProcReturn(sql, "h_v_Xt_DefineBillMainSet_AutoLoadList");
+ // }
+
+ // objJsonResult.code = "1";
+ // objJsonResult.count = 1;
+ // objJsonResult.Message = "Sucess锛�";
+ // objJsonResult.data = ds.Tables[0];
+ // return objJsonResult;
+ // }
+ // catch (Exception e)
+ // {
+ // objJsonResult.code = "0";
+ // objJsonResult.count = 0;
+ // objJsonResult.Message = "Exception锛�" + e.ToString();
+ // objJsonResult.data = null;
+ // return objJsonResult;
+ // }
+ //}
+ //#endregion
+
+ #region 浠诲姟姹囨姤 涓婁紶浜哄ぉ鍗�
+ [Route("PM_WorkTaskReportBill/UploadFile")]
+ [HttpPost]
+ public object UploadFile()
+ {
+
+ string HNumber = HttpContext.Current.Request.Params["HNumber"]; //浜哄ぉ鍗曟枃浠跺悕
+ string HRemark = HttpContext.Current.Request.Params["HRemark"]; //澶囨敞
+ string HUserName = HttpContext.Current.Request.Params["HUserName"]; //鍒涘缓浜�
+ HttpPostedFile files = HttpContext.Current.Request.Files["file"];
+ string path = HttpContext.Current.Server.MapPath("~/../Files/WorkTaskReportBill/" + HNumber);
+ dynamic dyResult = UpLoadFile(files, path, HNumber, HRemark, HUserName);
+ if (dyResult != null && dyResult.result == 1)
+ {
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "涓婁紶鎴愬姛锛�";
+ objJsonResult.data = "Files/WorkTaskReportBill/" + HNumber + "/";
+ return objJsonResult;
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = dyResult.returnval;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ }
+
+ public dynamic UpLoadFile(HttpPostedFile files, string path, string HNumber, string HRemark, string HUserName)
+ {
+ dynamic Result_Ob = new { result = 1, returnval = "涓婁紶鎴愬姛锛�" };
+ string filePath = Path.GetFullPath(files.FileName);//鏂囦欢涓婁紶璺緞
+ string fileExtension = Path.GetExtension(files.FileName);// 鏂囦欢鎵╁睍鍚�
+ string filename = files.FileName;//鏂囦欢鍚�
+ string fileSavePath = path;// 涓婁紶淇濆瓨璺緞
+ int filesize = files.ContentLength;//鑾峰彇涓婁紶鏂囦欢鐨勫ぇ灏忓崟浣嶄负瀛楄妭byte
+ int Maxsize = 40000 * 1024;//瀹氫箟涓婁紶鏂囦欢鐨勬渶澶х┖闂村ぇ灏忎负40M
+ try
+ {
+ if (files == null || files.ContentLength <= 0)
+ {
+ Result_Ob = new { result = 0, returnval = "鏂囦欢涓嶈兘涓虹┖!" };
+ return Result_Ob;
+ }
+ if (filesize >= Maxsize)
+ {
+ Result_Ob = new { result = 0, returnval = "涓婁紶鏂囦欢瓒呰繃40M锛屼笉鑳戒笂浼狅紒" };
+ return Result_Ob;
+ }
+
+ string fileurl = Path.Combine(fileSavePath, filename);
+ if (Directory.Exists(fileurl) == true) //濡傛灉瀛樺湪閲嶅悕鏂囦欢灏辨彁绀�
+ {
+ Result_Ob = new { result = 0, returnval = "瀛樺湪鍚屽悕鏂囦欢锛�" };
+ return Result_Ob;
+ }
+ //鍒犻櫎鏁版嵁琛ㄦ暟鎹�
+ ds = oCN.RunProcReturn("delete from MES_AccessoriesList where HSourceBillNo ='" + HNumber + "' and HFileName='" + filename + "'", "MES_AccessoriesList");
+ if (Directory.Exists(path))
+ {
+ File.Delete(fileurl); //鍒犻櫎鎸囧畾鏂囦欢
+ files.SaveAs(fileurl);
+ string StrPath = "/files/WorkTaskReportBill/" + HNumber + "/" + filename;
+ if (File.Exists(fileurl))
+ {
+ //杩欓噷鍙互鎵ц涓�浜涘叾瀹冪殑鎿嶄綔锛屾瘮濡傛洿鏂版暟鎹簱
+ //鍐欏叆鏁版嵁琛�
+ oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" +
+ ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" +
+ ",HFileClsID,HSourceBillNo" +
+ ") values('"
+ + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" +
+ ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize +
+ "','" + 0 + "','" + HNumber +
+ "') ");
+ }
+ else
+ {
+ Result_Ob = new { result = 0, returnval = "涓婁紶澶辫触锛佹鏂囦欢涓烘伓鎰忔枃浠�" };
+ }
+ }
+ else
+ {
+ Directory.CreateDirectory(fileSavePath); //娣诲姞鏂囦欢澶�
+ files.SaveAs(fileurl);
+ string StrPath = "/files/WorkTaskReportBill/" + HNumber + "/" + filename;
+ if (File.Exists(fileurl))
+ {
+ //杩欓噷鍙互鎵ц涓�浜涘叾瀹冪殑鎿嶄綔锛屾瘮濡傛洿鏂版暟鎹簱
+ //鍐欏叆鏁版嵁琛�
+ oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" +
+ ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" +
+ ",HFileClsID,HSourceBillNo" +
+ ") values('"
+ + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" +
+ ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize +
+ "','" + 0 + "','" + HNumber +
+ "') ");
+ }
+ else
+ {
+ Result_Ob = new { result = 0, returnval = "涓婁紶澶辫触锛佹鏂囦欢涓烘伓鎰忔枃浠�" };
+ }
+ }
+
+ }
+ catch (Exception e)
+ {
+ Result_Ob = new { result = 0, returnval = e.Message };
+ }
+ return Result_Ob;
+ }
+
+ #endregion
}
}
\ No newline at end of file
--
Gitblit v1.9.1