public WxOfficial GetEntityByAppId(string appId) { var specification = new Specification <WxOfficial>(p => p.AppId == appId); WxOfficial wxOfficial = wxOfficialRepository.Find(specification); return(wxOfficial); }
public void Subscribe(string toUserName, string fromUserName, DateTime subscribeTime) { var wxOfficialSpecification = new Specification <WxOfficial>(p => p.Account == toUserName); WxOfficial wxOfficial = wxOfficialRepository.Find(wxOfficialSpecification); var wxUserSpecification = new Specification <WxUser>(p => p.AppId == wxOfficial.AppId && p.OpenId == fromUserName); WxUser wxUser = wxUserRepository.Find(wxUserSpecification); if (wxUser == null) { wxUser = new WxUser(); wxUser.Id = IdWorkerHelper.GenId64(); wxUser.AppId = wxOfficial.AppId; wxUser.OpenId = fromUserName; wxUser.SubscribeTime = subscribeTime; wxUser.SubscribeStatus = 1; wxUserRepository.Add(wxUser); } else { wxUser.SubscribeStatus = 1; wxUser.SubscribeTime = subscribeTime; wxUserRepository.Update(wxUser); } }
public void DeleteForm(string keyValue) { var id = Convert.ToInt64(keyValue); WxOfficial wxOfficial = wxOfficialRepository.Get(id); wxOfficial.DeletedMark = true; wxOfficial.DeletionTime = DateTime.Now; wxOfficialRepository.Update(wxOfficial); }
public WxOfficialOutputDto GetForm(string keyValue) { var id = Convert.ToInt64(keyValue); WxOfficialOutputDto wxOfficialOutputDto = new WxOfficialOutputDto(); WxOfficial wxOfficial = wxOfficialRepository.Get(id); AutoMapper.Mapper.Map <WxOfficial, WxOfficialOutputDto>(wxOfficial, wxOfficialOutputDto); return(wxOfficialOutputDto); }
public ActionResult Get(PostModel postModel, string echostr) { WxOfficialService wxOfficialService = new WxOfficialService(); WxOfficial wxOfficial = wxOfficialService.GetEntityByAppId(postModel.AppId); if (CheckSignature.Check(postModel.Signature, postModel.Timestamp, postModel.Nonce, wxOfficial.Token)) { return(Content(echostr)); //返回随机字符串则表示验证通过 } else { return(Content("failed:" + postModel.Signature + "," + Senparc.Weixin.MP.CheckSignature.GetSignature(postModel.Timestamp, postModel.Nonce, wxOfficial.Token) + "。" + "如果你在浏览器中看到这句话,说明此地址可以被作为微信公众账号后台的Url,请注意保持Token一致。")); } }
//public void Unsubscribe(string appId, string openId, DateTime subscribeTime) //{ // var specification = new Specification<WxUser>(p => p.AppId == appId && p.OpenId == openId); // WxUser wxUser = wxUserRepository.Find(specification); // if (wxUser != null) // { // wxUser.SubscribeStatus = 0; // wxUser.SubscribeTime = subscribeTime; // wxUserRepository.Update(wxUser); // } //} public void Unsubscribe(string toUserName, string fromUserName, DateTime createTime) { var wxOfficialSpecification = new Specification <WxOfficial>(p => p.Account == toUserName); WxOfficial wxOfficial = wxOfficialRepository.Find(wxOfficialSpecification); var wxUserSpecification = new Specification <WxUser>(p => p.AppId == wxOfficial.AppId && p.OpenId == fromUserName); WxUser wxUser = wxUserRepository.Find(wxUserSpecification); if (wxUser != null) { wxUser.SubscribeStatus = 0; wxUser.SubscribeTime = createTime; wxUserRepository.Update(wxUser); } }
public void SubmitForm(WxOfficialInputDto wxOfficialInputDto, string keyValue) { WxOfficial wxOfficial = new WxOfficial(); if (!string.IsNullOrEmpty(keyValue)) { var id = Convert.ToInt64(keyValue); wxOfficial = wxOfficialRepository.Get(id); AutoMapper.Mapper.Map <WxOfficialInputDto, WxOfficial>(wxOfficialInputDto, wxOfficial); wxOfficial.LastModificationTime = DateTime.Now; wxOfficialRepository.Update(wxOfficial); } else { AutoMapper.Mapper.Map <WxOfficialInputDto, WxOfficial>(wxOfficialInputDto, wxOfficial); wxOfficial.Id = IdWorkerHelper.GenId64(); wxOfficial.DeletedMark = false; wxOfficial.CreationTime = DateTime.Now; wxOfficial.CreatorUserId = 1; wxOfficialRepository.Add(wxOfficial); } }