Example #1
0
 /// <summary>
 /// Writes message to log
 /// </summary>
 /// <param name="m"> Message to write </param>
 public void WriteLog(Message m)
 {
     String logDirectory = ConfigurationManager.AppSettings.Get("LogsDirectory");
     CreateDirectory(logDirectory);
     String currentYear = DateTime.Now.ToString("yyyy");
     logDirectory = Path.Combine(logDirectory, currentYear);
     CreateDirectory(logDirectory);
     String currentMonth = DateTime.Now.ToString("MMMM");
     logDirectory = Path.Combine(logDirectory, currentMonth);
     CreateDirectory( logDirectory );
     String fileName = Path.Combine(logDirectory,
                                    (m.Type == MessageType.Common ? "Common" : m.ConferenceNumber) + ".log");
     CreateFile( fileName );
     using (FileStream fs = File.OpenWrite(fileName))
     {
         using (StreamWriter writer = new StreamWriter(fs))
         {
             writer.WriteLine(m.GetMessageString());
             writer.Close();
         }
     }
 }
 /// <summary>
 /// Prints message text in message area.
 /// </summary>
 /// <param name="message"> Message object to print </param>
 public void ShowMessage(Message message)
 {
     Dispatcher.Invoke((ThreadStart)delegate
     {
         switch (message.Type)
         {
             case MessageType.Common:
                 {
                     ShowAt(0, new Run(message.GetMessageString()));
                     break;
                 }
             case MessageType.Conference:
                 {
                     for (int i = 1; i < Tabs.Items.Count - 1; i++)
                     {
                         if (((TabItem)Tabs.Items[i]).Tag.ToString() == message.ConferenceNumber)
                         {
                             ShowAt(i, RunBuilder.DefaultRun(message));
                             return;
                         }
                     }
                     CreateTab(message);
                     ShowAt(Tabs.Items.Count - 2, RunBuilder.DefaultRun(message));
                     break;
                 }
             default:
                 {
                     for (int i = 0; i < Tabs.Items.Count - 1; i++)
                     {
                         ListBox lb = (ListBox)((Grid)((TabItem)Tabs.Items[i]).Content).Children[0];
                         foreach (CheckBox item in lb.Items)
                         {
                             if (item.Content.ToString() == message.SenderName && item.IsChecked == true)
                             {
                                 ShowAt(i, RunBuilder.SystemRun(message));
                             }
                         }
                     }
                     break;
                 }
         }
     });
 }