Example #1
0
        internal void Remove(string sSourceName)
        {
            DataRow [] rows = DataSource.Select(string.Format("source = '{0}'", sSourceName));
            foreach (DataRow row in rows)
            {
                DataSource.Rows.Remove(row);
            }

            SourceInfo foundInfo = LogFileSource.Find(m => string.Equals(sSourceName, m.Name));

            if (foundInfo != null)
            {
                LogFileSource.Remove(foundInfo);
            }
        }
Example #2
0
        internal void RenameSourceAsync(string sOldName, SourceInfo info)
        {
            string sQuery = string.Format("source='{0}'", sOldName);

            DataRow[] aryRows = DataSource.Select(sQuery);
            Task.Run(() =>
            {
                //List<DataRow> rows = new List<DataRow>();
                //rows.AddRange(aryRows);
                foreach (DataRow row in aryRows)
                {
                    row["source"] = info.Name;
                }
            }).Wait();
            DataSource.AcceptChanges();
        }
Example #3
0
        public void DoParse_Old(string sFullFilename, ParserInfo info, DataTable tbLog)
        {
            m_regexDivider  = info.RegexForDivider;
            m_regexContents = info.RegexForContents;

            m_tbLog = tbLog;
            if (m_tbLog == null)
            {
                ClearSources();
                BuildupLogTable();
            }
            else
            {
                m_tbLog = tbLog.Copy();
            }

            SourceInfo sourceInfo = new SourceInfo(sFullFilename);

            AllSources.Add(sourceInfo);

            Thread thread = new Thread(new ParameterizedThreadStart(WorkerMakeTable));

            thread.Start(new object[] { sourceInfo, m_tbLog, m_regexDivider, m_regexContents });
        }
Example #4
0
        /// <summary>
        /// Docking Control 중 기존 이름을 기준으로 새롭게 바뀐 이름으로 변경하기 위한 이벤트 핸들러
        /// </summary>
        /// <param name="sOldName">기존 이름</param>
        /// <param name="info">새롭게 개선된 Source 정보에 대한 개체</param>
        private void ctrlLoadAndAppendLogs1_OnLogRenameRequest(string sOldName, SourceInfo info)
        {
            DevExpress.XtraBars.Docking.DockPanel panel = m_aryDocPanels.Find(m => string.Equals(m.Text, sOldName));
            if (panel != null)
            {
                panel.Text = info.Name;

                GridControl      gridControl = panel.Controls[0].Controls[0] as GridControl;
                CriteriaOperator criteria    = new BinaryOperator(new OperandProperty("source"), new OperandValue(info.Name), BinaryOperatorType.Equal);
                DevExpress.XtraGrid.Views.Grid.GridView view = gridControl.MainView as DevExpress.XtraGrid.Views.Grid.GridView;
                view.ActiveFilterCriteria = criteria;

                foreach (GridControl ctrl in m_aryGridCtrls)
                {
                    ctrl.DataSource = null;
                }
                m_docManager.RenameSourceAsync(sOldName, info);

                foreach (GridControl ctrl in m_aryGridCtrls)
                {
                    ctrl.DataSource = m_docManager.DataSource;
                }
            }
        }
Example #5
0
        private void WorkerMakeTable(object param)
        {
            object[] aryParams = (object[])param;

            SourceInfo sourceInfo    = aryParams[0] as SourceInfo;
            DataTable  tbLog         = (DataTable)aryParams[1];
            Regex      regexDivider  = (Regex)aryParams[2];
            Regex      regexContents = (Regex)aryParams[3];

            bool        bIsSucess  = false;
            int         nPercent   = 0;
            int         nLineIndex = 0;
            List <Task> aryTasks   = new List <Task>();

            try
            {
                using (StreamReader reader = new StreamReader(sourceInfo.FullFilename))
                {
                    long lnSize = reader.BaseStream.Length;

                    StringBuilder sbBuffer = new StringBuilder();
                    while (!reader.EndOfStream)
                    {
                        nLineIndex++;
                        long lnPosition = reader.BaseStream.Position;

                        int nCurPercent = (int)(lnPosition * 100 / lnSize * 0.9);
                        if (nCurPercent != nPercent)
                        {
                            nPercent = nCurPercent;
                            OnProcessUpdated?.Invoke(nPercent);
                        }

                        string sLine = reader.ReadLine();
                        if (regexDivider.IsMatch(sLine) && sbBuffer.Length > 0)
                        {
                            string sContents = sbBuffer.ToString();
                            Task   task      = Task.Factory.StartNew((object obj) =>
                            {
                                try
                                {
                                    string sContent = obj as string;
                                    Match match     = regexContents.Match(sContent);
                                    if (match.Success)
                                    {
                                        lock (m_montior)
                                        {
                                            DataRow newRow      = tbLog.NewRow();
                                            newRow["source"]    = sourceInfo.Name;
                                            newRow["line"]      = nLineIndex;
                                            string sLogContents = sContent.Replace(match.Value, "").Trim();

                                            if (!string.IsNullOrEmpty(sLogContents))
                                            {
                                                newRow["content"] = sLogContents;
                                                foreach (StructInfo structInfo in ConfigManager.Current.AllStructures)
                                                {
                                                    if (!string.IsNullOrEmpty(structInfo.RegexName))
                                                    {
                                                        newRow[structInfo.Name] = match.Groups[structInfo.RegexName].Value.Trim();
                                                    }
                                                }
                                                tbLog.Rows.Add(newRow);
                                            }
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Debug.WriteLine(ex);
                                }
                            }, sContents);

                            aryTasks.Add(task);

                            sbBuffer = new StringBuilder();
                            sbBuffer.AppendLine(sLine);
                            continue;
                        }
                        sbBuffer.AppendLine(sLine);
                    }
                }
                Task.WaitAll(aryTasks.ToArray());
                bIsSucess = true;
            }
            catch (Exception ex)
            {
            }
            OnCompleted?.Invoke(bIsSucess, sourceInfo.Name, tbLog);
        }
Example #6
0
        internal bool IsSourceContained(string sLogFilename)
        {
            SourceInfo foundInfo = AllSources.Find(m => string.Equals(sLogFilename, m.FullFilename));

            return(foundInfo != null);
        }
Example #7
0
 public void Load(string sFullFilename, ParserInfo info)
 {
     m_currentSource = new SourceInfo(sFullFilename);
     m_parserEngine.DoParse(m_currentSource, info, DataSource);
 }