/// <summary> /// Queries for application data for billing purposes. This method returns a list of /// <see cref="T:Aneka.Entity.ApplicationView"/> instances containing user and cost /// information for generating bills. /// </summary> /// <param name="fromDate">The starting <see cref="T:System.DateTime"/> of period to query</param> /// <param name="toDate">The ending <see cref="T:System.DateTime"/> of the period to query</param> /// <returns>A list of <see cref="T:Aneka.Entity.ApplicationView"/>s ensapsulating /// data on each of the applications completed within the specified period</returns> public IList<ApplicationView> QueryBillingData(DateTime fromDate, DateTime toDate) { IList<ApplicationView> applicationViews = new List<ApplicationView>(); // Define new request to query all applications executed within // the specified timeslot AccountingQueryRequest request = new AccountingQueryRequest(fromDate, toDate); // Compose query message AccountingQueryMessage queryMessage = new QueryApplicationMessage(Constants.AccountingService, request); queryMessage.SecurityToken = this.securityToken; // Dispatch message and check result Message response = MessageDispatcher.SendMessage(ClientName, this.serviceAddress.Uri, queryMessage); if (response is ErrorMessage) { throw new ApplicationException("Failed to query utilization history: " + ((ErrorMessage)response).Cause); } else if (response is AccountingQueryResponseMessage) { applicationViews = ((AccountingQueryResponseMessage)response).DataList.ConvertAll<ApplicationView>( delegate(IAccountable accountable) { return (ApplicationView)accountable; }); } return applicationViews; }
/// <summary> /// This function will get all the historical applications from Aneka /// </summary> /// <param name="data">The type of data to get from Aneka</param> /// <param name="fromDate">Limit the result From This Date</param> /// <param name="toDate">Limit the result To This Date</param> /// <returns></returns> public List<IAccountable> getDoneApplications(appQureyType.Type data, DateTime? fromDate, DateTime? toDate) { List<IAccountable> appViewListResult = new List<IAccountable>(); try { List<IAccountable> appViewList = null; global::Aneka.Accounting.AccountingManager manager = new AccountingManager(serviceAddress); AccountingQueryRequest request; if (fromDate == null || toDate == null) { request = new AccountingQueryRequest(credentials.Username, QueryMode.USER, 1, 1); } else { request = new AccountingQueryRequest((DateTime)fromDate, (DateTime)toDate); } //query via the accounting manager appViewList = manager.Query(credentials, typeof(global::Aneka.Entity.ApplicationView), request); if (data == appQureyType.Type.NonSuccessfulOnly) { foreach (global::Aneka.Entity.ApplicationView app in appViewList) { if (app.Total != app.Completed) appViewListResult.Add(app); } } if (data == appQureyType.Type.ALL) appViewListResult = appViewList; } catch (Exception) { throw; } return appViewListResult; }