Ejemplo n.º 1
0
        Settings(
            string deviceId,
            string targetModuleId,
            TransportType transportType,
            TimeSpan directMethodDelay,
            Option <Uri> analyzerUrl,
            InvocationSource invocationSource,
            Option <string> serviceClientConnectionString,
            string moduleId,
            TimeSpan testDuration,
            TimeSpan testStartDelay,
            Option <Uri> testResultCoordinatorUrl,
            Option <string> trackingId)
        {
            Preconditions.CheckRange(testDuration.Ticks, 0);
            Preconditions.CheckRange(testStartDelay.Ticks, 0);

            this.DeviceId       = Preconditions.CheckNonWhiteSpace(deviceId, nameof(deviceId));
            this.TargetModuleId = Preconditions.CheckNonWhiteSpace(targetModuleId, nameof(targetModuleId));
            Preconditions.CheckArgument(TransportType.IsDefined(typeof(TransportType), transportType));
            this.TransportType                 = transportType;
            this.DirectMethodDelay             = directMethodDelay;
            this.InvocationSource              = invocationSource;
            this.AnalyzerUrl                   = analyzerUrl;
            this.ServiceClientConnectionString = serviceClientConnectionString;
            this.ModuleId                 = Preconditions.CheckNonWhiteSpace(moduleId, nameof(moduleId));
            this.TestDuration             = testDuration;
            this.TestStartDelay           = testStartDelay;
            this.TestResultCoordinatorUrl = testResultCoordinatorUrl;
            this.TrackingId               = trackingId;
        }
Ejemplo n.º 2
0
        Settings(
            string deviceId,
            string targetModuleId,
            TransportType transportType,
            TimeSpan directMethodFrequency,
            Option <Uri> reportingEndpointUrl,
            InvocationSource invocationSource,
            Option <string> serviceClientConnectionString,
            string moduleId,
            TimeSpan testDuration,
            TimeSpan testStartDelay,
            Option <string> directMethodName,
            Option <string> trackingId,
            Option <string> directMethodResultType)
        {
            Preconditions.CheckRange(testDuration.Ticks, 0);
            Preconditions.CheckRange(testStartDelay.Ticks, 0);

            this.DeviceId       = Preconditions.CheckNonWhiteSpace(deviceId, nameof(deviceId));
            this.TargetModuleId = Preconditions.CheckNonWhiteSpace(targetModuleId, nameof(targetModuleId));
            Preconditions.CheckArgument(TransportType.IsDefined(typeof(TransportType), transportType));
            this.TransportType                 = transportType;
            this.DirectMethodFrequency         = directMethodFrequency;
            this.InvocationSource              = invocationSource;
            this.ReportingEndpointUrl          = reportingEndpointUrl;
            this.ServiceClientConnectionString = serviceClientConnectionString;
            this.ModuleId               = Preconditions.CheckNonWhiteSpace(moduleId, nameof(moduleId));
            this.TestDuration           = testDuration;
            this.TestStartDelay         = testStartDelay;
            this.DirectMethodName       = directMethodName.GetOrElse("HelloWorldMethod");
            this.TrackingId             = trackingId;
            this.DirectMethodResultType = (DirectMethodResultType)Enum.Parse(typeof(DirectMethodResultType), directMethodResultType.GetOrElse("LegacyDirectMethodTestResult"));
        }
Ejemplo n.º 3
0
        public static async Task <DirectMethodSenderBase> CreateClientAsync(InvocationSource invocationSource)
        {
            DirectMethodSenderBase directMethodClient = null;

            switch (invocationSource)
            {
            case InvocationSource.Local:
                // Implicit OpenAsync()
                directMethodClient = await DirectMethodLocalSender.CreateAsync(
                    Settings.Current.TransportType,
                    ModuleUtil.DefaultTimeoutErrorDetectionStrategy,
                    ModuleUtil.DefaultTransientRetryStrategy,
                    Logger);

                break;

            case InvocationSource.Cloud:
                // Implicit OpenAsync()
                directMethodClient = await DirectMethodCloudSender.CreateAsync(
                    Settings.Current.ServiceClientConnectionString.Expect(() => new ArgumentException("ServiceClientConnectionString is null")),
                    (Microsoft.Azure.Devices.TransportType) Settings.Current.TransportType,
                    Logger);

                break;

            default:
                throw new NotImplementedException("Invalid InvocationSource type");
            }

            return(directMethodClient);
        }
        protected override void Execute(CodeActivityContext executionContext)
        {
            ITracingService tracer = executionContext.GetExtension <ITracingService>();

            tracer.Trace("Inicialize context");
            IWorkflowContext context = executionContext.GetExtension <IWorkflowContext>();

            //Create an Organization Service
            tracer.Trace("Inicialize serviceFactory");
            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>();

            tracer.Trace("Inicialize orgService");
            IOrganizationService orgService = serviceFactory.CreateOrganizationService(context.InitiatingUserId);

            //Registered Step Guid
            var pluginStepGuid = Guid.Empty;

            try
            {
                //Plugin Step object
                tracer.Trace("Inicialize pluginStep");
                CrmPluginStep pluginStep = new CrmPluginStep();

                pluginStep.PrimaryEntity = PrimaryEntity.Get <string>(executionContext);
                tracer.Trace("PrimaryEntity: " + pluginStep.PrimaryEntity);

                pluginStep.PluginAssemblyName = AssemblyName.Get <string>(executionContext);
                tracer.Trace("PluginAssemblyName: " + pluginStep.PluginAssemblyName);

                pluginStep.EventHandler = EventHandler.Get <string>(executionContext);
                tracer.Trace("EventHandler: " + pluginStep.EventHandler);

                pluginStep.Mode = Mode.Get <int>(executionContext);
                tracer.Trace("Mode: " + pluginStep.Mode);

                pluginStep.Rank = Rank.Get <int>(executionContext);
                tracer.Trace("Rank: " + pluginStep.Rank);

                pluginStep.FilteringAttributes = FilteringAttributes.Get <string>(executionContext);
                tracer.Trace("FilteringAttributes: " + pluginStep.FilteringAttributes);

                pluginStep.InvocationSource = InvocationSource.Get <int>(executionContext);
                tracer.Trace("InvocationSource: " + pluginStep.InvocationSource);

                pluginStep.Stage = Stage.Get <int>(executionContext);
                tracer.Trace("Stage: " + pluginStep.Stage);

                pluginStep.Deployment = Deployment.Get <int>(executionContext);
                tracer.Trace("Deployment: " + pluginStep.Deployment);

                pluginStep.Message = Message.Get <string>(executionContext);
                tracer.Trace("Message: " + pluginStep.Message);

                pluginStep.Name = pluginStep.EventHandler + ": " + pluginStep.Message + " of " + pluginStep.PrimaryEntity;
                tracer.Trace("Name: " + pluginStep.Name);

                pluginStep.tracer = tracer;

                tracer.Trace("--- Register Plugin Step --- ");
                //Register Step
                pluginStepGuid = pluginStep.RegisterPluginStep(ref orgService);

                tracer.Trace("pluginStepGuid: " + pluginStepGuid);
                PluginStepGuid.Set(executionContext, pluginStepGuid.ToString());
            }
            catch (Exception e)
            {
                throw new InvalidPluginExecutionException("(RegisterPluginStep) Error! " + e.Message);
            }
        }