Type() public abstract method

public abstract Type ( ) : int
return int
Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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;
        }