public override string ToString() { var str = "{"; str += RawDataReport.NewProp("name", name); str += RawDataReport.NewProp("url", url); str += RawDataReport.NewProp("size", size); str += RawDataReport.NewProp("date", date, true); str += "}"; return(str); }
public override string ToString() { var str = "{"; str += RawDataReport.NewProp("startDate", RawDataReport.ToDateStr(startDate)); str += RawDataReport.NewProp("endDate", RawDataReport.ToDateStr(endDate)); str += RawDataReport.NewProp("format", format); str += RawDataReport.NewProp("dataset", dataset, true); str += "}"; return(str); }
public void Download(RawDataReport report) { for (int a = 0; a < report.result.fileList.Count; a++) { string file = report.result.fileList[a].url; using (WebClient client = new WebClient()) { string fileName = report.result.fileList[a].name; if (fileName.Contains("headers.gz")) { fileName = report.request.dataset + "_" + report.result.fileList[a].name; } string savePath = PathFromFileName(fileName); client.DownloadFile(file, savePath); } } }
public override string ToString() { var str = "{"; str += RawDataReport.NewProp("size", size); str += RawDataReport.NewProp("eventCount", eventCount); str += "\"fileList\":["; for (var a = 0; a < fileList.Count; a++) { str += fileList[a].ToString(); if (a < fileList.Count - 1) { str += ","; } } str += "]}"; return(str); }
public bool FilesHaveLoaded(RawDataReport report) { if (report.result == null || report.result.fileList.Count == 0) { return(false); } for (var a = 0; a < report.result.fileList.Count; a++) { string fileName = report.result.fileList[a].name; if (fileName.Contains("headers.gz")) { fileName = report.request.dataset + "_" + report.result.fileList[a].name; } if (!FileHasLoaded(fileName)) { return(false); } } return(true); }
private RawDataReport SubmitRequest(RawDataRequest request) { RawDataReport report = null; using (WebClient client = new WebClient()) { client.Encoding = System.Text.Encoding.UTF8; Authorization(client); string url = string.Format(CreateJobPath, m_AppId); string start = request.startDate.ToString("yyyy-MM-dd"); string end = request.endDate.ToString("yyyy-MM-dd"); string data = "\"startDate\":\"{0}\",\"endDate\":\"{1}\",\"format\":\"{2}\",\"dataset\":\"{3}\""; data = "{" + string.Format(data, start, end, "tsv", request.dataset) + "}"; string result = client.UploadString(new Uri(url), "POST", data); var dict = MiniJSON.Json.Deserialize(result) as Dictionary <string, object>; report = new RawDataReport(dict); } return(report); }
public RawDataReport ContinueFromJob(RawDataReport priorReport, DateTime endDate) { RawDataReport report = null; using (WebClient client = new WebClient()) { client.Encoding = System.Text.Encoding.UTF8; Authorization(client); string url = string.Format(CreateJobPath, m_AppId); string end = endDate.ToString("yyyy-MM-dd"); string data = "\"continueFrom\":\"{0}\",\"endDate\":\"{1}\",\"format\":\"{2}\",\"dataset\":\"{3}\""; data = "{" + string.Format(data, priorReport.id, end, "tsv", priorReport.request.dataset) + "}"; string result = client.UploadString(new Uri(url), "POST", data); var dict = MiniJSON.Json.Deserialize(result) as Dictionary <string, object>; report = new RawDataReport(dict); // fill in the startDate for reporting purposes report.request.startDate = priorReport.request.endDate; } return(report); }
void OnGUIFetchView() { if (Event.current.type == EventType.Layout) { m_RawDataClient.TestFilesAreLocal(m_Jobs); } using (new GUILayout.VerticalScope("box")) { string oldKey = m_SecretKey; m_AppId = EditorGUILayout.TextField(m_UpidContent, m_AppId); RestoreAppId(); m_SecretKey = EditorGUILayout.TextField(m_SecretKeyContent, m_SecretKey); m_RawDataClient.m_DataPath = m_DataPath; m_RawDataClient.m_AppId = m_AppId; m_RawDataClient.m_SecretKey = m_SecretKey; if (oldKey != m_SecretKey && !string.IsNullOrEmpty(m_SecretKey)) { EditorPrefs.SetString(k_FetchKey, m_SecretKey); } } using (new GUILayout.VerticalScope("box")) { GUILayout.Label("New Job", EditorStyles.boldLabel); var oldStartDate = m_StartDate; var oldEndDate = m_EndDate; m_StartDate = EditorGUILayout.TextField(m_StartDateContent, m_StartDate); m_EndDate = EditorGUILayout.TextField(m_EndDateContent, m_EndDate); if (oldStartDate != m_StartDate || oldEndDate != m_EndDate) { EditorPrefs.SetString(k_StartDate, m_StartDate); EditorPrefs.SetString(k_EndDate, m_EndDate); } if (GUILayout.Button("Create Job")) { RawDataReport report = null; try { DateTime startDate = DateTime.Parse(m_StartDate).ToUniversalTime(); DateTime endDate = DateTime.Parse(m_EndDate).ToUniversalTime(); report = m_RawDataClient.CreateJob("custom", startDate, endDate); } catch (Exception ex) { string exText = "Unknown exception."; if (ex is FormatException) { exText = "Date formats appear to be incorrect. Start and End Dates must be ISO-8601 format (YYYY-MM-DD)."; } else if (ex is WebException) { WebException webEx = ex as WebException; exText = webEx.Message; } EditorUtility.DisplayDialog("Can't create job", exText, "OK"); } if (m_Jobs == null) { m_Jobs = new List <RawDataReport>(); } if (report != null) { m_Jobs.Add(report); } m_JobFoldouts = m_Jobs.Select(fb => false).ToArray(); } } using (new GUILayout.VerticalScope("box")) { using (new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button(m_GetJobsContent)) { m_RawDataClient.GetJobs(GetJobsCompletionHandler); } if (GUILayout.Button(m_DownloadAllContent)) { m_RawDataClient.DownloadAll(m_Jobs); } } m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition); if (m_Jobs != null) { for (int a = m_Jobs.Count - 1; a > -1; a--) { var job = m_Jobs[a]; string start = String.Format("{0:yyyy-MM-dd}", job.request.startDate); string end = String.Format("{0:yyyy-MM-dd}", job.request.endDate); string shortStart = String.Format("{0:MM-dd}", job.request.startDate); string shortEnd = String.Format("{0:MM-dd}", job.request.endDate); string created = String.Format("{0:yyyy-MM-dd hh:mm:ss}", job.createdAt); string type = job.request.dataset; using (new EditorGUILayout.HorizontalScope()) { float windowWidth = EditorGUIUtility.currentViewWidth; float foldoutWidth = windowWidth * .5f; float downloadButtonWidth = 75f; float continueButtonWidth = 25f; float downloadedWidth = downloadButtonWidth; float statusWidth = 20f; GUIContent foldoutContent = new GUIContent(type + ": " + shortStart + " to " + shortEnd, start + " — " + end + "\n" + job.id); Rect pos = GUILayoutUtility.GetRect(foldoutContent, "foldout"); Rect rect = new Rect(pos.x, pos.y, foldoutWidth, 20f); m_JobFoldouts[a] = EditorGUI.Foldout( rect, m_JobFoldouts[a], foldoutContent, true ); var statusContent = m_CompleteContent; switch (job.status) { case RawDataReport.Failed: statusContent = m_FailedContent; break; case RawDataReport.Running: statusContent = m_RunningContent; break; } GUILayout.Label(statusContent, GUILayout.Width(statusWidth)); if (job.status == RawDataReport.Completed) { if (job.isLocal) { GUILayout.Label("Downloaded", GUILayout.Width(downloadedWidth)); } else if (job.result != null && job.result.size == 0) { GUILayout.Label("No Data", GUILayout.Width(downloadedWidth)); } else if (GUILayout.Button(m_DownloadJobContent, GUILayout.Width(downloadButtonWidth))) { m_RawDataClient.Download(job); } if (GUILayout.Button(m_ContinueJobContent, GUILayout.Width(continueButtonWidth))) { RawDataReport report = m_RawDataClient.ContinueFromJob(job); m_Jobs.Add(report); m_JobFoldouts = m_Jobs.Select(fb => false).ToArray(); } } } if (m_JobFoldouts[a]) { Color defaultColor = GUI.color; GUI.backgroundColor = s_BoxColor; using (new GUILayout.VerticalScope("box")) { GUILayout.Label("ID: " + job.id); GUILayout.Label("Created: " + created); GUILayout.Label("Duration: " + (job.duration / 1000) + " seconds"); if (job.result != null) { GUILayout.Label("# Events: " + job.result.eventCount); GUILayout.Label("# Bytes: " + job.result.size); GUILayout.Label("# Files: " + job.result.fileList.Count); GUILayout.Label("Partial day: " + job.result.intraDay); } } GUI.backgroundColor = defaultColor; } } if (m_Jobs.Count == 0) { GUILayout.Label("No jobs found", EditorStyles.boldLabel); } } else { GUILayout.Label("No data yet", EditorStyles.boldLabel); } GUILayout.Space(10f); EditorGUILayout.EndScrollView(); } using (new GUILayout.HorizontalScope()) { if (GUILayout.Button("Purge")) { PurgeData(); } if (GUILayout.Button("Dashboard")) { Application.OpenURL(m_RawDataClient.DashboardPath); } if (GUILayout.Button("Project Config")) { Application.OpenURL(m_RawDataClient.ConfigPath); } } }
public RawDataReport ContinueFromJob(RawDataReport priorReport) { return(ContinueFromJob(priorReport, DateTime.UtcNow)); }