Esempio n. 1
0
 private void AddFilesToBeIgnored(DirectoryInfo dir)
 {
     if (Config.IgnoreFilePatterns != null && Config.IgnoreFilePatterns.Length > 0)
     {
         dir.GetFiles(Config.IgnoreFilePatterns)
         .Select(f => f.FullName)
         .Each(f => IgnoreFiles.Add(f));
     }
 }
Esempio n. 2
0
        public void AddIgnoreFile(string fileName)
        {
            if (IgnoreFiles == null)
            {
                IgnoreFiles = new List <string>();
            }

            IgnoreFiles.Add(fileName);
        }
Esempio n. 3
0
        private void SetEnvironments()
        {
            {
                List <string> rawLines;
                if (Environment.Is64BitProcess)
                {
                    rawLines = FileUtility.Inst.GetFileLines(GetResourcePath(SYSTEMENVIRONMENTS_x64_FILE));
                }
                else
                {
                    rawLines = FileUtility.Inst.GetFileLines(GetResourcePath(SYSTEMENVIRONMENTS_x86_FILE));
                }

                foreach (var item in rawLines)
                {
                    int tipStartPos = item.IndexOf(',');
                    var envVariable = item.Substring(0, tipStartPos);
                    var nextSection = item.Substring(tipStartPos + 1);
                    tipStartPos = nextSection.IndexOf(',');
                    var envValue = nextSection.Substring(0, tipStartPos);
                    nextSection = nextSection.Substring(tipStartPos + 1);
                    tipStartPos = nextSection.IndexOf(',');
                    var displayName = nextSection.Substring(0, tipStartPos);
                    var envTips     = nextSection.Substring(tipStartPos + 1);

                    ToolTipMap.Add(envVariable, envTips);

                    var filePath = new Model.EnvironmentInfo();
                    filePath.VarName      = envVariable;
                    filePath.Tips         = envTips;
                    filePath.DisplayName  = displayName;
                    filePath.RelativePath = envValue;
                    filePath.ShortPath    = envValue.GetAbsolutePath(true);
                    filePath.LongPath     = envValue.GetAbsolutePath(false);

                    SystemEnvironments.Add(envVariable, filePath);
                }
            }

            {
                var rawLines = FileUtility.Inst.GetFileLines(GetResourcePath(APPENVIRONMENTS_FILE));

                foreach (var item in rawLines)
                {
                    int tipStartPos = item.IndexOf(',');

                    var envVariable = item.Substring(0, tipStartPos);
                    var envTips     = item.Substring(tipStartPos);

                    ToolTipMap.Add(envVariable, envTips);

                    var filePath = new Model.EnvironmentInfo();
                    filePath.RelativePath = envVariable;
                    filePath.ShortPath    = envVariable.GetAbsolutePath(true);
                    filePath.LongPath     = envVariable.GetAbsolutePath(false);

                    AppEnvironments.Add(envVariable, filePath);
                }
            }

            {
                var rawLines = FileUtility.Inst.GetFileLines(GetResourcePath(IGNOREFOLDERS_FILE));

                foreach (var item in rawLines)
                {
                    var expandedValue = Environment.ExpandEnvironmentVariables(item);

                    var filePath = new Model.FilePath();
                    filePath.RelativePath = item;
                    filePath.ShortPath    = expandedValue;
                    filePath.LongPath     = string.Format(@"\\?\{0}", expandedValue);

                    IgnoreFolders.Add(filePath);
                }
            }

            {
                var rawLines = FileUtility.Inst.GetFileLines(GetResourcePath(IGNOREFILES_FILE));

                foreach (var item in rawLines)
                {
                    var expandedValue = Environment.ExpandEnvironmentVariables(item);

                    var filePath = new Model.FilePathEx();
                    filePath.RelativePath = item;
                    filePath.ShortPath    = new Regex(expandedValue.Replace("\\", "\\\\"),
                                                      RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.CultureInvariant | RegexOptions.Compiled);
                    var tempVal = string.Format(@"\\?\{0}", expandedValue);
                    filePath.LongPath = new Regex(tempVal.Replace("\\", "\\\\"),
                                                  RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.CultureInvariant | RegexOptions.Compiled);

                    IgnoreFiles.Add(filePath);
                }
            }

            IgnoreRegKeys = FileUtility.Inst.GetFileLines(GetResourcePath(IGNOREREGISTRYKEYS_FILE));
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes the run options.
        /// </summary>
        /// <param name="args">The command line args.</param>
        /// <returns></returns>
        public void Init(string[] args)
        {
            //defaults
            Init();

            //parse up args
            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i])
                {
                case "-d":
                case "--data":
                    foreach (string table in args[++i].Split(','))
                    {
                        LoadData.Add(table);
                    }
                    break;

                case "--diffFile":
                    DiffFile = args[++i];
                    break;

                case "-f":
                case "--fullyScripted":
                    FullyScripted = true;
                    break;

                case "-h":
                case "--help":
                    Logger.Log("A tool to run scripts on a Microsoft SQL Server 2000 server", OutputLevel.Errors);
                    Logger.Log("Usage: SQLUpdater <args> [-t] <target> [-r] [reference]", OutputLevel.Errors);
                    Logger.Log("\t-d <name[,name]>: Tables to load data from", OutputLevel.Errors);
                    Logger.Log("\t-f: the database is fully scripted", OutputLevel.Errors);
                    Logger.Log("\t-h: display this help message and exit", OutputLevel.Errors);
                    Logger.Log("\t-l <level>: transaction level (None, TableOnly, Everything)", OutputLevel.Errors);
                    Logger.Log("\t-o <level>: output level (Errors, Differences, Updates, Reads)", OutputLevel.Errors);
                    Logger.Log("\t-s <directory>: directory to store scripts in before execution", OutputLevel.Errors);
                    Logger.Log("\t-w <name[,name]>: objects to write out changes to", OutputLevel.Errors);
                    Logger.Log("\t--diffFile <filename>: name of a single file to store a difference summary in", OutputLevel.Errors);
                    Logger.Log("\t--ignore <name[,name]>: script files to ignore", OutputLevel.Errors);
                    Logger.Log("\t--minimalDependencies: only recreate otherwise dropped objects", OutputLevel.Errors);
                    Logger.Log("\t--parserOutput <directory>: directory for debugging parser output", OutputLevel.Errors);
                    Logger.Log("\t--scriptFile <filename>: name of a single file to store scripts in in conjunction with -s", OutputLevel.Errors);
                    Logger.Log("\t--test: run in test mode without updating the database", OutputLevel.Errors);
                    Environment.Exit(0);
                    break;

                case "--ignore":
                    foreach (string name in args[++i].Split(','))
                    {
                        IgnoreFiles.Add(name);
                    }
                    break;

                case "-l":
                    TransactionLevel = (TransactionLevel)Enum.Parse(typeof(TransactionLevel), args[++i]);
                    break;

                case "-m":
                case "--minimalDependencies":
                    MinimalDependencies = true;
                    break;

                case "-o":
                case "--outputlevel":
                    OutputLevel = (OutputLevel)Enum.Parse(typeof(OutputLevel), args[++i]);
                    break;

                case "--parserOutput":
                    ParserOutput = args[++i];
                    break;

                case "-r":
                    AddConnection(args[++i], Connections.References);
                    break;

                case "-s":
                    ScriptOutputDirectory = args[++i];
                    if (!ScriptOutputDirectory.EndsWith("\\"))
                    {
                        ScriptOutputDirectory = ScriptOutputDirectory + "\\";
                    }
                    break;

                case "--scriptFile":
                    ScriptFile = args[++i];
                    break;

                case "-t":
                    AddConnection(args[++i], Connections.Targets);
                    break;

                case "--test":
                    Test = true;
                    break;

                case "-w":
                case "--write":
                    foreach (string name in args[++i].Split(','))
                    {
                        WriteObjects.Add(name);
                    }
                    break;

                default:
                    if (args[i][0] == '-' || (Connections.References.Count > 0 && Connections.Targets.Count > 0))
                    {
                        Logger.Log("Unknown argument: " + args[i], OutputLevel.Errors);
                        Environment.Exit(-1);
                    }
                    else
                    {
                        if (Connections.Targets.Count == 0)
                        {
                            AddConnection(args[i], Connections.Targets);
                        }
                        else
                        {
                            AddConnection(args[i], Connections.References);
                        }
                    }
                    break;
                }
            }
        }