/// <summary> /// Get the functional group indices that have specified values of specified traits /// </summary> /// <param name="searchTraits">Vector of trait names to search for</param> /// <param name="searchTraitValues">Vector of trait values to search for</param> /// <param name="intersection">Whether the intersection of the indices for the traits should be returned, otherwise return the union of the indices</param> /// <returns>A vector of functional group indices with the specified values of the specified traits</returns> public int[] GetFunctionalGroupIndex(string[] searchTraits, string[] searchTraitValues, Boolean intersection) { // Check that the numbers of traits and of trait values specified are equal Debug.Assert((searchTraits.Length == searchTraitValues.Length), "Unequal search string arrays"); // List to hold the functional group indices for each trait-trait value pair List <int[]> IndexList = new List <int[]>(); int[] TempIndexList; //Sorted dictionary to hold the trait value index list sorted dictionary from the lookup table SortedDictionary <string, int[]> TraitIndexList; //Loop over the number of trait name and trait value pairs for (int nn = 0; nn < searchTraits.Length; nn++) { //Check if the trait name is in the lookup table and if so pull out the <trait value, index vector> sorted dictionary for it if (IndexLookupFromTrait.TryGetValue(searchTraits[nn].ToLower(), out TraitIndexList)) { //Check if the trait value string is found in the lookup table and if found pull out the index vector for it //and add it to the List of these for processing - intersection of union if (TraitIndexList.TryGetValue(searchTraitValues[nn], out TempIndexList)) { IndexList.Add(TempIndexList); } //If trait value string not found then show error message else { Debug.Fail("Trait Value to search for not found in lookup tables"); } } //If trait name string not found then show error message else { Debug.Fail("Trait to search for not found in lookup tables"); } } //If we are only searching for one traitname and trait value pair then return the index vector if (searchTraits.Length == 1) { return(IndexList[0]); } //Otherwise process the List of index vectors else { //Object to hold the array of index values found by the intersection method IEnumerable <int> ReturnList; //If intersection true then find the index values common to all traitname and trait value pairs if (intersection) { ReturnList = IndexList[0].Intersect(IndexList[1]); for (int nn = 2; nn < IndexList.Count; nn++) { ReturnList = ReturnList.Intersect(IndexList[nn]); } } //If intersection false then return all the index values found above else { ReturnList = IndexList[0].Union(IndexList[1]); for (int nn = 2; nn < IndexList.Count; nn++) { ReturnList = ReturnList.Union(IndexList[nn]); } } return(ReturnList.ToArray()); } }
public override List <string> CreateMetric() { base.CreateMetric(); MOE.Common.Business.AnalysisPhaseCollection analysisPhaseCollection = new MOE.Common.Business.AnalysisPhaseCollection(SignalID, StartDate, EndDate); //If there are phases in the collection add the charts if (analysisPhaseCollection.Items.Count > 0) { foreach (MOE.Common.Business.Plan plan in analysisPhaseCollection.Plans.PlanList) { plan.SetProgrammedSplits(SignalID); plan.SetHighCycleCount(analysisPhaseCollection); } //If there are phases in the collection add the charts //dummy chart to create a legend for the entire split monitor page. Chart dummychart = new Chart(); ChartArea chartarea1 = new ChartArea(); dummychart.ImageType = ChartImageType.Jpeg; dummychart.Height = 200; dummychart.Width = 800; //add comments to the chart dummychart.ImageStorageMode = ImageStorageMode.UseImageLocation; dummychart.BorderlineDashStyle = ChartDashStyle.Dot; Series PedActivity = new Series(); Series GapoutSeries = new Series(); Series MaxOutSeries = new Series(); Series ForceOffSeries = new Series(); Series ProgramedSplit = new Series(); Series UnknownSeries = new Series(); PedActivity.Name = "Ped Activity"; GapoutSeries.Name = "Gap Out"; MaxOutSeries.Name = "Max Out"; ForceOffSeries.Name = "Force Off"; ProgramedSplit.Name = "Programmed Split"; UnknownSeries.Name = "Unknown Termination Cause"; PedActivity.MarkerStyle = MarkerStyle.Cross; GapoutSeries.MarkerStyle = MarkerStyle.Circle; MaxOutSeries.MarkerStyle = MarkerStyle.Circle; ForceOffSeries.MarkerStyle = MarkerStyle.Circle; ProgramedSplit.BorderDashStyle = ChartDashStyle.Solid; UnknownSeries.MarkerStyle = MarkerStyle.Circle; GapoutSeries.Color = Color.OliveDrab; PedActivity.Color = Color.DarkGoldenrod; MaxOutSeries.Color = Color.Red; ForceOffSeries.Color = Color.MediumBlue; ProgramedSplit.Color = Color.OrangeRed; UnknownSeries.Color = Color.Black; dummychart.Series.Add(ProgramedSplit); dummychart.Series.Add(GapoutSeries); dummychart.Series.Add(MaxOutSeries); dummychart.Series.Add(ForceOffSeries); dummychart.Series.Add(UnknownSeries); dummychart.Series.Add(PedActivity); dummychart.ChartAreas.Add(chartarea1); Legend dummychartLegend = new Legend(); dummychartLegend.Name = "DummyLegend"; dummychartLegend.IsDockedInsideChartArea = true; dummychartLegend.Title = "Chart Legend"; dummychartLegend.Docking = Docking.Bottom; dummychartLegend.Alignment = StringAlignment.Center; dummychart.Legends.Add(dummychartLegend); List <Title> removethese = new List <Title>(); foreach (Title t in dummychart.Titles) { if (t.Text == "" || t.Text == null) { removethese.Add(t); } } foreach (Title t in removethese) { dummychart.Titles.Remove(t); } string dummyChartFileName = CreateFileName(); dummychart.SaveImage(MetricFileLocation + dummyChartFileName); ReturnList.Add(MetricWebPath + dummyChartFileName); if (analysisPhaseCollection.Items.Count > 0) { var phasesInOrder = (from r in analysisPhaseCollection.Items select r).OrderBy(r => r.PhaseNumber); foreach (MOE.Common.Business.AnalysisPhase Phase in phasesInOrder) { Chart chart = GetNewSplitMonitorChart(StartDate, EndDate, SignalID, GetSignalLocation(), Phase.PhaseNumber); AddSplitMonitorDataToChart(chart, StartDate, EndDate, Phase, SignalID, analysisPhaseCollection.Plans); if (ShowPlanStripes) { SetSimplePlanStrips(analysisPhaseCollection.Plans, chart, StartDate); SetSplitMonitorStatistics(analysisPhaseCollection.Plans, Phase, chart); } string chartFileName = CreateFileName(); removethese = new List <Title>(); foreach (Title t in chart.Titles) { if (t.Text == "" || t.Text == null) { removethese.Add(t); } } foreach (Title t in removethese) { chart.Titles.Remove(t); } chart.SaveImage(MetricFileLocation + chartFileName); ReturnList.Add(MetricWebPath + chartFileName); } } } return(ReturnList); }
public void CancelReturn([FromBody] ReturnList returnList) { ReturnList.DeleteOne(x => x.Id == returnList.Id); }
/// <summary> /// Return folder content in the form of a list fo FileNodes /// If the folder as not already been parsed, we parse it from the server /// If the folder has been parsed, we serve content from the cache and update the cache from the server in a background task. So that we have a refreshed view for next call /// </summary> public (bool Success, List <Tuple <String, FileNode> > Content, String ErrorMessage) GetFolderContent(FileNode CurrentFolder, String Marker) { List <FileNode> FileNodeToRefreshList = new List <FileNode>(); List <Tuple <String, FileNode> > ReturnList = null; if (_mode == CacheMode.Disabled) { var Result = ListRemoteServerFolderContent(CurrentFolder); if (!Result.Success) { return(Result); } else { return(true, Result.Content, null); } } lock (CacheLock) { if (!CurrentFolder.IsParsed) { var Result = ListRemoteServerFolderContent(CurrentFolder); if (!Result.Success) { return(Result); } CurrentFolder.IsParsed = true; CurrentFolder.LastRefresh = DateTime.Now; //Caching the folder content foreach (var Node in Result.Content) { this.AddFileNodeNoLock(Node.Item2); } //Handling . & .. if (!FileNode.IsRepositoryRootPath(CurrentFolder.RepositoryPath)) { //if this is not the root directory add the dot entries if (Marker == null) { Result.Content.Add(new Tuple <String, FileNode>(".", CurrentFolder)); } if (Marker == null || Marker == ".") { String ParentPath = FileNode.ConvertRepositoryPathToLocalPath(FileNode.GetRepositoryParentPath(CurrentFolder.RepositoryPath)); if (ParentPath != null) { if (FileNodeCache.ContainsKey(ParentPath)) { Result.Content.Add(new Tuple <String, FileNode>("..", FileNodeCache[ParentPath])); } } } } ReturnList = Result.Content; } else { String FolderNameForSearch = CurrentFolder.LocalPath; if (FolderNameForSearch != "\\") { FolderNameForSearch += "\\"; } ReturnList = new List <Tuple <String, FileNode> >(); ReturnList.Add(new Tuple <string, FileNode>(".", CurrentFolder)); //TODO : Add .. from cache ReturnList.AddRange(FileNodeCache.Where(x => x.Key != CurrentFolder.LocalPath && x.Key.StartsWith($"{FolderNameForSearch}") && x.Key.LastIndexOf('\\').Equals(FolderNameForSearch.Length - 1)).Select(x => new Tuple <String, FileNode>(x.Value.Name, x.Value))); if ((DateTime.Now - CurrentFolder.LastRefresh).TotalSeconds > CacheDurationInSeconds) { FileNodeToRefreshList.Add(CurrentFolder); //Refresh current directory if the cache is too old } } //Sort list by path (mandatory if we want to handle a potential marker correctly) ReturnList = ReturnList.OrderBy(x => x.Item1).ToList(); if (!String.IsNullOrEmpty(Marker)) //Dealing with potential marker { var WantedTuple = ReturnList.FirstOrDefault(x => x.Item1.Equals(Marker)); var WantedTupleIndex = ReturnList.IndexOf(WantedTuple); if (WantedTupleIndex + 1 < ReturnList.Count) { ReturnList = ReturnList.GetRange(WantedTupleIndex + 1, ReturnList.Count - 1 - WantedTupleIndex); } else { ReturnList.Clear(); } } if (this._PreLoadFoldersInCache) { foreach (var FolderNode in ReturnList.Where(x => (x.Item2.FileInfo.FileAttributes & (UInt32)System.IO.FileAttributes.Directory) != 0)) { if (FolderNode.Item1 == "." || FolderNode.Item1 == "..") { continue; //Bypass special folders } if (!FileNodeCache[FolderNode.Item2.LocalPath].IsParsed) { FileNodeToRefreshList.Add(FolderNode.Item2); //Pre-loading of sub-folders of current folder } } } } foreach (var FileNodeToRefresh in FileNodeToRefreshList) { AddRefreshTask(FileNodeToRefresh); } return(true, ReturnList, null); }
public override List <string> CreateMetric() { base.CreateMetric(); var analysisPhaseCollection = new AnalysisPhaseCollection(SignalID, StartDate, EndDate); //If there are phases in the collection add the charts if (analysisPhaseCollection.Items.Count > 0) { foreach (var plan in analysisPhaseCollection.Plans) { plan.SetProgrammedSplits(SignalID); plan.SetHighCycleCount(analysisPhaseCollection); } //If there are phases in the collection add the charts //dummy chart to create a legend for the entire split monitor page. var dummychart = new Chart(); var chartarea1 = new ChartArea(); ChartFactory.SetImageProperties(dummychart); dummychart.BorderlineDashStyle = ChartDashStyle.Dot; dummychart.Height = 100; var PedActivity = new Series(); var GapoutSeries = new Series(); var MaxOutSeries = new Series(); var ForceOffSeries = new Series(); var ProgramedSplit = new Series(); var UnknownSeries = new Series(); PedActivity.Name = "Ped Activity"; GapoutSeries.Name = "Gap Out"; MaxOutSeries.Name = "Max Out"; ForceOffSeries.Name = "Force Off"; ProgramedSplit.Name = "Programmed Split"; UnknownSeries.Name = "Unknown Termination Cause"; PedActivity.MarkerStyle = MarkerStyle.Cross; GapoutSeries.MarkerStyle = MarkerStyle.Circle; MaxOutSeries.MarkerStyle = MarkerStyle.Circle; ForceOffSeries.MarkerStyle = MarkerStyle.Circle; ProgramedSplit.BorderDashStyle = ChartDashStyle.Solid; UnknownSeries.MarkerStyle = MarkerStyle.Circle; GapoutSeries.Color = Color.OliveDrab; PedActivity.Color = Color.DarkGoldenrod; MaxOutSeries.Color = Color.Red; ForceOffSeries.Color = Color.MediumBlue; ProgramedSplit.Color = Color.OrangeRed; UnknownSeries.Color = Color.Black; dummychart.Series.Add(ProgramedSplit); dummychart.Series.Add(GapoutSeries); dummychart.Series.Add(MaxOutSeries); dummychart.Series.Add(ForceOffSeries); dummychart.Series.Add(UnknownSeries); dummychart.Series.Add(PedActivity); dummychart.ChartAreas.Add(chartarea1); var dummychartLegend = new Legend(); dummychartLegend.Name = "DummyLegend"; dummychartLegend.IsDockedInsideChartArea = true; dummychartLegend.Title = "Chart Legend"; dummychartLegend.Docking = Docking.Bottom; dummychartLegend.Alignment = StringAlignment.Center; dummychart.Legends.Add(dummychartLegend); var removethese = new List <Title>(); foreach (var t in dummychart.Titles) { if (string.IsNullOrEmpty(t.Text)) { removethese.Add(t); } } foreach (var t in removethese) { dummychart.Titles.Remove(t); } var dummyChartFileName = CreateFileName(); dummychart.SaveImage(MetricFileLocation + dummyChartFileName); ReturnList.Add(MetricWebPath + dummyChartFileName); if (analysisPhaseCollection.Items.Count > 0) { var phasesInOrder = (analysisPhaseCollection.Items.Select(r => r)).OrderBy(r => r.PhaseNumber); foreach (var phase in phasesInOrder) { var chart = GetNewSplitMonitorChart(StartDate, EndDate, phase.PhaseNumber); AddSplitMonitorDataToChart(chart, phase, analysisPhaseCollection.Plans); if (ShowPlanStripes) { SetSimplePlanStrips(analysisPhaseCollection.Plans, chart, StartDate); SetSplitMonitorStatistics(analysisPhaseCollection.Plans, phase, chart); } var chartFileName = CreateFileName(); removethese = new List <Title>(); foreach (var t in chart.Titles) { if (string.IsNullOrEmpty(t.Text)) { removethese.Add(t); } } foreach (var t in removethese) { chart.Titles.Remove(t); } chart.SaveImage(MetricFileLocation + chartFileName); ReturnList.Add(MetricWebPath + chartFileName); } } } return(ReturnList); }
private void CreateLegend() { Chart dummychart = new Chart(); ChartArea chartarea1 = new ChartArea(); dummychart.ImageType = ChartImageType.Jpeg; dummychart.Height = 200; dummychart.Width = 1100; dummychart.ImageStorageMode = ImageStorageMode.UseImageLocation; dummychart.BorderlineDashStyle = ChartDashStyle.Dot; Series PedActivity = new Series(); Series GapoutSeries = new Series(); Series MaxOutSeries = new Series(); Series ForceOffSeries = new Series(); Series UnknownSeries = new Series(); PedActivity.Name = "Ped Activity"; GapoutSeries.Name = "Gap Out"; MaxOutSeries.Name = "Max Out"; ForceOffSeries.Name = "Force Off"; UnknownSeries.Name = "Unknown"; PedActivity.MarkerStyle = MarkerStyle.Cross; GapoutSeries.MarkerStyle = MarkerStyle.Circle; MaxOutSeries.MarkerStyle = MarkerStyle.Circle; ForceOffSeries.MarkerStyle = MarkerStyle.Circle; UnknownSeries.MarkerStyle = MarkerStyle.Circle; GapoutSeries.Color = Color.OliveDrab; PedActivity.Color = Color.DarkGoldenrod; MaxOutSeries.Color = Color.Red; ForceOffSeries.Color = Color.MediumBlue; UnknownSeries.Color = Color.FromArgb(255, 255, 0); dummychart.Series.Add(GapoutSeries); dummychart.Series.Add(MaxOutSeries); dummychart.Series.Add(ForceOffSeries); dummychart.Series.Add(UnknownSeries); dummychart.Series.Add(PedActivity); dummychart.ChartAreas.Add(chartarea1); Legend dummychartLegend = new Legend(); dummychartLegend.Name = "DummyLegend"; dummychartLegend.IsDockedInsideChartArea = true; dummychartLegend.Title = "Chart Legend"; dummychartLegend.Docking = Docking.Top; dummychartLegend.Alignment = StringAlignment.Center; dummychart.Legends.Add(dummychartLegend); dummychart.SaveImage(MetricFileLocation + "PPTLegend.jpeg", System.Web.UI.DataVisualization.Charting.ChartImageFormat.Jpeg); ReturnList.Add(MetricWebPath + "PPTLegend.jpeg"); }