示例#1
0
 public List <SelectListItem> GetLookupList(LookupType type)
 {
     if (type == LookupType.Boolean)
     {
         return(new List <SelectListItem>()
         {
             new SelectListItem {
                 Text = "Yes", Value = "True"
             },
             new SelectListItem {
                 Text = "No", Value = "False"
             }
         });
     }
     else
     {
         return(_all.Where(l => l.Type == type.ToString())
                .Select(l => new SelectListItem
         {
             Text = l.Name,
             Value = l.Name
         })
                //.OrderBy(l => l.Text)
                .ToList());
     }
 }
        public Response <Dictionary <string, List <dynamic> > > GetLookupsByType(LookupType lookupType)
        {
            string apiUrl = BaseRoute + "GetLookupsByType";

            var parameters = new NameValueCollection {
                { "lookupType", lookupType.ToString() }
            };

            var response = _communicationManager.Get <Response <Dictionary <string, List <dynamic> > > >(parameters, apiUrl);

            return(response);
        }
        private void LaunchLookup()
        {
            switch (LookupType)
            {
            case LookupType.Reference:
                GenericLookup <ReferenceSearchResult>();
                break;

            case LookupType.Region:
                GenericLookup <Region>();
                break;

            case LookupType.Trap:
                GenericLookup <Trap>();
                break;

            case LookupType.Material:
                GenericLookup <Material>();
                break;

            case LookupType.Site:
                GenericLookup <Site>();
                break;

            case LookupType.SiteVisit:
                GenericLookup <SiteVisit>();
                break;

            case LookupType.Taxon:
                GenericLookup <Taxon>();
                break;

            case LookupType.Journal:
                GenericLookup <Journal>();
                break;

            case LookupType.SiteOrRegion:
                GenericLookup <SiteExplorerNode>();
                break;

            case LookupType.Contact:
                GenericLookup <Contact>();
                break;

            default:
                throw new Exception("Unhandled Lookup type: " + LookupType.ToString());
            }
        }
示例#4
0
 public List <string> GetLookupText(LookupType type)
 {
     if (type == LookupType.Boolean)
     {
         return(new List <string>()
         {
             "Yes",
             "No"
         });
     }
     else
     {
         return(_all.Where(l => l.Type == type.ToString())
                .Select(l => l.Name)
                .ToList());
     }
 }
示例#5
0
        public ILookupRepository CreateLookupRepository(LookupType lookupType)
        {
            switch (lookupType)
            {
            case LookupType.Product:
                return(new ProductLookupRepository(_overtureClient, _cacheProvider));

            case LookupType.Order:
                return(new OrderLookupRepository(_overtureClient, _cacheProvider));

            case LookupType.Customer:
                return(new CustomerLookupRepository(_overtureClient, _cacheProvider));

            case LookupType.Marketing:
                return(new MarketingLookupRepository(_overtureClient, _cacheProvider));
            }


            throw new NotSupportedException(lookupType.ToString());
        }
示例#6
0
        private async Task <(string gamertag, string xuid)> GetProfileSettings(LookupType type, string value)
        {
            var token = await _tokenClient.GetXblToken(null, new GetTokenRequest());

            var options = new HttpClientOptions();
            var query   = new Dictionary <string, string>();
            var path    = string.Format(_pathTemplate, type.ToString().ToLowerInvariant(), value);

            options.Headers.Add("authorization", string.Format(_authHeader, token.Uhs, token.Token));
            options.Headers.Add("X-XBL-Contract-Version", "2");
            query.Add("settings", "gamertag");

            try
            {
                var response = await _client.Do <ProfileSettings>("GET", path, query, options);

                var user     = response.ProfileUsers[0];
                var xuid     = user.ID.ToString();
                var gamertag = user.Settings.First(s => s.ID == "Gamertag").Value;

                return(gamertag, xuid);
            }
            catch (CrpcException ex)
            {
                switch (ex.Message)
                {
                case "2":                         // XUIDInvalid
                    throw new CrpcException("invalid_xuid");

                case "8":                         // ProfileNotFound
                    throw new CrpcException("profile_not_found");

                default:
                    throw new CrpcException("resolve_identity_failed", null, ex);
                }
            }
        }
示例#7
0
        /// <summary>
        /// Get all items for the current type
        /// </summary>
        /// <returns>A list of Lookup objects</returns>
        public IList <Lookup> List(LookupType type)
        {
            //Cache Section
            string cacheKey          = null;
            MembershipHelperUser mhu = MembershipHelper.GetUser();

            if (mhu != null)
            {
                cacheKey = string.Format("LOOKUPS_{0}_{1}_{2}", mhu.UserId, typeof(Lookup).ToString(), type.ToString());
            }

            object result = CacheManager.GetCached(typeof(Lookup), cacheKey);

            ICriteria crit = GetCriteria();

            if (result == null)
            {
                string query = "SELECT L FROM Lookup L WHERE";

                query += " LookupType = :Type";
                query += " ORDER BY UPPER(Description)";

                IQuery q = NHibernateSession.CreateQuery(query);

                q.SetEnum("Type", type);

                result = q.List <Lookup>();
                //crit.Add(Expression.Eq("LookupType", type));
                //crit.AddOrder(new Order("Description", true));

                //result = crit.List<Lookup>();
                CacheManager.AddItem(typeof(Lookup), cacheKey, result);
            }
            return(result as IList <Lookup>);
        }
    public static string GetLookupsByLookupType(LookupType lookupType)
    {
        string SQL = String.Format(@"Select id, name, value, lookuptype from lookups where lookuptype = '{0}'", lookupType.ToString());

        return(SQL);
    }
        public SelectedObjectChooser(User user, List<ViewModelBase> items, LookupType objectType)
        {
            InitializeComponent();

            GridView view = new GridView();

            var m = new RDESiteVisit();

            switch (objectType) {
                case LookupType.Site:
                    AddColumn(view, "Site Name", "SiteName", 300);
                    AddColumn(view, "Site ID", "SiteID");
                    AddColumn(view, "Longitude","Longitude");
                    AddColumn(view, "Latitude","Latitude");
                    break;
                case LookupType.SiteVisit:
                    AddColumn(view, "Site Visit Name", "VisitName", 300);
                    AddColumn(view, "Site Name", "Site.SiteName", 300);
                    AddColumn(view, "Site Visit ID", "SiteVisitID");
                    AddColumn(view, "Site ID", "Site.SiteID");
                    AddColumn(view, "Longitude","Site.Longitude");
                    AddColumn(view, "Latitude","Site.Latitude");
                    break;
                case LookupType.Material:
                    AddColumn(view, "Material Name", "MaterialName", 100);
                    AddColumn(view, "BiotaID", "BiotaID");
                    AddColumn(view, "Site Visit Name", "SiteVisit.VisitName", 300);
                    AddColumn(view, "Site Name", "SiteVisit.Site.SiteName", 300);
                    AddColumn(view, "Material ID", "MaterialID");
                    AddColumn(view, "Site Visit ID", "SiteVisit.SiteVisitID");
                    AddColumn(view, "Site ID", "SiteVisit.Site.SiteID");
                    AddColumn(view, "Longitude","SiteVisit.Site.Longitude");
                    AddColumn(view, "Latitude","SiteVisit.Site.Latitude");
                    break;

            }

            lvw.View = view;
            lvw.ItemsSource = items;

            lvw.AddHandler(GridViewColumnHeader.ClickEvent, new RoutedEventHandler(GridViewColumnHeaderClickedHandler));

            lblStatus.Content = string.Format("{0} items listed.", items.Count);

            lvw.MouseRightButtonUp += new MouseButtonEventHandler(lvw_MouseRightButtonUp);

            this.Title = string.Format("Multiple {0} records found at this location", objectType.ToString());
        }
示例#10
0
 private string GenerateRedisKey(LookupType type, string value)
 {
     return($"{type.ToString().ToLowerInvariant()}-{value.Trim().ToSlug()}");
 }
        public SelectedObjectChooser(User user, List <ViewModelBase> items, LookupType objectType)
        {
            InitializeComponent();

            GridView view = new GridView();

            var m = new RDESiteVisit();

            switch (objectType)
            {
            case LookupType.Site:
                AddColumn(view, "Site Name", "SiteName", 300);
                AddColumn(view, "Site ID", "SiteID");
                AddColumn(view, "Longitude", "Longitude");
                AddColumn(view, "Latitude", "Latitude");
                break;

            case LookupType.SiteVisit:
                AddColumn(view, "Site Visit Name", "VisitName", 300);
                AddColumn(view, "Site Name", "Site.SiteName", 300);
                AddColumn(view, "Site Visit ID", "SiteVisitID");
                AddColumn(view, "Site ID", "Site.SiteID");
                AddColumn(view, "Longitude", "Site.Longitude");
                AddColumn(view, "Latitude", "Site.Latitude");
                break;

            case LookupType.Material:
                AddColumn(view, "Material Name", "MaterialName", 100);
                AddColumn(view, "BiotaID", "BiotaID");
                AddColumn(view, "Site Visit Name", "SiteVisit.VisitName", 300);
                AddColumn(view, "Site Name", "SiteVisit.Site.SiteName", 300);
                AddColumn(view, "Material ID", "MaterialID");
                AddColumn(view, "Site Visit ID", "SiteVisit.SiteVisitID");
                AddColumn(view, "Site ID", "SiteVisit.Site.SiteID");
                AddColumn(view, "Longitude", "SiteVisit.Site.Longitude");
                AddColumn(view, "Latitude", "SiteVisit.Site.Latitude");
                break;
            }

            lvw.View        = view;
            lvw.ItemsSource = items;

            lvw.AddHandler(GridViewColumnHeader.ClickEvent, new RoutedEventHandler(GridViewColumnHeaderClickedHandler));

            lblStatus.Content = string.Format("{0} items listed.", items.Count);

            lvw.MouseRightButtonUp += new MouseButtonEventHandler(lvw_MouseRightButtonUp);

            this.Title = string.Format("Multiple {0} records found at this location", objectType.ToString());
        }
示例#12
0
 public GetPicklistKeywordsRequest(LookupType lookupType) : base("getPicklistKeywords")
 {
     Key = lookupType.ToString();
 }
示例#13
0
        private void AddLookupItem(ContextMenuBuilder builder, LookupType lookupType, params String[] aliases)
        {
            int index = -1;
            foreach (string alias in aliases) {
                var field = alias;

                for (int i = 0; i < Data.Columns.Count; ++i) {
                    var col = Data.Columns[i];
                    if (col.Name.Contains(alias)) {
                        index = i;
                        break;
                    }
                }

                if (index >= 0) {
                    break;
                }
            }

            if (index > -1) {
                var row = lvw.SelectedItem as MatrixRow;

                int objectId = 0;
                var enabled = false;
                if (row[index] != null) {
                    if (Int32.TryParse(row[index].ToString(), out objectId) && objectId > 0) {
                        enabled = true;
                    }
                }

                var pinnable = PluginManager.Instance.GetPinnableForLookupType(lookupType, objectId);

                var commands = new List<Command>();

                if (pinnable != null) {
                    var vm = PluginManager.Instance.GetViewModel(pinnable);
                    if (vm != null) {
                        var selected = new List<ViewModelBase>();
                        selected.Add(vm);
                        commands.AddRange(PluginManager.Instance.SolicitCommandsForObjects(selected));
                    }
                }

                if (commands.Count > 0) {

                    MenuItemBuilder b = new MenuItemBuilder();

                    var typeItem = b.New(lookupType.ToString()).MenuItem;

                    typeItem.Items.Add(b.New("Pin {0} to pinboard", lookupType).Handler(() => {
                        PluginManager.Instance.PinObject(pinnable);
                    }).Enabled(enabled).MenuItem);
                    typeItem.Items.Add(new Separator());

                    commands.ForEach((cmd) => {
                        if (cmd is CommandSeparator) {
                            typeItem.Items.Add(new Separator());
                        } else {
                            typeItem.Items.Add(b.New(cmd.Caption).Handler(() => {
                                cmd.CommandAction(pinnable);
                            }).Enabled(enabled).MenuItem);
                        }
                    });

                    builder.AddMenuItem(typeItem);
                } else {
                    builder.New("Edit " + lookupType.ToString()).Handler(() => {
                        PluginManager.Instance.EditLookupObject(lookupType, objectId);
                    }).Enabled(enabled).End();
                }
            }

            addSetOperations(builder, lookupType, aliases);
        }
示例#14
0
        private void addSetOperations(ContextMenuBuilder builder, LookupType type, params string[] idColAliases)
        {
            int index = -1;

            foreach (string alias in idColAliases)
            {
                var field = alias;
                for (int i = 0; i < Data.Columns.Count; ++i)
                {
                    var col = Data.Columns[i];
                    if (col.Name.Contains(alias))
                    {
                        index = i;
                        break;
                    }
                }

                if (index >= 0)
                {
                    break;
                }
            }

            if (index > -1)
            {
                List <int> idSet = new List <int>();

                if (lvw.SelectedItems.Count > 1)
                {
                    foreach (object selected in lvw.SelectedItems)
                    {
                        var row         = selected as MatrixRow;
                        var selectedRow = Data.Rows.IndexOf(row);
                        idSet.Add((int)row[selectedRow]);
                    }
                }
                else
                {
                    Data.Rows.ForEach(row => {
                        var objectIndex = row[index];
                        if (objectIndex is int)
                        {
                            idSet.Add((int)row[index]);
                        }
                    });
                }

                if (idSet.Count > 0)
                {
                    var commands = PluginManager.Instance.SolicitCommandsForObjectSet(idSet, type);
                    if (commands != null && commands.Count > 0)
                    {
                        MenuItemBuilder b = new MenuItemBuilder();

                        var typeItem = b.New(type.ToString() + String.Format(" Set ({0} items)", idSet.Count)).MenuItem;

                        commands.ForEach((cmd) => {
                            if (cmd is CommandSeparator)
                            {
                                typeItem.Items.Add(new Separator());
                            }
                            else
                            {
                                typeItem.Items.Add(b.New(cmd.Caption).Handler(() => {
                                    cmd.CommandAction(idSet);
                                }).MenuItem);
                            }
                        });
                        builder.AddMenuItem(typeItem);
                    }
                }
            }
        }
示例#15
0
 public List <Lookup> All(LookupType type)
 {
     return(_all.Where(l => l.Type == type.ToString()).OrderBy(l => l.Name).ToList());
 }
示例#16
0
 public bool Exist(LookupType type, string value)
 {
     return(_all.Where(l => l.Type == type.ToString() && l.Name == value).Count() > 0);
 }
示例#17
0
        private void AddLookupItem(ContextMenuBuilder builder, LookupType lookupType, params String[] aliases)
        {
            int index = -1;

            foreach (string alias in aliases)
            {
                var field = alias;

                for (int i = 0; i < Data.Columns.Count; ++i)
                {
                    var col = Data.Columns[i];
                    if (col.Name.Contains(alias))
                    {
                        index = i;
                        break;
                    }
                }

                if (index >= 0)
                {
                    break;
                }
            }

            if (index > -1)
            {
                var row = lvw.SelectedItem as MatrixRow;

                int objectId = 0;
                var enabled  = false;
                if (row[index] != null)
                {
                    if (Int32.TryParse(row[index].ToString(), out objectId) && objectId > 0)
                    {
                        enabled = true;
                    }
                }

                var pinnable = PluginManager.Instance.GetPinnableForLookupType(lookupType, objectId);

                var commands = new List <Command>();

                if (pinnable != null)
                {
                    var vm = PluginManager.Instance.GetViewModel(pinnable);
                    if (vm != null)
                    {
                        var selected = new List <ViewModelBase>();
                        selected.Add(vm);
                        commands.AddRange(PluginManager.Instance.SolicitCommandsForObjects(selected));
                    }
                }

                if (commands.Count > 0)
                {
                    MenuItemBuilder b = new MenuItemBuilder();

                    var typeItem = b.New(lookupType.ToString()).MenuItem;

                    typeItem.Items.Add(b.New("Pin {0} to pinboard", lookupType).Handler(() => {
                        PluginManager.Instance.PinObject(pinnable);
                    }).Enabled(enabled).MenuItem);
                    typeItem.Items.Add(new Separator());

                    commands.ForEach((cmd) => {
                        if (cmd is CommandSeparator)
                        {
                            typeItem.Items.Add(new Separator());
                        }
                        else
                        {
                            typeItem.Items.Add(b.New(cmd.Caption).Handler(() => {
                                cmd.CommandAction(pinnable);
                            }).Enabled(enabled).MenuItem);
                        }
                    });

                    builder.AddMenuItem(typeItem);
                }
                else
                {
                    builder.New("Edit " + lookupType.ToString()).Handler(() => {
                        PluginManager.Instance.EditLookupObject(lookupType, objectId);
                    }).Enabled(enabled).End();
                }
            }

            addSetOperations(builder, lookupType, aliases);
        }
示例#18
0
        private void addSetOperations(ContextMenuBuilder builder, LookupType type, params string[] idColAliases)
        {
            int index = -1;
            foreach (string alias in idColAliases) {
                var field = alias;
                for (int i = 0; i < Data.Columns.Count; ++i) {
                    var col = Data.Columns[i];
                    if (col.Name.Contains(alias)) {
                        index = i;
                        break;
                    }
                }

                if (index >= 0) {
                    break;
                }
            }

            if (index > -1) {

                List<int> idSet = new List<int>();

                if (lvw.SelectedItems.Count > 1) {
                    foreach (object selected in lvw.SelectedItems) {
                        var row = selected as MatrixRow;
                        var selectedRow = Data.Rows.IndexOf(row);
                        idSet.Add((int)row[selectedRow]);
                    }
                } else {
                    Data.Rows.ForEach(row => {
                        var objectIndex = row[index];
                        if (objectIndex is int) {
                            idSet.Add((int)row[index]);
                        }
                    });
                }

                if (idSet.Count > 0) {
                    var commands = PluginManager.Instance.SolicitCommandsForObjectSet(idSet, type);
                    if (commands != null && commands.Count > 0) {
                        MenuItemBuilder b = new MenuItemBuilder();

                        var typeItem = b.New(type.ToString() + String.Format(" Set ({0} items)", idSet.Count)).MenuItem;

                        commands.ForEach((cmd) => {
                            if (cmd is CommandSeparator) {
                                typeItem.Items.Add(new Separator());
                            } else {
                                typeItem.Items.Add(b.New(cmd.Caption).Handler(() => {
                                    cmd.CommandAction(idSet);
                                }).MenuItem);
                            }
                        });
                        builder.AddMenuItem(typeItem);
                    }
                }
            }
        }
示例#19
0
 public GetPicklistColorsRequest(LookupType lookupType) : base("getPicklistColors")
 {
     Key = lookupType.ToString();
 }