Exemplo n.º 1
0
        public VersionInfoViewModel(DirectoryInfo directoryInfo, VersionManagerViewModel manager)
        {
            Manager = manager;

            DirectoryInfo = directoryInfo;
            DirectoryPath = directoryInfo.FullName;
            Version       = Convert.ToInt32(directoryInfo.Name);

            foreach (var file in directoryInfo.EnumerateFiles())
            {
                VersionFiles.Add(new VersionFileViewModel(file));
            }
        }
Exemplo n.º 2
0
        public Result <VersionFiles> VersionFiles(int current_version)
        {
            VersionFiles version = new VersionFiles()
            {
                version    = Config.client_version,
                version_no = Config.client_version_no
            };

            if (current_version >= Config.client_version)
            {
                return(Result(ApiResultEnum.LatestVersion, version));
            }

            version.files            = ClientFileDA.List(current_version);
            version.total_file_count = version.files.Count;
            version.total_size       = version.files.Sum(f => f.size);
            return(Result(ApiResultEnum.Success, version));
        }
Exemplo n.º 3
0
        void ProcessFiles()
        {
            // find all sql files and place them into an array
            string[] filesFound = System.IO.Directory.GetFiles(_filePath, "*.sql", System.IO.SearchOption.AllDirectories);

            System.Collections.Generic.SortedList <int, VersionFiles> list = new SortedList <int, VersionFiles>();

            //  Use regex to find the version number in the file

            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"^.*Version\s+No\s*(?<version>\d+)", System.Text.RegularExpressions.RegexOptions.Multiline | System.Text.RegularExpressions.RegexOptions.IgnoreCase);
            System.Text.RegularExpressions.Match match;

            foreach (string filename in filesFound)
            {
                if (filename.ToLower().EndsWith(".sql"))
                {
                    string fileContents = System.IO.File.ReadAllText(filename);

                    match = regex.Match(fileContents);

                    int version = 1000000;

                    if (match.Success)
                    {
                        version = int.Parse(match.Result("${version}"));
                    }

                    // now check to see if the version number is already present. If so just add it

                    if (list.ContainsKey(version))
                    {
                        VersionFiles existingVersion = list[version];
                        existingVersion.AddFile(filename);
                    }
                    else
                    {
                        VersionFiles newVersion = new VersionFiles(version);
                        newVersion.AddFile(filename);
                        list.Add(version, newVersion);
                    }
                }
            }

            // we now have a sortlist of version numbers together with a set of files
            // for each version. Just need to process these in order to create the script


            System.IO.File.Delete(_outputFileName);

            //We create a log file of the items written

            string logFilepath = Path.Combine(Path.GetDirectoryName(_outputFileName), "Script.log");

            System.IO.File.Delete(logFilepath);


            foreach (System.Collections.Generic.KeyValuePair <int, VersionFiles> currentVersion in list)
            {
                string[] files = currentVersion.Value.Files();
                Array.Sort(files);
                Array.Reverse(files);

                foreach (string currentFile in files)
                {
                    System.Text.StringBuilder sb = new StringBuilder();

                    sb.Append(System.IO.File.ReadAllText(currentFile));
                    sb.Append("\r\nGO\r\n"); // append a CR LF to the end of the file plus a GO plus another CR LF


                    System.IO.File.AppendAllText(_outputFileName, sb.ToString());
                    System.IO.File.AppendAllText(logFilepath, currentFile + "\r\n");
                }
            }
        }
Exemplo n.º 4
0
 public ResultVersionFiles(ApiResultEnum code, VersionFiles data) : base(code)
 {
     Data = data;
 }