コード例 #1
0
        private void SearchTraceLog(string path, TraceLogParameter param)
        {
            var files = GetLogFiles(path, param.BeginDate, param.EndDate);

            var result = new List<object>();

            foreach(var file in files)
            {
                try
                {
                    if (File.Exists(file) == false) continue;

                    DateTime date = DateTime.MinValue;
                    string message = string.Empty;

                    var lines = File.ReadAllLines(file);
                    var fileSearchResult = from item in lines
                                           where ParseTraceLogInfo(item, out date, out message) == true
                                           where IsInDateTime(date, param.BeginDate, param.EndDate)
                                           select new
                                           {
                                               Date = date,
                                               Message = message
                                           };

                    result.AddRange(fileSearchResult);
                }
                catch (Exception e)
                {
                    Trace.WriteLine(e.ToString());
                    continue;
                }
            }

            FindResult = null;

            Result =
                new
                {
                    LogList = result
                };
        }
コード例 #2
0
        private bool ParsingAlarmSearchParameters(object param, out TraceLogParameter result)
        {
            result = new TraceLogParameter();

            if (param == null)
            {
                string msg = Utility.UtilityClass.GetStringResource(this, "ThereIsNoData", "There is no data.");
                Manager.MessageWindowManager.Instance.Show(EquipmentInstance, "UserSelectet", msg);
            }

            if ((param is object[]) == false)
            {
                Manager.LogManager.Instance.WriteSystemLog("SearchCommandHandler's param is not object[].");
                return false;
            }

            var parameters = param as object[];

            try
            {
                result.BeginDate = (parameters[0] as LogSearchingDateTime).ToDateTime();
                result.EndDate = (parameters[1] as LogSearchingDateTime).ToDateTime();
                return true;
            }
            catch (Exception e)
            {
                Manager.LogManager.Instance.WriteSystemLog(e.ToString());
                return false;
            }
        }