Exemplo n.º 1
0
        public void PopulatePossibleValues()
        {
            // Get possible values
            PossibleValues.Clear();
            var type = GetTypeName(SelectedProeprty.PropertyType);
            HashSet <string> collections = new HashSet <string>();

            foreach (var item in Inputs)
            {
                var val = _SelectedProeprty.GetValue(item, null)?.ToString();
                if (val != null)
                {
                    if (type == "ObjectId")
                    {
                        try
                        {
                            var attributes = _SelectedProeprty.GetCustomAttribute(typeof(ColumnAttribute)) as ColumnAttribute;
                            var option     = attributes.Options;
                            if (string.IsNullOrWhiteSpace(option) || option.Contains(">") || string.IsNullOrWhiteSpace(val))
                            {
                                continue;
                            }
                            var link = DataHelpers.GetMongoData(option, "Id", ObjectId.Parse(val), true) as IEnumerable <ExtendedDocument>;
                            if (link == null)
                            {
                                continue;
                            }
                            collections.Add(link.FirstOrDefault()?.Name);
                            StatusLabel = $"Récupération des données - {link.FirstOrDefault()?.Name}";
                            NotifyOfPropertyChange("StatusLabel");
                        }
                        catch (Exception s)
                        {
                            MessageBox.Show(s.Message);
                        }
                    }
                    else
                    {
                        collections.Add(val as string);
                    }
                }
            }
            PossibleValues.AddRange(collections);
            StatusLabel = $"Términé";
            NotifyOfPropertyChange("StatusLabel");
            NotifyOfPropertyChange("PossibleValues");
        }
Exemplo n.º 2
0
        public void PopulatePossibleValues()
        {
            // Get possible values
            PossibleValues.Clear();
            var type = GetTypeName(SelectedProeprty.PropertyType);
            HashSet <string> collections = new HashSet <string>();

            foreach (var item in Inputs)
            {
                var val = _SelectedProeprty.GetValue(item, null)?.ToString();
                if (val != null)
                {
                    if (type == "Guid")
                    {
                        try
                        {
                            var attributes = _SelectedProeprty.GetCustomAttribute(typeof(ColumnAttribute)) as ColumnAttribute;
                            var option     = attributes.Options;
                            if (string.IsNullOrWhiteSpace(option) || option.Contains(">") || string.IsNullOrWhiteSpace(val))
                            {
                                continue;
                            }
                            var link = DS.Generic(option)?.GetById(GuidParser.Convert(val));//, true) as IEnumerable<IDocument>;
                            if (link == null)
                            {
                                continue;
                            }
                            collections.Add(link?.Name);
                            StatusLabel = $"{_("Récupération des données")} - {link?.Name}";
                            NotifyOfPropertyChange("StatusLabel");
                        }
                        catch (Exception s)
                        {
                            DataHelpers.ShowMessage(s.Message);
                        }
                    }
                    else
                    {
                        collections.Add(val as string);
                    }
                }
            }
            PossibleValues.AddRange(collections);
            StatusLabel = _($"Términé");
            NotifyOfPropertyChange("StatusLabel");
            NotifyOfPropertyChange("PossibleValues");
        }