Esempio n. 1
0
        /// <summary>
        /// Loads a WorkflowSections object one file at a time (PreWork, RollIn, RollBack, and PostWork)
        /// </summary>
        /// <param name="preworkFilePath">Path to the PreWork file to load</param>
        /// <param name="rollinFilePath">Path to the RollIn file to load</param>
        /// <param name="rollbackFilePath">Path to the RollBack file to load</param>
        /// <param name="postworkFilePath">Path to the PostWork file to load</param>
        /// <returns>A validated WorkflowSections object</returns>
        public static WorkflowSections LoadAndValidateManifestFile(string preworkFilePath,
                                                                   string rollinFilePath, string rollbackFilePath, string postworkFilePath,
                                                                   bool continueOnError, bool showSqlInOutput, bool setQuotedIdentifier)
        {
            WorkflowSections ws          = new WorkflowSections();
            bool             failOnError = !continueOnError;

            if (!string.IsNullOrWhiteSpace(preworkFilePath))
            {
                ws.PreWork.LoadAndValidateManifestFile(preworkFilePath, failOnError, showSqlInOutput, setQuotedIdentifier);
            }
            if (!string.IsNullOrWhiteSpace(rollinFilePath))
            {
                ws.RollIn.LoadAndValidateManifestFile(rollinFilePath, failOnError, showSqlInOutput, setQuotedIdentifier);
            }
            if (!string.IsNullOrWhiteSpace(rollbackFilePath))
            {
                ws.RollBack.LoadAndValidateManifestFile(rollbackFilePath, failOnError, showSqlInOutput, setQuotedIdentifier);
            }
            if (!string.IsNullOrWhiteSpace(postworkFilePath))
            {
                ws.PostWork.LoadAndValidateManifestFile(postworkFilePath, failOnError, showSqlInOutput, setQuotedIdentifier);
            }


            //note: at least some file should exist, and the file should have content
            //optimistic initialization immed following section load, assuming ws.IsValid = true
            ws.WorkflowSuccess = ws.IsValid;

            return(ws);
        }
Esempio n. 2
0
        public virtual bool PrepareAndValidateSections()
        {
            Sections = new WorkflowSections();

            if (Directory.Exists(ScriptFolder.SourcePath))
            {
                PreworkManifestFile          = Path.Combine(ScriptFolder.SourcePath, _preworkManifestFile);
                RollInManifestFile           = Path.Combine(ScriptFolder.SourcePath, _rollInManifestFile);
                RollBackManifestFile         = Path.Combine(ScriptFolder.SourcePath, _rollBackManifestFile);
                PostworkManifestFile         = Path.Combine(ScriptFolder.SourcePath, _postworkManifestFile);
                WorkflowSectionsManifestFile = Path.Combine(ScriptFolder.SourcePath, _workflowSectionsManifestFile);
            }
            else
            {
                IsValid = false;
                return(false);
            }


            if (File.Exists(WorkflowSectionsManifestFile, PathFormat.FullPath))   //HasWorkflowSectionsManifestFile
            {
                Sections = WorkflowSections.LoadAndValidateManifestFile(WorkflowSectionsManifestFile);
            }
            else
            {
                Sections = WorkflowSections.LoadAndValidateManifestFile(
                    PreworkManifestFile, RollInManifestFile, RollBackManifestFile, PostworkManifestFile,
                    ContinueOnError, ShowSqlInOutput, SetQuotedIdentifier.Value);
            }
            Sections.NameSections();
            IsValid &= Sections.IsValid;

            return(Sections.IsValid);
        }
Esempio n. 3
0
        /// <summary>
        /// Loads the Xml manifest that contains the PreWork, RollIn, RollBack, and PostWork sections
        /// </summary>
        /// <param name="filePath">Path to the file to load</param>
        /// <returns>A validated WorkflowSections object</returns>
        public static WorkflowSections LoadAndValidateManifestFile(string filePath)
        {
            WorkflowSections ws = new WorkflowSections();

            //note: ws.WorkflowSuccess will equal false if !File.Exists, thus failing workflow as desired
            if (File.Exists(filePath))
            {
                string folderPath = Path.GetDirectoryName(filePath);
                ws = Utils.DeserializeFile <WorkflowSections>(filePath);
                foreach (Section section in ws.Sections)
                {
                    ValidateSection(section, folderPath);
                }

                //optimistic initialization immed following section load
                ws.WorkflowSuccess = true;
            }
            else
            {
                //workflow sections have optimistic initialization, invalidate them if manifest does not exist
                ws.PreWork.IsValid              =
                    ws.RollIn.IsValid           =
                        ws.RollBack.IsValid     =
                            ws.PostWork.IsValid = false;
            }

            return(ws);
        }