Esempio n. 1
0
        public void SetLaunchHistory(string SearchPhrase, Guid Key)
        {
            string searchPhrase = SearchPhrase.Trim().ToLowerInvariant();

            LaunchHistory foundHistory = LaunchHistories.FirstOrDefault(t =>
                                                                        t.FileLink.Key == Key &&
                                                                        t.SearchPhrase.Trim().ToLowerInvariant() == searchPhrase);

            if (foundHistory == null)
            {
                LaunchHistory newHistory = new LaunchHistory
                {
                    SearchPhrase  = searchPhrase,
                    CountLaunches = 1,
                    LastLaunched  = DateTime.Now,
                    FileLink      = FileLinks.FirstOrDefault(t => t.Key == Key)
                };
                LaunchHistories.Add(newHistory);
            }
            else
            {
                foundHistory.CountLaunches++;
                foundHistory.LastLaunched = DateTime.Now;
            }
        }
Esempio n. 2
0
        private void LoadHistory()
        {
            LaunchHistories = new List <LaunchHistory>();

            if (File.Exists(HistoryFileName))
            {
                using (FileStream stream = new FileStream(HistoryFileName, FileMode.Open))
                    using (BinaryReader reader = new BinaryReader(stream, Encoding.UTF8, false))
                    {
                        while (reader.PeekChar() != -1)
                        {
                            LaunchHistory history = new LaunchHistory();
                            history.SearchPhrase  = reader.ReadString();
                            history.CountLaunches = reader.ReadInt32();
                            history.LastLaunched  = DateTime.FromBinary(reader.ReadInt64());
                            Guid key = Guid.Parse(reader.ReadString());
                            history.FileLink = FileLinks.FirstOrDefault(t => t.Key == key);
                            LaunchHistories.Add(history);
                        }
                    }
            }
        }
Esempio n. 3
0
 public FileLink GetFileLink(Guid Key)
 {
     return(FileLinks.FirstOrDefault(t => t.Key == Key));
 }