Beispiel #1
0
        // KBR TODO duplicated code?
        public override ListViewItem ToListViewItem()
        {
            ListViewItem lvi = new ListViewItem();

            lvi.Text       = Name;
            lvi.Tag        = this;
            lvi.ImageIndex = Win32.GetFileIconIndex(Name, Win32.FileIconSize.Small);
            lvi.SubItems.Add(Length.ToKB());
            lvi.SubItems.Add(CreationTime.ToString("g"));
            lvi.SubItems.Add(LastWriteTime.ToString("g"));
            lvi.SubItems.Add(Attributes.ToString());

            lvi.SubItems.Add(Keywords);
            lvi.SubItems.Add(Extension);

            lvi.SubItems.Add(GetVolumeUserName());
            lvi.SubItems.Add(GetPath());
            if (Hash != 0)
            {
                lvi.SubItems.Add(Hash.ToString("X"));
            }
            else
            {
                lvi.SubItems.Add(string.Empty);
            }
            return(lvi);
        }
Beispiel #2
0
 public IDictionary <string, string> ToDictionary()
 {
     return(new Dictionary <string, string>
     {
         { "LastWriteTime", LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") },
         { "Size", Size.ToString() },
         { "Name", Name },
         { "IsDir", IsDir.ToString() }
     });
 }
Beispiel #3
0
        private void ReadLog(string fileName)
        {
            var lines = new List <string>();

            using (FileStream inputStream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                using (StreamReader reader = new StreamReader(inputStream))
                {
                    while (!reader.EndOfStream)
                    {
                        lines.Add(reader.ReadLine());
                    }
                }
            }

            if (Logger == string.Empty)
            {
                Logger = lines.Where(line => line.Contains("Listener:")).FirstOrDefault().Split(new string[] { ":        " }, StringSplitOptions.RemoveEmptyEntries)[1];
            }
            lines.Reverse();

            var messages = new List <LogLine>();

            lines.ForEach(line =>
            {
                if (!line.Contains("MOTD"))
                {
                    try
                    {
                        messages.Add(new LogLine(line));
                    }
                    catch (Exception ex) { }
                }
            });
            messages.Reverse();

            using (var hubConnection = new HubConnection(Properties.Settings.Default.IntelHubURL))
            {
                var hub = hubConnection.CreateHubProxy("IntelHub");
                hubConnection.Start().Wait();

                ReportUserLogging(hub);

                if (messages.Where(message => message.LogDateTime > LastWriteTime).ToList().Count > 0)
                {
                    ClearCurrentConsoleLine();
                    Poll(messages.Where(message => message.LogDateTime > LastWriteTime).ToList(), hub);
                    LastWriteTime = messages.LastOrDefault().LogDateTime;
                    Properties.Settings.Default.LastWriteTime = LastWriteTime.ToString();
                    Console.WriteLine("");
                }
                hubConnection.Stop();
            }
        }
Beispiel #4
0
 public string ToString(string sep)
 {
     return(string.Join(sep, new string[] { Name, FileSize.ToString(), LastWriteTime.ToString(), HashString, FileVersion,
                                            ProductVersion, BuildDateTime.ToString(), LinkerVersion }));
 }