Esempio n. 1
0
        private static void Generate(string tempFolder, ConfigFile config)
        {
            var connectionString    = ConfigurationManager.ConnectionStrings["integration_testing"].ConnectionString;
            CrmServiceClient crmSvc = new CrmServiceClient(connectionString);
            var userId = crmSvc.GetMyCrmUserId();
            var trace  = new TraceLogger();


            using (var ctx = new OrganizationServiceContext(crmSvc))
            {
                ctx.MergeOption = MergeOption.NoTracking;

                // Act
                var task = new EarlyBoundClassGeneratorTask(ctx, trace);
                task.ConectionString = connectionString;

                task.CreateEarlyBoundTypes(ctx, config);
            }
        }
Esempio n. 2
0
        public static String[] CreateEarlyBoundClass(String connectionString, String[] entities)
        {
            if (String.IsNullOrWhiteSpace(connectionString))
            {
                throw new Exception("Missing connection string.");
            }

            var trace = new MemorySpklTraceLogger();
            MemoryTraceLogger traceCollection = new MemoryTraceLogger();

            var        temporaryFilePath = System.IO.Path.GetTempFileName();
            var        temporaryFile     = System.IO.Path.GetFileName(temporaryFilePath);
            var        temporaryFolder   = System.IO.Path.GetDirectoryName(temporaryFilePath);
            ConfigFile mockConfigFile    = GetMockConfigFile(entities, temporaryFile, temporaryFolder);
            var        fakeContext       = new FakeServiceContext();

            try
            {
                var earlyBound = new EarlyBoundClassGeneratorTask(fakeContext, trace);
                earlyBound.ConectionString = connectionString;
                earlyBound.CreateEarlyBoundTypes(null, mockConfigFile);
            }
            catch (Exception ex)
            {
                for (int i = traceCollection.traces.Count - 1; i > 0; i--)
                {
                    if (!Regex.Match(traceCollection.traces[i], "Exiting program with exception").Success)
                    {
                        continue;
                    }

                    var snippets = traceCollection.traces[i].Split(new string[] { "Exiting program with exception: " }, StringSplitOptions.RemoveEmptyEntries);
                    throw new Exception(snippets[snippets.Length - 1], ex);
                }

                throw ex;
            }

            System.Collections.Generic.IEnumerable <String> lines = System.IO.File.ReadLines(temporaryFilePath);
            return(lines.ToArray <String>());
        }
Esempio n. 3
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()));
            }
        }
Esempio n. 4
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()));
            }
        }