コード例 #1
0
ファイル: CustomDirReceiver.cs プロジェクト: nonari/Logbert
 /// <summary>
 /// Creates a new and configured instance of the <see cref="CustomDirReceiver"/> class.
 /// </summary>
 /// <param name="directoryToObserve">The directory the new <see cref="CustomDirReceiver"/> instance should observe.</param>
 /// <param name="filenamePattern">The <see cref="Regex"/> to find the files to load and observe.</param>
 /// <param name="startFromBeginning">Determines whether the new <see cref="Log4NetDirReceiver"/> should read all files within the given <paramref name="directoryToObserve"/>, or not.</param>
 /// <param name="columnizer">The <see cref="Columnizer"/> instance to use for parsing.</param>
 public CustomDirReceiver(string directoryToObserve, string filenamePattern, bool startFromBeginning, Columnizer columnizer, int codePage) : base(codePage)
 {
     mDirectoryToObserve = directoryToObserve;
     mFilenamePattern    = filenamePattern;
     mStartFromBeginning = startFromBeginning;
     mColumnizer         = columnizer;
 }
コード例 #2
0
ファイル: FrmColumnizer.cs プロジェクト: nonari/Logbert
        /// <summary>
        /// Handles the Click event of the test columnizer <see cref="ToolStripButton"/>.
        /// </summary>
        private void TsbTestColumnizerClick(object sender, System.EventArgs e)
        {
            // Create a new temporary columnizer object for testing.
            Columnizer tmpColumnizer = new Columnizer(txtName.Text);

            foreach (DataGridViewRow dgvRow in dgvColumns.Rows)
            {
                bool optional = dgvRow.Cells[2].Value != null;

                LogColumnType columnType = (LogColumnType)System.Enum.Parse(
                    typeof(LogColumnType)
                    , (string)dgvRow.Cells[3].Value);

                tmpColumnizer.Columns.Add(new LogColumn(
                                              (string)dgvRow.Cells[0].Value
                                              , (string)dgvRow.Cells[1].Value
                                              , optional
                                              , columnType
                                              , int.Parse((string)dgvRow.Cells[4].Value)));
            }

            using (FrmColumnizerTest testColumnizerDlg = new FrmColumnizerTest(tmpColumnizer))
            {
                testColumnizerDlg.ShowDialog(this);
            }
        }
コード例 #3
0
        /// <summary>
        /// Creates a new instance of the <see cref="LogMessageCustom"/> object.
        /// </summary>
        /// <param name="rawData">The data <see cref="Array"/> the new <see cref="LogMessageCustom"/> represents.</param>
        /// <param name="index">The index of the <see cref="LogMessage"/>.</param>
        /// <param name="columns">The <see cref="Columnizer"/> to use for parsing.</param>
        public LogMessageCustom(string rawData, int index, Columnizer columns) : base(rawData, index)
        {
            mColumnizer = columns;

            if (!ParseData(rawData))
            {
                throw new ApplicationException("Unable to parse the logger data.");
            }
        }
コード例 #4
0
ファイル: FrmColumnizer.cs プロジェクト: nonari/Logbert
        /// <summary>
        /// Initializes a new instance of the <see cref="FrmColumnizer"/> dialog with the specified parameters.
        /// </summary>
        /// <param name="columnizer">The <see cref="Columnizer"/> instance to edit.</param>
        public FrmColumnizer(Columnizer columnizer)
        {
            InitializeComponent();

            mColumnizer = columnizer ?? new Columnizer();

            // Apply a proper renderer for the embedded toolstrip.
            tsColumns.Renderer = new CustomToolStripSystemRenderer();
        }
コード例 #5
0
        /// <summary>
        /// Loads already existing columnizer from a repository.
        /// </summary>
        /// <returns>An <see cref="Array"/> of loaded <see cref="Columnizer"/>.</returns>
        private static Columnizer[] LoadColumnizer()
        {
            string columnizerRepository = Path.Combine(Environment.GetFolderPath(
                                                           Environment.SpecialFolder.ApplicationData)
                                                       , Application.CompanyName
                                                       , Application.ProductName
                                                       , Settings.Default.ColumnizerRepository);

            if (File.Exists(columnizerRepository))
            {
                List <Columnizer> restoredColumnizer = new List <Columnizer>();

                try
                {
                    XmlDocument userDefXml = new XmlDocument();

                    using (XmlTextReader xmlReader = new XmlTextReader(columnizerRepository))
                    {
                        userDefXml.Load(xmlReader);
                    }

                    XmlNode rootNode = userDefXml.SelectSingleNode("CustomColumnizer");

                    if (rootNode != null && rootNode.HasChildNodes)
                    {
                        foreach (XmlNode node in rootNode.ChildNodes)
                        {
                            Columnizer columnizer = new Columnizer();

                            if (columnizer.DeserializeFromXml(node))
                            {
                                restoredColumnizer.Add(columnizer);
                            }
                        }
                    }

                    return(restoredColumnizer.ToArray());
                }
                catch (Exception ex)
                {
                    Logger.Error(
                        "An error occurred while loading custom columnizer: {0}"
                        , ex.Message);

                    return(new Columnizer[0]);
                }
            }

            return(new Columnizer[0]);
        }
コード例 #6
0
        /// <summary>
        /// Saves the configure <see cref="Columnizer"/> into the local repository.
        /// </summary>
        private void SaveColumnizer()
        {
            List <Columnizer> columnizerToSave = new List <Columnizer>();

            // Collect all columnizer.
            foreach (object objItem in cmbColumnizer.Items)
            {
                Columnizer cmbColumnizerItem = objItem as Columnizer;

                if (cmbColumnizerItem != null)
                {
                    columnizerToSave.Add(cmbColumnizerItem);
                }
            }

            // Serialize them into the local columnizer repository.
            SaveColumnizer(columnizerToSave);
        }
コード例 #7
0
        /// <summary>
        /// Creates anew instance of the <see cref="CustomDetailsControl"/> <see cref="Control"/>.
        /// </summary>
        public CustomDetailsControl(Columnizer columnizer)
        {
            InitializeComponent();

            // Apply the current application theme to the control.
            ThemeManager.CurrentApplicationTheme.ApplyTo(logDetailToolStrip);

            mColumnizer      = columnizer;
            mBoldCaptionFont = new Font(
                Font
                , FontStyle.Bold);

            lblCaptionNumber.Font = mBoldCaptionFont;

            foreach (LogColumn column in columnizer.Columns)
            {
                AddLogMsgRowItem(column);
            }
        }
コード例 #8
0
        /// <summary>
        /// Creates anew instance of the <see cref="CustomDetailsControl"/> <see cref="Control"/>.
        /// </summary>
        public CustomDetailsControl(Columnizer columnizer)
        {
            InitializeComponent();

            mColumnizer      = columnizer;
            mBoldCaptionFont = FontCache.GetFontFromIdentifier(
                Font.Name
                , Font.Size
                , FontStyle.Bold);

            lblCaptionNumber.Font = mBoldCaptionFont;

            foreach (LogColumn column in columnizer.Columns)
            {
                AddLogMsgRowItem(column);
            }

            // Apply the current application theme to the control.
            ThemeManager.ApplyTo(this);
        }
コード例 #9
0
ファイル: CustomUdpReceiver.cs プロジェクト: nonari/Logbert
 /// <summary>
 /// Creates a new and configured instance of the <see cref="CustomUdpReceiver"/> class.
 /// </summary>
 /// <param name="multicastIp">The multicast IP address to listen for.</param>
 /// <param name="listenInterface">The network interface to listen on.</param>
 /// <param name="columnizer">The <see cref="Columnizer"/> instance to use for parsing.</param>
 /// <param name="codePage">The codepage to use for encoding of the data to parse.</param>
 public CustomUdpReceiver(IPAddress multicastIp, IPEndPoint listenInterface, Columnizer columnizer, int codePage) : base(codePage)
 {
     mMulticastIpAddress = multicastIp;
     mListenInterface    = listenInterface;
     mColumnizer         = columnizer;
 }
コード例 #10
0
 /// <summary>
 /// Creates a new and configured instance of the <see cref="NlogTcpReceiver"/> class.
 /// </summary>
 /// <param name="port">The port to listen on for new <see cref="LogMessage"/>s</param>
 /// <param name="listenInterface">The network interface to listen on.</param>
 /// <param name="codePage">The codepage to use for encoding of the data to parse.</param>
 public CustomTcpReceiver(int port, IPEndPoint listenInterface, Columnizer columnizer, int codePage) : base(codePage)
 {
     mPort            = port;
     mListenInterface = listenInterface;
     mColumnizer      = columnizer;
 }
コード例 #11
0
 /// <summary>
 /// Creates a new and configured instance of the <see cref="CustomFileReceiver"/> class.
 /// </summary>
 /// <param name="fileToObserve">The file the new <see cref="CustomFileReceiver"/> instance should observe.</param>
 /// <param name="startFromBeginning">Determines whether the new <see cref="CustomFileReceiver"/> should read the given <paramref name="CustomFileReceiver"/> from beginnin, or not.</param>
 /// <param name="columnizer">The <see cref="Columnizer"/> instance to use for parsing.</param>
 public CustomFileReceiver(string fileToObserve, bool startFromBeginning, Columnizer columnizer)
 {
     mFileToObserve      = fileToObserve;
       mStartFromBeginning = startFromBeginning;
       mColumnizer         = columnizer;
 }
コード例 #12
0
ファイル: CustomHttpReceiver.cs プロジェクト: views63/Logbert
 /// <summary>
 /// Creates a new and configured instance of the <see cref="NlogTcpReceiver"/> class.
 /// </summary>
 /// <param name="port">The port to listen on for new <see cref="LogMessage"/>s</param>
 /// <param name="listenInterface">The network interface to listen on.</param>
 /// <param name="codePage">The codepage to use for encoding of the data to parse.</param>
 public CustomHttpReceiver(string url, BasicHttpAuthentication authentication, int pollTime, Columnizer columnizer, int codePage) : base(codePage)
 {
     mAuthentication = authentication;
     mUrl            = url;
     mColumnizer     = columnizer;
 }
コード例 #13
0
 /// <summary>
 /// Creates a new and configured instance of the <see cref="CustomFileReceiver"/> class.
 /// </summary>
 /// <param name="fileToObserve">The file the new <see cref="CustomFileReceiver"/> instance should observe.</param>
 /// <param name="startFromBeginning">Determines whether the new <see cref="CustomFileReceiver"/> should read the given <paramref name="CustomFileReceiver"/> from beginnin, or not.</param>
 /// <param name="columnizer">The <see cref="Columnizer"/> instance to use for parsing.</param>
 public CustomFileReceiver(string fileToObserve, bool startFromBeginning, Columnizer columnizer)
 {
     mFileToObserve      = fileToObserve;
     mStartFromBeginning = startFromBeginning;
     mColumnizer         = columnizer;
 }
コード例 #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FrmColumnizerTest"/> dialog.
        /// </summary>
        /// <param name="columnizer">The <see cref="Columnizer"/> instance to test.</param>
        public FrmColumnizerTest(Columnizer columnizer)
        {
            mColumnizer = columnizer;

            InitializeComponent();
        }
コード例 #15
0
        /// <summary>
        /// Loads already existing columnizer from a repository.
        /// </summary>
        /// <returns>An <see cref="Array"/> of loaded <see cref="Columnizer"/>.</returns>
        private static Columnizer[] LoadColumnizer()
        {
            string columnizerRepository = Path.Combine(Environment.GetFolderPath(
              Environment.SpecialFolder.ApplicationData)
            , Application.CompanyName
            , Application.ProductName
            , Settings.Default.ColumnizerRepository);

              if (File.Exists(columnizerRepository))
              {
            List<Columnizer> restoredColumnizer = new List<Columnizer>();

            try
            {
              XmlDocument userDefXml = new XmlDocument();

              using (XmlTextReader xmlReader = new XmlTextReader(columnizerRepository))
              {
            userDefXml.Load(xmlReader);
              }

              XmlNode rootNode = userDefXml.SelectSingleNode("CustomColumnizer");

              if (rootNode != null && rootNode.HasChildNodes)
              {
            foreach (XmlNode node in rootNode.ChildNodes)
            {
              Columnizer columnizer = new Columnizer();

              if (columnizer.DeserializeFromXml(node))
              {
                restoredColumnizer.Add(columnizer);
              }
            }
              }

              return restoredColumnizer.ToArray();
            }
            catch (Exception ex)
            {
              Logger.Error(
              "An error occurred while loading custom columnizer: {0}"
            , ex.Message);

              return new Columnizer[0];
            }
              }

              return new Columnizer[0];
        }