Esempio n. 1
0
 public void Z()
 {
     var files = new DirectoryInfo(@"c:\proj\visionquest\src\sharpdx").GetFiles("*.cs", SearchOption.AllDirectories).ToList();
     files.Sort((x, y) => -x.LastWriteTime.CompareTo(y.LastWriteTime));
     for (var i = 0; i < 99; i++)
         System.Diagnostics.Debug.Print("{0:yyyy MMMM dd HH mm} {1}", files[i].LastWriteTime, files[i].FullName);
 }
Esempio n. 2
0
        private void LoadMatches()
        {
            FileInfo summaryFile = new FileInfo(App.SummaryPath);
              var dir = new DirectoryInfo(App.Rootpath);
              if (!dir.Exists) dir.Create();

              Logger.WriteLine("Loading replays from {0}", App.Rootpath);

              FileStream loadSummary;
              if (!summaryFile.Exists) loadSummary = summaryFile.Create();
              else loadSummary = summaryFile.Open(FileMode.Open);
              var mems = new MemoryStream();
              loadSummary.CopyTo(mems);
              loadSummary.Close();

              dynamic summary;
              try {
            summary = MFroehlich.Parsing.MFro.MFroFormat.Deserialize(mems.ToArray());
            Logger.WriteLine("Loaded {0} summaries from {1}", summary.Count, summaryFile.FullName);
              } catch (Exception x) {
            summary = new JSONObject();
            Logger.WriteLine(Priority.Error, "Error loading summaries {0}, starting new summary list", x.Message);
              }
              dynamic newSummary = new JSONObject();

              List<FileInfo> files = new DirectoryInfo(App.Rootpath).EnumerateFiles("*.lol").ToList();
              files.Sort((a, b) => b.Name.CompareTo(a.Name));

              int summaries = 0;
              var timer = new System.Diagnostics.Stopwatch(); timer.Start();

              for (int i = 0; i < files.Count; i++) {
            string filename = files[i].Name.Substring(0, files[i].Name.Length - 4);

            ReplayItem item;
            if (summary.ContainsKey(filename)) {
              item = new ReplayItem((SummaryData) summary[filename], files[i]);
              newSummary.Add(filename, summary[filename]);
            } else {
              SummaryData data = new SummaryData(new MFroReplay(files[i]));
              newSummary.Add(filename, JSONObject.From(data));
              item = new ReplayItem(data, files[i]);
              summaries++;
            }
            item.MouseUp += OpenDetails;
            replays.Add(item);
              }

              Logger.WriteLine("All replays loaded, took {0}ms", timer.ElapsedMilliseconds);

              using (FileStream saveSummary = summaryFile.Open(FileMode.Open)) {
            byte[] summBytes = MFroehlich.Parsing.MFro.MFroFormat.Serialize(newSummary);
            saveSummary.Write(summBytes, 0, summBytes.Length);
            Logger.WriteLine("Saved summaries, {0} total summaries, {1} newly generated", newSummary.Count, summaries);
              }
              Search();
              ReplayArea.Visibility = System.Windows.Visibility.Visible;
              LoadArea.Visibility = System.Windows.Visibility.Hidden;
              Console.WriteLine("DONE");
        }
Esempio n. 3
0
        public void HardResetUpdatesTheContentOfTheWorkingDirectory()
        {
            bool progressCalled = false;

            string path = SandboxStandardTestRepo();
            using (var repo = new Repository(path))
            {
                var names = new DirectoryInfo(repo.Info.WorkingDirectory).GetFileSystemInfos().Select(fsi => fsi.Name).ToList();

                File.Delete(Path.Combine(repo.Info.WorkingDirectory, "README"));
                Touch(repo.Info.WorkingDirectory, "WillNotBeRemoved.txt", "content\n");

                Assert.True(names.Count > 4);

                var commit = repo.Lookup<Commit>("HEAD~3");
                repo.Reset(ResetMode.Hard, commit, new CheckoutOptions()
                {
                    OnCheckoutProgress = (_path, _completed, _total) => { progressCalled = true; },
                });

                names = new DirectoryInfo(repo.Info.WorkingDirectory).GetFileSystemInfos().Select(fsi => fsi.Name).ToList();
                names.Sort(StringComparer.Ordinal);

                Assert.Equal(true, progressCalled);
                Assert.Equal(new[] { ".git", "README", "WillNotBeRemoved.txt", "branch_file.txt", "new.txt", "new_untracked_file.txt" }, names);
            }
        }
        public void Validate(string directoryPath)
        {
            var regex = new Regex(@"^(?<index>[0-9]+).+\.sql$");

            var indexes = new DirectoryInfo(directoryPath)
                .GetFiles()
                .Select(f =>
                {
                    var match = regex.Match(f.Name);

                    var index = match.Groups["index"].Value;

                    return int.Parse(index);
                })
                .ToList();
            
            if (indexes.Count < 2)
            {
                return;
            }

            indexes.Sort();
            
            for (var i = 0; i < indexes.Count - 1; i++)
            {
                var diff = indexes[i + 1] - indexes[i];

                if (diff != 1)
                {
                    throw new WrongOrderException("There is a gap between scripts. Files should be contiguous");
                }
            }            
        }
        void Init()
        {
            if (!Directory.Exists(_info.DatePath)) {
                return;
            }

            var list = new DirectoryInfo(_info.DatePath).GetFiles().ToList();
            list.Sort((x, y) => String.Compare(x.Name, y.Name, StringComparison.Ordinal));

            foreach (var file in list) {
                var macth = Regex.Match(file.Name, @"\d{8}");
                if (macth.Success) {
                    DateTime date;
                    if (DateTime.TryParseExact(macth.Groups[0].Value, "yyyyMMdd", null, DateTimeStyles.None, out date)
                        && date >= _info.DateTime1
                        && date <= _info.DateTime2) {
                        _files.AddLast(file);
                        _count += (int)file.Length;
                    }
                }
            }

            if (_count > 0) {
                EndOfSeries = false;
                _progressDelta = (int)Math.Ceiling(((double)_count / 100));
                _progressCount = _progressDelta;
                _progressPercent = 0;
                OpenReader();
            }

            if (_current == null)
                EndOfSeries = true;
        }
        public void HardResetUpdatesTheContentOfTheWorkingDirectory()
        {
            string path = CloneStandardTestRepo();
            using (var repo = new Repository(path))
            {
                var names = new DirectoryInfo(repo.Info.WorkingDirectory).GetFileSystemInfos().Select(fsi => fsi.Name).ToList();

                File.Delete(Path.Combine(repo.Info.WorkingDirectory, "README"));
                File.WriteAllText(Path.Combine(repo.Info.WorkingDirectory, "WillNotBeRemoved.txt"), "content\n");

                Assert.True(names.Count > 4);

                repo.Reset(ResetOptions.Hard, "HEAD~3");

                names = new DirectoryInfo(repo.Info.WorkingDirectory).GetFileSystemInfos().Select(fsi => fsi.Name).ToList();
                names.Sort(StringComparer.Ordinal);

                Assert.Equal(new[] { ".git", "README", "WillNotBeRemoved.txt", "branch_file.txt", "new.txt", "new_untracked_file.txt" }, names);
            }
        }