示例#1
0
        private async Task <Result> GetAccessTokenAsync()
        {
            string apiGetToken = _configuration.GetValue <string>("AuthenToken:api");

            if (string.IsNullOrEmpty(apiGetToken))
            {
                return(Result.Fail("Không tìm thấy cấu hình AuthenToken:api trong file appsettings.json"));
            }

            string username = _configuration.GetValue <string>("AuthenToken:username");

            if (string.IsNullOrEmpty(username))
            {
                return(Result.Fail("Không tìm thấy cấu hình AuthenToken:username trong file appsettings.json"));
            }

            string password = _configuration.GetValue <string>("AuthenToken:password");

            if (string.IsNullOrEmpty(password))
            {
                return(Result.Fail("Không tìm thấy cấu hình AuthenToken:password trong file appsettings.json"));
            }

            string client_id = _configuration.GetValue <string>("AuthenToken:client_id");

            if (string.IsNullOrEmpty(client_id))
            {
                return(Result.Fail("Không tìm thấy cấu hình AuthenToken:client_id trong file appsettings.json"));
            }

            string grant_type = _configuration.GetValue <string>("AuthenToken:grant_type");

            if (string.IsNullOrEmpty(grant_type))
            {
                return(Result.Fail("Không tìm thấy cấu hình AuthenToken:grant_type trong file appsettings.json"));
            }

            string tendiaban = _configuration.GetValue <string>("AuthenToken:tendiaban");

            if (string.IsNullOrEmpty(tendiaban))
            {
                return(Result.Fail("Không tìm thấy cấu hình AuthenToken:tendiaban trong file appsettings.json"));
            }

            TokenParam tokenParam = new TokenParam
            {
                username   = username,
                password   = password,
                client_id  = client_id,
                grant_type = grant_type,
                tendiaban  = tendiaban
            };

            HttpClientPost httpClientPost = new HttpClientPost();

            return(await httpClientPost.SendsRequest(apiGetToken, "", tokenParam));
        }
示例#2
0
        private async Task <Result> GetSysScheduler(string urlAPI, string token)
        {
            string api = _configuration.GetValue <string>("ApiName:GetScheduler");

            if (string.IsNullOrEmpty(api))
            {
                return(Result.Fail("Không tìm thấy cấu hình ApiName:GetScheduler trong file appsettings.json"));
            }

            HttpClientPost httpClientPost = new HttpClientPost();

            return(await httpClientPost.SendsRequest(urlAPI + api, token));
        }
        public async Task <Result> SendDataToAPI()
        {
            string msg = GetDataReport(out List <F01_02_P2BCQTModel> oListF01_02_P2BCQT);

            if (msg.Length > 0)
            {
                return(Result.Fail(msg));
            }

            string api = _configuration.GetValue <string>("ApiName:F01_02_P2BCQT_Receive");

            if (string.IsNullOrEmpty(api))
            {
                return(Result.Fail("Không tìm thấy cấu hình ApiName:F01_02_P2BCQT_Receive trong file appsettings.json"));
            }

            HttpClientPost httpClientPost = new HttpClientPost();

            return(await httpClientPost.SendsRequest(_urlAPI + api, _token, oListF01_02_P2BCQT));
        }