From 10f1e7187eec02fb09cdbcb126761a8708f0181f Mon Sep 17 00:00:00 2001 From: falcon <9504402@qq.com> Date: Thu, 7 Mar 2019 15:23:17 +0800 Subject: [PATCH] =?UTF-8?q?(#2)=E5=A2=9E=E5=8A=A0=E4=B8=87=E4=BB=95?= =?UTF-8?q?=E8=BE=BE=E5=A4=84=E6=96=B9=E8=B0=83=E7=94=A8=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebSiteCode/Cmdjy/Cmdjy/Cmdjy.csproj | 2 + WebSiteCode/Cmdjy/Cmdjy/Dal/DjyDbContext.cs | 4 ++ .../Cmdjy/Cmdjy/Dal/Tables/WsdRequestLog.cs | 41 +++++++++++++++++++ WebSiteCode/Cmdjy/Cmdjy/WebContext.cs | 21 ++++++++++ .../Cmdjy/Cmdjy/ws/WsdInterface.asmx.cs | 28 +++++++++++++ 5 files changed, 96 insertions(+) create mode 100644 WebSiteCode/Cmdjy/Cmdjy/Dal/Tables/WsdRequestLog.cs create mode 100644 WebSiteCode/Cmdjy/Cmdjy/WebContext.cs diff --git a/WebSiteCode/Cmdjy/Cmdjy/Cmdjy.csproj b/WebSiteCode/Cmdjy/Cmdjy/Cmdjy.csproj index 9a21f34..3435ef1 100644 --- a/WebSiteCode/Cmdjy/Cmdjy/Cmdjy.csproj +++ b/WebSiteCode/Cmdjy/Cmdjy/Cmdjy.csproj @@ -192,6 +192,7 @@ + @@ -204,6 +205,7 @@ + HisInterface.asmx diff --git a/WebSiteCode/Cmdjy/Cmdjy/Dal/DjyDbContext.cs b/WebSiteCode/Cmdjy/Cmdjy/Dal/DjyDbContext.cs index 2907aa6..75c22d1 100644 --- a/WebSiteCode/Cmdjy/Cmdjy/Dal/DjyDbContext.cs +++ b/WebSiteCode/Cmdjy/Cmdjy/Dal/DjyDbContext.cs @@ -28,5 +28,9 @@ namespace Cmdjy.Dal /// 药品信息 /// public DbSet DrugInfos { get; set; } + /// + /// 万仕达下载日志 + /// + public DbSet WsdRequestLogs { get; set; } } } \ No newline at end of file diff --git a/WebSiteCode/Cmdjy/Cmdjy/Dal/Tables/WsdRequestLog.cs b/WebSiteCode/Cmdjy/Cmdjy/Dal/Tables/WsdRequestLog.cs new file mode 100644 index 0000000..89e0735 --- /dev/null +++ b/WebSiteCode/Cmdjy/Cmdjy/Dal/Tables/WsdRequestLog.cs @@ -0,0 +1,41 @@ +using System; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Cmdjy.Dal.Tables +{ + /// + /// 客户端下载处方记录 + /// + [Table("WsdRequestLog")] + public class WsdRequestLog + { + /// + /// 主键。日志流水号 + /// + public int Id { get; set; } + /// + /// 日志记录时间 + /// + public DateTime LogDatatime { get; set; } + /// + /// 客户端地址 + /// + public string ClientAddress { get; set; } + /// + /// 获取的处方流水 + /// + public string PrescriptionId { get; set; } + /// + /// 获取的药品流水号 + /// + public string DrugId { get; set; } + /// + /// 开始编号 + /// + public string StartNo { get; set; } + /// + /// 获取最大记录数 + /// + public string MaxCount { get; set; } + } +} \ No newline at end of file diff --git a/WebSiteCode/Cmdjy/Cmdjy/WebContext.cs b/WebSiteCode/Cmdjy/Cmdjy/WebContext.cs new file mode 100644 index 0000000..f7793df --- /dev/null +++ b/WebSiteCode/Cmdjy/Cmdjy/WebContext.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Cmdjy +{ + /// + /// 网站执行上下文 + /// + public static class WebContext + { + /// + /// 记录日志记录 + /// + /// 日志信息 + public static void Log(string msg) { + + } + } +} \ No newline at end of file diff --git a/WebSiteCode/Cmdjy/Cmdjy/ws/WsdInterface.asmx.cs b/WebSiteCode/Cmdjy/Cmdjy/ws/WsdInterface.asmx.cs index d305b73..618df52 100644 --- a/WebSiteCode/Cmdjy/Cmdjy/ws/WsdInterface.asmx.cs +++ b/WebSiteCode/Cmdjy/Cmdjy/ws/WsdInterface.asmx.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Web.Services; using Cmdjy.Bll; using Newtonsoft.Json; +using System.Threading.Tasks; namespace Cmdjy.ws { @@ -71,12 +72,39 @@ namespace Cmdjy.ws try { var resStr = JsonConvert.SerializeObject(result); var mw = DesHelper.GetHelper().Encrypty(resStr); + logWsdRequest(info,result,resStr,mw); return mw; } catch(Exception ex) { return ex.ToString(); } } + /// + /// 记录日志 + /// + /// 请求信息 + /// 响应对象 + /// 响应字符串 + /// 响应密文 + private void logWsdRequest(WsdRequest info,WsdResult result,string resStr,string mw) { + using(var db = new Dal.DjyDbContext()) { + if(result != null && result.Prescriptions != null) { + foreach(var p in result.Prescriptions) { + if(p.Drugs != null) { + foreach(var d in p.Drugs) { + db.WsdRequestLogs.Add(new Dal.Tables.WsdRequestLog { + StartNo = info.StartNo,MaxCount = info.MaxCount, + ClientAddress = this.Context.Request.UserHostAddress, + LogDatatime = DateTime.Now,DrugId = d.Id.ToString(), + PrescriptionId = p.Id.ToString(), + }); + } + } + } + } + db.SaveChanges(); + } + } /// /// 从数据库获取药品列表