ExternalViewController.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. using PMS.Interface.ExternalManage;
  2. using PMS.Interface;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.Mvc;
  8. using PMS.Plugins.Common;
  9. using PMS.EntityModels.ExternalManage;
  10. using PMS.Interface.ProManager;
  11. using System.Runtime.Remoting.Contexts;
  12. using Microsoft.AspNet.SignalR.Infrastructure;
  13. using QWPlatform.SystemLibrary.LogManager;
  14. using Org.BouncyCastle.Asn1.Crmf;
  15. namespace PMS.WebUI.Controllers
  16. {
  17. [CheckLogin(false)]
  18. public class ExternalViewController : BaseController
  19. {
  20. IExternalView externalView = InterfaceFactory.CreateBusinessInstance<IExternalView>();
  21. IProModule ProModule = InterfaceFactory.CreateBusinessInstance<IProModule>();
  22. private static Logger Log = Logger.Instance;
  23. // GET: ExternalView
  24. public ActionResult ExternalView(string id)
  25. {
  26. var res = externalView.GetAccredit(id);
  27. if(res.状态 == 1)
  28. {
  29. ViewBag.RequestId = id;
  30. return View("~/Views/ExternalManage/ExternalView.cshtml");
  31. }else
  32. {
  33. return Content("页面不存在", "text/plain");
  34. }
  35. }
  36. [HttpPost]
  37. public ActionResult GetAccreditByUrl(string id, string projectId)
  38. {
  39. var json = externalView.GetAccreditByUrl(id, projectId);
  40. if(json != null)
  41. {
  42. return this.ResponseJson(System.Net.HttpStatusCode.OK, "", json.ID);
  43. }else
  44. {
  45. return this.ResponseJson(System.Net.HttpStatusCode.OK, "您还没有申请验证码,请申请验证码!", externalView.GetAccredit(id).ID);
  46. }
  47. }
  48. [HttpPost]
  49. public ActionResult ApplyVerifyCode(ExternalValidate model)
  50. {
  51. if(model.ID.IsNullOrEmpty())
  52. {
  53. var ipAddress = Request.ServerVariables["REMOTE_ADDR"];
  54. var data = new ExternalRecords()
  55. {
  56. 渠道ID = model.渠道ID,
  57. 项目ID = model.项目ID,
  58. 访问IP = ipAddress,
  59. 访问操作 = RecordsType.申请验证码
  60. };
  61. }
  62. var json = externalView.ApplyVerifyCode(model);
  63. if (!json.ID.IsNullOrEmpty())
  64. {
  65. if (model.ID.IsNullOrEmpty())
  66. {
  67. var ipAddress = Request.ServerVariables["REMOTE_ADDR"];
  68. var data = new ExternalRecords()
  69. {
  70. 渠道ID = model.渠道ID,
  71. 项目ID = model.项目ID,
  72. 访问IP = ipAddress,
  73. 访问操作 = RecordsType.申请验证码,
  74. 授权ID = json.ID
  75. };
  76. var res = externalView.AddAccessRecords(data);
  77. if (!res)
  78. {
  79. Log.Error($"访客ip【{ipAddress}】进行了申请验证码操作");
  80. }
  81. }
  82. return this.ResponseJson(System.Net.HttpStatusCode.OK, "成功", json.ID);
  83. }
  84. else
  85. {
  86. return this.ResponseJson(System.Net.HttpStatusCode.InternalServerError, "失败");
  87. }
  88. }
  89. [HttpPost]
  90. public ActionResult VerifyCode(ExternalValidate model)
  91. {
  92. var ipAddress = Request.ServerVariables["REMOTE_ADDR"];
  93. var data = new ExternalRecords()
  94. {
  95. 渠道ID = model.渠道ID,
  96. 项目ID = model.项目ID,
  97. 访问IP = ipAddress,
  98. 授权ID = model.ID
  99. };
  100. string msg = "";
  101. var json = externalView.VerifyCode(model);
  102. if (json != null && !json.ID.IsNullOrEmpty())
  103. {
  104. if(json.状态 == 0)
  105. {
  106. data.访问操作 = RecordsType.验证码输入错误;
  107. msg = "您输入的验证码已停用!";
  108. }
  109. else
  110. {
  111. data.访问操作 = RecordsType.验证码输入正确并开始访问文档;
  112. }
  113. }
  114. else
  115. {
  116. data.访问操作 = RecordsType.验证码输入错误;
  117. msg = "您输入的验证码错误!";
  118. }
  119. var res = externalView.AddAccessRecords(data);
  120. if (!res)
  121. {
  122. Log.Error($"访客ip【{ipAddress}】进行了输入验证码操作");
  123. }
  124. return this.ResponseJson(msg == "" ? System.Net.HttpStatusCode.OK : System.Net.HttpStatusCode.InternalServerError, msg);
  125. }
  126. /// <summary>
  127. /// 关键字查询外部服务分类
  128. /// </summary>
  129. /// <param name="keyword">关键字</param>
  130. /// <returns></returns>
  131. [HttpPost]
  132. public ActionResult GetExternalClass(string keyword, List<string> classIds, string id, int type)
  133. {
  134. var json = externalView.GetExternalClass(keyword, classIds, id, type);
  135. return Content(json, "application/json");
  136. }
  137. /// <summary>
  138. /// 获取服务列表
  139. /// </summary>
  140. /// <param name="class_id">分类id</param>
  141. /// <param name="keyword">关键字</param>
  142. /// <returns></returns>
  143. [HttpPost]
  144. public ActionResult GetExternalView(string class_id, string keyword)
  145. {
  146. var json = externalView.GetExternalView(class_id, keyword);
  147. return Content(json, "application/json");
  148. }
  149. /// <summary>
  150. /// 获取全部渠道信息
  151. /// </summary>
  152. /// <returns></returns>
  153. public ActionResult Datagrid()
  154. {
  155. string json = externalView.Datagrid();
  156. return Content(json, "application/json");
  157. }
  158. /// <summary>
  159. /// 根据数据权限获取项目
  160. /// </summary>
  161. /// <param name="ChannelID"></param>
  162. /// <param name="UserID"></param>
  163. /// <returns></returns>
  164. public ActionResult BingProData(string ChannelID, string Search)
  165. {
  166. string json = ProModule.Get_Pro_NoAuthor(ChannelID, Search);
  167. return Content(json, "application/json");
  168. }
  169. }
  170. }