public void Enqueue(CheckPointMessage msg)
        {
            bool queued = false;

            if (m_queue.Count <= m_maxQueueDepth)
            {
                lock (m_sync)
                {
                    if (m_queue.Count <= m_maxQueueDepth)
                    {
                        try
                        {
                            m_queue.Enqueue(msg);
                            queued = true;
                        }
                        catch
                        {
                        }
                    }
                }
            }

            if (!queued)
            {
                EventLogHelper.Publish(new Exception("Internal Instrumentation Queue is full"));
            }
        }
Пример #2
0
        /// <summary>
        /// persists log message to TRACK and trace tables.  Trace is optional
        /// and will only be saved if event type is error or trace
        /// </summary>
        /// <param name="message">logMessage to persist</param>
        /// <param name="pushErrorToInternal"></param>
        public void InsertLogMessage(CheckPointMessage message, int pushErrorToInternal)
        {
            pushErrorToInternal = 1;
            SqlParameter[] logParams = null;
            logParams = createInsertEventSQLParameters(message, pushErrorToInternal);

            using (SqlConnection conn = new SqlConnection(utility.getParameter("RfgTrackingDb")))
            {
                conn.Open();
                {
                    using (SqlCommand cmd = conn.CreateCommand())
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = "Insert_Entity_Event";
                        attachParameters(cmd, logParams);

                        cmd.ExecuteNonQuery();
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// write event to file.  using level 'INFO' so if log level is reduced this type of events can be turned off
        /// </summary>
        /// <param name="checkPoint"></param>
        /// <param name="entityId"></param>
        /// <param name="entityType"></param>
        /// <param name="entitySubType"></param>
        /// <param name="entityStatus"></param>
        /// <param name="sourceUri"></param>
        /// <param name="targetUri"></param>
        /// <param name="runId"></param>
        /// <param name="itemCount"></param>
        /// <param name="sizeInKb"></param>
        /// <param name="message"></param>
        /// <param name="customKey1"></param>
        /// <param name="customKey2"></param>
        /// <param name="customKey3"></param>
        public void PublishTrackingEvent(string checkPoint, string entityId, string entityType, string entitySubType,
            string sourceUri, string targetUri, string runId, EventState eventState, TraceLevel traceLevel, bool hasXmlMsg, Exception ex,string message)
        {
            if (traceLevel == TraceLevel.None || traceLevel > m_tracingLevel)
                return;

            string formattedMessage = null;
            if (hasXmlMsg)
                formattedMessage = message;
            else
                formattedMessage = getFormattedString(ex, message);

            int sizeInKb = 0;
            if (sizeInKb == 0 && !string.IsNullOrEmpty(formattedMessage))
            {
                sizeInKb = formattedMessage.Length / 1024;
            }

            CheckPointMessage msg = new CheckPointMessage(m_appName, traceLevel, checkPoint, EventType.Step_Tracking, eventState,
                string.Empty, entityId, string.Empty, string.Empty, entityType, entitySubType, string.Empty,
                sourceUri, targetUri, runId, 0, sizeInKb, formattedMessage, string.Empty, string.Empty, string.Empty);

            CheckPointMessageQueueManager.Instance.Enqueue(msg);
        }
Пример #4
0
        private SqlParameter[] createInsertEventSQLParameters(CheckPointMessage logMessage, int pushErrorToInternal)
        {
            var logParams = new SqlParameter[26];

            logParams[0] = new SqlParameter("@in_checkPointId", SqlDbType.Int);
            logParams[0].Direction = ParameterDirection.Input;
            logParams[0].Value = LookupKeyValue(
                logMessage.AppName, LookupPropertyType.CheckPoint, logMessage.CheckPointName);

            logParams[1] = new SqlParameter("@in_eventId", SqlDbType.NVarChar, 64);
            logParams[1].Direction = ParameterDirection.Input;
            logParams[1].Value = logMessage.EventId;

            logParams[2] = new SqlParameter("@in_eventType", SqlDbType.Int);
            logParams[2].Direction = ParameterDirection.Input;
            logParams[2].Value = LookupKeyValue(
                "ALL", LookupPropertyType.EventType, logMessage.EventType.ToString());

            logParams[3] = new SqlParameter("@in_eventState", SqlDbType.Int);
            logParams[3].Direction = ParameterDirection.Input;
            logParams[3].Value = LookupKeyValue(
                "ALL", LookupPropertyType.EventState, logMessage.EventState.ToString());

            logParams[4] = new SqlParameter("@in_eventSubState", SqlDbType.NVarChar, 64);
            logParams[4].Direction = ParameterDirection.Input;
            logParams[4].Value = logMessage.EventSubState;

            logParams[5] = new SqlParameter("@in_eventDateTime", SqlDbType.DateTime2);
            logParams[5].Direction = ParameterDirection.Input;
            logParams[5].Value = logMessage.EventDateTime.ToUniversalTime();

            logParams[6] = new SqlParameter("@in_entityId", SqlDbType.NVarChar, 64);
            logParams[6].Direction = ParameterDirection.Input;
            logParams[6].Value = logMessage.EntityId;

            logParams[7] = new SqlParameter("@in_entityName", SqlDbType.NVarChar, 64);
            logParams[7].Direction = ParameterDirection.Input;
            logParams[7].Value = logMessage.EntityName;

            logParams[8] = new SqlParameter("@in_entityRevisionId", SqlDbType.NVarChar, 64);
            logParams[8].Direction = ParameterDirection.Input;
            logParams[8].Value = logMessage.EntityRevisionId;

            logParams[9] = new SqlParameter("@in_entityType", SqlDbType.Int);
            logParams[9].Direction = ParameterDirection.Input;
            logParams[9].Value = LookupKeyValue(
                "ALL", LookupPropertyType.EntityType, logMessage.EntityType);

            logParams[10] = new SqlParameter("@in_entitySubType", SqlDbType.Int);
            logParams[10].Direction = ParameterDirection.Input;
            logParams[10].Value = LookupKeyValue(
                "ALL", LookupPropertyType.EntitySubType, logMessage.EntitySubType);

            logParams[11] = new SqlParameter("@in_entityStatus", SqlDbType.Int);
            logParams[11].Direction = ParameterDirection.Input;
            logParams[11].Value = LookupKeyValue(
                "ALL", LookupPropertyType.EntityStatus, logMessage.EntityStatus);

            logParams[12] = new SqlParameter("@in_applicationId", SqlDbType.Int);
            logParams[12].Direction = ParameterDirection.Input;
            logParams[12].Value = LookupKeyValue(
                "ALL", LookupPropertyType.ApplicationName, logMessage.AppName);

            logParams[13] = new SqlParameter("@in_sourceUriId", SqlDbType.Int);
            logParams[13].Direction = ParameterDirection.Input;
            logParams[13].Value = LookupKeyValue(
                "ALL", LookupPropertyType.SourceUri, logMessage.SourceUri);

            logParams[14] = new SqlParameter("@in_targetUriId", SqlDbType.Int);
            logParams[14].Direction = ParameterDirection.Input;
            logParams[14].Value = LookupKeyValue(
                "ALL", LookupPropertyType.TargetUri, logMessage.TargetUri);

            logParams[15] = new SqlParameter("@in_runId", SqlDbType.NVarChar, 64);
            logParams[15].Direction = ParameterDirection.Input;
            logParams[15].Value = logMessage.RunId;

            logParams[16] = new SqlParameter("@in_osProcessId", SqlDbType.NVarChar, 64);
            logParams[16].Direction = ParameterDirection.Input;
            logParams[16].Value = logMessage.OSProcessId;

            logParams[17] = new SqlParameter("@in_osThreadId", SqlDbType.NVarChar, 64);
            logParams[17].Direction = ParameterDirection.Input;
            logParams[17].Value = logMessage.OSThreadId;

            logParams[18] = new SqlParameter("@in_machineId", SqlDbType.Int);
            logParams[18].Direction = ParameterDirection.Input;
            logParams[18].Value = LookupKeyValue(
                "ALL", LookupPropertyType.MachineName, logMessage.MachineName);

            logParams[19] = new SqlParameter("@in_sizeInKBytes", SqlDbType.BigInt);
            logParams[19].Direction = ParameterDirection.Input;
            logParams[19].Value = logMessage.SizeInKBytes;

            logParams[20] = new SqlParameter("@in_itemCount", SqlDbType.BigInt);
            logParams[20].Direction = ParameterDirection.Input;
            logParams[20].Value = logMessage.ItemCount;

            logParams[21] = new SqlParameter("@in_customkey1", SqlDbType.NVarChar, 64);
            logParams[21].Direction = ParameterDirection.Input;
            logParams[21].Value = logMessage.CustomKey1;

            logParams[22] = new SqlParameter("@in_customkey2", SqlDbType.NVarChar, 64);
            logParams[22].Direction = ParameterDirection.Input;
            logParams[22].Value = logMessage.CustomKey2;

            logParams[23] = new SqlParameter("@in_customkey3", SqlDbType.NVarChar, 64);
            logParams[23].Direction = ParameterDirection.Input;
            logParams[23].Value = logMessage.CustomKey3;

            logParams[24] = new SqlParameter("@in_message", SqlDbType.NText
                                            , logMessage.Message == null
                                                   ? 1
                                                   : logMessage.Message.Length + 1);
            logParams[24].Direction = ParameterDirection.Input;
            logParams[24].Value = logMessage.Message;

            logParams[25] = new SqlParameter("@in_pushErrorToInternal", SqlDbType.Int);
            logParams[25].Direction = ParameterDirection.Input;
            logParams[25].Value = pushErrorToInternal;

            return logParams;
        }