public bool ValidateData(bool checkSummary = true) { if (string.IsNullOrEmpty(this.AppID)) { throw new WXException(1, "AppID can't be empty."); } if (string.IsNullOrEmpty(this.SdkVersion) || string.IsNullOrEmpty(this.CheckContent) || string.IsNullOrEmpty(this.CheckSummary)) { return(false); } if (this.Req == null && this.Resp == null) { return(false); } if (this.Req != null && !this.Req.ValidateData()) { return(false); } if (this.Resp != null && !this.Resp.ValidateData()) { return(false); } if (checkSummary) { string checkSummary2 = WXApiImplV1.getCheckSummary(this.CheckContent, this.SdkVersion, this.AppID); if (checkSummary2 == null || !checkSummary2.Equals(this.CheckSummary, StringComparison.CurrentCultureIgnoreCase)) { return(false); } } return(true); }
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); }