using PMS.Interface.ExternalManage; using PMS.Interface; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using PMS.Plugins.Common; using PMS.EntityModels.ExternalManage; using PMS.Interface.ProManager; using System.Runtime.Remoting.Contexts; using Microsoft.AspNet.SignalR.Infrastructure; using QWPlatform.SystemLibrary.LogManager; using Org.BouncyCastle.Asn1.Crmf; namespace PMS.WebUI.Controllers { [CheckLogin(false)] public class ExternalViewController : BaseController { IExternalView externalView = InterfaceFactory.CreateBusinessInstance(); IProModule ProModule = InterfaceFactory.CreateBusinessInstance(); private static Logger Log = Logger.Instance; // GET: ExternalView public ActionResult ExternalView(string id) { var res = externalView.GetAccredit(id); if(res.状态 == 1) { ViewBag.RequestId = id; return View("~/Views/ExternalManage/ExternalView.cshtml"); }else { return Content("页面不存在", "text/plain"); } } [HttpPost] public ActionResult GetAccreditByUrl(string id, string projectId) { var json = externalView.GetAccreditByUrl(id, projectId); if(json != null) { return this.ResponseJson(System.Net.HttpStatusCode.OK, "", json.ID); }else { return this.ResponseJson(System.Net.HttpStatusCode.OK, "您还没有申请验证码,请申请验证码!", externalView.GetAccredit(id).ID); } } [HttpPost] public ActionResult ApplyVerifyCode(ExternalValidate model) { if(model.ID.IsNullOrEmpty()) { var ipAddress = Request.ServerVariables["REMOTE_ADDR"]; var data = new ExternalRecords() { 渠道ID = model.渠道ID, 项目ID = model.项目ID, 访问IP = ipAddress, 访问操作 = RecordsType.申请验证码 }; } var json = externalView.ApplyVerifyCode(model); if (!json.ID.IsNullOrEmpty()) { if (model.ID.IsNullOrEmpty()) { var ipAddress = Request.ServerVariables["REMOTE_ADDR"]; var data = new ExternalRecords() { 渠道ID = model.渠道ID, 项目ID = model.项目ID, 访问IP = ipAddress, 访问操作 = RecordsType.申请验证码, 授权ID = json.ID }; var res = externalView.AddAccessRecords(data); if (!res) { Log.Error($"访客ip【{ipAddress}】进行了申请验证码操作"); } } return this.ResponseJson(System.Net.HttpStatusCode.OK, "成功", json.ID); } else { return this.ResponseJson(System.Net.HttpStatusCode.InternalServerError, "失败"); } } [HttpPost] public ActionResult VerifyCode(ExternalValidate model) { var ipAddress = Request.ServerVariables["REMOTE_ADDR"]; var data = new ExternalRecords() { 渠道ID = model.渠道ID, 项目ID = model.项目ID, 访问IP = ipAddress, 授权ID = model.ID }; string msg = ""; var json = externalView.VerifyCode(model); if (json != null && !json.ID.IsNullOrEmpty()) { if(json.状态 == 0) { data.访问操作 = RecordsType.验证码输入错误; msg = "您输入的验证码已停用!"; } else { data.访问操作 = RecordsType.验证码输入正确并开始访问文档; } } else { data.访问操作 = RecordsType.验证码输入错误; msg = "您输入的验证码错误!"; } var res = externalView.AddAccessRecords(data); if (!res) { Log.Error($"访客ip【{ipAddress}】进行了输入验证码操作"); } return this.ResponseJson(msg == "" ? System.Net.HttpStatusCode.OK : System.Net.HttpStatusCode.InternalServerError, msg); } /// /// 关键字查询外部服务分类 /// /// 关键字 /// [HttpPost] public ActionResult GetExternalClass(string keyword, List classIds, string id, int type) { var json = externalView.GetExternalClass(keyword, classIds, id, type); return Content(json, "application/json"); } /// /// 获取服务列表 /// /// 分类id /// 关键字 /// [HttpPost] public ActionResult GetExternalView(string class_id, string keyword) { var json = externalView.GetExternalView(class_id, keyword); return Content(json, "application/json"); } /// /// 获取全部渠道信息 /// /// public ActionResult Datagrid() { string json = externalView.Datagrid(); return Content(json, "application/json"); } /// /// 根据数据权限获取项目 /// /// /// /// public ActionResult BingProData(string ChannelID, string Search) { string json = ProModule.Get_Pro_NoAuthor(ChannelID, Search); return Content(json, "application/json"); } } }