Exemplo n.º 1
0
        public ScriptFilesComparerBase CreateScriptFilesComparer <TScriptFileType>(DBCommands dbCommands, string folderPath)
            where TScriptFileType : ScriptFileTypeBase, new()
        {
            DBExecutedFiles dbExecutedFiles = new DBExecutedFiles(dbCommands, ScriptFileTypeBase.Create <TScriptFileType>());

            ScriptFilesComparerBase scriptFilesComparer = null;

            if (typeof(TScriptFileType) == typeof(IncrementalScriptFileType))
            {
                FileSystemScriptFiles fileSystemScriptFiles = new FileSystemScriptFiles(_fileChecksum, ScriptFileTypeBase.Create <TScriptFileType>(), folderPath);
                scriptFilesComparer = new IncrementalScriptFilesComparer(fileSystemScriptFiles, dbExecutedFiles);
            }
            else if (typeof(TScriptFileType) == typeof(RepeatableScriptFileType))
            {
                FileSystemScriptFiles fileSystemScriptFiles = new FileSystemScriptFiles(_fileChecksum, ScriptFileTypeBase.Create <TScriptFileType>(), folderPath);
                scriptFilesComparer = new RepeatableScriptFilesComparer(fileSystemScriptFiles, dbExecutedFiles);
            }
            else if (typeof(TScriptFileType) == typeof(DevDummyDataScriptFileType))
            {
                FileSystemScriptFiles fileSystemScriptFiles = new FileSystemScriptFiles(_fileChecksum, ScriptFileTypeBase.Create <TScriptFileType>(), folderPath);
                scriptFilesComparer = new DevDummyDataScriptFilesComparer(fileSystemScriptFiles, dbExecutedFiles);
            }

            return(scriptFilesComparer);
        }
        protected RuntimeScriptFile CreateLasetExecutedFileItem()
        {
            RuntimeScriptFile prevExecutionLastScriptFile = null;

            if (!string.IsNullOrWhiteSpace(DBExecutedFiles.LastFileOfLastExecutedFilename))
            {
                string lastFileFullPath = Path.Combine(FileSystemScriptFiles.FolderPath, DBExecutedFiles.LastFileOfLastExecutedFilename);
                prevExecutionLastScriptFile = FileSystemScriptFiles.CreateRuntimeScriptFileInstanceByFilename(lastFileFullPath);
            }

            return(prevExecutionLastScriptFile);
        }
        public ScriptFilesComparerBase(FileSystemScriptFiles fileSystemScriptFiles,
                                       DBExecutedFiles dbExecutedFiles)
        {
            fileSystemScriptFiles.ThrowIfNull(nameof(fileSystemScriptFiles));
            dbExecutedFiles.ThrowIfNull(nameof(dbExecutedFiles));

            ScriptFileType        = fileSystemScriptFiles.ScriptFileType;
            FileSystemScriptFiles = fileSystemScriptFiles;
            DBExecutedFiles       = dbExecutedFiles;

            SetIsHashDifferentFlag();

            CreateFileExistInDBButNotExistInSystemList(fileSystemScriptFiles);
        }
        private void CreateFileExistInDBButNotExistInSystemList(FileSystemScriptFiles fileSystemScriptFiles)
        {
            NotExistInFileSystemButExistInDB = new List <RuntimeScriptFile>();

            foreach (DataRow dbExecutedFileRow in DBExecutedFiles.ExecutedFilesList)
            {
                string dbFilename = Convert.ToString(dbExecutedFileRow["Filename"], CultureInfo.InvariantCulture);

                RuntimeScriptFile fileSystemFile =
                    AllFileSystemScriptFiles.FirstOrDefault(e => dbFilename.Trim().ToUpperInvariant() == e.Filename.Trim().ToUpperInvariant());

                if (fileSystemFile == null)
                {
                    string            fileFullPath = Path.Combine(fileSystemScriptFiles.FolderPath, dbFilename);
                    RuntimeScriptFile misssingFileSystemFileItem = fileSystemScriptFiles.CreateRuntimeScriptFileInstanceByFilename(fileFullPath);
                    NotExistInFileSystemButExistInDB.Add(misssingFileSystemFileItem);
                }

                if (dbFilename == DBExecutedFiles.LastFileOfLastExecutedFilename)
                {
                    break;
                }
            }
        }
 public RuntimeScriptFile CreateNextNewScriptFile(string scriptName)
 {
     return(FileSystemScriptFiles.CreateNextRuntimeScriptFileInstance(scriptName, LastScriptFile));
 }
 public bool TryParseNextRuntimeScriptFileName(string scriptName, out RuntimeScriptFile newRuntimeScriptFile)
 {
     return(FileSystemScriptFiles.TryParseNextRuntimeScriptFileName(scriptName, LastScriptFile, out newRuntimeScriptFile));
 }