/// <summary> /// Logs an exception to the log file. /// </summary> /// <param name="e">Exception to log.</param> /// <summary> /// Logs an exception to the log file. /// </summary> /// <param name="e">Exception to log.</param> protected void LogExceptionDetails(Exception e) { string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, GlobalConstants.ErrorLogFile); StringBuilder errorMessage = new StringBuilder(); errorMessage.Append("Exception occurred at: "); errorMessage.AppendLine(DateTime.Now.ToString()); errorMessage.AppendLine(e.Message); errorMessage.AppendLine("Stack trace:"); errorMessage.AppendLine(e.StackTrace); errorMessage.AppendLine(); using (System.IO.StreamWriter file = new System.IO.StreamWriter(fileName, true)) { file.WriteLine(errorMessage.ToString()); } WindowDialogViewModel dialog = new WindowDialogViewModel() { ShowPositiveButton = true, PositiveButtonName = "Ok", Title = "Error Occurred", Text = "An error occurred. Please see the error log file for details." }; _winDialogService.ShowDialog(dialog); }
private void OnAccept(object obj) { try { // Get the Application object Outlook.Application application = Globals.ThisAddIn.Application; // Get the active Inspector object and check if is type of MailItem Outlook.Inspector inspector = application.ActiveInspector(); Outlook.AppointmentItem meetingItem = inspector.CurrentItem as Outlook.AppointmentItem; if (meetingItem == null) { meetingItem = (Outlook.AppointmentItem)inspector.Application.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem); return; } meetingItem.Location = SelectedFacility.name; meetingItem.MeetingStatus = Outlook.OlMeetingStatus.olMeeting; meetingItem.Body = Remarks; // Meeting dates //meetingItem.Start = this.SelectedDate; //meetingItem.End = this.DateEnd; //meetingItem.Subject = "Time slot to discuss Outlook Addin"; object missing = System.Reflection.Missing.Value; } catch (Exception ex) { WindowDialogViewModel dialog = new WindowDialogViewModel() { ShowPositiveButton = true, PositiveButtonName = "Ok", Title = "Error Occurred", Text = ex.Message }; _winDialogService.ShowDialog(dialog); } }