public void Parse03() { var historyFile = HistoryFile.Parse(new FileInfo("abc.txt.20161117011122.backuphistory")); Assert.AreEqual("abc.txt", historyFile.FileName); Assert.AreEqual(new DateTime(2016, 11, 17, 1, 11, 22), historyFile.DateTime); }
/// <summary> /// A asynchronous Run method for an REPL /// </summary> /// <param name="configuration">Prompt Configuration, null for using default settings</param> /// <param name="token">Cancellation Token, allows the task to exit nicely</param> /// <returns></returns> public static async Task RunAsync(IPromptConfiguration configuration = null, CancellationToken token = default) { var prompt = new Prompt(configuration); var cmd = string.Empty; while (!string.Equals(cmd, "exit", StringComparison.OrdinalIgnoreCase)) { var promptText = $"{prompt.Configuration.GetOption("PromptPreFix")}{prompt.CurrentFolder}{prompt.Configuration.GetOption("PromptPostFix")}"; // ReadLine is not await able, hence running as a Task.Run. Improve foreign project to // include ReadLine.ReadAsync( with CancellationToken) await Task.Run(() => cmd = ReadLine.Read(promptText), token); try { prompt.Run(cmd); } catch (Exception exception) { // Don't allow an exception to crash the application by a throw Console.WriteLine(exception); } } HistoryFile.Save(configuration); }
private static void Execute(string id) { var catalog = ApiCatalog.Load(); var api = catalog[id]; if (api.NoVersionHistory) { Console.WriteLine($"Skipping version history update for {id}"); return; } string historyFilePath = HistoryFile.GetPathForPackage(id); var root = DirectoryLayout.DetermineRootDirectory(); using (var repo = new Repository(root)) { var releases = LoadReleases(repo, api).ToList(); if (!File.Exists(historyFilePath)) { File.WriteAllText(historyFilePath, "# Version history\r\n\r\n"); } var historyFile = HistoryFile.Load(historyFilePath); historyFile.MergeReleases(releases); historyFile.Save(historyFilePath); } var relativePath = Path.GetRelativePath(DirectoryLayout.DetermineRootDirectory(), historyFilePath) .Replace('\\', '/'); Console.WriteLine($"Updated version history file: {relativePath}"); }
private static void Execute(string id) { var catalog = ApiCatalog.Load(); var api = catalog[id]; if (api.NoVersionHistory) { Console.WriteLine($"Skipping version history update for {id}"); return; } string historyFilePath = HistoryFile.GetPathForPackage(id); var root = DirectoryLayout.DetermineRootDirectory(); using var repo = new Repository(root); var releases = Release.LoadReleases(repo, catalog, api).ToList(); var historyFile = HistoryFile.Load(historyFilePath); var sectionsInserted = historyFile.MergeReleases(releases); if (sectionsInserted.Count != 0) { historyFile.Save(historyFilePath); var relativePath = Path.GetRelativePath(DirectoryLayout.DetermineRootDirectory(), historyFilePath) .Replace('\\', '/'); Console.WriteLine($"Updated version history file: {relativePath}"); Console.WriteLine("New content:"); Console.WriteLine(); foreach (var line in sectionsInserted.SelectMany(section => section.Lines)) { Console.WriteLine(line); } } }
public int Compare(HistoryFile x, HistoryFile y) { if (x.CashDate.Equals(y.CashDate) && x.CashValue.Equals(y.CashValue)) { return(0); } return(1); }
protected override void ExecuteImpl(string[] args) { var diffs = FindChangedVersions(); if (diffs.Count != 1) { throw new UserErrorException($"Can only automate a single-package release commit with exactly 1 release. Found {diffs.Count}. Did you mean 'commit-multiple'?"); } var diff = diffs[0]; if (diff.NewVersion is null) { throw new UserErrorException($"Cannot automate a release commit for a deleted API."); } var historyFilePath = HistoryFile.GetPathForPackage(diff.Id); if (!File.Exists(historyFilePath)) { throw new UserErrorException($"Cannot automate a release commit without a version history file."); } var historyFile = HistoryFile.Load(historyFilePath); var section = historyFile.Sections.FirstOrDefault(s => s.Version?.ToString() == diff.NewVersion); if (section is null) { throw new UserErrorException($"Unable to find history file section for {diff.NewVersion}. Cannot automate a release commit in this state."); } string header = $"Release {diff.Id} version {diff.NewVersion}"; var message = string.Join("\n", new[] { header, "", "Changes in this release:", "" }.Concat(section.Lines.Skip(2))); var root = DirectoryLayout.DetermineRootDirectory(); using (var repo = new Repository(root)) { RepositoryStatus status = repo.RetrieveStatus(); // TODO: Work out whether this is enough, and whether we actually need all of these. // We basically want git add --all. AddAll(status.Modified); AddAll(status.Missing); AddAll(status.Untracked); repo.Index.Write(); var signature = repo.Config.BuildSignature(DateTimeOffset.UtcNow); var commit = repo.Commit(message, signature, signature); Console.WriteLine($"Created commit {commit.Sha}. Review the message and amend if necessary."); void AddAll(IEnumerable <StatusEntry> entries) { foreach (var entry in entries) { repo.Index.Add(entry.FilePath); } } } }
public void ComputeFileName03() { var historyFile = new HistoryFile(new FileInfo("abc.txt")); historyFile.DateTime = new DateTime(2016, 11, 17, 1, 11, 22); string fileName = historyFile.ComputeFileName(); Assert.AreEqual("abc.txt.20161117011122.backuphistory", fileName); }
public FormEvents(ClipboardManager clipManager, NotifyIcon icon, Form form, Settings settings, HistoryFile history, OnlineSettings onlineSettings) { exitFileWritten = false; ActiveForm = form; _clipboardManager = clipManager; NotificationIcon = icon; _settings = settings; _writeHistory = history; _settings.PropertyChanged += ChangeIconStyle; _clipboardManager.PropertyChanged += ShowCopyNotification; _onlineSettings = onlineSettings; SetIconStyle(); SetWindowStartupState(); }
//At some point you could take a look at IoC Containers //It'll take off the responsibility from you to initialize everything in MainForm //And inject every required class. //You'll only need to register them in the IoC Container and then use them just like, // in AspNetCore public MainForm() { InitializeComponent(); _settingsHandler = new SettingsHandler(); _settings = _settingsHandler.LoadSettingsFile() as Settings; _onlineSettings = _settingsHandler.LoadSettingsFile(true) as OnlineSettings; _inboundMessage = new SignalRMessage(); _outgoingMessage = new SignalRMessage(); _clipboardManager = new ClipboardManager(_inboundMessage, _outgoingMessage, _settings); _cloudInteractions = new CloudInteractions(_inboundMessage, _outgoingMessage, _settings, _onlineSettings); _writeHistoryFile = new HistoryFile(_clipboardManager, _settings); _languageOnForm = new LanguageOnForm(); _formEvents = new FormEvents(_clipboardManager, notificationIcon, this, _settings, _writeHistoryFile, _onlineSettings); _startWithWindows = new LaunchOnStartup(_settings); _checkConnection = new CheckStaticConnectionState(Label_Connection_DONOTMODIFY, timer_checkConnection); EnumSetLang(); BindProperties(); BindButtonActions(); }
public Prompt(IPromptConfiguration configuration) { try { // If Configuration is null, use default settings Configuration = configuration ?? new PromptConfiguration(); ReadLine.HistoryEnabled = string.Equals(Configuration.GetOption("HistoryEnabled"), true.ToString()); BuildCommands.ScanForPrompt(this); HistoryFile.Load(configuration); } catch (Exception e) { // Don't allow an exception to crash the application by a throw // Show the error so that an developer can fix the problem. Console.WriteLine(e); } }
public void OnHistorySelectedCommand(object parameter) { HistoryStatus status = (HistoryStatus)parameter; HistoryDetail = status.Detail; HistoryDetailCommitId = status.CommitId; HistoryFileList.Clear(); if (String.IsNullOrEmpty(status.CommitId) == false) { foreach (var filename in git_.GetFilelistOfCommit(status.CommitId)) { HistoryFile file = new HistoryFile(); file.Directory = filename; file.FileName = filename; file.IsSelected = false; HistoryFileList.Add(file); } } NotifyPropertyChanged("HistoryFileList"); }
private void button3_Click(object sender, EventArgs e) { HistoryFile file = t.GetHistoryFileForUnitSingle("CODE", new DateTime(2013, 10, 4), HistoryFileType.STO, 0); MessageBox.Show(file.fileContent.Length + " bytes"); }
public void Parse02() { var historyFile = HistoryFile.Parse(new FileInfo("abc.backuphistory")); Assert.AreEqual(null, historyFile); }
protected override void ExecuteImpl(string[] args) { var catalog = ApiCatalog.Load(); // Work out the package group that we're modifying. var diffs = FindChangedVersions(); var groups = diffs.Select(pair => catalog[pair.Id].PackageGroup).Distinct().ToList(); if (groups.Count != 1 || groups[0] is null) { throw new UserErrorException("Current set of changes does not represent a package group."); } var packageGroup = groups[0]; if (packageGroup.PackageIds.Count != diffs.Count) { throw new UserErrorException($"Expected complete package group to be updated. Group contains: '{string.Join("', '", packageGroup.PackageIds)}'"); } if (diffs.Any(diff => diff.NewVersion is null)) { throw new UserErrorException($"Cannot automate a release commit for a deleted API."); } var diffsWithHistory = diffs .Where(diff => !catalog[diff.Id].NoVersionHistory) .ToList(); if (diffsWithHistory.Any(diff => !File.Exists(HistoryFile.GetPathForPackage(diff.Id)))) { // Not a great message, but a very rare condition. throw new UserErrorException($"Not all expected history file paths exist."); } var diffHistoryPairs = diffsWithHistory .Select(diff => (diff, history: HistoryFile.Load(HistoryFile.GetPathForPackage(diff.Id)))) .ToList(); // Commit has three sections: // - Title generated from the package group // - Lists of changes (one list per package that has history) // - List of released packages var lines = new List <string>(); // If we've got a single new version, use that in the commit title. Otherwise don't use it at all. var allNewVersions = diffs.Select(d => d.NewVersion).Distinct().ToList(); var suffix = allNewVersions.Count == 1 ? $" version {allNewVersions[0]}" : ""; lines.Add($"Release {packageGroup.DisplayName} libraries{suffix}"); lines.Add(""); foreach (var(diff, history) in diffHistoryPairs) { lines.Add($"Changes in {diff.Id} version {diff.NewVersion}:"); lines.Add(""); var section = history.Sections.FirstOrDefault(s => s.Version?.ToString() == diff.NewVersion); if (section is null) { throw new UserErrorException($"Unable to find history file section for {diff.Id} version {diff.NewVersion}. Cannot automate a release commit in this state."); } lines.AddRange(section.Lines.Skip(2)); lines.Add(""); } lines.Add("Packages in this release:"); foreach (var diff in diffs) { lines.Add($"- Release {diff.Id} version {diff.NewVersion}"); } var message = string.Join("\n", lines); var root = DirectoryLayout.DetermineRootDirectory(); using (var repo = new Repository(root)) { RepositoryStatus status = repo.RetrieveStatus(); // TODO: Work out whether this is enough, and whether we actually need all of these. // We basically want git add --all. AddAll(status.Modified); AddAll(status.Missing); AddAll(status.Untracked); repo.Index.Write(); var signature = repo.Config.BuildSignature(DateTimeOffset.UtcNow); var commit = repo.Commit(message, signature, signature); Console.WriteLine($"Created commit {commit.Sha}. Review the message and amend if necessary."); void AddAll(IEnumerable <StatusEntry> entries) { foreach (var entry in entries) { repo.Index.Add(entry.FilePath); } } } }
public void HistoryFileIntergrityTest() { string testFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "history.test"); if (File.Exists(testFile)) { File.Delete(testFile); } var inv1 = Generator.ActivateResponse <ClientData>(); { inv1.ClientId = 10; inv1.DatabaseId = 101; inv1.NickName = "Invoker1"; } var inv2 = Generator.ActivateResponse <ClientData>(); { inv2.ClientId = 20; inv2.DatabaseId = 102; inv2.NickName = "Invoker2"; } var ar1 = new SoundcloudResource("asdf", "sc_ar1", "https://soundcloud.de/sc_ar1"); var ar2 = new MediaResource("./File.mp3", "me_ar2", "https://splamy.de/sc_ar2", RResultCode.Success); var data1 = new PlayData(null, inv1, "", false) { Resource = ar1, }; var data2 = new PlayData(null, inv2, "", false) { Resource = ar2, }; HistoryFile hf = new HistoryFile(); hf.OpenFile(testFile); hf.Store(data1); var lastXEntries = hf.GetLastXEntrys(1); Assert.True(lastXEntries.Any()); var lastEntry = lastXEntries.First(); Assert.AreEqual(ar1, lastEntry); hf.CloseFile(); hf.OpenFile(testFile); lastXEntries = hf.GetLastXEntrys(1); Assert.True(lastXEntries.Any()); lastEntry = lastXEntries.First(); Assert.AreEqual(ar1, lastEntry); hf.Store(data1); hf.Store(data2); lastXEntries = hf.GetLastXEntrys(1); Assert.True(lastXEntries.Any()); lastEntry = lastXEntries.First(); Assert.AreEqual(ar2, lastEntry); hf.CloseFile(); // store and order check hf.OpenFile(testFile); var lastXEntriesArray = hf.GetLastXEntrys(2).ToArray(); Assert.AreEqual(2, lastXEntriesArray.Length); Assert.AreEqual(ar1, lastXEntriesArray[0]); Assert.AreEqual(ar2, lastXEntriesArray[1]); var ale1 = hf.GetEntryById(hf.Contains(ar1).Value); hf.LogEntryRename(ale1, "sc_ar1X", false); hf.LogEntryPlay(ale1); hf.CloseFile(); // check entry renaming hf.OpenFile(testFile); lastXEntriesArray = hf.GetLastXEntrys(2).ToArray(); Assert.AreEqual(2, lastXEntriesArray.Length); Assert.AreEqual(ar2, lastXEntriesArray[0]); Assert.AreEqual(ar1, lastXEntriesArray[1]); var ale2 = hf.GetEntryById(hf.Contains(ar2).Value); hf.LogEntryRename(ale2, "me_ar2_loong1"); hf.LogEntryPlay(ale2); ale1 = hf.GetEntryById(hf.Contains(ar1).Value); hf.LogEntryRename(ale1, "sc_ar1X_loong1"); hf.LogEntryPlay(ale1); hf.LogEntryRename(ale2, "me_ar2_exxxxxtra_loong1"); hf.LogEntryPlay(ale2); hf.CloseFile(); // reckeck order hf.OpenFile(testFile); lastXEntriesArray = hf.GetLastXEntrys(2).ToArray(); Assert.AreEqual(2, lastXEntriesArray.Length); Assert.AreEqual(ar1, lastXEntriesArray[0]); Assert.AreEqual(ar2, lastXEntriesArray[1]); hf.CloseFile(); // delete entry 2 hf.OpenFile(testFile); hf.LogEntryRemove(hf.GetEntryById(hf.Contains(ar2).Value)); lastXEntriesArray = hf.GetLastXEntrys(2).ToArray(); Assert.AreEqual(1, lastXEntriesArray.Length); Assert.AreEqual(ar1, lastXEntriesArray[0]); hf.CloseFile(); // delete entry 1 hf.OpenFile(testFile); hf.LogEntryRemove(hf.GetEntryById(hf.Contains(ar1).Value)); lastXEntriesArray = hf.GetLastXEntrys(2).ToArray(); Assert.AreEqual(0, lastXEntriesArray.Length); hf.CloseFile(); File.Delete(testFile); }
public void Parse01() { var historyFile = HistoryFile.Parse(new FileInfo("abc.txt")); Assert.AreEqual(null, historyFile); }
public List <HistoryDetails> GetHistory(string mobileNumber, string CPno) { try { SqlParameter[] sqlparam; sqlparam = new SqlParameter[2]; sqlparam[0] = new SqlParameter("@mobileNumber", mobileNumber); sqlparam[1] = new SqlParameter("@CPno", CPno); DataSet ds = CommonFunction.GetDataSet("USP_Get_HistoryByMobile_App", sqlparam, ""); List <HistoryDetails> HD = new List <HistoryDetails>(); List <ObservationDetails> OD = new List <ObservationDetails>(); List <TestDetails> TD = new List <TestDetails>(); List <MedicinesDetails> MD = new List <MedicinesDetails>(); List <HistoryFile> HF = new List <HistoryFile>(); //History if (ds != null && ds.Tables[0].Rows.Count > 0) { DataTable dt1 = ds.Tables[0]; foreach (DataRow dr in dt1.Rows) { HistoryDetails histrydetails = new HistoryDetails(); // HistoryDetails lstHD = new HistoryDetails(); CommonFunction.ReflectSingleData(histrydetails, dr); if (ds != null && ds.Tables[0].Rows.Count > 0) { DataTable dt0 = ds.Tables[0]; foreach (DataRow dr0 in dt0.Rows) { if (Convert.ToInt32(dr0["QueueId"]) == histrydetails.QueueId) { HistoryDetails lstHD = new HistoryDetails(); CommonFunction.ReflectSingleData(lstHD, dr0); histrydetails.lstHD.Add(lstHD); } } } //Observation if (ds != null && ds.Tables[1].Rows.Count > 0) { DataTable dt2 = ds.Tables[1]; foreach (DataRow dr1 in dt2.Rows) { if (Convert.ToInt32(dr1["QueueId"]) == histrydetails.QueueId) { ObservationDetails lstOD = new ObservationDetails(); CommonFunction.ReflectSingleData(lstOD, dr1); histrydetails.lstOD.Add(lstOD); } } } //Test if (ds != null && ds.Tables[2].Rows.Count > 0) { DataTable dt3 = ds.Tables[2]; foreach (DataRow dr2 in dt3.Rows) { if (Convert.ToInt32(dr2["QueueId"]) == histrydetails.QueueId) { TestDetails lstOD = new TestDetails(); CommonFunction.ReflectSingleData(lstOD, dr2); histrydetails.lstTD.Add(lstOD); } } } //Medicine if (ds != null && ds.Tables[3].Rows.Count > 0) { DataTable dt4 = ds.Tables[3]; foreach (DataRow dr3 in dt4.Rows) { if (Convert.ToInt32(dr3["QueueId"]) == histrydetails.QueueId) { MedicinesDetails lstMD = new MedicinesDetails(); CommonFunction.ReflectSingleData(lstMD, dr3); histrydetails.lstMD.Add(lstMD); } } } // if (ds != null && ds.Tables[4].Rows.Count > 0) { DataTable dt5 = ds.Tables[4]; foreach (DataRow dr4 in dt5.Rows) { if (Convert.ToInt32(dr4["QueueId"]) == histrydetails.QueueId) { HistoryFile lstHF = new HistoryFile(); CommonFunction.ReflectSingleData(lstHF, dr4); histrydetails.lstHF.Add(lstHF); } } } HD.Add(histrydetails); } } // HD.lstOD = OD; //histrydetails.lstHD = HD; //histrydetails.lstOD = OD; //histrydetails.lstTD = TD; //histrydetails.lstMD = MD; return(HD); } catch (Exception Ex) { throw Ex; } }
protected override void ExecuteImpl(string[] args) { string title = args[0]; var diffs = FindChangedVersions(); if (diffs.Count < 2) { throw new UserErrorException($"Can only automate a multi-package release commit with more than one release. Found {diffs.Count}. Did you mean 'commit'?"); } if (diffs.Any(diff => diff.NewVersion is null)) { throw new UserErrorException($"Cannot automate a release commit for a deleted API."); } var catalog = ApiCatalog.Load(); var diffsWithHistory = diffs .Where(diff => !catalog[diff.Id].NoVersionHistory) .ToList(); if (diffsWithHistory.Any(diff => !File.Exists(HistoryFile.GetPathForPackage(diff.Id)))) { // Not a great message, but a very rare condition. throw new UserErrorException($"Not all expected history file paths exist."); } var diffHistoryPairs = diffsWithHistory .Select(diff => (diff, history: HistoryFile.Load(HistoryFile.GetPathForPackage(diff.Id)))) .ToList(); // Commit has three sections: // - User-provided title // - Lists of changes (one list per package that has history) // - List of released packages var lines = new List <string>(); lines.Add(title); lines.Add(""); foreach (var(diff, history) in diffHistoryPairs) { lines.Add($"Changes in {diff.Id} version {diff.NewVersion}:"); lines.Add(""); var section = history.Sections.FirstOrDefault(s => s.Version?.ToString() == diff.NewVersion); if (section is null) { throw new UserErrorException($"Unable to find history file section for {diff.Id} version {diff.NewVersion}. Cannot automate a release commit in this state."); } lines.AddRange(section.Lines.Skip(2)); lines.Add(""); } lines.Add("Packages in this release:"); foreach (var diff in diffs) { lines.Add($"- Release {diff.Id} version {diff.NewVersion}"); } var message = string.Join("\n", lines); var root = DirectoryLayout.DetermineRootDirectory(); using (var repo = new Repository(root)) { RepositoryStatus status = repo.RetrieveStatus(); // TODO: Work out whether this is enough, and whether we actually need all of these. // We basically want git add --all. AddAll(status.Modified); AddAll(status.Missing); AddAll(status.Untracked); repo.Index.Write(); var signature = repo.Config.BuildSignature(DateTimeOffset.UtcNow); var commit = repo.Commit(message, signature, signature); Console.WriteLine($"Created commit {commit.Sha}. Review the message and amend if necessary."); void AddAll(IEnumerable <StatusEntry> entries) { foreach (var entry in entries) { repo.Index.Add(entry.FilePath); } } } }