// GET: api/LoadsData public static List <Load> GetLoads() { // return the data or perform an action using the remote webApiUrl string webApiPath = "api/LoadsData"; string results = ""; try { results = client.GetAsync(AppCommon.BuildUrl(AppCommon.GetRemoteWebApiUrl(), webApiPath)).Result.Content.ReadAsStringAsync().Result; return(JsonConvert.DeserializeObject <List <Load> >(results)); } catch (Exception e) { string message = AppCommon.AppendInnerExceptionMessages("GetLoads: " + e.Message, e); throw new Exception(message); } } // GetLoads
public static void Generate(Report report, string fileSaveDirectory, Application app) { // generates the report in the specified reportFormat with the // specified report.Filename saves it in fileSaveDirectory and always overwrites it string saveFilename = Path.Combine(fileSaveDirectory.TrimEnd('\\'), report.Filename.TrimStart('\\')) + "." + report.Extension; // gen up the Word objects we need Document document = app.Documents.Add(); // load our styles into the document ReportCommon.LoadDocumentStyles(document); try { // build the report document // set the document properties ReportCommon.SetDocumentDefaultProperties(document, app); // add header AddDocumentHeader(document); // add body AddDocumentBody(document); // save the document document.SaveAs2(saveFilename, report.SaveFormat); // display ready message AppCommon.Log(report.Name + " ready. Open at: " + AppCommon.BuildUrl(AppCommon.GetAppEngineUrl(), report.Filename + "." + report.Extension, AppCommon.GetAppEnginePort()) + " .", EventLogEntryType.Information); } catch (Exception e) { string message = AppCommon.AppendInnerExceptionMessages("LoadsIndexViewReport.Generate: " + e.Message, e); message += " - Filename = " + saveFilename + ""; throw new Exception(message); } finally { // close and dispose of the writer if it exists document.Close(WdSaveOptions.wdDoNotSaveChanges); } } // Generate