Пример #1
0
        private async void buttonRESTGet_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (quotaClient == null)
                {
                    quotaClient = new QuotaClient(
                        tbApplicationId.Text,
                        tbPassword.Text,
                        tbSubscriptionId.Text,
                        tbTenantId.Text,
                        tbResourceGroupName.Text,
                        tbResourceName.Text);
                }
                var quota = await quotaClient.GetQuotaAsync();

                var sb = new StringBuilder();
                if (actionStatistics != null)
                {
                    if (lastQuota != null)
                    {
                        actionStatistics.IncOfMessage = quota.TotalMessage - lastQuota.TotalMessage;
                        sb.AppendLine("Timestamp:" + actionStatistics.Timestamp.ToString("yyyy/MM/dd HH:mm:ss"));
                        sb.AppendLine("Action: " + actionStatistics.Action);
                        sb.AppendLine("Increased : " + actionStatistics.IncOfMessage);
                    }
                }
                else
                {
                    sb.AppendLine("Timestamp:" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
                    sb.AppendLine(string.Format("CurrentMessages/Max : {0}/{1}", quota.TotalMessage, quota.MessageMaxValue));
                }
                lastQuota = quota;
                if (!string.IsNullOrEmpty(tbRESTResult.Text))
                {
                    sb.AppendLine("--------------------------------------------");
                    sb.Append(tbRESTResult.Text);
                }
                tbRESTResult.Text = sb.ToString();
            }
            catch (Exception ex)
            {
                new Task(() =>
                {
                    MessageBox.Show(ex.Message);
                }).Start();
            }
        }
Пример #2
0
        public async Task Run()
        {
            var quotaClient = new QuotaClient(applicationId, password, subscriptionId, tenantId, resourceGroupName, iotHubName);

            try
            {
                var result = await quotaClient.GetQuotaAsync();

                Console.WriteLine("MeasuredTime:" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
                Console.WriteLine("TotalMessage:" + result.TotalMessage + "/MaxMessage:" + result.MessageMaxValue + ",TotalDevice:" + result.TotalDeviceCount + "/MaxDevice:" + result.TotalDeviceMaxValue);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Please check arguments or network!");
                Console.WriteLine(ex.Message);
            }
        }