protected void Page_Load(object sender, EventArgs e) { setNotification(""); (Page.Master.FindControl("linkMainMenuDetails") as HyperLink).CssClass = "nav-text btn active"; (Page.Master.FindControl("linkMainMenuOverview") as HyperLink).CssClass = "nav-text btn"; (Page.Master.FindControl("linkMainMenuReports") as HyperLink).CssClass = "nav-text btn"; if (Session["MySession"] == null) { Session["MySession"] = new CachedDashboardObjects(); } _cache = (CachedDashboardObjects)Session["MySession"]; try { TaggedExtractorConfigArrays tecas = _cache.getConfigs(); ExtractorConfigurationTO[] active = getConfigByKey("Active", tecas); ExtractorConfigurationTO[] queued = getConfigByKey("Queued", tecas); ExtractorConfigurationTO[] completed = getConfigByKey("Completed", tecas); ExtractorConfigurationTO[] errored = getConfigByKey("Errored", tecas); Dictionary <String, EtlDownstreamStageTO> stageBySite = _cache.getEtlStages(); labelRunningCount.Text = active.Length.ToString(); labelFailureCount.Text = errored.Length.ToString(); bindRepeater(getBindableTable(tecas, stageBySite)); } catch (Exception exc) { ((Label)Page.Master.FindControl("labelNotifications")).Text = exc.Message; } }
void refreshFromCachedFiles() { _timeToNextRun = DateTime.Now.AddDays(1).ToString(); // new DateTime(2014, 1, 1).ToString(); _lastRunCompletedTime = DateTime.Now.AddDays(-1).ToString(); _configDict = JsonUtils.Deserialize <TaggedExtractorConfigArrays>(new FileDao(false).readFile("C:\\inetpub\\wwwroot\\dashboard2\\resources\\data\\activeJobsJson.dat")); _extractors = JsonUtils.Deserialize <ExtractorArray>(new FileDao(false).readFile("C:\\inetpub\\wwwroot\\dashboard2\\resources\\data\\extractorsJson.dat")); EtlDownstreamStageArray temp = JsonUtils.Deserialize <EtlDownstreamStageArray>(new FileDao(false).readFile("C:\\inetpub\\wwwroot\\dashboard2\\resources\\data\\etlDowntreamStages.dat")); _etlStages = convertStageArrayToDict(temp); }
ExtractorConfigurationTO[] getConfigByKey(String key, TaggedExtractorConfigArrays teca) { for (int i = 0; i < teca.values.Length; i++) { if (String.Equals(teca.values[i].key, key, StringComparison.CurrentCultureIgnoreCase)) { return(teca.values[i].value); } } return(new ExtractorConfigurationTO[0]); }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["show"] == "Overview") { // show overview } else if (Request.QueryString["show"] == "Reports") { // show reports } string orchestratorHostName = ConfigurationManager.AppSettings[com.bitscopic.downstream.config.AppConfigSettingsConstants.OrchestratorHostName]; // allow user to dynamically change via request URL if (Request.QueryString != null && Request.QueryString.Count > 0 && !String.IsNullOrEmpty(Request.QueryString["orchestrator"])) { orchestratorHostName = Request.QueryString["orchestrator"]; } Client dashboardClient = new Client(); try { Int32 orchestratorListeningPort = Convert.ToInt32(ConfigurationManager.AppSettings[com.bitscopic.downstream.config.AppConfigSettingsConstants.OrchestratorListeningPort]); dashboardClient.connect(orchestratorHostName, orchestratorListeningPort); String jsonString = dashboardClient.sendGetWorkListsRequest(); TaggedExtractorConfigArrays deserialized = JsonUtils.Deserialize <TaggedExtractorConfigArrays>(jsonString); Dictionary <string, IList <ExtractorConfiguration> > worklists = deserialized.convertToDictionary(); IList <Extractor> extractors = dashboardClient.sendGetExtractorsRequest(); if (extractors != null && extractors.Count > 0) { labelActiveCount.Text = extractors.Count.ToString(); datagridActive.DataSource = getActiveDataTable(extractors); datagridActive.DataBind(); } else { labelActiveCount.Text = "No active jobs!"; datagridActive.Visible = false; } bindDataGrid("Queued", worklists, datagridQueued); bindDataGrid("Completed", worklists, datagridCompleted); bindDataGrid("Errored", worklists, datagridErrored); } catch (Exception) { labelMessage.Text = "The orchestrator does not appear to be running!"; } }
private string findBatchId(TaggedExtractorConfigArrays _configDict) { // use these three lines while debugging - DON'T FORGET TO COMMENT THEM OUT FOR DEPLOYMENT!!! //EtlDownstreamStageArray temp = JsonUtils.Deserialize<EtlDownstreamStageArray>(new FileDao(false).readFile("C:\\inetpub\\wwwroot\\dashboard2\\resources\\data\\etlDowntreamStages.dat")); //_etlStages = convertStageArrayToDict(temp); //return _etlStages.First().Value.mapItem.downstreamBatchId; for (int i = 0; i < _configDict.values.Length; i++) { if (_configDict.values[i] != null && _configDict.values[i].value != null && _configDict.values[i].value.Length > 0) { return(_configDict.values[i].value[0].batchId); } } throw new ApplicationException("Couldn't find any extractor configurations to build ETL GUI queries!"); }
void refresh() { _lastRefreshed = DateTime.Now; if (String.Equals(ConfigurationManager.AppSettings["DemoMode"], "true", StringComparison.CurrentCultureIgnoreCase)) { refreshFromCachedFiles(); return; } _timeToNextRun = (JsonUtils.Deserialize <TextTO>( new HttpClient(new Uri(ConfigurationManager.AppSettings["DashboardWebServiceURL"])).makeRequest("nextRunTime"))).text; _lastRunCompletedTime = JsonUtils.Deserialize <KeyValuePair <String, DateTime> >(((JsonUtils.Deserialize <TextTO>( new HttpClient(new Uri(ConfigurationManager.AppSettings["DashboardWebServiceURL"])).makeRequest("lastRunCompletedTime"))).text)).Value.ToString(); _configDict = JsonUtils.Deserialize <TaggedExtractorConfigArrays>( new HttpClient(new Uri(ConfigurationManager.AppSettings["DashboardWebServiceURL"])).makeRequest("activeJobs")); _extractors = JsonUtils.Deserialize <ExtractorArray>( new HttpClient(new Uri(ConfigurationManager.AppSettings["DashboardWebServiceURL"])).makeRequest("extractors")); if (_configDict != null && _configDict.count > 0) { bool foundOne = false; // since the findBatchId function below throws an exception if the configs are all empty, we need to check it first since it will be empty between runs foreach (TaggedExtractorConfigArray teca in _configDict.values) { if (teca != null && teca.count > 0 && teca.value != null && teca.value.Length > 0) { foundOne = true; break; } } if (!foundOne) { return; } String batchId = findBatchId(_configDict); _etlStages = convertStageArrayToDict(JsonUtils.Deserialize <EtlDownstreamStageArray>( new HttpClient(new Uri(ConfigurationManager.AppSettings["DashboardWebServiceURL"])).makeRequest("etlStages/" + batchId))); } }
DataTable getBindableTable(TaggedExtractorConfigArrays tecas, Dictionary <String, EtlDownstreamStageTO> etlStageBySite) { Dictionary <String, String> siteIdsAndNames = DataBindingUtils.getSiteIdAndNameDict(); Dictionary <String, IList <ExtractorConfigurationTO> > active = getConfigsByKeyAndSite("Active", tecas); Dictionary <String, IList <ExtractorConfigurationTO> > queued = getConfigsByKeyAndSite("Queued", tecas); Dictionary <String, IList <ExtractorConfigurationTO> > errored = getConfigsByKeyAndSite("Errored", tecas); Dictionary <String, IList <ExtractorConfigurationTO> > completed = getConfigsByKeyAndSite("Completed", tecas); DataTable mock = new DataTable(); mock.Columns.Add("site"); mock.Columns.Add("progressBarMarkup"); mock.Columns.Add("status"); mock.Columns.Add("statusMarkup"); mock.Columns.Add("adtStatus"); mock.Columns.Add("adtFinishedTimestamp"); mock.Columns.Add("labStatus"); mock.Columns.Add("labFinishedTimestamp"); mock.Columns.Add("vitalsStatus"); mock.Columns.Add("vitalsFinishedTimestamp"); mock.Columns.Add("bcmaStatus"); mock.Columns.Add("bcmaFinishedTimestamp"); mock.Columns.Add("pharmaStatus"); mock.Columns.Add("pharmaFinishedTimestamp"); for (int i = 0; i < siteIdsAndNames.Count; i++) { String currentSite = siteIdsAndNames.ElementAt(i).Key; String dateTimeFormatString = "M/d h:mm tt"; // if any config has been marked errored for this site - show failure if (errored.ContainsKey(currentSite) && errored[currentSite] != null && errored[currentSite].Count > 0) { String controlsText = DataBindingUtils.getProgressBarTextFromEnum(ProgressBarType.Failed_NotStarted); String statusMarkup = DataBindingUtils.getStatusCssClassMarkupFromEnum(ProgressBarType.Failed_NotStarted); mock.Rows.Add(new object[] { siteIdsAndNames.ElementAt(i).Value, DataBindingUtils.getProgressBarCssClassMarkupFromEnum(ProgressBarType.Failed_NotStarted), controlsText, statusMarkup, controlsText, DateTime.Now.ToString(dateTimeFormatString), // ADT controlsText, DateTime.Now.ToString(dateTimeFormatString), // labs controlsText, DateTime.Now.ToString(dateTimeFormatString), // vitals controlsText, DateTime.Now.ToString(dateTimeFormatString), // BCMA controlsText, DateTime.Now.ToString(dateTimeFormatString), // pharma }); continue; } // if all jobs for a site are in queued and no other collections contain site ID, then mark as not started if (!errored.ContainsKey(currentSite) && !active.ContainsKey(currentSite) && !completed.ContainsKey(currentSite) && queued.ContainsKey(currentSite)) { String controlsText = DataBindingUtils.getProgressBarTextFromEnum(ProgressBarType.NotStarted_NotStarted); String statusMarkup = DataBindingUtils.getStatusCssClassMarkupFromEnum(ProgressBarType.NotStarted_NotStarted); mock.Rows.Add(new object[] { siteIdsAndNames.ElementAt(i).Value, DataBindingUtils.getProgressBarCssClassMarkupFromEnum(ProgressBarType.NotStarted_NotStarted), controlsText, statusMarkup, controlsText, DateTime.Now.ToString(dateTimeFormatString), // ADT controlsText, DateTime.Now.ToString(dateTimeFormatString), // labs controlsText, DateTime.Now.ToString(dateTimeFormatString), // vitals controlsText, DateTime.Now.ToString(dateTimeFormatString), // BCMA controlsText, DateTime.Now.ToString(dateTimeFormatString), // pharma }); continue; } // if any config for this site is running or queued - show in progress if ((queued.ContainsKey(currentSite) && queued[currentSite] != null && queued[currentSite].Count > 0) || (active.ContainsKey(currentSite) && active[currentSite] != null && active[currentSite].Count > 0)) { String controlsText = DataBindingUtils.getProgressBarTextFromEnum(ProgressBarType.InProgress_NotStarted); String statusMarkup = DataBindingUtils.getStatusCssClassMarkupFromEnum(ProgressBarType.InProgress_NotStarted); mock.Rows.Add(new object[] { siteIdsAndNames.ElementAt(i).Value, DataBindingUtils.getProgressBarCssClassMarkupFromEnum(ProgressBarType.InProgress_NotStarted), controlsText, statusMarkup, controlsText, DateTime.Now.ToString(dateTimeFormatString), // ADT controlsText, DateTime.Now.ToString(dateTimeFormatString), // labs controlsText, DateTime.Now.ToString(dateTimeFormatString), // vitals controlsText, DateTime.Now.ToString(dateTimeFormatString), // BCMA controlsText, DateTime.Now.ToString(dateTimeFormatString), // pharma }); continue; } // if we show at least one job completed for this site and no configs found in active or queued or errored, consider it complete! if (completed.ContainsKey(currentSite) && completed[currentSite] != null && completed[currentSite].Count > 0) { String controlsText = ""; String statusMarkup = ""; ProgressBarType currentType = 0; if (etlStageBySite.ContainsKey(currentSite)) { EtlBatchStage etlStage = (EtlBatchStage)Enum.Parse(typeof(EtlBatchStage), etlStageBySite[currentSite].stage); if (etlStage == EtlBatchStage.COMPLETED_WORKFLOW) { controlsText = DataBindingUtils.getProgressBarTextFromEnum(ProgressBarType.Completed_Completed); statusMarkup = DataBindingUtils.getStatusCssClassMarkupFromEnum(ProgressBarType.Completed_Completed); currentType = ProgressBarType.Completed_Completed; } else if (etlStage == EtlBatchStage.NOT_STARTED) { controlsText = DataBindingUtils.getProgressBarTextFromEnum(ProgressBarType.Completed_InProgress); statusMarkup = DataBindingUtils.getStatusCssClassMarkupFromEnum(ProgressBarType.Completed_InProgress); currentType = ProgressBarType.Completed_InProgress; } else if (etlStage >= EtlBatchStage.START_WORKFLOW) { controlsText = DataBindingUtils.getProgressBarTextFromEnum(ProgressBarType.Completed_InProgress); statusMarkup = DataBindingUtils.getStatusCssClassMarkupFromEnum(ProgressBarType.Completed_InProgress); currentType = ProgressBarType.Completed_InProgress; } // TBD - how do we show failed ETL????? } else // didn't find site ID in ETL stages { controlsText = DataBindingUtils.getProgressBarTextFromEnum(ProgressBarType.Completed_InProgress); // TBD - should there be a Completed_notStarted status??? seems like there should be... statusMarkup = DataBindingUtils.getStatusCssClassMarkupFromEnum(ProgressBarType.Completed_InProgress); currentType = ProgressBarType.Completed_InProgress; } mock.Rows.Add(new object[] { siteIdsAndNames.ElementAt(i).Value, DataBindingUtils.getProgressBarCssClassMarkupFromEnum(currentType), controlsText, statusMarkup, controlsText, DateTime.Now.ToString(dateTimeFormatString), // ADT controlsText, DateTime.Now.ToString(dateTimeFormatString), // labs controlsText, DateTime.Now.ToString(dateTimeFormatString), // vitals controlsText, DateTime.Now.ToString(dateTimeFormatString), // BCMA controlsText, DateTime.Now.ToString(dateTimeFormatString), // pharma }); continue; } } return(mock); }
Dictionary <String, IList <ExtractorConfigurationTO> > getConfigsByKeyAndSite(String key, TaggedExtractorConfigArrays tecas) { Dictionary <String, IList <ExtractorConfigurationTO> > result = new Dictionary <string, IList <ExtractorConfigurationTO> >(); ExtractorConfigurationTO[] configs = getConfigByKey(key, tecas); if (configs == null || configs.Length == 0) { return(result); } for (int i = 0; i < configs.Length; i++) { if (!result.ContainsKey(configs[i].siteCode)) { result.Add(configs[i].siteCode, new List <ExtractorConfigurationTO>()); } result[configs[i].siteCode].Add(configs[i]); } return(result); }
protected void Page_Load(object sender, EventArgs e) { setNotification(""); (Page.Master.FindControl("linkMainMenuOverview") as HyperLink).CssClass = "nav-text btn active"; (Page.Master.FindControl("linkMainMenuDetails") as HyperLink).CssClass = "nav-text btn"; (Page.Master.FindControl("linkMainMenuReports") as HyperLink).CssClass = "nav-text btn"; if (Request.QueryString != null && Request.QueryString.Count > 0) { if (Request.QueryString.ToString().Contains("getLog")) { if (!String.IsNullOrEmpty(Request.QueryString["site"]) && !String.IsNullOrEmpty(Request.QueryString["vistaFile"]) && !String.IsNullOrEmpty(Request.QueryString["batchId"])) { downloadLog(Request.QueryString["site"], Request.QueryString["vistaFile"], Request.QueryString["batchId"]); return; } } } if (Session["MySession"] == null) { Session["MySession"] = new CachedDashboardObjects(); } _cache = (CachedDashboardObjects)Session["MySession"]; try { labelNextRunTime.Text = _cache.getTimeToNextRun(); labelLastRunCompleted.Text = _cache.getLastRunCompletedTime(); TaggedExtractorConfigArrays tecas = _cache.getConfigs(); ExtractorConfigurationTO[] active = getConfigByKey("Active", tecas); ExtractorConfigurationTO[] queued = getConfigByKey("Queued", tecas); ExtractorConfigurationTO[] completed = getConfigByKey("Completed", tecas); ExtractorConfigurationTO[] errored = getConfigByKey("Errored", tecas); if (active.Length == 0 && queued.Length == 0 && completed.Length == 0 && errored.Length == 0) { setNotification("Downstream is between runs. Please see the next/last run time for information regarding upcoming extraction schedules"); return; } Dictionary <String, EtlDownstreamStageTO> stages = _cache.getEtlStages(); labelActiveExtractionsCount.Text = active.Length.ToString(); labelQueuedExtractionsCount.Text = queued.Length.ToString(); labelCompletedExtractionsCount.Text = completed.Length.ToString(); labelFailedExtractionsCount.Text = errored.Length.ToString(); labelActiveEtlCount.Text = getEtlCount(stages, "Active"); labelCompletedEtlCount.Text = getEtlCount(stages, "Completed"); labelFailedEtlCount.Text = getEtlCount(stages, "Errored"); bindFailedExtractionsDataGrid(errored.ToList()); bindCompletedExtractionsDataGrid(completed.ToList()); bindInProgressExtractionsDataGrid(active.ToList()); bindPrioritizedRepeater(); } catch (Exception exc) { setNotification(exc.Message); } }