Ejemplo n.º 1
0
        public LoggingViewDataSet RetrieveInstrumentation(LogIDPairEntity logIDPair, DateTimeCompare timeEntity,string userName, string ipAddress, string moduleId, string functionId, string componentName, string category, string pcName)
        {
            long minLogID = logIDPair.MinLogID;
            long maxLogID = logIDPair.MaxLogID;
            long currentMinLogID = maxLogID - MaxRecords;

            LoggingViewDataSet logDs;
            LoggingViewDataSet logDsByFilter = new LoggingViewDataSet();
            DbCommand command;
            int recordCount = 0;
            int computeCount = 0;

            while (recordCount == 0 && minLogID <= maxLogID && computeCount < MaxNullFounds)
            {
                command = Helper.BuildDbCommand("dbo.P_IC_LOGGING_INSTRUMENTATION_S");
                command.CommandTimeout = 0;
                if (currentMinLogID < minLogID)
                {
                    currentMinLogID = minLogID;
                }

                logDs = new LoggingViewDataSet();

                Helper.AssignParameterValues(command, currentMinLogID, maxLogID);
                Helper.Fill(logDs.T_IC_LOGGING_LOG, command);

                var list = (from n in logDs.T_IC_LOGGING_LOG
            // ReSharper disable ConditionIsAlwaysTrueOrFalse
                            where (string.IsNullOrEmpty(category) || n.CATEGORY_NAME.Equals(category))
                            && (string.IsNullOrEmpty(componentName) || n.COMPONENT.Equals(ConvertToString(componentName)))
                            && (!string.IsNullOrEmpty(userName) ? SearchHelper.IsRegexMatch(ConvertToString(n.USER_NAME), userName, @"[\w|\W]*") : true)
                            && (!string.IsNullOrEmpty(ipAddress) ? SearchHelper.IsRegexMatch(ConvertToString(n.IP_ADDRESS), ipAddress, @"[\w|\W]*") : true)
                            && (!string.IsNullOrEmpty(moduleId) ? SearchHelper.IsRegexMatch(ConvertToString(n.MODULE_ID), moduleId, @"[\w|\W]*") : true)
                            && (!string.IsNullOrEmpty(functionId) ? SearchHelper.IsRegexMatch(ConvertToString(n.FUNCTION_ID), functionId, @"[\w|\W]*") : true)
                            && (!string.IsNullOrEmpty(pcName) ? SearchHelper.IsRegexMatch(ConvertToString(n.MACHINE_NAME), pcName, @"[\w|\W]*") : true)
            // ReSharper restore ConditionIsAlwaysTrueOrFalse
                            && (timeEntity == null ? true : n.LOG_TIME <= timeEntity.EndTime)
                            && (timeEntity == null ? true : n.LOG_TIME >= timeEntity.StartTime)
                            select n);

                maxLogID = currentMinLogID - 1;
                currentMinLogID = maxLogID - MaxRecords;
                recordCount += list.Count();
                computeCount += 1;

                foreach (var row in list)
                {
                    logDsByFilter.T_IC_LOGGING_LOG.ImportRow(row);
                }
                logDs.Dispose();
            }

            logDsByFilter.ExtendedProperties.Add("LogIDPair", minLogID.ToString() + "," + maxLogID.ToString());

            logDsByFilter.AcceptChanges();

            return logDsByFilter;
        }
Ejemplo n.º 2
0
        public LoggingViewDataSet RetrieveExceptionLog(LogIDPairEntity logIDPair, DateTimeCompare timeEntity, string userName, string category, string severity, string machineName, string logContent, string instanceID)
        {
            const int MaxErrorLogNumber = 1000;
            if (!string.IsNullOrEmpty(instanceID))
            {
                LoggingViewDataSet logDs = new LoggingViewDataSet();
                DbCommand command;
                command = Helper.BuildDbCommand("dbo.P_IC_LOGGING_EXCEPTION_LOG_S_BY_ID");
                Helper.AssignParameterValues(command, instanceID);
                Helper.Fill(logDs.T_IC_LOGGING_LOG, command);
                return logDs;
            }
            else
            {
                long minLogID = logIDPair.MinLogID;
                long maxLogID = logIDPair.MaxLogID;
                long currentMinLogID = maxLogID - MaxErrorLogNumber;

                LoggingViewDataSet logDs;
                LoggingViewDataSet logDsByFilter = new LoggingViewDataSet();
                DbCommand command;
                int recordCount = 0;
                int computeCount = 0;

                string temporaryUserNameInput = TranslateWildcardForExceptionLog(userName);

                string temporaryMachineameInput = TranslateWildcardForExceptionLog(machineName);

                while (recordCount == 0 && minLogID <= maxLogID && computeCount < MaxNullFounds)
                {
                    command = Helper.BuildDbCommand("dbo.P_IC_LOGGING_EXCEPTION_LOG_S");
                    command.CommandTimeout = 0;
                    if (currentMinLogID < minLogID)
                    {
                        currentMinLogID = minLogID;
                    }

                    logDs = new LoggingViewDataSet();
                    Helper.AssignParameterValues(command, currentMinLogID, maxLogID, temporaryUserNameInput, temporaryMachineameInput);
                    Helper.Fill(logDs.T_IC_LOGGING_LOG, command);

                    var list = (from n in logDs.T_IC_LOGGING_LOG
            // ReSharper disable ConditionIsAlwaysTrueOrFalse
                                where (string.IsNullOrEmpty(severity) || ConvertToString(n.SEVERITY).Equals(severity))
                                && (!string.IsNullOrEmpty(userName) ? SearchHelper.IsRegexMatch(ConvertToString(n.USER_NAME), userName, @"[\w|\W]*") : true)
                                && (string.IsNullOrEmpty(category) || ConvertToString(n.CATEGORY_NAME).Equals(category))
                                && (!string.IsNullOrEmpty(machineName) ? SearchHelper.IsRegexMatch(ConvertToString(n.MACHINE_NAME), machineName, @"[\w|\W]*") : true)
                                && (!string.IsNullOrEmpty(logContent) ? SearchHelper.IsRegexMatch(ConvertToString(n.FORMATTED_MESSAGE), logContent, @"[\w|\W]*") : true)
                                && (string.IsNullOrEmpty(instanceID) || ConvertToString(n.INSTANCE_ID).Equals(instanceID))
                                && (timeEntity == null ? true : n.LOG_TIME <= timeEntity.EndTime)
                                && (timeEntity == null ? true : n.LOG_TIME >= timeEntity.StartTime)
            // ReSharper restore ConditionIsAlwaysTrueOrFalse
                                select n);

                    maxLogID = currentMinLogID - 1;
                    currentMinLogID = maxLogID - MaxErrorLogNumber;
                    recordCount += list.Count();
                    computeCount += 1;

                    foreach (var row in list)
                    {
                        logDsByFilter.T_IC_LOGGING_LOG.ImportRow(row);
                    }

                    logDs.Dispose();
                }

                logDsByFilter.ExtendedProperties.Add("LogIDPair", minLogID.ToString() + "," + maxLogID.ToString());

                logDsByFilter.AcceptChanges();

                return logDsByFilter;
            }
        }