Exemple #1
0
        private void SpklInstrument_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                Overlay.ShowMessage(_dte, "Instrumenting...", vsStatusAnimation.vsStatusAnimationSync);

                if (CrmAssemblyList.SelectedIndex == -1)
                {
                    return;
                }

                var service = (IOrganizationService)ConnPane.CrmService.OrganizationServiceProxy;
                var ctx     = new OrganizationServiceContext(service);

                Project project = ConnPane.SelectedProject;
                ProjectWorker.BuildProject(project);

                string path = Path.GetDirectoryName(project.FullName);

                DownloadPluginMetadataTask downloadPluginMetadataTask = new DownloadPluginMetadataTask(ctx, new TraceLogger());
                downloadPluginMetadataTask.Execute(path);
            }
            finally
            {
                Overlay.HideMessage(_dte, vsStatusAnimation.vsStatusAnimationSync);
            }
        }
Exemple #2
0
        public void DownloadWorkflowMetadata()
        {
            CrmServiceClient crmSvc = new CrmServiceClient(ConfigurationManager.ConnectionStrings["integration_testing"].ConnectionString);
            var userId = crmSvc.GetMyCrmUserId();
            var trace  = new TraceLogger();
            var task   = new DownloadPluginMetadataTask(crmSvc, trace);
            var path   = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                      @"..\..\..\TestWorkflowActivity");

            task.Execute(path);
        }
Exemple #3
0
        public void DuplicatePluginNameOnDownload()
        {
            // Since the name is used to uniquely identify plugins per type, we can't have existing duplicates when downloading steps


            // Arrange
            ServiceLocator.Init();
            var trace = new TraceLogger();

            var ctx     = A.Fake <OrganizationServiceContext>(a => a.Strict());
            var queries = A.Fake <IQueries>();

            ServiceLocator.ServiceProvider.RemoveService(typeof(IQueries));
            ServiceLocator.ServiceProvider.AddService(typeof(IQueries), queries);

            A.CallTo(() => queries.GetPluginSteps(A <OrganizationServiceContext> .Ignored, A <string> .Ignored))
            .WithAnyArguments()
            .ReturnsLazily((OrganizationServiceContext context, string name) =>
            {
                return(new List <SdkMessageProcessingStep>()
                {
                    new SdkMessageProcessingStep
                    {
                        Name = "step"
                    },
                    new SdkMessageProcessingStep
                    {
                        Name = "step"
                    }
                });
            });

            var task = new DownloadPluginMetadataTask(ctx, trace);
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                    @"..\..\..\TestPlugin");

            bool exception = false;

            // Act
            try
            {
                task.Execute(path);
            }
            catch (SparkleTaskException ex)
            {
                exception = (ex.ExceptionType == SparkleTaskException.ExceptionTypes.DUPLICATE_STEP);
            }

            // Assert
            Assert.IsTrue(exception, "Duplicate step names not detected");
        }
Exemple #4
0
        public void DuplicatePluginNameOnDownload()
        {
            // Since the name is used to uniquely identify plugins per type, we can't have existing duplicates when downloading steps

            using (ShimsContext.Create())
            {
                // Arrange
                Fakes.ShimQueries.GetPluginStepsOrganizationServiceContextString = (OrganizationServiceContext context, string name) =>
                {
                    return(new List <SdkMessageProcessingStep>()
                    {
                        new SdkMessageProcessingStep
                        {
                            Name = "step"
                        },
                        new SdkMessageProcessingStep
                        {
                            Name = "step"
                        }
                    });
                };

                var trace = new TraceLogger();
                OrganizationServiceContext ctx = new Microsoft.Xrm.Sdk.Client.Fakes.ShimOrganizationServiceContext();

                var task = new DownloadPluginMetadataTask(ctx, trace);
                var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                        @"..\..\..\TestPlugin");

                bool exception = false;

                // Act
                try
                {
                    task.Execute(path);
                }
                catch (SparkleTaskException ex)
                {
                    exception = (ex.ExceptionType == SparkleTaskException.ExceptionTypes.DUPLICATE_STEP);
                }

                // Assert
                Assert.IsTrue(exception, "Duplicate step names not detected");
            }
        }
Exemple #5
0
        private static void RunTask(CommandLineArgs arguments, IOrganizationService service, ITrace trace)
        {
            if (arguments.Path == null)
            {
                arguments.Path = Directory.GetCurrentDirectory();
            }
            else
            {
                // Strip trailing \
                arguments.Path = arguments.Path.TrimEnd('\\');
                arguments.Path = Path.Combine(Directory.GetCurrentDirectory(), arguments.Path);
            }

            BaseTask task    = null;
            string   command = arguments.Task.ToLower();

            switch (command)
            {
            case "plugins":
                trace.WriteLine("Deploying Plugins");
                task = new DeployPluginsTask(service, trace);
                break;

            case "workflow":
                trace.WriteLine("Deploying Custom Workflow Activities");
                task = new DeployWorkflowActivitiesTask(service, trace);
                break;

            case "webresources":
                trace.WriteLine("Deploying WebResources");
                task = new DeployWebResourcesTask(service, trace);
                break;

            case "instrument":
                trace.WriteLine("Downloading Plugin/Workflow Activity Metadata");
                task = new DownloadPluginMetadataTask(service, trace);
                break;

            case "download-webresources":
                trace.WriteLine("Downloading Webresources");
                task = new DownloadWebresourceFileTask(service, trace)
                {
                    Overwrite = arguments.Overwrite
                };
                break;

            case "get-webresources":
                trace.WriteLine("Downloading Webresources");
                task        = new DownloadWebresourceConfigTask(service, trace);
                task.Prefix = arguments.Prefix;
                break;

            case "earlybound":
                trace.WriteLine("Generating early bound types");
                var earlyBound = new EarlyBoundClassGeneratorTask(service, trace);
                task = earlyBound;
                earlyBound.ConectionString = arguments.Connection;
                break;

            case "unpack":
                trace.WriteLine("Unpacking solution");
                var packager = new SolutionPackagerTask(service, trace);
                packager.command = command;
                task             = packager;
                break;

            case "unpacksolution":
                trace.WriteLine("Unpacking solution Zip");
                var unpackfromsolution = new SolutionPackagerTask(service, trace);
                unpackfromsolution.command = command;
                task = unpackfromsolution;
                break;

            case "pack":
                trace.WriteLine("Packing Solution");
                var pack = new SolutionPackagerTask(service, trace);
                pack.command = command;
                task         = pack;
                break;

            case "import":
                trace.WriteLine("Packing & Import Solution");
                var import = new SolutionPackagerTask(service, trace);
                import.command = command;
                task           = import;
                break;

            case "compare":
                trace.WriteLine("Comparing Solution");
                var compare = new SolutionPackagerTask(service, trace);
                compare.command = command;
                task            = compare;
                break;
            }


            if (task != null)
            {
                if (arguments.Profile != null)
                {
                    task.Profile = arguments.Profile;
                }
                task.Execute(arguments.Path);
            }
            else
            {
                throw new SparkleTaskException(SparkleTaskException.ExceptionTypes.NO_TASK_SUPPLIED, String.Format("Task '{0}' not recognised. Please consult help!", arguments.Task.ToLower()));
            }
        }
Exemple #6
0
        private static void RunTask(CommandLineArgs arguments, IOrganizationService service, ITrace trace)
        {
            if (arguments.Path == null)
            {
                arguments.Path = Directory.GetCurrentDirectory();
            }
            else
            {
                // Strip trailing \
                arguments.Path = arguments.Path.TrimEnd('\\');
                arguments.Path = Path.Combine(Directory.GetCurrentDirectory(), arguments.Path);
            }

            BaseTask task = null;

            switch (arguments.Task.ToLower())
            {
            case "plugins":
                trace.WriteLine("Deploying Plugins");
                task = new DeployPluginsTask(service, trace);
                break;

            case "workflow":
                trace.WriteLine("Deploying Custom Workflow Activities");
                task = new DeployWorkflowActivitiesTask(service, trace);
                break;

            case "webresources":
                trace.WriteLine("Deploying WebResources");
                task = new DeployWebResourcesTask(service, trace);
                break;

            case "instrument":
                trace.WriteLine("Downloading Plugin/Workflow Activity Metadata");
                task = new DownloadPluginMetadataTask(service, trace);
                break;

            case "get-webresources":
                trace.WriteLine("Downloading Webresources");
                task        = new DownloadWebresourceConfigTask(service, trace);
                task.Prefix = arguments.Prefix;
                break;

            case "earlybound":
                trace.WriteLine("Generating early bound types");
                var earlyBound = new EarlyBoundClassGeneratorTask(service, trace);
                task = earlyBound;
                earlyBound.ConectionString = arguments.Connection;
                break;
            }


            if (task != null)
            {
                if (arguments.Profile != null)
                {
                    task.Profile = arguments.Profile;
                }
                task.Execute(arguments.Path);
            }
            else
            {
                throw new SparkleTaskException(SparkleTaskException.ExceptionTypes.NO_TASK_SUPPLIED, String.Format("Task '{0}' not recognised. Please consult help!", arguments.Task.ToLower()));
            }
        }