Example #1
0
        protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (localContext == null)
            {
                throw new ArgumentNullException(nameof(localContext));
            }

            string   aiSetupJson = AiSetupJson.Get(context);
            AiLogger aiLogger    = new AiLogger(aiSetupJson, localContext.OrganizationService, localContext.TracingService,
                                                localContext.WorkflowExecutionContext, null, localContext.WorkflowExecutionContext.WorkflowCategory);

            string name   = Name.Get(context);
            int    value  = MetricValue.Get(context);
            int?   count  = Count.Get(context);
            int?   min    = Min.Get(context);
            int?   max    = Max.Get(context);
            int    stdDev = StdDev.Get(context);

            bool logSuccess = aiLogger.WriteMetric(name, value, count, min, max, stdDev);

            LogSuccess.Set(context, logSuccess);
        }
Example #2
0
        protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (localContext == null)
            {
                throw new ArgumentNullException(nameof(localContext));
            }

            string   aiSetupJson = AiSetupJson.Get(context);
            AiLogger aiLogger    = new AiLogger(aiSetupJson, localContext.OrganizationService, localContext.TracingService,
                                                localContext.WorkflowExecutionContext, null, localContext.WorkflowExecutionContext.WorkflowCategory);

            string name       = Name.Get(context);
            string method     = Method.Get(context);
            string type       = Type.Get(context);
            int    duration   = Duration.Get(context);
            int?   resultCode = ResultCode.Get(context);
            bool   success    = Success.Get(context);
            string data       = Data.Get(context);

            bool logSuccess = aiLogger.WriteDependency(name, method, type, duration, resultCode, success, data);

            LogSuccess.Set(context, logSuccess);
        }
Example #3
0
        protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (localContext == null)
            {
                throw new ArgumentNullException(nameof(localContext));
            }

            string   aiSetupJson = AiSetupJson.Get(context);
            AiLogger aiLogger    = new AiLogger(aiSetupJson, localContext.OrganizationService, localContext.TracingService,
                                                localContext.WorkflowExecutionContext, null, localContext.WorkflowExecutionContext.WorkflowCategory);

            string message  = Message.Get(context);
            string severity = Severity.Get(context);

            string severityValidationResult = AiTrace.ValidateSeverityValue(severity);

            if (!string.IsNullOrEmpty(severityValidationResult))
            {
                localContext.TracingService.Trace(severityValidationResult);
                LogSuccess.Set(context, false);
                return;
            }

            Enum.TryParse(severity, out AiTraceSeverity traceSeverity);

            bool logSuccess = aiLogger.WriteTrace(message, traceSeverity);

            LogSuccess.Set(context, logSuccess);
        }
Example #4
0
        protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (localContext == null)
            {
                throw new ArgumentNullException(nameof(localContext));
            }

            string   aiSetupJson = AiSetupJson.Get(context);
            AiLogger aiLogger    = new AiLogger(aiSetupJson, localContext.OrganizationService, localContext.TracingService,
                                                localContext.WorkflowExecutionContext, null, localContext.WorkflowExecutionContext.WorkflowCategory);

            string name             = Name.Get(context);
            string measurementName  = MeasurementName.Get(context);
            double measurementValue = MeasurementValue.Get(context);

            string measurementNameValidationResult = AiEvent.ValidateMeasurementName(measurementName);

            if (!string.IsNullOrEmpty(measurementNameValidationResult))
            {
                localContext.TracingService.Trace(measurementNameValidationResult);
                LogSuccess.Set(context, false);
                return;
            }

            Dictionary <string, double> measurements =
                new Dictionary <string, double> {
                { measurementName, Convert.ToDouble(measurementValue) }
            };

            bool logSuccess = aiLogger.WriteEvent(name, measurements);

            LogSuccess.Set(context, logSuccess);
        }