public async Task <bool> SendResp(BaseResp response, string targetAppId) { if (response == null) { throw new WXException(1, "Resp can't be null."); } if (string.IsNullOrEmpty(targetAppId)) { throw new WXException(1, "targetAppID can't be empty."); } var data = new TransactData { Resp = response, AppId = _appId, ConmandId = response.Type(), SdkVersion = ConstantsAPI.SDK_VERSION, CheckContent = GetCheckContent(), CheckSummary = GetCheckSummary(GetCheckContent(), ConstantsAPI.SDK_VERSION, _appId) }; if (string.IsNullOrEmpty(response.Transaction)) { response.Transaction = GetTransactionId(); } var folder = await ApplicationData.Current.LocalFolder.CreateFileAsync(ConstantsAPI.SDK_TEMP_DIR_PATH); string fileName = $"{TempFileName}.{targetAppId}"; //if (await FileUtil.fileExists(fileName)) //{ // await FileUtil.deleteFile(fileName); //} if (data.ValidateData(false)) { try { TransactData.WriteToFile(data, fileName, ConstantsAPI.SDK_TEMP_DIR_PATH); SendOut(fileName, targetAppId); return(true); } catch (Exception exception) { throw new WXException(0, exception.Message); } } return(false); }
public bool SendResp(BaseResp response, string targetAppID) { if (response == null) { throw new WXException(1, "Resp can't be null."); } if (string.IsNullOrEmpty(targetAppID)) { throw new WXException(1, "targetAppID can't be empty."); } TransactData transactData = new TransactData(); transactData.Resp = response; transactData.AppID = this.mAppID; transactData.ConmandID = response.Type(); transactData.SdkVersion = "1.5"; transactData.CheckContent = WXApiImplV1.getCheckContent(); transactData.CheckSummary = WXApiImplV1.getCheckSummary(transactData.CheckContent, transactData.SdkVersion, transactData.AppID); if (string.IsNullOrEmpty(response.Transaction)) { response.Transaction = WXApiImplV1.getTransactionId(); } if (!FileUtil.dirExists("wechat_sdk")) { FileUtil.createDir("wechat_sdk"); } string text = "wechat_sdk\\wp." + targetAppID; if (FileUtil.fileExists(text)) { FileUtil.deleteFile(text); } if (transactData.ValidateData(false)) { try { TransactData.WriteToFile(transactData, text); this.sendOut(text, targetAppID); return(true); } catch (Exception ex) { throw new WXException(0, ex.Message); } //return false; } return(false); }
public async Task<bool> SendResp(BaseResp response, string targetAppId) { if (response == null) { throw new WXException(1, "Resp can't be null."); } if (string.IsNullOrEmpty(targetAppId)) { throw new WXException(1, "targetAppID can't be empty."); } var data = new TransactData { Resp = response, AppId = _appId, ConmandId = response.Type(), SdkVersion = ConstantsAPI.SDK_VERSION, CheckContent = GetCheckContent(), CheckSummary = GetCheckSummary(GetCheckContent(), ConstantsAPI.SDK_VERSION, _appId) }; if (string.IsNullOrEmpty(response.Transaction)) { response.Transaction = GetTransactionId(); } var folder = await ApplicationData.Current.LocalFolder.CreateFileAsync(ConstantsAPI.SDK_TEMP_DIR_PATH); string fileName = $"{TempFileName}.{targetAppId}"; //if (await FileUtil.fileExists(fileName)) //{ // await FileUtil.deleteFile(fileName); //} if (data.ValidateData(false)) { try { TransactData.WriteToFile(data, fileName, ConstantsAPI.SDK_TEMP_DIR_PATH); SendOut(fileName, targetAppId); return true; } catch (Exception exception) { throw new WXException(0, exception.Message); } } return false; }
internal void FromProto(object protoObj) { if (protoObj == null) { return; } TransactDataP transactDataP = protoObj as TransactDataP; if (transactDataP == null) { return; } this.ConmandID = (int)transactDataP.ConmandID; this.AppID = transactDataP.AppID; this.SdkVersion = transactDataP.SdkVersion; this.CheckContent = transactDataP.CheckContent; this.CheckSummary = transactDataP.CheckSummary; if (!string.IsNullOrEmpty(transactDataP.GetReq.Base.Transaction)) { this.Req = new GetMessageFromWX.Req(); this.Req.FromProto(transactDataP.GetReq); } if (!string.IsNullOrEmpty(transactDataP.AuthReq.Base.Transaction)) { this.Req = new SendAuth.Req(); this.Req.FromProto(transactDataP.AuthReq); } if (!string.IsNullOrEmpty(transactDataP.SendReq.Base.Transaction)) { this.Req = new SendMessageToWX.Req(); this.Req.FromProto(transactDataP.SendReq); } if (!string.IsNullOrEmpty(transactDataP.ShowReq.Base.Transaction)) { this.Req = new ShowMessageFromWX.Req(); this.Req.FromProto(transactDataP.ShowReq); } if (!string.IsNullOrEmpty(transactDataP.GetResp.Base.Transaction)) { this.Resp = new GetMessageFromWX.Resp(); this.Resp.FromProto(transactDataP.GetResp); } if (!string.IsNullOrEmpty(transactDataP.AuthResp.Base.Transaction)) { this.Resp = new SendAuth.Resp(); this.Resp.FromProto(transactDataP.AuthResp); } if (!string.IsNullOrEmpty(transactDataP.SendResp.Base.Transaction)) { this.Resp = new SendMessageToWX.Resp(); this.Resp.FromProto(transactDataP.SendResp); } if (!string.IsNullOrEmpty(transactDataP.ShowResp.Base.Transaction)) { this.Resp = new ShowMessageFromWX.Resp(); this.Resp.FromProto(transactDataP.ShowResp); } if (!string.IsNullOrEmpty(transactDataP.PayReq.Base.Transaction)) { this.Req = new SendPay.Req(); this.Req.FromProto(transactDataP.PayReq); } if (!string.IsNullOrEmpty(transactDataP.PayResp.Base.Transaction)) { this.Resp = new SendPay.Resp(); this.Resp.FromProto(transactDataP.PayResp); } }