コード例 #1
0
ファイル: BuildEngine.cs プロジェクト: mmcquillan/DBBuild
        private void RunOnce(string cmd)
        {
            // var to hold the currently processing file
            string currentFile = "";

            try
            {
                // get the list of files
                string[] myfiles = GetFiles(cmd);

                // loop through the files
                foreach (string file in myfiles)
                {
                    // feedback
                    UI.Feedback("RUNONCE", file, mac.GetTF("$VERBOSE$"));

                    // set current file
                    currentFile = file;

                    // check if this file has been run
                    if (runner.ChangeCheck(file))
                    {
                        try
                        {
                            // mark start
                            runner.ChangeStart(file);

                            // read in the file
                            StreamReader sr = new StreamReader(file);

                            // run var fix
                            string content = mac.Substitute(sr.ReadToEnd());

                            // send to DB
                            if (!mac.GetTF("$RUNONCESKIP$"))
                            {
                                runner.ExecuteSQL(content);
                            }
                            else
                            {
                                UI.Feedback("WARNING", "File was logged but did not run.");
                            }

                            // mark success
                            runner.ChangeSucceeded(file);

                            // update the catalog
                            runner.SetCatalog();
                        }
                        catch (Exception)
                        {
                            // mark fail
                            runner.ChangeFailed(file);
                            throw;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                UI.Feedback("ERROR", ex.GetBaseException().Message);
                UI.Feedback("ERROR", "Processing File: '" + currentFile + "'");
                throw;
            }
        }