Exemplo n.º 1
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;
        }
        public ExecuteCommandCreateNewClassBasedProcessTask(IBasicActivateItems activator, LoadMetadata loadMetadata, LoadStage loadStage,
                                                            [DemandsInitialization("Class to execute, must be an attacher, mutilater etc", TypeOf = typeof(IDisposeAfterDataLoad))]
                                                            Type type) : base(activator)
        {
            _loadMetadata = loadMetadata;
            _loadStage    = loadStage;
            _type         = type;

            if (typeof(IAttacher).IsAssignableFrom(_type))
            {
                _processTaskType = ProcessTaskType.Attacher;
            }
            else
            if (typeof(IDataProvider).IsAssignableFrom(_type))
            {
                _processTaskType = ProcessTaskType.DataProvider;
            }
            else
            if (typeof(IMutilateDataTables).IsAssignableFrom(_type))
            {
                _processTaskType = ProcessTaskType.MutilateDataTable;
            }
            else
            {
                SetImpossible($"Type '{_type}' was not a compatible one e.g. IAttacher, IDataProvider or IMutilateDataTables");
            }
        }
Exemplo n.º 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;
        }
Exemplo n.º 4
0
        public void EmptyFilePath(string path, ProcessTaskType typeThatRequiresFiles)
        {
            _task.ProcessTaskType = typeThatRequiresFiles;
            _task.Path            = path;
            _task.SaveToDatabase();
            var ex = Assert.Throws <Exception>(() => _checker.Check(new ThrowImmediatelyCheckNotifier()));

            StringAssert.Contains("does not have a path specified", ex.Message);
        }
Exemplo n.º 5
0
        public void EmptyClassPath(string path, ProcessTaskType typeThatRequiresMEF, LoadStage stage)
        {
            _task.ProcessTaskType = typeThatRequiresMEF;
            _task.Path            = path;
            _task.LoadStage       = stage;
            _task.SaveToDatabase();
            var ex = Assert.Throws <ArgumentException>(() => _checker.Check(new ThrowImmediatelyCheckNotifier()));

            Assert.IsTrue(Regex.IsMatch(ex.Message, "Path is blank for ProcessTask 'New Process.*' - it should be a class name of type"));
        }
Exemplo n.º 6
0
        private void AddTypeIntoStage(Type type, ProcessTaskType taskType)
        {
            var lmd   = _loadStageNode.LoadMetadata;
            var stage = _loadStageNode.LoadStage;

            ProcessTask newTask = new ProcessTask((ICatalogueRepository)lmd.Repository, lmd, stage);

            newTask.Path            = type.FullName;
            newTask.ProcessTaskType = taskType;
            newTask.Name            = type.Name;

            newTask.SaveToDatabase();
            Publish(lmd);
            Activate(newTask);
        }
Exemplo n.º 7
0
        internal ProcessTask(ICatalogueRepository repository, DbDataReader r)
            : base(repository, r)
        {
            LoadMetadata_ID = int.Parse(r["LoadMetaData_ID"].ToString());

            if (r["RelatesSolelyToCatalogue_ID"] != DBNull.Value)
            {
                _relatesSolelyToCatalogueID = int.Parse(r["RelatesSolelyToCatalogue_ID"].ToString());
            }

            Path  = r["Path"] as string;
            Name  = r["Name"] as string;
            Order = int.Parse(r["Order"].ToString());

            ProcessTaskType processTaskType;

            if (ProcessTaskType.TryParse(r["ProcessTaskType"] as string, out processTaskType))
            {
                ProcessTaskType = processTaskType;
            }
            else
            {
                throw new Exception("Could not parse ProcessTaskType:" + r["ProcessTaskType"]);
            }

            LoadStage loadStage;

            if (LoadStage.TryParse(r["LoadStage"] as string, out loadStage))
            {
                LoadStage = loadStage;
            }
            else
            {
                throw new Exception("Could not parse LoadStage:" + r["LoadStage"]);
            }

            IsDisabled = Convert.ToBoolean(r["IsDisabled"]);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Returns true if the <see cref="ProcessTaskType"/> is allowed to happen during the given <see cref="LoadStage"/>  (e.g. you can't use an IAttacher to
        /// load data into STAGING/LIVE - only RAW).
        /// </summary>
        /// <param name="type"></param>
        /// <param name="stage"></param>
        /// <returns></returns>
        public static bool IsCompatibleStage(ProcessTaskType type, LoadStage stage)
        {
            switch (type)
            {
            case ProcessTaskType.Executable:
                return(true);

            case ProcessTaskType.SQLFile:
                return(stage != LoadStage.GetFiles);

            case ProcessTaskType.Attacher:
                return(stage == LoadStage.Mounting);

            case ProcessTaskType.DataProvider:
                return(true);

            case ProcessTaskType.MutilateDataTable:
                return(stage != LoadStage.GetFiles);

            default:
                throw new ArgumentOutOfRangeException("type");
            }
        }
Exemplo n.º 9
0
        private void SetType(Type type)
        {
            _type = type;

            if (typeof(IAttacher).IsAssignableFrom(_type))
            {
                _processTaskType = ProcessTaskType.Attacher;
            }
            else
            if (typeof(IDataProvider).IsAssignableFrom(_type))
            {
                _processTaskType = ProcessTaskType.DataProvider;
            }
            else
            if (typeof(IMutilateDataTables).IsAssignableFrom(_type))
            {
                _processTaskType = ProcessTaskType.MutilateDataTable;
            }
            else
            {
                SetImpossible($"Type '{_type}' was not a compatible one e.g. IAttacher, IDataProvider or IMutilateDataTables");
            }
        }