public static void SeekFileStreamHelper(FileStream fs, long offset, SeekOrigin origin)
 {
     try
     {
         fs.Seek(offset, origin);
     }
     catch (IOException e)
     {
         LogFileException ex = new LogFileException(SR.GetString("MsgIOExceptionSeek") + fs.Name + SR.GetString("MsgFilePathEnd"), fs.Name, e);
         ExceptionManager.LogAppError(ex);
         throw ex;
     }
     catch (NotSupportedException e2)
     {
         LogFileException ex2 = new LogFileException(SR.GetString("MsgFailToSeekFile") + fs.Name + SR.GetString("MsgFilePathEnd"), fs.Name, e2);
         ExceptionManager.LogAppError(ex2);
         throw ex2;
     }
     catch (ArgumentException e3)
     {
         LogFileException ex3 = new LogFileException(SR.GetString("MsgFailToSeekFile") + fs.Name + SR.GetString("MsgFilePathEnd"), fs.Name, e3);
         ExceptionManager.LogAppError(ex3);
         throw ex3;
     }
     catch (ObjectDisposedException e4)
     {
         LogFileException ex4 = new LogFileException(SR.GetString("MsgFailToSeekFile") + fs.Name + SR.GetString("MsgFilePathEnd") + SR.GetString("MsgStreamClosed"), fs.Name, e4);
         ExceptionManager.LogAppError(ex4);
         throw ex4;
     }
 }
 public static FileStream CreateFileStreamHelper(string filePath, FileMode mode, FileAccess access, FileShare share)
 {
     try
     {
         return(new FileStream(filePath, mode, access, share));
     }
     catch (ArgumentException e)
     {
         LogFileException ex = new LogFileException(SR.GetString("MsgCannotOpenFile") + filePath + SR.GetString("MsgFilePathNotSupport"), filePath, e);
         ExceptionManager.LogAppError(ex);
         throw ex;
     }
     catch (FileNotFoundException e2)
     {
         LogFileException ex2 = new LogFileException(SR.GetString("MsgCannotOpenFile") + filePath + SR.GetString("MsgFileNotFound"), filePath, e2);
         ExceptionManager.LogAppError(ex2);
         throw ex2;
     }
     catch (SecurityException e3)
     {
         LogFileException ex3 = new LogFileException(SR.GetString("MsgCannotOpenFile") + filePath + SR.GetString("MsgAccessDenied"), filePath, e3);
         ExceptionManager.LogAppError(ex3);
         throw ex3;
     }
     catch (DirectoryNotFoundException e4)
     {
         LogFileException ex4 = new LogFileException(SR.GetString("MsgCannotOpenFile") + filePath + SR.GetString("MsgDirectoryNotFound"), filePath, e4);
         ExceptionManager.LogAppError(ex4);
         throw ex4;
     }
     catch (UnauthorizedAccessException e5)
     {
         LogFileException ex5 = new LogFileException(SR.GetString("MsgCannotOpenFile") + filePath + SR.GetString("MsgAccessDenied"), filePath, e5);
         ExceptionManager.LogAppError(ex5);
         throw ex5;
     }
     catch (PathTooLongException e6)
     {
         LogFileException ex6 = new LogFileException(SR.GetString("MsgCannotOpenFile") + filePath + SR.GetString("MsgFilePathTooLong"), filePath, e6);
         ExceptionManager.LogAppError(ex6);
         throw ex6;
     }
     catch (NotSupportedException e7)
     {
         LogFileException ex7 = new LogFileException(SR.GetString("MsgCannotOpenFile") + filePath + SR.GetString("MsgFilePathNotSupport"), filePath, e7);
         ExceptionManager.LogAppError(ex7);
         throw ex7;
     }
     catch (IOException e8)
     {
         LogFileException ex8 = new LogFileException(SR.GetString("MsgIOException") + filePath + SR.GetString("MsgFilePathEnd"), filePath, e8);
         ExceptionManager.LogAppError(ex8);
         throw ex8;
     }
 }
 public static BinaryReader CreateBinaryReaderHelper(FileStream fs)
 {
     try
     {
         return(new BinaryReader(fs));
     }
     catch (ArgumentException e)
     {
         LogFileException ex = new LogFileException(SR.GetString("MsgCannotOpenFile") + fs.Name + SR.GetString("MsgFilePathEnd"), fs.Name, e);
         ExceptionManager.LogAppError(ex);
         throw ex;
     }
 }
 public static StreamReader CreateStreamReaderHelper(FileStream fs)
 {
     try
     {
         return(new StreamReader(fs));
     }
     catch (ArgumentException e)
     {
         LogFileException ex = new LogFileException(SR.GetString("MsgFileStreamNotReadable"), fs.Name, e);
         ExceptionManager.LogAppError(ex);
         throw ex;
     }
 }
 public static byte[] ReadBytesHelper(BinaryReader binaryReader, int count)
 {
     try
     {
         return(binaryReader.ReadBytes(count));
     }
     catch (IOException e)
     {
         LogFileException ex = new LogFileException(SR.GetString("MsgBinaryReaderExp") + SR.GetString("MsgReturnBack") + SR.GetString("MsgIOExp"), string.Empty, e);
         ExceptionManager.LogAppError(ex);
         throw ex;
     }
     catch (ObjectDisposedException e2)
     {
         LogFileException ex2 = new LogFileException(SR.GetString("MsgBinaryReaderExp") + SR.GetString("MsgReturnBack") + SR.GetString("MsgStreamClosed"), string.Empty, e2);
         ExceptionManager.LogAppError(ex2);
         throw ex2;
     }
 }
 public static object UIThreadInvokeHelper(IUserInterfaceProvider userIP, Delegate d, params object[] props)
 {
     if (userIP != null && (object)d != null)
     {
         RuntimeHelpers.PrepareConstrainedRegions();
         try
         {
             if (props == null)
             {
                 return(userIP.InvokeOnUIThread(d));
             }
             return(userIP.InvokeOnUIThread(d, props));
         }
         catch (Exception ex)
         {
             ExceptionManager.GeneralExceptionFilter(ex);
             ExceptionManager.LogAppError(new TraceViewerException(SR.GetString("MsgInvokeExceptionOccur"), ex.GetType().ToString() + SR.GetString("MsgReturnBack") + ex.ToString()));
         }
     }
     return(null);
 }
예제 #7
0
        private void FilterNowAction()
        {
            FilterCriteria filterCriteria = new FilterCriteria();

            filterCriteria.FilterSourceLevel = FilterEngine.ParseLevel((traceLevelList.SelectedItem != null) ? traceLevelList.SelectedItem.ToString() : SR.GetString("AppFilterItem1"));
            if (searchInList.SelectedIndex >= 12)
            {
                filterCriteria.SearchOption = SearchOptions.CustomFilter;
            }
            else
            {
                filterCriteria.SearchOption = FilterEngine.ParseSearchOption((searchInList.SelectedItem != null) ? searchInList.SelectedItem.ToString() : SR.GetString("AppFilterItem13"));
            }
            switch (filterCriteria.SearchOption)
            {
            case SearchOptions.EventID:
            case SearchOptions.SourceName:
            case SearchOptions.ProcessName:
            case SearchOptions.TraceCode:
            case SearchOptions.Description:
            case SearchOptions.EndpointAddress:
            case SearchOptions.AppDataSection:
            case SearchOptions.EntireRawData:
                filterCriteria.searchCondition = toolStripTextBoxLookFor.Text;
                break;

            case SearchOptions.StartTime:
            {
                DateTime value4    = dtpTime.Value;
                DateTime dateTime2 = new DateTime(value4.Year, value4.Month, value4.Day, value4.Hour, value4.Minute, value4.Second, 0, value4.Kind);
                filterCriteria.searchCondition = dateTime2;
                break;
            }

            case SearchOptions.StopTime:
            {
                DateTime value3   = dtpTime.Value;
                DateTime dateTime = new DateTime(value3.Year, value3.Month, value3.Day, value3.Hour, value3.Minute, value3.Second, 999, value3.Kind);
                filterCriteria.searchCondition = dateTime;
                break;
            }

            case SearchOptions.TimeRange:
            {
                DateTime value     = dtpTimeFrom.Value;
                DateTime startTime = new DateTime(value.Year, value.Month, value.Day, value.Hour, value.Minute, value.Second, 0, value.Kind);
                DateTime value2    = dtpTimeTo.Value;
                DateTime endTime   = new DateTime(value2.Year, value2.Month, value2.Day, value2.Hour, value2.Minute, value2.Second, 999, value2.Kind);
                filterCriteria.searchCondition = new DateTimePair(startTime, endTime);
                break;
            }

            case SearchOptions.CustomFilter:
                if (customFilterMap.ContainsKey(searchInList.SelectedIndex))
                {
                    filterCriteria.searchCondition = new CustomFilterCondition();
                    ((CustomFilterCondition)filterCriteria.searchCondition).customFilter = customFilterMap[searchInList.SelectedIndex];
                    if (((CustomFilterCondition)filterCriteria.searchCondition).customFilter.ContainsParameters)
                    {
                        string text = ((CustomFilterCondition)filterCriteria.searchCondition).customFilter.ParseXPathExpression(toolStripTextBoxLookFor.Text);
                        if (string.IsNullOrEmpty(text))
                        {
                            errorReport.ReportErrorToUser(SR.GetString("CF_IPError"));
                            return;
                        }
                        ((CustomFilterCondition)filterCriteria.searchCondition).parsedXPathExpress = text;
                    }
                }
                break;
            }
            FilterEngine.CurrentFilterCriteria = filterCriteria;
            try
            {
                if (this.TraceFilterChangedEvent != null)
                {
                    this.TraceFilterChangedEvent(this, new TraceFilterChangedEventArgs(filterCriteria));
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.GeneralExceptionFilter(ex);
                ExceptionManager.LogAppError(new TraceViewerException(SR.GetString("MsgTraceFilterChangeCallbackError") + ex.Message));
            }
        }