123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- 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<IExternalView>();
- IProModule ProModule = InterfaceFactory.CreateBusinessInstance<IProModule>();
- 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);
- }
- /// <summary>
- /// 关键字查询外部服务分类
- /// </summary>
- /// <param name="keyword">关键字</param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetExternalClass(string keyword, List<string> classIds, string id, int type)
- {
- var json = externalView.GetExternalClass(keyword, classIds, id, type);
- return Content(json, "application/json");
- }
- /// <summary>
- /// 获取服务列表
- /// </summary>
- /// <param name="class_id">分类id</param>
- /// <param name="keyword">关键字</param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetExternalView(string class_id, string keyword)
- {
- var json = externalView.GetExternalView(class_id, keyword);
- return Content(json, "application/json");
- }
- /// <summary>
- /// 获取全部渠道信息
- /// </summary>
- /// <returns></returns>
- public ActionResult Datagrid()
- {
- string json = externalView.Datagrid();
- return Content(json, "application/json");
- }
- /// <summary>
- /// 根据数据权限获取项目
- /// </summary>
- /// <param name="ChannelID"></param>
- /// <param name="UserID"></param>
- /// <returns></returns>
- public ActionResult BingProData(string ChannelID, string Search)
- {
- string json = ProModule.Get_Pro_NoAuthor(ChannelID, Search);
- return Content(json, "application/json");
- }
- }
- }
|