From 6515a15d6922ef7dae289f1ff1f44883cc36c4dd Mon Sep 17 00:00:00 2001 From: YL <YL@LAPTOP-SE03PLUR> Date: 星期二, 09 十一月 2021 16:02:44 +0800 Subject: [PATCH] 公告信息 --- WebAPI/Controllers/WebAPIController.cs | 116 +++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 95 insertions(+), 21 deletions(-) diff --git a/WebAPI/Controllers/WebAPIController.cs b/WebAPI/Controllers/WebAPIController.cs index 1ecfa5b..bce9931 100644 --- a/WebAPI/Controllers/WebAPIController.cs +++ b/WebAPI/Controllers/WebAPIController.cs @@ -1,4 +1,6 @@ 锘縰sing DAL; +using DBUtility; +using Microsoft.AspNet.SignalR; using Model; using SQLHelper; using System; @@ -17,7 +19,7 @@ { private JsonResult objJsonResult = new JsonResult(); private json objjson = new json(); - // private POInStockBillServices oclscg_poinstockbillmain = new POInStockBillServices(); + // private POInStockBillServices oclscg_poinstockbillmain = new POInStockBillServices(); public string sWhere = ""; public WebServer webserver = new WebServer(); public DataSet ds = new DataSet(); @@ -40,25 +42,25 @@ public static bool Add_Log(string WorkList, string CurUserName, string State) { - DBUtility.ClsPub.SetIPAddress(); - string IPAddress; - string ComputerName; - IPAddress = DBUtility.ClsPub.IPAddress; - ComputerName = DBUtility.ClsPub.ComputerName; - ClsCNSRM oCnLoc = new ClsCNSRM(); - try - { - oCnLoc.RunProc("Insert into System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " + - "(getdate(),'" + CurUserName + "','" + ComputerName + "','" + WorkList + "','SRM绯荤粺','" + IPAddress + "','" + State + "')" - ); + DBUtility.ClsPub.SetIPAddress(); + string IPAddress; + string ComputerName; + IPAddress = DBUtility.ClsPub.IPAddress; + ComputerName = DBUtility.ClsPub.ComputerName; + ClsCNSRM oCnLoc = new ClsCNSRM(); + try + { + oCnLoc.RunProc("Insert into System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " + + "(getdate(),'" + CurUserName + "','" + ComputerName + "','" + WorkList + "','SRM绯荤粺','" + IPAddress + "','" + State + "')" + ); - return true; - } - catch (Exception e) - { - return false; + return true; + } + catch (Exception e) + { + return false; - } + } } /// <summary> @@ -165,12 +167,12 @@ return objJsonResult; } } - catch (Exception) + catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "鐧诲綍寮傚父锛�"; + objJsonResult.Message = "鐧诲綍寮傚父锛�" + e.ToString(); objJsonResult.data = null; return objJsonResult; ; } @@ -695,6 +697,78 @@ #endregion - + /// <summary> + /// 瑙﹀彂hub鐨刟pi + /// </summary> + /// <param name="request">request</param> + /// <returns>message</returns> + [AllowAnonymous] + [Route("show/hub"), HttpGet] + public HttpResponseMessage GetMessage(HttpRequestMessage request) + { + var hub = GlobalHost.ConnectionManager.GetHubContext<MyHub>(); + //娉ㄦ剰杩欓噷鐨剆howMessage 灏辨槸瀵筊epairHub涓嬪畾涔夌殑showMessage鏂规硶璋冪敤,鍚屾牱鍓嶇涔熸槸璋冪敤杩欎釜鏂规硶 + string aa = hub.Clients.All.showMessage("杩欓噷闈㈠彲浠ユ斁鍏ヤ换鎰忓璞�,鍓嶅彴鍙互鏀跺埌姝ゅ唴瀹�"); + return request.CreateResponse(HttpStatusCode.OK, aa); + } + + [Route("Message/MsgCount")] + [HttpPost] + public object MsgCount() + { + ClsCNSRM oCn = new ClsCNSRM(); + DataSet oDs = new DataSet(); + oDs = oCn.RunProcReturn("select * from Gy_Message", "Gy_Message"); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "杩斿洖鏁版嵁"; + objJsonResult.data = oDs; + return objJsonResult; ; + } + + + #region [鍏憡鏁版嵁鏌ヨ] + [Route("MsgData")] + [HttpGet] + public object MsgData(string sWhere) + { + ClsCNSRM oCn = new ClsCNSRM(); + DataSet oDs = new DataSet(); + var sql = "select A.HInterID,b.HEntryID,A.HContext,A.HDeptID,D.HName HDeptName, A.HSendMan, B.HReceiveMan,A.HLevel,A.HDescription,case when B.HReadFlag=0 then '鏈槄' when B.HReadFlag=1 then '宸查槄' end HReadFlag,A.HDate" + + " from OA_InformBillMain A inner join OA_InformBillSub B on A.HInterID=B.HInterID left join Gy_Department D on A.HDeptID=D.HItemID where 1=1 " + sWhere; + oDs = oCn.RunProcReturn(sql, "OA_InformBillMain"); + if (oDs.Tables[0].Rows.Count > 0) + { + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "杩斿洖鏁版嵁鎴愬姛锛�"; + objJsonResult.data = oDs; + } + else { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "杩斿洖鏁版嵁澶辫触锛�"; + objJsonResult.data = oDs; + } + return objJsonResult; ; + } + #endregion + + #region[鏇存敼鍏憡鐘舵�乚 + [Route("UpdateMessage")] + [HttpGet] + public object UpdateMessage(string UserName, string HInterID,string HEntryID) + { + ClsCNSRM oCn = new ClsCNSRM(); + oCn.BeginTran(); + oCn.RunProc("Update OA_InformBillSub set HReadFlag=1 HUpDater='"+ UserName + "',HUpDateDate=getdate() where HInterID='" + HInterID + "' and HEntryID='"+ HEntryID + "'", ref ClsPub.sExeReturnInfo); + oCn.Commit(); + objjson.code = "1"; + objjson.count = 1; + objjson.Message =ClsPub.sExeReturnInfo; + objjson.data = null; + return objjson;; + } + #endregion } } -- Gitblit v1.9.1