/// <summary>
        /// 获取产品汇总费用分布
        /// </summary>
        /// <param name="req"><see cref="DescribeBillSummaryByProductRequest"/></param>
        /// <returns><see cref="DescribeBillSummaryByProductResponse"/></returns>
        public DescribeBillSummaryByProductResponse DescribeBillSummaryByProductSync(DescribeBillSummaryByProductRequest req)
        {
            JsonResponseModel <DescribeBillSummaryByProductResponse> rsp = null;

            try
            {
                var strResp = this.InternalRequestSync(req, "DescribeBillSummaryByProduct");
                rsp = JsonConvert.DeserializeObject <JsonResponseModel <DescribeBillSummaryByProductResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }
Ejemplo n.º 2
0
        public void Test()
        {
            int createFileIndex = 1;

            string[] allFiles = Directory.GetFiles(path, "*.xlsx");
            foreach (string strFile in allFiles)
            {
                File.Delete(strFile);
            }
            ListBoxItemAdd(this, this.listBox1, "프로그램 시작 합니다. ^_^");
            foreach (int indexChecked in checkedListBox1.CheckedIndices)
            {
                String lineStr = tt[indexChecked].ToString();
                Console.WriteLine(lineStr);
                try
                {
                    string[] sArray = lineStr.Split('	');
                    if (sArray.Count() < 2)                                      //작업완료 판단
                    {
                        break;
                    }

                    Company            = sArray[0];
                    UIN                = sArray[1].Replace(" ", "");
                    SecretIdfromeFile  = sArray[2].Replace(" ", "");
                    SecretKeyfromeFile = sArray[3].Replace(" ", "");
                    SecretKeyfromeFile = sArray[3].Replace(" ", "");
                    CVMRegion          = sArray[4].Replace(" ", "");

                    BeginTime = dateTimePicker1.Value.ToString("yyyy-MM-01 00:00:00");
                    EndTime   = dateTimePicker1.Value.ToString("yyyy-MM-01 00:00:01");
                    months    = dateTimePicker1.Value.ToString("yyyy년MM월");
                    Console.WriteLine(Company);
                    Console.WriteLine(UIN);
                    Console.WriteLine(SecretIdfromeFile);
                    Console.WriteLine(SecretKeyfromeFile);
                    Console.WriteLine(BeginTime);
                    Console.WriteLine(EndTime);
                    Thread.Sleep(1000);
                    ListBoxItemAdd(this, this.listBox1, "======<< 업체명 : " + Company + " >>=====");

                    fileName = createFileIndex + "-" + Company + "-" + months + ".xlsx";   //파일생성
                    WriteExel(fileName, 1, 1, "TotalCost");
                    WriteExel("모든업체-" + months + ".xlsx", allCompanyIndex, 1, Company);

                    Credential cred = new Credential
                    {
                        SecretId  = SecretIdfromeFile,
                        SecretKey = SecretKeyfromeFile
                    };

                    ClientProfile clientProfile = new ClientProfile();
                    HttpProfile   httpProfile   = new HttpProfile();
                    httpProfile.Endpoint      = ("billing.tencentcloudapi.com");
                    clientProfile.HttpProfile = httpProfile;
                    BillingClient client = new BillingClient(cred, CVMRegion, clientProfile);
                    DescribeBillSummaryByProductRequest req = new DescribeBillSummaryByProductRequest();
                    string strParams = "{\"PayerUin\":\"" + UIN + "\",\"BeginTime\":\"" + BeginTime + "\",\"EndTime\":\"" + EndTime + "\"}";
                    req = DescribeBillSummaryByProductRequest.FromJsonString <DescribeBillSummaryByProductRequest>(strParams);
                    DescribeBillSummaryByProductResponse resp = client.DescribeBillSummaryByProduct(req).ConfigureAwait(false).GetAwaiter().GetResult();
                    //  Console.WriteLine(AbstractModel.ToJsonString(resp));
                    String ttt = AbstractModel.ToJsonString(resp);

                    String total = GetSummaryTotal(ttt);
                    WriteExel(fileName, 1, 2, total);
                    WriteExel("모든업체-" + months + ".xlsx", allCompanyIndex, 2, total);
                    allCompanyIndex++;

                    ListBoxItemAdd(this, this.listBox1, "Total : =》  " + total);

                    Dictionary <string, string> Overview = GetSummaryOverview(ttt);
                    exelIndex = 2;
                    foreach (var item in Overview)
                    {
                        Console.WriteLine(item.Key + item.Value);
                        WriteExel(fileName, exelIndex, 1, item.Key);
                        WriteExel(fileName, exelIndex, 2, item.Value);
                        exelIndex++;
                        ListBoxItemAdd(this, this.listBox1, item.Key + "  --->    " + item.Value);
                    }
                    createFileIndex++;
                    Thread.Sleep(100);
                }
                catch (Exception e)
                {
                    //WriteExel(fileName, exelIndex, 1, Company);
                    WriteExel("모든업체-" + months + ".xlsx", allCompanyIndex, 2, "에러");
                    createFileIndex++;
                    ListBoxItemAdd(this, this.listBox1, "<< 업체명 : " + Company + " >> 요금 실패~~");
                }
                ListBoxItemAdd(this, this.listBox1, " ");
                ListBoxItemAdd(this, this.listBox1, " ");
            }
        }