public static WriteToFile ( |
||
data | ||
fileName | string | |
folderName | string | |
return | void |
public async Task <string> SendReq(BaseReq request, string targetAppId = ConstantsAPI.WECHAT_APP_ID) { int p = 0; try { if (request == null) { throw new WXException(1, "Req can't be null."); } if (string.IsNullOrEmpty(targetAppId)) { throw new WXException(1, "targetAppID can't be empty."); } p = 1; var data = new TransactData { Req = request, AppId = _appId, ConmandId = request.Type(), SdkVersion = ConstantsAPI.SDK_VERSION, CheckContent = GetCheckContent() }; data.CheckSummary = GetCheckSummary(data.CheckContent, data.SdkVersion, data.AppId); p = 2; if (string.IsNullOrEmpty(request.Transaction)) { request.Transaction = GetTransactionId(); } var folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(ConstantsAPI.SDK_TEMP_DIR_PATH, CreationCollisionOption.OpenIfExists); p = 3; string fileName = $"{TempFileName}.{targetAppId}"; //if (await FileUtil.fileExists(fileName)) //{ // await FileUtil.deleteFile(fileName); //} if (data.ValidateData(false)) { try { p = 4; 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"); } catch (Exception e) { return(e.Message + "p:" + p); } }
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); }