Exemplo n.º 1
0
 private void OnFeatureSelected(FeatureNames feature)
 {
     if (FeatureSelected != null)
     {
         FeatureSelected(this, new DataEventArgs <FeatureNames> (feature));
     }
 }
Exemplo n.º 2
0
        public RoomFeature(FeatureNames name)
        {
            Name = name;

            // TODO: I put this in, but should there be a test to force it, pin it and justify it?
            // Cost = 0;
        }
Exemplo n.º 3
0
        public bool IsFeatureValid(FeatureNames featureName)
        {
            bool ret = true;

            switch (featureName.Name)
            {
            case "ExternalStore":
                ret = _externalStoreValid;
                break;

            case "PatientUpdater":
                ret = _patientUpdaterValid;
                break;

            case "AutoCopy":
                ret = _autoCopyValid;
                break;

            case "Forwarder":
                ret = _forwarderValid;
                break;

            case "Gateway":
                ret = _gatewayValid;
                break;

            case "Server":
                ret = _securityValid;
                break;
            }
            return(ret);
        }
Exemplo n.º 4
0
 private bool Equals(DataVector <TValue> other)
 {
     return((
                (_values == null && other._values == null) || ((_values != null && other._values != null) && _values.SequenceEqual(other.Values))) &&
            (
                (FeatureNames == null && other.FeatureNames == null) ||
                ((FeatureNames != null && other.FeatureNames != null) && FeatureNames.SequenceEqual(other.FeatureNames))
            ));
 }
Exemplo n.º 5
0
        public Tree ToTree()
        {
            Node.Node io = ToTreeRecursion(Root);
            Tree      t  = new Tree();

            t.FeatureNames           = FeatureNames.ToList();
            t.ResolutionFeatureName  = ResolutionFeatureName;
            t.MaxItemCountInCategory = MaxItemCountInCategory;
            t.Root = io;
            return(t);
        }
Exemplo n.º 6
0
        public void SelectFeature(FeatureNames feature)
        {
            if (_featurePages.ContainsKey(feature))
            {
                if (null != treeView1.SelectedNode && treeView1.SelectedNode.Tag is Control)
                {
                    HideNodeControl(treeView1.SelectedNode);
                }

                treeView1.SelectedNode = treeView1.Nodes.Find(feature.Name, true) [0];

                SelectNodeControl(treeView1.SelectedNode);
            }
        }
Exemplo n.º 7
0
        public void LoadData(string csv)
        {
            FeatureNames.Clear();
            AllFeatures.Clear();
            data         = LoadCSV(csv);
            ActiveData   = new DataSet();
            FeatureNames = data[0].ToList();
            FeatureNames.Remove(FeatureNames[FeatureNames.Count - 1]);// target feature
            for (int i = 0; i < FeatureNames.Count; i++)
            {
                AllFeatures.Add(i);
            }

            data.RemoveAt(0);
        }
Exemplo n.º 8
0
 public void DisableFeature(FeatureNames feature)
 {
     if (_featurePages.ContainsKey(feature))
     {
         TreeNode node = treeView1.Nodes.Find(feature.Name, true)[0];
         if (node != null && node.Tag != null)
         {
             Control c = node.Tag as Control;
             if (c != null)
             {
                 c.Enabled = false;
             }
         }
     }
 }
        //Methods
        /// <summary>
        /// Adds the given feature to the state and removes related queries. This feature is
        /// additionaly marked as the "MostRecentFeature" for convienance.
        /// </summary>
        /// <param name="theFeature"></param>
        private void AddFeature(FeatureValuePair theFeature)
        {
            //Add to list of features
            FeatureValuePair fvp = new FeatureValuePair(theFeature.Name, theFeature.Value); //copy to prevent storing derived classes such as FeatureValuePairWithImportance

            Features.Add(fvp);
            FeatureNames.Add(theFeature.Name);

            //Remove queries with same feature name
            foreach (var q in Queries.ToList())
            {
                if (q.Key.Feature.Name == theFeature.Name)
                {
                    Queries.Remove(q.Key);
                }
            }
        }
Exemplo n.º 10
0
        public void AddFeatureControl(FeatureNames feature, Control page, FeatureNames parentFeature)
        {
            if (_featurePages.ContainsKey(feature))
            {
                throw new InvalidOperationException("Feature is already added");
            }

            if (parentFeature != null && !_featurePages.ContainsKey(parentFeature))
            {
                throw new InvalidOperationException("Parent feature is not added");
            }

            TreeNode featureNode = CreateFeatureNode(feature, parentFeature);

            featureNode.Tag = page;

            //page.Visible = _featurePages.Count == 0  ;

            page.Visible = false;
            PagesContainerPanel.Controls.Add(page);
            page.Dock = DockStyle.Fill;
            _featurePages.Add(feature, page);
        }
        /// <summary>
        /// All features of the datavector are inspected. If a feature-value combination is not
        /// in the list of queries, it is added. If a new label is encountered, it is also added.
        /// New queries are created optomistically with an expected reward of 1.
        /// New labels are created with an expected reward of 0;
        /// </summary>
        /// <param name="dataVector"></param>
        public void AddMissingQueriesAndLabels(DataVectorTraining dataVector)
        {
            //Try to create new queries
            foreach (FeatureValuePairWithImportance theFeature in dataVector.Features.ToList())
            {
                //Skip features names that are already in feature list.
                if (FeatureNames.Contains(theFeature.Name))
                {
                    continue;
                }

                //Create the possibly new query
                Query newQuery = new Query(theFeature, dataVector.Label);

                //Try to add the query
                if (!Queries.ContainsKey(newQuery))
                {
                    Queries.Add(newQuery, 1);
                }
            }

            //Try to add the label
            AdjustLabels(dataVector.Label);
        }
Exemplo n.º 12
0
        private TreeNode CreateFeatureNode(FeatureNames feature, FeatureNames parentFeature)
        {
            TreeNode[] parent = null;
            TreeNode   featureNode;

            if (null != parentFeature)
            {
                parent = treeView1.Nodes.Find(parentFeature.Name, true);
            }

            featureNode      = new TreeNode(feature.DisplayName);
            featureNode.Name = feature.Name;

            if (null != parent && parent.Length > 0)
            {
                parent [0].Nodes.Add(featureNode);
            }
            else
            {
                treeView1.Nodes.Add(featureNode);
            }

            return(featureNode);
        }
Exemplo n.º 13
0
 public RoomFeature(FeatureNames name, decimal cost)
 {
     Name = name;
     Cost = cost;
 }
Exemplo n.º 14
0
 public TValue this[string featureName] => _values[FeatureNames.IndexOf(featureName)];
Exemplo n.º 15
0
 public void RemoveFeature(FeatureNames featureName)
 {
     Features.RemoveAll(feature => feature.Name == featureName);
 }
Exemplo n.º 16
0
 public void AddFeature(FeatureNames featureName, decimal cost = decimal.Zero)
 {
     Features.Add(new RoomFeature(featureName, cost));
 }
Exemplo n.º 17
0
 public IDataVector <TValue> Set(string featureName, TValue value)
 {
     return(Set(FeatureNames.IndexOf(featureName), value));
 }
Exemplo n.º 18
0
 public bool IsFeatureAdded(FeatureNames feature)
 {
     return(_featurePages.ContainsKey(feature));
 }
Exemplo n.º 19
0
        public void PopulateEvent(Event ev)
        {
            if (MinDate.HasValue || MaxDate.HasValue)
            {
                ev.Date = RandomData.GetDateTime(MinDate ?? DateTime.MinValue, MaxDate ?? DateTime.MaxValue);
            }

            ev.Type = new [] { Event.KnownTypes.Error, Event.KnownTypes.FeatureUsage, Event.KnownTypes.Log, Event.KnownTypes.NotFound }.Random();
            if (ev.Type == Event.KnownTypes.FeatureUsage)
            {
                ev.Source = FeatureNames.Random();
            }
            else if (ev.Type == Event.KnownTypes.NotFound)
            {
                ev.Source = PageNames.Random();
            }
            else if (ev.Type == Event.KnownTypes.Log)
            {
                ev.Source  = LogSources.Random();
                ev.Message = RandomData.GetString();

                string level = LogLevels.Random();
                if (!String.IsNullOrEmpty(level))
                {
                    ev.Data[Event.KnownDataKeys.Level] = level;
                }
            }

            if (RandomData.GetBool(80))
            {
                ev.Geo = RandomData.GetCoordinate();
            }

            if (RandomData.GetBool(20))
            {
                ev.Value = RandomData.GetInt(0, 10000);
            }

            ev.SetUserIdentity(Identities.Random());
            ev.SetVersion(RandomData.GetVersion("2.0", "4.0"));

            ev.AddRequestInfo(new RequestInfo {
                //ClientIpAddress = ClientIpAddresses.Random(),
                Path = PageNames.Random()
            });

            ev.Data.Add(Event.KnownDataKeys.EnvironmentInfo, new EnvironmentInfo {
                IpAddress   = MachineIpAddresses.Random() + ", " + MachineIpAddresses.Random(),
                MachineName = MachineNames.Random()
            });

            for (int i = 0; i < RandomData.GetInt(1, 3); i++)
            {
                string key = RandomData.GetWord();
                while (ev.Data.ContainsKey(key) || key == Event.KnownDataKeys.Error)
                {
                    key = RandomData.GetWord();
                }

                ev.Data.Add(key, RandomData.GetString());
            }

            int tagCount = RandomData.GetInt(1, 3);

            for (int i = 0; i < tagCount; i++)
            {
                string tag = EventTags.Random();
                if (!ev.Tags.Contains(tag))
                {
                    ev.Tags.Add(tag);
                }
            }

            if (ev.Type == Event.KnownTypes.Error)
            {
                if (RandomData.GetBool())
                {
                    // limit error variation so that stacking will occur
                    if (_randomErrors == null)
                    {
                        _randomErrors = new List <Error>(Enumerable.Range(1, 25).Select(i => GenerateError()));
                    }

                    ev.Data[Event.KnownDataKeys.Error] = _randomErrors.Random();
                }
                else
                {
                    // limit error variation so that stacking will occur
                    if (_randomSimpleErrors == null)
                    {
                        _randomSimpleErrors = new List <SimpleError>(Enumerable.Range(1, 25).Select(i => GenerateSimpleError()));
                    }

                    ev.Data[Event.KnownDataKeys.SimpleError] = _randomSimpleErrors.Random();
                }
            }
        }
Exemplo n.º 20
0
        private static void SendEvent(bool writeToConsole = true)
        {
            var ev = new Event();

            if (_dateSpans[_dateSpanIndex] != TimeSpan.Zero)
            {
                ev.Date = RandomHelper.GetDateTime(DateTime.Now.Subtract(_dateSpans[_dateSpanIndex]), DateTime.Now);
            }

            ev.Type = EventTypes.Random();
            if (ev.Type == Event.KnownTypes.FeatureUsage)
            {
                ev.Source = FeatureNames.Random();
            }
            else if (ev.Type == Event.KnownTypes.NotFound)
            {
                ev.Source = PageNames.Random();
            }
            else if (ev.Type == Event.KnownTypes.Log)
            {
                ev.Source  = LogSources.Random();
                ev.Message = RandomHelper.GetPronouncableString(RandomHelper.GetRange(5, 15));
            }

            ev.SetUserIdentity(Identities.Random());

            for (int i = 0; i < RandomHelper.GetRange(1, 5); i++)
            {
                string key = RandomHelper.GetPronouncableString(RandomHelper.GetRange(5, 10));
                while (ev.Data.ContainsKey(key) || key == Event.KnownDataKeys.Error)
                {
                    key = RandomHelper.GetPronouncableString(RandomHelper.GetRange(5, 15));
                }

                ev.Data.Add(key, RandomHelper.GetPronouncableString(RandomHelper.GetRange(5, 25)));
            }

            int tagCount = RandomHelper.GetRange(1, 3);

            for (int i = 0; i < tagCount; i++)
            {
                string tag = EventTags.Random();
                if (!ev.Tags.Contains(tag))
                {
                    ev.Tags.Add(tag);
                }
            }

            if (ev.Type == Event.KnownTypes.Error)
            {
                // limit error variation so that stacking will occur
                if (_randomErrors == null)
                {
                    _randomErrors = new List <Error>(Enumerable.Range(1, 25).Select(i => GenerateError()));
                }

                ev.Data[Event.KnownDataKeys.Error] = _randomErrors.Random();
            }

            // use server settings to see if we should include this data
            if (ExceptionlessClient.Default.Configuration.Settings.GetBoolean("IncludeConditionalData", true))
            {
                ev.AddObject(new { Total = 32.34, ItemCount = 2, Email = "*****@*****.**" }, "Conditional Data");
            }

            //ev.AddRecentTraceLogEntries();

            ExceptionlessClient.Default.SubmitEvent(ev);

            if (writeToConsole)
            {
                Console.SetCursorPosition(0, OPTIONS_MENU_LINE_COUNT + 2);
                Console.WriteLine("Sent 1 event.");
                Trace.WriteLine("Sent 1 event.");

                ClearNonOptionsLines();
            }
        }