/// <summary> /// View details for a specific observational data service /// </summary> /// <param name="id">The DatabaseID of the data service.</param> /// <returns></returns> public ActionResult ObservationalDataService(int id) { var item = db.ODMDatabases.SingleOrDefault(d => d.DatabaseID == id); if (item != null) { var metaDataList = (from md in db.ODMDatabaseMetadatas where (md.DatabaseID == item.DatabaseID) orderby md.DisplayOrder select md).ToList(); var siteList = new List <Site>(); using (var db2 = DataQueryRepository.GetODMDbDataContext(item)) { siteList = db2.Sites.ToList(); } return(View(new ODMDatabaseModel { ODMDatabase = item, Metadata = metaDataList, MetadataContact = (item.MetadataContactID != null) ? db.Contacts.SingleOrDefault(c => c.ContactID == item.MetadataContactID) : null, Sites = siteList })); } return(View("NotFound")); }
/// <summary> /// Downloads the selected time series into a single file. /// </summary> /// <param name="dataQueryForm">The data query form.</param> /// <param name="form">Parameters passed to the server.</param> public void DownloadToSingleFile(DataQueryFormModel dataQueryForm, FormCollection form) { HttpContext.Response.Clear(); string fileName = String.Format("data-{0}.csv", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss")); HttpContext.Response.ContentType = "text/csv"; HttpContext.Response.AddHeader("content-disposition", "filename=" + fileName); DataQueryRepository.Download(db, dataQueryForm, form); HttpContext.Response.End(); }
public ActionResult DataQuery(UnparsedDataQueryFormModel unparsedDataQueryForm, string submit, FormCollection form) { DateTime startTime = new DateTime(); DateTime endTime = new DateTime(); if (unparsedDataQueryForm.StartTime != null) { if (!DateTime.TryParse(unparsedDataQueryForm.StartTime.ToString(), out startTime)) { ViewData["startTime"] = "Invalid start date!"; return(View(DataQueryRepository.NewDataQueryModel(db))); } } if (unparsedDataQueryForm.EndTime != null) { if (!DateTime.TryParse(unparsedDataQueryForm.EndTime.ToString(), out endTime)) { ViewData["endTime"] = "Invalid end date!"; return(View(DataQueryRepository.NewDataQueryModel(db))); } } DataQueryFormModel dataQueryForm = DataQueryRepository.ParsedDataQueryForm(unparsedDataQueryForm); ViewData["norecords"] = "No records found."; switch (submit) { case "Query": return(View(DataQueryRepository.NewDataQueryModel(db, dataQueryForm))); break; case "Download": DownloadToSingleFile(dataQueryForm, form); return(View("Download")); break; } return(View(DataQueryRepository.NewDataQueryModel(db))); }
/// <summary> /// Returns the Data Query start page. /// </summary> /// <returns></returns> public ActionResult DataQuery() { return(View(DataQueryRepository.NewDataQueryModel(db))); }