/// <summary> /// Exports a list of Web Role objects for a given subscription. Each role object contains some metadata of the actual web role /// Since the "Exporter" was injected - we do not care how this is actually implemented - that decision is left to the exporter! /// </summary> public void ExportAllWebRoles() { // first get the correct header names and export these var _instanceNameHeader = MemberUtils.GetPropertyName <ComputeRole>(cr => cr.InstanceName); var _instanceSizeHeader = MemberUtils.GetPropertyName <ComputeRole>(cr => cr.InstanceSize); var _instanceStatusHeader = MemberUtils.GetPropertyName <ComputeRole>(cr => cr.InstanceStatus); var _roleNameHeader = MemberUtils.GetPropertyName <ComputeRole>(cr => cr.RoleName); var _serviceNameHeader = MemberUtils.GetPropertyName <ComputeRole>(cr => cr.ServiceName); var _osVersionHeader = MemberUtils.GetPropertyName <ComputeRole>(cr => cr.OsVersion); var _hourlyRateHeader = MemberUtils.GetPropertyName <ComputeRole>(cr => cr.HourlyRate); var _monthlyRateHeader = MemberUtils.GetPropertyName <ComputeRole>(cr => cr.MonthlyRate); IList <string> dataHeaders = new List <string> { _instanceNameHeader, _instanceSizeHeader, _instanceStatusHeader, _roleNameHeader, _serviceNameHeader, _osVersionHeader, _hourlyRateHeader, _monthlyRateHeader }; Exporter.ExportHeader(dataHeaders); // then retrieve the data values and export these var webRoleObj = GetAllWebRoles(); if (webRoleObj != null) { IList <string> dataCols = null; int totalMonthlyRate = 0; int runningTotalMonthlyRate = 0; foreach (var cr in webRoleObj.MyComputeRoles) { dataCols = new List <string> { cr.InstanceName, cr.InstanceSize, cr.InstanceStatus, cr.RoleName, cr.ServiceName, cr.OsVersion, cr.HourlyRate, cr.MonthlyRate }; Exporter.ExportDataRow(dataCols); int.TryParse(cr.MonthlyRate, out runningTotalMonthlyRate); totalMonthlyRate += runningTotalMonthlyRate; } var totals = new List <string> { "", "", "", "", "", "", "Total:", totalMonthlyRate.ToString() }; Exporter.ExportDataRow(totals); } }
/// <summary> /// Exports a list of Cloud Service objects for a given subscription. Each cloud service contains some metadata of the actual cloud service /// Since the "Exporter" was injected - we do not care how this is actually implemented - that decision is left to the exporter! /// </summary> public void ExportAllCloudServices() { // first get the correct header names and export these var _serviceNameHeader = MemberUtils.GetPropertyName <CloudService>(cs => cs.ServiceName); var _serviceUriHeader = MemberUtils.GetPropertyName <CloudService>(cs => cs.Uri); IList <string> dataHeaders = new List <string> { _serviceNameHeader, _serviceUriHeader }; Exporter.ExportHeader(dataHeaders); IList <string> dataCols = null; // then retrieve the data values and export these foreach (var cloudService in GetAllCloudServices().MyCloudServices) { dataCols = new List <string> { cloudService.ServiceName, cloudService.Uri }; Exporter.ExportDataRow(dataCols); } }
/// <summary> /// Exports a list of Virtual Machine Role objects for a given subscription. Each role object contains some metadata of the actual virtual machine role /// Since the "Exporter" was injected - we do not care how this is actually implemented - that decision is left to the exporter! /// </summary> public void ExportAllVirtualMachineRoles() { // first get the correct header names and export these var _roleNameHeader = MemberUtils.GetPropertyName <VirtualMachine>(vm => vm.RoleName); var _roleSizeHeader = MemberUtils.GetPropertyName <VirtualMachine>(vm => vm.RoleSize); var _roleTypeHeader = MemberUtils.GetPropertyName <VirtualMachine>(vm => vm.RoleType); var _osVersionHeader = MemberUtils.GetPropertyName <VirtualMachine>(vm => vm.OsVersion); var _hourlyRateHeader = MemberUtils.GetPropertyName <VirtualMachine>(cr => cr.HourlyRate); var _monthlyRateHeader = MemberUtils.GetPropertyName <VirtualMachine>(cr => cr.MonthlyRate); IList <string> dataHeaders = new List <string> { _roleNameHeader, _roleSizeHeader, _roleTypeHeader, _osVersionHeader, _hourlyRateHeader, _monthlyRateHeader }; Exporter.ExportHeader(dataHeaders); // then retrieve the data values and export these var vmObj = GetAllVirtualMachineRoles(); if (vmObj != null) { IList <string> dataCols = null; int totalMonthlyRate = 0; int runningTotalMonthlyRate = 0; foreach (var vm in vmObj.MyVirtualMachines) { dataCols = new List <string> { vm.RoleName, vm.RoleSize, vm.RoleType, vm.OsVersion, vm.HourlyRate, vm.MonthlyRate }; Exporter.ExportDataRow(dataCols); int.TryParse(vm.MonthlyRate, out runningTotalMonthlyRate); totalMonthlyRate += runningTotalMonthlyRate; } var totals = new List <string> { "", "", "", "", "Total:", totalMonthlyRate.ToString() }; Exporter.ExportDataRow(totals); } }