MyHttpServer.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. using Common;
  2. using LisPacsDataUpload;
  3. using Newtonsoft.Json;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. namespace ZLPlugin_LisPacs_MR_YJMZ
  11. {
  12. public class MyHttpServer : HttpServer
  13. {
  14. public MyHttpServer(int port)
  15. : base(port)
  16. {
  17. }
  18. public override void handleGETRequest(HttpProcessor p)
  19. {
  20. Object obj = new { result = 0, errmsg = "拒绝Get请求,请用Post方式提交。" };
  21. //Console.WriteLine("request: {0}", p.http_url);
  22. //Console.WriteLine("666");
  23. p.writeSuccess();
  24. p.outputStream.Write(JsonConvert.SerializeObject(obj));
  25. //p.outputStream.WriteLine("<html><body><h1>test server</h1>");
  26. //p.outputStream.WriteLine("Current Time: " + DateTime.Now.ToString());
  27. //p.outputStream.WriteLine("url : {0}", p.http_url);
  28. //p.outputStream.WriteLine("<form method=post action=/form>");
  29. //p.outputStream.WriteLine("<input type=text name=foo value=foovalue>");
  30. //p.outputStream.WriteLine("<input type=submit name=bar value=barvalue>");
  31. //p.outputStream.WriteLine("</form>");
  32. }
  33. public override void handlePOSTRequest(HttpProcessor p, StreamReader inputData)
  34. {
  35. Object obj = new { result = 1, errmsg = "hello啊打发撒旦" };
  36. //SocketClient client = new SocketClient("127.0.0.1", 6061);
  37. try
  38. {
  39. string input = inputData.ReadToEnd();
  40. LogHelper.Info("input:" + input);
  41. Data data = JsonConvert.DeserializeObject<Data>(input);
  42. ////obj = new { result = 1, errmsg = "" };
  43. ////int res = 1;
  44. ////int waittingdate = 0;
  45. //string sql = @"Select 互认 As AGREE,WAITINGDATE From zllpmr.互认配置表";
  46. //DataTable dt = OracleHelper<object>.RunQueryDS(sql);
  47. //int res = Convert.ToInt32(dt.Rows[0]["AGREE"]);
  48. //int waittingdate = Convert.ToInt32(dt.Rows[0]["WAITINGDATE"]);
  49. ////LisPacs_MR_Bll.IsAgree(out res, out waittingdate);
  50. //if (res == 0)//互认关闭
  51. //{
  52. // obj = new { result = 0, errmsg = "互认已关闭。" };
  53. // return;
  54. //}
  55. //List<YZData> ss_list = LisPacs_MR_Bll.GetYZList(lngSendID);
  56. //string code = "";
  57. //List<Codes> listlis;
  58. //List<Codes> listpacs;
  59. //LisPacs_MR_Bll.GetTreatmentId(ss_list, out code, out listlis, out listpacs);
  60. //Recordset rd = LisPacs_MR_Bll.GetMZPostJson(lngClinicID, code, hrType);
  61. //int hrType = 0;
  62. //if (listlis.Count == 0 && listpacs.Count == 0)
  63. //{
  64. // obj = new { result = 1, errmsg = "新开项目不存在检查或检验。" };
  65. // return;
  66. //}
  67. //else if (listlis.Count > 0 && listpacs.Count == 0)//只有检验
  68. //{
  69. // hrType = 1;
  70. //}
  71. //else if (listpacs.Count > 0 && listlis.Count == 0)//只有检查
  72. //{
  73. // hrType = 2;
  74. //}
  75. //if (lngModual == 1253)//住院
  76. //{
  77. // rd = LisPacs_MR_Bll.GetZYPostJson(lngPatientID, lngClinicID, code, hrType);
  78. //}
  79. //else
  80. //{
  81. // rd = LisPacs_MR_Bll.GetMZPostJson(lngClinicID, code, hrType);
  82. //}
  83. //string json = ZLPlugin_LisPacs_MR.Tools.RecordsetToJson(rd);
  84. //client.Send(json);
  85. //ZLPlugin_LisPacs_MR.Tools.Delay(10000, 0);
  86. //if (!string.IsNullOrWhiteSpace(SocketClient.Message))
  87. //{
  88. // //Log.Info(SocketClient.Message);
  89. // ResultsEx rex = new ResultsEx();
  90. // rex = JSON.JsonToObject<ResultsEx>(ZLPlugin_LisPacs_MR.Tools.FormatStr(SocketClient.Message), Encoding.UTF8);
  91. // if (rex.ResultCode == 2)//有互认
  92. // {
  93. // SocketClient.Message = null;
  94. // return SaveData(waittingdate, lngPatientID, lngClinicID, listlis, listpacs);
  95. // }
  96. // else if (rex.ResultCode == -1)//互认引用失败
  97. // {
  98. // //MessageBox.Show(rex.ResultText.ToString(), "中联软件", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
  99. // //return true;
  100. // }
  101. // else
  102. // {
  103. // //return true;//此病人不存在互认信息
  104. // }
  105. //}
  106. }
  107. catch(Exception ex)
  108. {
  109. LogHelper.Error(ex);
  110. //obj = new { result = 0, errmsg = ex.Message };
  111. }
  112. //if (client != null )
  113. //{
  114. // client.Close();
  115. //}
  116. p.writeSuccess();
  117. p.outputStream.Write(JsonConvert.SerializeObject(obj));
  118. //p.outputStream.WriteLine("<html><body><h1>test server</h1>");
  119. //p.outputStream.WriteLine("<a href=/test>return</a><p>");
  120. //p.outputStream.WriteLine("postbody: <pre>{0}</pre>", data);
  121. }
  122. }
  123. }