コード例 #1
0
ファイル: LoadStageNodeMenu.cs プロジェクト: lulzzz/RDMP
        private void AddMenu <T>(string menuName, Func <Type, bool> filterTypes)
        {
            var types = _mef.GetTypes <T>().Where(filterTypes).ToArray();
            var menu  = new ToolStripMenuItem(menuName);

            ProcessTaskType taskType;

            if (typeof(T) == typeof(IDataProvider))
            {
                taskType = ProcessTaskType.DataProvider;
            }
            else
            if (typeof(T) == typeof(IAttacher))
            {
                taskType = ProcessTaskType.Attacher;
            }
            else if (typeof(T) == typeof(IMutilateDataTables))
            {
                taskType = ProcessTaskType.MutilateDataTable;
            }
            else
            {
                throw new ArgumentException("Type '" + typeof(T) + "' was not expected", "T");
            }

            foreach (Type type in types)
            {
                Type toAdd = type;
                menu.DropDownItems.Add(type.Name, null, (s, e) => AddTypeIntoStage(toAdd, taskType));
            }

            menu.Enabled = ProcessTask.IsCompatibleStage(taskType, _loadStageNode.LoadStage) && types.Any();

            Items.Add(menu);
        }
コード例 #2
0
        public ExecuteCommandCreateNewProcessTask(IActivateItems activator, ProcessTaskType taskType, LoadMetadata loadMetadata, LoadStage loadStage, FileInfo file = null) : base(activator)
        {
            _taskType     = taskType;
            _loadMetadata = loadMetadata;
            _loadStage    = loadStage;

            try
            {
                _LoadDirectory = new LoadDirectory(_loadMetadata.LocationOfFlatFiles);
            }
            catch (Exception)
            {
                SetImpossible("Could not construct LoadDirectory");
            }

            if (taskType == ProcessTaskType.SQLFile)
            {
                _image = activator.CoreIconProvider.GetImage(RDMPConcept.SQL, OverlayKind.Add);
            }
            else if (taskType == ProcessTaskType.Executable)
            {
                _image = new IconOverlayProvider().GetOverlayNoCache(CatalogueIcons.Exe, OverlayKind.Add);
            }
            else
            {
                SetImpossible("Only SQLFile and Executable task types are supported by this command");
            }

            if (!ProcessTask.IsCompatibleStage(taskType, loadStage))
            {
                SetImpossible("You cannot run " + taskType + " in " + loadStage);
            }

            _file = file;
        }
コード例 #3
0
        public ExecuteCommandCreateNewFileBasedProcessTask(IBasicActivateItems activator, ProcessTaskType taskType, LoadMetadata loadMetadata, LoadStage loadStage, FileInfo file = null) : base(activator)
        {
            _taskType     = taskType;
            _loadMetadata = loadMetadata;
            _loadStage    = loadStage;

            try
            {
                _LoadDirectory = new LoadDirectory(_loadMetadata.LocationOfFlatFiles);
            }
            catch (Exception)
            {
                SetImpossible("Could not construct LoadDirectory");
            }

            if (!(taskType == ProcessTaskType.SQLFile || taskType == ProcessTaskType.Executable))
            {
                SetImpossible("Only SQLFile and Executable task types are supported by this command");
            }

            if (!ProcessTask.IsCompatibleStage(taskType, loadStage))
            {
                SetImpossible("You cannot run " + taskType + " in " + loadStage);
            }

            _file = file;
        }
コード例 #4
0
        public ExecuteCommandChangeLoadStage(IActivateItems activator, ProcessTaskCommand sourceProcessTaskCommand, LoadStageNode targetStage) : base(activator)
        {
            _sourceProcessTask = sourceProcessTaskCommand.ProcessTask;
            _targetStage       = targetStage;

            if (sourceProcessTaskCommand.ProcessTask.LoadMetadata_ID != targetStage.LoadMetadata.ID)
            {
                SetImpossible("ProcessTask belongs to a different LoadMetadata");
            }

            if (!ProcessTask.IsCompatibleStage(_sourceProcessTask.ProcessTaskType, _targetStage.LoadStage))
            {
                SetImpossible("Task type '" + _sourceProcessTask.ProcessTaskType + "' cannot run in " + _targetStage.LoadStage);
            }
        }