public string GetEnrollmentUsageByMonth(DateTime month, UsageReportType type, string enrollmentNumber, string jwt, string format, bool throwWebException = false) { string url = string.Format(downloadUsageByMonthUrlTemplate, enrollmentNumber, month, type, format); string response = GetResponse(url, jwt, throwWebException); return(response); }
public UsageReportApiResponse(UsageReportType type, DateTime reportMonth, string reportExtensionName, Byte[] reportFileStream) { this.Type = type; this.reportMonth = reportMonth; this.ReportExtensionName = reportExtensionName; this.ReportFileStream = reportFileStream; this.ObjectType = "Usage"; }
private void btnStreamDownload_Click(object sender, EventArgs e) { ValidateInputForUsageMonth(); UsageReportType type = (UsageReportType)reportTypeCB.SelectedIndex; string json = downloadHlHelper.GetEnrollmentUsageByMonthStream(monthCalendar.SelectionEnd, type, enrollmentMonthTx.Text, accessKeyMonthTx.Text, formatCB.Text); reportBytes = Encoding.Default.GetBytes(json); jsonMonthTx.Text = json; }
private void btnStreamDownload_Click(object sender, EventArgs e) { using (var wcur = new WaitCursor()) { ValidateInputForUsageMonth(); UsageReportType type = (UsageReportType)reportTypeCB.SelectedIndex; string json = GetEnrollmentUsageByMonthStream(monthCalendar.SelectionEnd, type, enrollmentMonthTx.Text, accessKeyUsageTxt.Text, formatCB.Text).Result; reportBytes = Encoding.Default.GetBytes(json); jsonMonthTx.Text = json; } }
public async Task <string> GetEnrollmentUsageByMonthStream(DateTime month, UsageReportType type, string enrollmentNumber, string jwt, string format) { string url = string.Format(downloadUsageByMonthUrlTemplate, enrollmentNumber, month, type, format); HttpResponseMessage response = await GetResponseStream(url, jwt); string responseMsg = string.Empty; responseMsg = await response.Content.ReadAsStringAsync(); if (!response.StatusCode.Equals(HttpStatusCode.OK)) { MessageBox.Show("An error occured getting data GetEnrollmentUsageByMonthStream::" + responseMsg); } return(responseMsg); }
private async void displayReportData(string reportDate, string reportType, string UrlToReport) { using (new WaitCursor()) { string urlToFetch = UrlToReport; DateTime currentReportDate = DateTime.Parse(reportDate); UsageReportType curType = (UsageReportType)Enum.Parse(typeof(UsageReportType), reportType); updateStatus("Fetching data ...", true); string usageDataJson = await GetEnrollmentUsageByMonth(currentReportDate, curType, currentConfig.EnrollmentNumber, currentToken.Token, "json"); usageReportDataGrid.DataSource = null; usageReportDataGrid.AutoGenerateColumns = true; usageListJsonTx.Text = usageDataJson; currentDataLabel.Text = $"{reportType} {currentReportDate.ToString("MMMM")}-{currentReportDate.Year}"; switch (curType) { case UsageReportType.Detail: { try { dataTabBindingSource.DataSource = JsonConvert.DeserializeObject <List <EAUsageDetailItem> >(usageDataJson); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } break; } case UsageReportType.PriceSheet: { try { dataTabBindingSource.DataSource = JsonConvert.DeserializeObject <List <EAPriceSheetItem> >(usageDataJson); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } break; } case UsageReportType.StoreCharge: { dataTabBindingSource.DataSource = JsonConvert.DeserializeObject <List <EAStoreChargeItem> >(usageDataJson); break; } case UsageReportType.Summary: { try { dataTabBindingSource.DataSource = JsonConvert.DeserializeObject <List <EAUsageSummaryItem> >(usageDataJson); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } break; } case UsageReportType.ReconcileUsageToPriceSheet: { try { //For this case, we are combining 2 data sets. Get them both and then combine them dataTabBindingSource.DataSource = JsonConvert.DeserializeObject <List <EAUsageSummaryItem> >(usageDataJson); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } break; } case UsageReportType.ReconcileStoreChargeToPriceSheet: { try { dataTabBindingSource.DataSource = JsonConvert.DeserializeObject <List <EAUsageSummaryItem> >(usageDataJson); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } break; } } updateStatus("Data recieved, binding to views ...", true); dataTabs.SelectedTab = dataTabs.TabPages["dataTab"]; usageReportDataGrid.DataSource = dataTabBindingSource; usageReportDataGrid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); updateStatus("Ready", false); } }