using EMIS.CommonLogic.SystemServices; using EMIS.Utility.OnlinePay; using System; using System.Collections.Generic; using System.Linq; using System.Web; using Senparc.Weixin; using System.Web.Mvc; using Senparc.Weixin.MP.AdvancedAPIs; using EMIS.CommonLogic.ProjectShareManage; namespace EMIS.Web.ServiceControllers.SystemManage { public class AnnouncementServicesController : Controller { public IAnnouncementServices AnnouncementServices { get; set; } public IShareRecordServices shareRecordServices { get; set; } public ActionResult GetAnnouncementViewInfo(Guid? announcementID) { return Json(AnnouncementServices.GetAnnouncementViewInfo(announcementID), JsonRequestBehavior.AllowGet); } public ActionResult GetUserAnnouncementView(Guid userID, int pageIndex, int pageSize) { return Json(AnnouncementServices.GetUserAnnouncementView(userID, pageIndex, pageSize), JsonRequestBehavior.AllowGet); } public ActionResult GetWeChatAppID() { string appID = Config.SenparcWeixinSetting.TenPayV3_AppId; return Json(appID); } public ActionResult GetEmpowerUrl(string url,string announcementID,string loginID) { var announcementIDStr = announcementID.Replace("-", ""); var stateStr = announcementIDStr + loginID; var urlStr = WechatHelper.GetBaseAuthorizeUrl(url, stateStr); //var openID = WechatHelper.GetOpenID(code); //var urlcode = Urlencode return Json(urlStr); } public ActionResult GetOpenID(string code) { try { var openID = WechatHelper.GetOpenID(code); return Json(openID); } catch (Exception ex) { return Json(ex.Message); } } public ActionResult CheckAndRecordScore(Guid? announcementID, string loginID, string openID) { try { shareRecordServices.CheckAndRecordScore(announcementID, loginID, openID); return Json("success"); } catch (Exception) { return Json("fail"); } } public ActionResult ChangeAnnouncementIDAndCheck(string stateStr) { var announcementIDStr = stateStr.Substring(0, 32); var LoginID = stateStr.Substring(32, stateStr.Length - 32); var announcementID = announcementIDStr.Insert(8, "-"); announcementID = announcementID.Insert(13, "-"); announcementID = announcementID.Insert(18, "-"); announcementID = announcementID.Insert(23, "-"); bool isok = AnnouncementServices.CheckAnnouncementID(announcementID); List vs = new List(); vs.Add(announcementID); vs.Add(LoginID); if (isok) { return Json(vs); } else { return Json(""); } } } }