示例#1
0
        public DataAccessCredentialUsageNodeMenu(RDMPContextMenuStripArgs args, DataAccessCredentialUsageNode node) : base(args, node)
        {
            var setUsage = new ToolStripMenuItem("Set Context");

            var existingUsages = _activator.RepositoryLocator.CatalogueRepository.TableInfoCredentialsManager.GetCredentialsIfExistsFor(node.TableInfo);

            foreach (DataAccessContext context in Enum.GetValues(typeof(DataAccessContext)))
            {
                Add(new ExecuteCommandSetDataAccessContextForCredentials(_activator, node, context, existingUsages), Keys.None, setUsage);
            }

            Items.Add(setUsage);
        }
        public ExecuteCommandSetDataAccessContextForCredentials(IActivateItems activator, DataAccessCredentialUsageNode node, DataAccessContext newContext, Dictionary <DataAccessContext, DataAccessCredentials> existingCredentials) : base(activator)
        {
            _node       = node;
            _newContext = newContext;

            //if context is same as before
            if (newContext == node.Context)
            {
                SetImpossible("This is the current usage context declared");
                return;
            }

            //if theres already another credentials for that context (other than this one)
            if (existingCredentials.ContainsKey(newContext))
            {
                SetImpossible("DataAccessCredentials '" + existingCredentials[newContext] + "' are used for accessing table under context " + newContext);
            }
        }