public ResultJSON <string> ApplyBeMyClient(string carNo, int id, PlaceType placeType) { try { string accessToken; if (placeType == PlaceType.水上) { accessToken = AccessTokenContainer.TryGetToken(this.option.CorpId, this.option.水上计划Secret); } else { accessToken = AccessTokenContainer.TryGetToken(this.option.CorpId, this.option.陆上计划Secret); } string agentId = placeType == PlaceType.水上 ? option.水上计划AgentId : option.陆上计划AgentId; //推送到“水上或陆上计划” MassApi.SendTextCard(accessToken, agentId, $"{UserName}申请{carNo}成为他的客户" , $"<div class=\"gray\">客户:{carNo}</div>" , $"https://vue.car0774.com/#/sales/myclient/{id.ToString()}/{UserName}", toUser: "******"); return(new ResultJSON <string> { Code = 0, Msg = "提交申请成功" }); } catch { return(new ResultJSON <string> { Code = 503, Msg = "推送失败请重试" }); } }
public ActionResult GetMenu() { string accessToken = AccessTokenContainer.TryGetToken(ConfigSettings.TestWeixinAppID, ConfigSettings.TestWeixinAppSecret); MenuJsonResult menuResult = CommonApi.GetMenu(accessToken); return(Json(menuResult)); }
public ActionResult Index(string companyId) { try { if (string.IsNullOrWhiteSpace(companyId)) { return(RedirectToAction("Index", "BrowseError", new { errorMsg = "请打开扫一扫" })); } WX_ApiConfig config = WXApiConfigServices.QueryWXApiConfig(companyId); var timeStamp = DateTimeHelper.TransferUnixDateTime(DateTime.Now).ToString(); var nonceStr = StringHelper.GetRndString(16); var url = Request.Url.ToString(); var accessToken = AccessTokenContainer.TryGetToken(config.AppId, config.AppSecret, false); var ticket = WxAdvApi.GetTicket(accessToken); string signature = WxService.GetJsApiSignature(nonceStr, ticket.ticket, timeStamp, url); ViewBag.Signature = signature; ViewBag.AppId = config.AppId; ViewBag.Timestamp = timeStamp; ViewBag.NonceStr = nonceStr; return(View()); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPageError", "调用扫码方法异常", ex, LogFrom.WeiXin); return(RedirectToAction("Index", "BrowseError", new { errorMsg = "调用扫码方法异常" })); } }
/// <summary> /// 获取渠道的二维码 /// </summary> /// <param name="channelName">渠道实体</param> /// <returns></returns> private void GetQrcode(ChannelEntity entity) { //获取微信公众平台接口访问凭据 string accessToken = AccessTokenContainer.TryGetToken(ConfigurationManager.AppSettings["appID"], ConfigurationManager.AppSettings["appsecret"]); //找出一个未被使用的场景值ID,确保不同渠道使用不同的场景值ID int scenid = GetNotUsedSmallSceneId(); if (scenid <= 0 || scenid > 100000) { throw new Exception("抱歉,您的二维码已经用完,请删除部分后重新添加"); } CreateQrCodeResult createQrCodeResult = QrCode.Create(accessToken, 0, scenid); if (!string.IsNullOrEmpty(createQrCodeResult.ticket)) { using (MemoryStream stream = new MemoryStream()) { //根据ticket获取二维码 QrCode.ShowQrCode(createQrCodeResult.ticket, stream); //将获取到的二维码图片转换为Base64String格式 byte[] imageBytes = stream.ToArray(); string base64Image = System.Convert.ToBase64String(imageBytes); //由于SqlServerCompact数据库限制最长字符4000,本测试项目将二维码保存到磁盘,正式项目中可直接保存到数据库 string imageFile = "QrcodeImage" + scenid.ToString() + ".img"; File.WriteAllText(System.Web.HttpContext.Current.Server.MapPath("~/App_Data/") + imageFile, base64Image); entity.Qrcode = imageFile; entity.SceneId = scenid; } } else { throw new Exception("抱歉!获取二维码失败"); } }
/// <summary> /// 访问微信接口查看是否关注 /// </summary> private bool IsAttentionByRPC(string openId) { var siteSetting = Himall.ServiceProvider.Instance <ISiteSettingService> .Create.GetSiteSettings(); string accessToken = ""; if (!string.IsNullOrEmpty(siteSetting.WeixinAppId) || !string.IsNullOrEmpty(siteSetting.WeixinAppSecret)) { accessToken = AccessTokenContainer.TryGetToken(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret); } else { throw new HimallException("未配置微信相关信息"); } var result = UserApi.Info(accessToken, openId); if (result.errcode == Senparc.Weixin.ReturnCode.合法的OpenID || result.subscribe == 0) { return(false); } else if (result.errcode != 0) { throw new Exception(result.errmsg); } return(result.subscribe == 1); }
/// <summary> /// 微信关注数据追加 /// </summary> private static void InsertWechatFollowReport(int AccountManageID) { var objConfig = WeChatCommonService.GetWeChatConfigByID(AccountManageID); string strToken = AccessTokenContainer.TryGetToken(objConfig.WeixinCorpId, objConfig.WeixinCorpSecret); var departmentList = MailListApi.GetDepartmentMemberInfo(strToken, 1, 1, 0); //关注用户列表 var followerList = departmentList.userlist.Where(a => a.status == 1).ToList(); //为关注用户列表 var unFollowerList = departmentList.userlist.Where(a => a.status == 4).ToList(); DateTime dtNow = DateTime.Now; WechatFollowReport wechatFollowReport = new WechatFollowReport() { StatisticsDate = Convert.ToDateTime(dtNow.AddDays(-1).ToString("yyyy-MM-dd")), FollowCount = followerList.Count, UnFollowCount = unFollowerList.Count, CreatedDate = dtNow }; BaseService <WechatFollowReport> ser = new BaseService <WechatFollowReport>(); ser.Repository.Insert(wechatFollowReport); }
private string DownloadWxImage(string mediaId) { var siteSetting = ServiceProvider.Instance <ISiteSettingService> .Create.GetSiteSettings(); var token = AccessTokenContainer.TryGetToken(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret); var address = string.Format("https://file.api.weixin.qq.com/cgi-bin/media/get?access_token={0}&media_id={1}", token, mediaId); Random ra = new Random(); var fileName = DateTime.Now.ToString("yyyyMMddHHmmssffffff") + ra.Next(10) + ".jpg"; var ImageDir = "/Storage/Plat/Comment/"; WebClient wc = new WebClient(); try { string fullPath = Path.Combine(ImageDir, fileName); var data = wc.DownloadData(address); MemoryStream stream = new MemoryStream(data); Core.HimallIO.CreateFile(fullPath, stream, FileCreateType.Create); return(fullPath); } catch (Exception ex) { Log.Error("下载图片发生异常" + ex.Message); return(string.Empty); } }
public static WX_Info GetWxUserBaseInfo(WX_ApiConfig config, string openId, bool errorRetry = true) { var accessToken = AccessTokenContainer.TryGetToken(config.AppId, config.AppSecret); if (!string.IsNullOrWhiteSpace(accessToken) && !string.IsNullOrWhiteSpace(openId)) { try { WX_Info user = new WX_Info(); var userInfo = WxAdvApi.GetUserInfo(accessToken, openId); if (userInfo.subscribe == 0) { return(null); } user.City = userInfo.city; user.Country = userInfo.country; user.Headimgurl = DownloadHeadImg(openId, userInfo.headimgurl, config.CompanyID); user.Language = userInfo.language; user.NickName = userInfo.nickname; user.Province = userInfo.province; user.Sex = userInfo.sex == "1" ? "M" : "F"; user.LastSubscribeDate = DateTimeHelper.TransferUnixDateTime(userInfo.subscribe_time); return(user); } catch (Exception) { if (errorRetry) { GetWxUserBaseInfo(config, openId, false); } } } return(null); }
/// <summary> /// 获取openId对应的用户信息并存入数据库 /// </summary> /// <param name="openId">微信用户openId</param> /// <param name="execute">修改、删除或插入操作</param> /// <param name="failList">未成功获取到用户信息的openId列表</param> private static void ExecuteWeixinUser(string openId, GetExecute execute, List <string> failList) { string accessToken = AccessTokenContainer.TryGetToken(ConfigurationManager.AppSettings["appID"], ConfigurationManager.AppSettings["appsecret"]); var userInfo = User.Info(accessToken, openId); if (userInfo.errcode != ReturnCode.请求成功) { failList.Add(openId); } else { WeixinUserInfo entity = new WeixinUserInfo() { City = userInfo.city, Province = userInfo.province, Country = userInfo.country, HeadImgUrl = userInfo.headimgurl, Language = userInfo.language, Subscribe_time = userInfo.subscribe_time, Sex = (Int16)userInfo.sex, NickName = userInfo.nickname, OpenId = userInfo.openid }; execute(entity); } }
public string GetAccessToken(string appConfigName) { var corpId = WeixinConfig.GetCorpId(); var secret = WeixinConfig.GetAppSecret(appConfigName); return(AccessTokenContainer.TryGetToken(corpId, secret)); }
public string GetContactsAccessToken() { var corpId = WeixinConfig.GetCorpId(); var secret = WeixinConfig.GetContactsSecret(); return(AccessTokenContainer.TryGetToken(corpId, secret)); }
public string GetJsApiTicket(bool first = true) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(); if (string.IsNullOrEmpty(masterSettings.WeixinAppId) || string.IsNullOrEmpty(masterSettings.WeixinAppSecret)) { return(""); } string text = AccessTokenContainer.TryGetToken(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, false); string result = string.Empty; string format = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={0}&type=jsapi"; string responseResult = this.GetResponseResult(string.Format(format, text)); if (responseResult.Contains("ticket")) { JObject jObject = JsonConvert.DeserializeObject(responseResult) as JObject; result = jObject["ticket"].ToString(); } else { Globals.AppendLog(responseResult, text, "", "GetJsApiTicket"); if (responseResult.Contains("access_token is invalid or not latest") & first) { text = AccessTokenContainer.TryGetToken(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, true); return(this.GetJsApiTicket(false)); } } return(result); }
public UserController(IOptionsSnapshot<WorkOption> option, UserRepository repository) { r = repository; this.option = option.Value; this.option.AccessToken = AccessTokenContainer.TryGetToken(this.option.CorpId, this.option.Secret); }
public static void PushWechatMsg(string msg, string empCode) { string CorpID = Configuration.WeChatCorpID; string Secret = Configuration.WeChatSecret; var token = AccessTokenContainer.TryGetToken(CorpID, Secret, true); var result = MassApi.SendText(token, empCode, null, null, "3", msg, 0); }
private async Task <string> GetToken(string local_name, string CropId, string Secret) { try { if (string.IsNullOrWhiteSpace(CropId) || string.IsNullOrWhiteSpace(Secret)) { return(""); } string token_result = ""; var token = await _cacheManager.GetCache(UserManageConsts.Abp_Login_Token_Cache).GetOrDefaultAsync(CropId); if (token == null) { token = AccessTokenContainer.TryGetToken(CropId, Secret); if (token != null) { await _cacheManager.GetCache(UserManageConsts.Abp_Login_Token_Cache).SetAsync(local_name, token.ToString(), TimeSpan.FromHours(2)); } } token_result = token?.ToString(); return(token_result); } catch (Exception e) { Console.WriteLine(e); throw; } }
private async Task <string> GetToken(string AppId, string Secret) { try { if (string.IsNullOrWhiteSpace(AppId) || string.IsNullOrWhiteSpace(Secret)) { return(""); } string token_result = ""; var token = await _cacheManager.GetCache("CurrentToken").GetOrDefaultAsync(AppId); if (token == null) { token = AccessTokenContainer.TryGetToken(AppId, Secret); if (token != null) { await _cacheManager.GetCache("CurrentToken").SetAsync(this._options.AppId, token.ToString(), TimeSpan.FromHours(2)); } } token_result = token?.ToString(); return(token_result); } catch (Exception e) { Console.WriteLine(e); throw; } }
public ActionResult ApplyWithDraw() { var siteSetting = SiteSettingApplication.SiteSettings; if (string.IsNullOrWhiteSpace(siteSetting.WeixinAppId) || string.IsNullOrWhiteSpace(siteSetting.WeixinAppSecret)) { throw new HimallException("未配置公众号参数"); } var token = AccessTokenContainer.TryGetToken(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret); SceneModel scene = new SceneModel(QR_SCENE_Type.WithDraw) { Object = CurrentUser.Id.ToString() }; SceneHelper helper = new SceneHelper(); var sceneid = helper.SetModel(scene); var ticket = Senparc.Weixin.MP.AdvancedAPIs.QrCode.QrCodeApi.Create(token, 300, sceneid); ViewBag.ticket = ticket.ticket; ViewBag.Sceneid = sceneid; var balance = MemberCapitalApplication.GetBalanceByUserId(CurrentUser.Id); ViewBag.ApplyWithMoney = balance; var member = _iMemberService.GetMember(CurrentUser.Id);//CurrentUser对象有缓存,取不到最新数据 ViewBag.IsSetPwd = string.IsNullOrWhiteSpace(member.PayPwd) ? false : true; ViewBag.WithDrawMinimum = siteSetting.WithDrawMinimum; ViewBag.WithDrawMaximum = siteSetting.WithDrawMaximum; ViewBag.Keyword = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword; ViewBag.Keywords = SiteSettings.HotKeyWords; return(View()); }
public JsonResult PublishMenu(string companyId) { try { WX_ApiConfig config = WXApiConfigServices.QueryWXApiConfig(companyId); if (config == null || string.IsNullOrWhiteSpace(config.AppId) || string.IsNullOrWhiteSpace(config.AppSecret) || string.IsNullOrWhiteSpace(config.SystemName)) { throw new MyException("获取微信基础信息失败,请确认微信基础信息已配置"); } var accessToken = AccessTokenContainer.TryGetToken(config.AppId, config.AppSecret, false); var buttonGroup = ToButtonGroup(WXMenuServices.GetMenus(companyId)); TxtLogServices.WriteTxtLogEx("PublishMenu", JsonHelper.GetJsonString(buttonGroup)); var result = WxApi.CreateMenu(companyId, accessToken, buttonGroup); if (!result) { throw new MyException("发布菜单失败"); } return(Json(MyResult.Success())); } catch (MyException ex) { return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "发布菜单失败"); return(Json(MyResult.Error("发布菜单失败"))); } }
public JsonResult ResetWXIndustry() { if (!string.IsNullOrWhiteSpace(SiteSettings.WeixinAppId) && !string.IsNullOrWhiteSpace(SiteSettings.WeixinAppSecret)) { var accessToken = AccessTokenContainer.TryGetToken(SiteSettings.WeixinAppId, SiteSettings.WeixinAppSecret); var rdata = ApiHandlerWapper.TryCommonApi(actoken => { const string urlFormat = "https://api.weixin.qq.com/cgi-bin/template/api_set_industry?access_token={0}"; var msgData = new { industry_id1 = "1", industry_id2 = "4" }; return(CommonJsonSend.Send <Senparc.Weixin.Entities.WxJsonResult>(accessToken, urlFormat, msgData, timeOut: 10000)); }, accessToken); if (rdata.errcode == Senparc.Weixin.ReturnCode.请求成功) { return(Json(new { success = true })); } else { return(Json(new { success = false, msg = rdata.errcode.ToString() + ":" + rdata.errmsg })); } } else { return(Json(new { success = false, msg = "未配置微信公众信息!" })); } }
public void Test() { Console.WriteLine("工作执行" + string.Format("推送! - {0}", DateTime.Now.ToString())); logger.Info("工作执行" + string.Format("推送! - {0}", DateTime.Now.ToString())); try { string webPath = ConfigurationManager.AppSettings.Get("domain"); string tempStr = GetTemp(webPath + "/Temp.html"); var accessToken = AccessTokenContainer.TryGetToken( ConfigurationManager.AppSettings.Get("ShortWeixinAppId"), ConfigurationManager.AppSettings.Get("ShortWeixinSecret")); PushNews(accessToken, webPath, tempStr); Console.WriteLine("提交" + string.Format("推送成功! - {0}", DateTime.Now.ToString())); logger.Info("提交" + string.Format("推送成功! - {0}", DateTime.Now.ToString())); //accessToken = AccessTokenContainer.TryGetToken( //ConfigurationManager.AppSettings.Get("LongNameAppId"), //ConfigurationManager.AppSettings.Get("LongNameAppSecret")); //PushNews(accessToken, webPath, tempStr); //var MailService = new MailSendFunc(); //MailService.SendMail("*****@*****.**", "正常运行推送一次", "运行推送正常", mailCfg); } catch (Exception ex) { var MailService = new MailSendFunc(); MailService.SendMail("*****@*****.**", ex.Message, " 定时运行推送异常", mailCfg); Console.WriteLine(DateTime.Now.ToString() + " 定时执行推送失败 异常信息为" + ex.Message); logger.ErrorException(DateTime.Now.ToString() + " 定时执行推送失败 " + ex.Message, ex); } }
public async Task <ResultJSON <string> > ExportExcel(DateTime start, DateTime end) { try { List <MoveStore> list = r.GetAllList(m => m.CreatedAt >= start && m.CreatedAt <= end); if (list == null || list.Count == 0) { return new ResultJSON <string> { Code = 503, Msg = "没有相关数据" } } ; var excellist = new List <MoveStoreExcel>(); MoveStoreExcel me; #region 赋值到excel model foreach (var item in list) { me = new MoveStoreExcel { 单号 = item.Name, 状态 = Enum.GetName(typeof(MoveStoreState), item.State), 生产员 = item.Worker, 转出仓 = item.OutStoreName, 转出油温 = item.OutTemperature, 转出密度 = item.OutDensity, 计划转出升数 = item.OutPlan, 实际转出升数 = item.OutFact, 转入仓 = item.InStoreName, 转入油温 = item.InTemperature, 转入密度 = item.InDensity, 创建时间 = item.CreatedAt.ToString("yyyy-MM-dd hh:mm") }; excellist.Add(me); } #endregion string filePath = Path.Combine(_hostingEnvironment.WebRootPath, @"excel\"); string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + "_转仓单.xlsx"; Helper.FileHelper.ExportExcelByEPPlus(excellist, filePath + fileName); string filePathURL = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, @"excel/" + fileName); //推送到“导出数据” this.option.导出数据AccessToken = AccessTokenContainer.TryGetToken(this.option.CorpId, this.option.导出数据Secret); await MassApi.SendTextCardAsync(option.导出数据AccessToken, option.导出数据AgentId, $"{UserName}导出转仓单数据到Excel" , $"<div class=\"gray\">操作时间:{DateTime.Now.ToString()}</div>" + $"<div class=\"gray\">导出时间段:{start.ToString()} - {end.ToString()}</div>" , filePathURL, toUser : "******"); return(new ResultJSON <string> { Code = 0, Data = filePathURL }); } catch (Exception e) { return(new ResultJSON <string> { Code = 503, Msg = e.Message }); } }
public ActionResult EditTicket(string id, int appId) { //var obj = GetObject(id); var obj = _objService.Repository.GetByKey(int.Parse(id)); var questionView = _objService.GetQuestionDetail(id, obj); var user = _objUserService.GetBylillyId(obj.CreatedUserId); if (user != null) { questionView.Tel = user.Tel; } var objConfig = WeChatCommonService.GetWeChatConfig(obj.AppId.GetValueOrDefault()); string strToken = AccessTokenContainer.TryGetToken(objConfig.WeixinCorpId, objConfig.WeixinCorpSecret); var objone = MailListApi.GetMember(strToken, obj.CreatedUserId); if (objone != null) { questionView.EMail = objone.email; } if (!string.IsNullOrEmpty(id) && id != "0") { AppDataPermissionCheck(_permissionService, appId, obj.AppId.GetValueOrDefault()); } return(Json(questionView, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 添加二维码 /// </summary> /// <param name="qr"></param> /// <returns></returns> public JsonResult AddQRCode(string qr) { var result = new Result <bool>(); var flag = false; string message = string.Empty; var isInsert = 0; try { var qrModel = JsonHelper.FromJson <QRCode>(qr); //preSaleProduct = JsonHelper.FromJson<PreSaleProduct>(productJson); var accesstoken = AccessTokenContainer.TryGetToken(AppId, AppSecret); var qrResult = Senparc.Weixin.MP.AdvancedAPIs.QrCode.QrCodeApi.CreateByStr(accesstoken, qrModel.SourceCode); var qrLink = Senparc.Weixin.MP.AdvancedAPIs.QrCode.QrCodeApi.GetShowQrCodeUrl(qrResult.ticket); qrModel.QRCodeUrl = qrLink; qrModel.CreateTime = DateTime.Now; qrModel.Status = 1; isInsert = UserService.InsertQRCode(qrModel); } catch (Exception ex) { isInsert = 0; } return(Json(isInsert)); }
/// <summary> /// 获取微店小程序码 /// </summary> /// <param name="openId"></param> /// <returns></returns> public object GetWxacode(string pagePath, int width) { var sitesetting = SiteSettingApplication.SiteSettings; var accessToken = AccessTokenContainer.TryGetToken(sitesetting.WeixinAppletId, sitesetting.WeixinAppletSecret); var data = "{\"path\":\"" + HttpUtility.UrlDecode(pagePath) + "\",\"width\":" + width + "}"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.weixin.qq.com/wxa/getwxacode?access_token=" + accessToken); //创建url request.Method = "POST"; request.ContentType = "application/json;charset=UTF-8"; byte[] load = Encoding.UTF8.GetBytes(data); request.ContentLength = load.Length; Stream writer = request.GetRequestStream(); writer.Write(load, 0, load.Length); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream s = response.GetResponseStream(); byte[] mg = StreamToBytes(s); MemoryStream ms = new MemoryStream(mg); string qrCodeImagePath = string.Empty; qrCodeImagePath = "data:image/gif;base64," + Convert.ToBase64String(ms.ToArray()); ms.Dispose(); var QrCodeImagePath = qrCodeImagePath; var result = SuccessResult <dynamic>(data: QrCodeImagePath); return(Json(result)); }
/// <summary> /// 获取访问令牌 /// </summary> /// <param name="appid"></param> /// <param name="secret"></param> /// <returns></returns> public string GetAccessToken(string appid, string secret, bool IsGetNew = false) { string result = ""; if (!string.IsNullOrWhiteSpace(appid) && !string.IsNullOrWhiteSpace(secret)) { try { if (IsGetNew) { result = AccessTokenContainer.TryGetToken(appid, secret, true); } else { result = AccessTokenContainer.TryGetToken(appid, secret); } }catch (Exception ex) { Log.Error("[WXACT]appId=" + appid + ";appSecret=" + secret + ";" + ex.Message); } } else { throw new HimallException("未配置微信公众信息"); } return(result); }
public string TargetedValue() { string appId = string.Empty; string appSecret = string.Empty; SqlConnection con = new SqlConnection(SystemDefaultConfig.ReadConnectionString); SqlDataAdapter da = new SqlDataAdapter("select top 1 * from WX_ApiConfig", con); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { appId = dt.Rows[0]["AppId"].ToString(); appSecret = dt.Rows[0]["AppSecret"].ToString(); } else { return("微信AppID未配置"); } var accessToken = AccessTokenContainer.TryGetToken(appId, appSecret, false); var ticket = WxAdvApi.GetTicket(accessToken); StringBuilder strbui = new StringBuilder(); strbui.Append("{"); strbui.Append("\"accesstoken\":" + accessToken + ","); strbui.Append("\"ticket\":" + ticket.ticket + ","); strbui.Append("}"); return(strbui.ToString()); }
/// <summary> /// 申请提现 /// </summary> /// <param name="post"></param> /// <returns></returns> public JsonResult <Result <bool> > PostWithdraw(DistributionApplyWithdraw post) { CheckUserLogin(); var sitesettings = SiteSettingApplication.SiteSettings; post.MemberId = CurrentUser.Id; if (post.Type == DistributionWithdrawType.WeChat) //获取用户微信账户 { var mo = MemberApplication.GetMemberOpenIdInfoByuserId(CurrentUser.Id, Entities.MemberOpenIdInfo.AppIdTypeEnum.Payment, "Himall.Plugin.OAuth.WeiXin"); if (mo == null) { return(Json(ErrorResult <bool>("无法获取微信账号,请先在微信端绑定账号!"))); } var openid = mo.OpenId; post.WithdrawAccount = openid; if (!(string.IsNullOrWhiteSpace(sitesettings.WeixinAppId) || string.IsNullOrWhiteSpace(sitesettings.WeixinAppSecret))) { string token = AccessTokenContainer.TryGetToken(sitesettings.WeixinAppId, sitesettings.WeixinAppSecret); var user = CommonApi.GetUserInfo(token, openid); post.WithdrawName = user?.nickname ?? string.Empty; } } DistributionApplication.ApplyWithdraw(post); return(JsonResult(true)); }
public ActionResult SsoResult(string samlResponse, string RelayState) { LogManager.GetLogger(this.GetType()).Debug("Entering SsoResult... RelayState=" + RelayState); string lillyID = GetUserIdFromSaml(samlResponse, RelayState); LogManager.GetLogger(this.GetType()).Debug("SsoResult - lillyID : " + lillyID); // TODO: 应该在生产服务器上完成,但现在DMZ不能主动连外网,只能搞到外网的测试服务器上测试了。 //ViewBag.samlResponse = samlResponse; //ViewBag.RelayState = RelayState; //return View(); if (string.IsNullOrEmpty(RelayState)) { var Token = AccessTokenContainer.TryGetToken(CorpId, CorpSecret); LogManager.GetLogger(this.GetType()).Debug("Starting ConcernApi.TwoVerification... Token=" + Token + " - lillyid=" + lillyID); var result = ConcernApi.TwoVerification(Token, lillyID); return(Redirect("/subscribed.html")); } else { // 如果是其他网站的请求,直接返回给对方网站 ViewBag.samlResponse = samlResponse; ViewBag.RelayState = RelayState; return(View()); } }
public ResultJSON <Purchase> ChangeState([FromBody] Purchase p) { r.CurrentUser = UserName; var model = r.Update(p); model.LastUpdatedBy = UserName; if (p.State == Purchase.UnloadState.完工) { //推送到“卸油审核” this.option.卸油审核AccessToken = AccessTokenContainer.TryGetToken(this.option.CorpId, this.option.卸油审核Secret); MassApi.SendTextCard(option.卸油审核AccessToken, option.卸油审核AgentId, "卸油施工结束,请审核更新油仓" , $"<div class=\"gray\">单号:{model.Name}</div>" + $"<div class=\"normal\">车号:{model.CarNo}</div>" + $"<div class=\"normal\">计划数量:{model.Count}吨</div>" + $"<div class=\"normal\">卸仓数量:{model.OilCount}升</div>" + $"<div class=\"normal\">密度:{model.Density}</div>" , $"http://vue.car0774.com/#/purchase/purchase/" + model.Id + "/buyboard", toUser: "******"); } return(new ResultJSON <Purchase> { Code = 0, Data = model }); }
public bool Notify(string content, string[] toUser = null, string[] toParty = null, string[] toTag = null, EventLevel level = EventLevel.Normal, int timeOut = 10000) { try { List <string> members = null;// UserHelper.GetExtendIdsFromMembers(toUser, toParty, toTag); string token = AccessTokenContainer.TryGetToken(corpID, corpSecret); string users = null; if (members != null && members.Count > 0) { users = string.Join("|", members); } if (string.IsNullOrEmpty(users)) { users = "@all"; } MassResult massresult = MassApi.SendText(token, users, null, null, "0", content, 0, timeOut); if (massresult.errcode == 0) { return(true); } } catch { } return(false); }