static void Main(string[] args) { var arguments = ConsoleApplication.ParseCommandLineArguments(args); var applicationName = arguments.ContainsKey("SettingsFolderName") ? arguments["SettingsFolderName"] : "Unknown Console Context"; //okay need to create app var dependencyResolver = new DependencyContainer(); var controller = new ConsoleApplicationController(applicationName, dependencyResolver); try { var settingsManager = new DesktopSettingsManager(controller); var applicationOptions = new ApplicationOptionsViewModel(controller); var app = new ConsoleApplication(controller, applicationOptions, settingsManager); //load modules in folder path app.LoadModulesInExecutionFolder(); //run app app.Run(args); } catch (Exception ex) { System.Console.WriteLine(ex.DisplayString()); System.Console.WriteLine("Fatal Error"); var logFile = new LogFileUserInterface(controller.LogPath, controller.ApplicationName, true, 50); logFile.LogMessage($"Fatal Error During Console Execution: {ex.XrmDisplayString()}"); throw; } }
static void Main(string[] args) { try { var arguments = ConsoleApplication.ParseCommandLineArguments(args); var applicationName = arguments.ContainsKey("SettingsFolderName") ? arguments["SettingsFolderName"] : "Unknown Console Context"; //okay need to create app var dependencyResolver = new PrismDependencyContainer(new UnityContainer()); var controller = new ConsoleApplicationController(applicationName, dependencyResolver); var settingsManager = new PrismSettingsManager(controller); var applicationOptions = new ApplicationOptionsViewModel(controller); var app = new ConsoleApplication(controller, applicationOptions, settingsManager); //load modules in folder path app.LoadModulesInExcecutionFolder(); //run app app.Run(args); System.Console.WriteLine("Process Completed. Finishing In 10 Seconds"); Thread.Sleep(10000); } catch (Exception ex) { System.Console.WriteLine(ex.DisplayString()); System.Console.WriteLine("Press Any Key To Close"); System.Console.ReadKey(); } }
/// <summary> /// Runs this instance. /// </summary> public void Run() { TraceService.WriteHeader("NugetPackagesController::Run"); //// we open the nuget package manager console so we don't have //// a wait condition later! this.nugetService.OpenNugetWindow(); this.nugetPackagesFactory.RegisterWizardData(); WizardFrameViewModel viewModel = this.ShowDialog <WizardFrameViewModel>(new WizardView()); if (viewModel.Continue) { ApplicationOptionsViewModel applicationOptionsViewModel = (ApplicationOptionsViewModel)viewModel.GetWizardStepViewModel("ApplicationOptionsViewModel").ViewModel; NinjaCoderOptionsViewModel ninjaCoderOptionsViewModel = (NinjaCoderOptionsViewModel)viewModel.GetWizardStepViewModel("NinjaCoderOptionsViewModel").ViewModel; ApplicationSamplesOptionsViewModel applicationSamplesOptionsViewModel = (ApplicationSamplesOptionsViewModel)viewModel.GetWizardStepViewModel("ApplicationSamplesOptionsViewModel").ViewModel; NugetPackagesViewModel nugetPackagesViewModel = (NugetPackagesViewModel)viewModel.GetWizardStepViewModel("NugetPackagesViewModel").ViewModel; XamarinFormsLabsViewModel xamarinFormsLabsViewModel = (XamarinFormsLabsViewModel)viewModel.GetWizardStepViewModel("XamarinFormsLabsViewModel").ViewModel; this.Process( applicationOptionsViewModel, ninjaCoderOptionsViewModel, applicationSamplesOptionsViewModel, nugetPackagesViewModel, xamarinFormsLabsViewModel); } }
public static DesktopApplication Create(string applicatonName) { var controller = new DesktopApplicationController(applicatonName, new DependencyContainer()); controller.RegisterType <IDialogController, DialogController>(); var options = new ApplicationOptionsViewModel(controller); var settingsManager = new DesktopSettingsManager(controller); return(new DesktopApplication(controller, options, settingsManager)); }
public async Task <ApplicationOptionsViewModel> GetOptionsAsync() { var options = _options.Value; var model = new ApplicationOptionsViewModel { Permissions = options.Permissions }; return(await Task.FromResult(model)); }
/// <summary> /// Runs this instance. /// </summary> public void Run() { TraceService.WriteHeader("ProjectsController::Run"); //// we open the nuget package manager console so we don't have a wait condition later! this.nugetService.OpenNugetWindow(); this.projectFactory.RegisterWizardData(); WizardFrameViewModel viewModel = this.ShowDialog <WizardFrameViewModel>(new WizardView()); try { if (viewModel.Continue) { ProjectsViewModel projectsViewModel = (ProjectsViewModel)viewModel.GetWizardStepViewModel("ProjectsViewModel").ViewModel; ApplicationOptionsViewModel applicationOptionsViewModel = (ApplicationOptionsViewModel)viewModel.GetWizardStepViewModel("ApplicationOptionsViewModel").ViewModel; NinjaCoderOptionsViewModel ninjaCoderOptionsViewModel = (NinjaCoderOptionsViewModel)viewModel.GetWizardStepViewModel("NinjaCoderOptionsViewModel").ViewModel; ApplicationSamplesOptionsViewModel applicationSamplesOptionsViewModel = (ApplicationSamplesOptionsViewModel)viewModel.GetWizardStepViewModel("ApplicationSamplesOptionsViewModel").ViewModel; ViewsViewModel viewsViewModel = (ViewsViewModel)viewModel.GetWizardStepViewModel("ViewsViewModel").ViewModel; PluginsViewModel pluginsViewModel = (PluginsViewModel)viewModel.GetWizardStepViewModel("PluginsViewModel").ViewModel; NugetPackagesViewModel nugetPackagesViewModel = (NugetPackagesViewModel)viewModel.GetWizardStepViewModel("NugetPackagesViewModel").ViewModel; XamarinFormsLabsViewModel xamarinFormsLabsViewModel = (XamarinFormsLabsViewModel)viewModel.GetWizardStepViewModel("XamarinFormsLabsViewModel").ViewModel; this.Process( projectsViewModel, applicationOptionsViewModel, ninjaCoderOptionsViewModel, applicationSamplesOptionsViewModel, viewsViewModel, pluginsViewModel, nugetPackagesViewModel, xamarinFormsLabsViewModel); } } catch (Exception exception) { //// TODO : this needs refactoring. this.VisualStudioService.WriteStatusBarMessage(string.Empty); TraceService.WriteError(exception); //// put the error messages in the readme! this.messages.InsertRange(0, TraceService.ErrorMessages); TraceService.ErrorMessages = new List <string>(); this.CreateReadMe(true, true); } }
/// <summary> /// Processes the specified form. /// </summary> /// <param name="applicationOptionsViewModel">The application options view model.</param> /// <param name="ninjaCoderOptionsViewModel">The ninja coder options view model.</param> /// <param name="applicationSamplesOptionsViewModel">The application samples options view model.</param> /// <param name="nugetPackagesViewModel">The nuget packages view model.</param> /// <param name="xamarinFormsLabsViewModel">The xamarin forms labs view model.</param> internal void Process( ApplicationOptionsViewModel applicationOptionsViewModel, NinjaCoderOptionsViewModel ninjaCoderOptionsViewModel, ApplicationSamplesOptionsViewModel applicationSamplesOptionsViewModel, NugetPackagesViewModel nugetPackagesViewModel, XamarinFormsLabsViewModel xamarinFormsLabsViewModel) { TraceService.WriteLine("NugetPackagesController::Process"); this.VisualStudioService.WriteStatusBarMessage(NinjaMessages.NinjaIsRunning); this.messages = new List <string>(); this.PopulateNugetActions(applicationOptionsViewModel); this.PopulateNugetActions(ninjaCoderOptionsViewModel); this.PopulateNugetActions(applicationSamplesOptionsViewModel); this.PopulateNugetActions(nugetPackagesViewModel); this.PopulateNugetActions(xamarinFormsLabsViewModel); if (this.SettingsService.OutputNugetCommandsToReadMe) { this.messages.Add(this.commands); } this.ReadMeService.AddLines( this.GetReadMePath(), "Add Nuget Packages", this.messages, TraceService.ErrorMessages, this.GetTraceMessages(false)); TraceService.WriteHeader("RequestedNugetCommands=" + this.commands); if (this.SettingsService.ProcessNugetCommands) { this.nugetService.Execute( this.GetReadMePath(), this.commands, this.SettingsService.SuspendReSharperDuringBuild); } string message = NinjaMessages.NugetDownload; if (this.SettingsService.UseLocalNuget) { message += " (using local " + this.SettingsService.LocalNugetName + ")"; } this.VisualStudioService.WriteStatusBarMessage(message); }
/// <summary> /// Processes the specified form. /// </summary> /// <param name="applicationOptionsViewModel">The application options view model.</param> /// <param name="ninjaCoderOptionsViewModel">The ninja coder options view model.</param> /// <param name="applicationSamplesOptionsViewModel">The application samples options view model.</param> /// <param name="nugetPackagesViewModel">The nuget packages view model.</param> /// <param name="xamarinFormsLabsViewModel">The xamarin forms labs view model.</param> internal void Process( ApplicationOptionsViewModel applicationOptionsViewModel, NinjaCoderOptionsViewModel ninjaCoderOptionsViewModel, ApplicationSamplesOptionsViewModel applicationSamplesOptionsViewModel, NugetPackagesViewModel nugetPackagesViewModel, XamarinFormsLabsViewModel xamarinFormsLabsViewModel) { TraceService.WriteLine("NugetPackagesController::Process"); this.VisualStudioService.WriteStatusBarMessage(NinjaMessages.NinjaIsRunning); this.messages = new List<string>(); this.PopulateNugetActions(applicationOptionsViewModel); this.PopulateNugetActions(ninjaCoderOptionsViewModel); this.PopulateNugetActions(applicationSamplesOptionsViewModel); this.PopulateNugetActions(nugetPackagesViewModel); this.PopulateNugetActions(xamarinFormsLabsViewModel); if (this.SettingsService.OutputNugetCommandsToReadMe) { this.messages.Add(this.commands); } this.ReadMeService.AddLines( this.GetReadMePath(), "Add Nuget Packages", this.messages, TraceService.ErrorMessages, this.GetTraceMessages(false)); TraceService.WriteHeader("RequestedNugetCommands=" + this.commands); if (this.SettingsService.ProcessNugetCommands) { this.nugetService.Execute( this.GetReadMePath(), this.commands, this.SettingsService.SuspendReSharperDuringBuild); } string message = NinjaMessages.NugetDownload; if (this.SettingsService.UseLocalNuget) { message += " (using local " + this.SettingsService.LocalNugetName + ")"; } this.VisualStudioService.WriteStatusBarMessage(message); }
public void ConsoleApplicationModuleWithXrmConnectionGenerateBatAndExecuteTest() { //this is done in the load.edit saved request form //a button is added the the saved request grid whiuch generates the .bat //so we need to save a request //then navigate to the save requests and trigger the generate bat button var testApplication = CreateThisApp(); //set to no previously saved ones var savedRequests = new SavedSettings(); var settingsManager = testApplication.Controller.ResolveType <ISettingsManager>(); settingsManager.SaveSettingsObject(savedRequests, typeof(TestSavedRequestWithXrmConnectionDialogRequest)); //navigate to the request and populate the string field var entryForm = testApplication.NavigateToDialogModuleEntryForm <TestSavedRequestWithXrmConnectionModule, TestSavedRequestWithXrmConnectionDialog>(); var request = new TestSavedRequestWithXrmConnectionDialogRequest() { SomeArbitraryString = nameof(TestSavedRequestWithXrmConnectionDialogRequest.SomeArbitraryString) }; testApplication.EnterObject(request, entryForm); //trigger save request var saveRequestButton = entryForm.GetButton("SAVEREQUEST"); saveRequestButton.Invoke(); //enter and save details including autoload var saveRequestForm = testApplication.GetSubObjectEntryViewModel(entryForm); var detailsEntered = new SaveAndLoadFields() { Name = "TestName" }; testApplication.EnterAndSaveObject(detailsEntered, saveRequestForm); Assert.IsFalse(entryForm.ChildForms.Any()); Assert.IsFalse(entryForm.LoadingViewModel.IsLoading); //reopen app/dialog testApplication = CreateThisApp(); entryForm = testApplication.NavigateToDialogModuleEntryForm <TestSavedRequestWithXrmConnectionModule, TestSavedRequestWithXrmConnectionDialog>(); //invoke load request dialog var loadRequestButton = entryForm.GetButton("LOADREQUEST"); loadRequestButton.Invoke(); var loadRequestForm = testApplication.GetSubObjectEntryViewModel(entryForm); //verify there is a saved request and trigger the generate bat button var subGrid = loadRequestForm.GetEnumerableFieldViewModel(nameof(SavedSettings.SavedRequests)); Assert.IsTrue(subGrid.GridRecords.Count() == 1); subGrid.GridRecords.First().IsSelected = true; var generateBatButton = subGrid.DynamicGridViewModel.GetButton("GENERATEBAT"); generateBatButton.Invoke(); var testFiles = FileUtility.GetFiles(TestingFolder); Assert.AreEqual(1, testFiles.Count()); Assert.IsTrue(testFiles.First().EndsWith(".bat")); var batContent = File.ReadAllText(testFiles.First()); var args = ConsoleTestUtility.CommandLineToArgs(batContent) .Skip(1) .ToArray(); var arguments = ConsoleApplication.ParseCommandLineArguments(args); var applicationName = arguments.ContainsKey("SettingsFolderName") ? arguments["SettingsFolderName"] : "Unknown Console Context"; //okay need to create app var dependencyResolver = new DependencyContainer(); var controller = new ConsoleApplicationController(applicationName, dependencyResolver); settingsManager = new DesktopSettingsManager(controller); var applicationOptions = new ApplicationOptionsViewModel(controller); var app = new ConsoleApplication(controller, applicationOptions, settingsManager); //load modules in folder path app.LoadModulesInExecutionFolder(); //for this we will register saved connections in the console //in reality they would have been created on disk by the app and loaded by the module\ //this was just debugging an invalid connection //var c1 = GetXrmRecordConfiguration(); //var c2 = GetSavedXrmRecordConfiguration(); //c1.Password = new Password("Nope", false, true); //c2.Password = new Password("Nope", false, true); //XrmConnectionModule.RefreshXrmServices(c1, app.Controller); //app.Controller.RegisterInstance<ISavedXrmConnections>(new SavedXrmConnections //{ // Connections = new[] { c2 } //}); XrmConnectionModule.RefreshXrmServices(GetXrmRecordConfiguration(), app.Controller); app.Controller.RegisterInstance <ISavedXrmConnections>(new SavedXrmConnections { Connections = new[] { GetSavedXrmRecordConfiguration() } }); //run app app.Run(args); }
/// <summary> /// Processes the specified solution path. /// </summary> /// <param name="projectsViewModel">The projects view model.</param> /// <param name="applicationOptionsViewModel">The application options view model.</param> /// <param name="ninjaCoderOptionsViewModel">The ninja coder options view model.</param> /// <param name="applicationSamplesOptionsViewModel">The application samples options view model.</param> /// <param name="viewsViewModel">The views view model.</param> /// <param name="pluginsViewModel">The plugins view model.</param> /// <param name="nugetPackagesViewModel">The nuget packages view model.</param> /// <param name="xamarinFormsLabsViewModel">The xamarin forms labs view model.</param> internal void Process( ProjectsViewModel projectsViewModel, ApplicationOptionsViewModel applicationOptionsViewModel, NinjaCoderOptionsViewModel ninjaCoderOptionsViewModel, ApplicationSamplesOptionsViewModel applicationSamplesOptionsViewModel, ViewsViewModel viewsViewModel, PluginsViewModel pluginsViewModel, NugetPackagesViewModel nugetPackagesViewModel, XamarinFormsLabsViewModel xamarinFormsLabsViewModel) { TraceService.WriteLine("ProjectsController::Process"); foreach (SelectableItemViewModel<ProjectTemplateInfo> projectTemplateInfo in projectsViewModel.Projects) { TraceService.WriteLine(projectTemplateInfo.Item.Name + " project selected=" + projectTemplateInfo.IsSelected); } this.VisualStudioService.WriteStatusBarMessage(NinjaMessages.NinjaIsRunning); this.applicationService.SuspendResharperIfRequested(); this.projectsService.IsNewSolution = this.VisualStudioService.SolutionAlreadyCreated; //// create the solution if we don't have one! if (this.projectsService.IsNewSolution == false) { this.VisualStudioService.SolutionService.CreateEmptySolution(projectsViewModel.GetSolutionPath(), projectsViewModel.Project); } if (this.SettingsService.CreateTestProjectsSolutionFolder) { this.VisualStudioService.SolutionService.AddSolutionFolder(this.SettingsService.TestProjectsSolutionFolderName); this.VisualStudioService.DTEService.SaveAll(); } this.messages = this.projectsService.AddProjects( this.VisualStudioService, projectsViewModel.GetSolutionPath(), projectsViewModel.GetFormattedRequiredTemplates()) .ToList(); this.projectsService.SetStartUpProject(); //// there is a bug in the xamarin iOS code that means it doesnt apply a couple of xml elements //// in the info.plist - here we fix that issue. if (this.SettingsService.FixInfoPlist) { this.applicationService.FixInfoPList(projectsViewModel.GetFormattedRequiredTemplates() .FirstOrDefault(x => x.ProjectSuffix == this.SettingsService.iOSProjectSuffix)); } IEnumerable<string> viewNugetCommands = new List<string>(); if (this.SettingsService.FrameworkType != FrameworkType.NoFramework && viewsViewModel != null) { //// if we dont have a viewmodel and view in memory - add one //// user will have dont show views and viewmodel options selected. if (!viewsViewModel.Views.Any()) { viewsViewModel.Add(); } IEnumerable<string> viewModelMessages = this.viewModelViewsService.AddViewModelsAndViews(viewsViewModel.Views); this.messages.AddRange(viewModelMessages); viewNugetCommands = this.viewModelViewsService.GetNugetCommands(); } TraceService.WriteLine("ProjectsController::Process GetApplication Commands"); //// we need to get the post nuget commands that are now hosted in xml file that used to be in code CommandsList commandsList = this.applicationService.GetCommandsList(); if (commandsList != null) { this.postNugetCommands.AddRange(commandsList.Commands); this.postNugetFileOperations.AddRange(commandsList.FileOperations); } IEnumerable<ProjectTemplateInfo> projectTemplateInfos = projectsViewModel.GetFormattedRequiredTemplates(); this.commands += this.nugetService.GetNugetCommands(projectTemplateInfos); if (viewNugetCommands.Any()) { foreach (string viewNugetCommand in viewNugetCommands) { this.commands += viewNugetCommand + Environment.NewLine; } } this.PopulateNugetActions(applicationOptionsViewModel); this.PopulateNugetActions(ninjaCoderOptionsViewModel); this.PopulateNugetActions(applicationSamplesOptionsViewModel); this.PopulateNugetActions(pluginsViewModel); this.PopulateNugetActions(nugetPackagesViewModel); this.PopulateNugetActions(xamarinFormsLabsViewModel); this.cachingService.PostNugetCommands = this.postNugetCommands; this.cachingService.PostNugetFileOperations = this.postNugetFileOperations; //// a bit of (unnecessary) tidying up - replace double new lines! this.commands = this.commands.Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine); this.CreateReadMe(false, false); TraceService.WriteHeader("RequestedNugetCommands=" + this.commands); if (this.SettingsService.ProcessNugetCommands) { this.ProcessNugetCommands(); } TraceService.WriteLine("ProjectsController::Process END"); }
public void DeploymentImportSqlTest() { //this script create some data in a database //then runs a synch twice into dynamics with a reference change in between //it also fakes the process running in a console app //also verifies email sent with summary var queues = XrmRecordService.RetrieveAllAndClauses(Entities.queue, new[] { new Condition(Fields.queue_.emailaddress, ConditionType.NotNull) }); Assert.IsTrue(queues.Count() > 1); var queueSendFrom = queues.ElementAt(0); var queueSendTo = queues.ElementAt(1); //script of basic database import PrepareTests(); DeleteAll(Entities.email); var sqlServer = @"localhost\SQLEXPRESS"; var databaseName = "TestScriptDatabaseImport"; //request with mappings from sql to dynamics var request = new ImportSqlRequest() { ConnectionString = $"Provider=sqloledb;Data Source={sqlServer};Initial Catalog={databaseName};Integrated Security=SSPI;", SendNotificationAtCompletion = true, SendNotificationFromQueue = XrmRecordService.ToLookup(queueSendFrom), SendNotificationToQueue = XrmRecordService.ToLookup(queueSendTo), Mappings = new[] { new ImportSqlRequest.SqlImportTableMapping { SourceTable = new RecordType("Accounts", "Accounts"), TargetType = new RecordType(Entities.account, Entities.account), Mappings = new [] { new ImportSqlRequest.SqlImportTableMapping.SqlImportFieldMapping() { SourceColumn = new RecordField("Name", "Name"), TargetField = new RecordField(Fields.account_.name, Fields.account_.name) } } }, new ImportSqlRequest.SqlImportTableMapping { SourceTable = new RecordType("TestRecords", "TestRecords"), TargetType = new RecordType(Entities.jmcg_testentity, Entities.jmcg_testentity), Mappings = new [] { new ImportSqlRequest.SqlImportTableMapping.SqlImportFieldMapping() { SourceColumn = new RecordField("Name", "Name"), TargetField = new RecordField(Fields.jmcg_testentity_.jmcg_name, Fields.jmcg_testentity_.jmcg_name) }, new ImportSqlRequest.SqlImportTableMapping.SqlImportFieldMapping() { SourceColumn = new RecordField("Account", "Account"), TargetField = new RecordField(Fields.jmcg_testentity_.jmcg_account, Fields.jmcg_testentity_.jmcg_account) }, new ImportSqlRequest.SqlImportTableMapping.SqlImportFieldMapping() { SourceColumn = new RecordField("Integer", "Integer"), TargetField = new RecordField(Fields.jmcg_testentity_.jmcg_integer, Fields.jmcg_testentity_.jmcg_integer) } } } } }; //create record and field metadata for the source mappings //which will be used to create the source database var recordMetadatas = new List <RecordMetadata>(); foreach (var item in request.Mappings) { var recordMetadata = new RecordMetadata() { SchemaName = item.SourceTable.Key, DisplayName = item.SourceTable.Key }; var fields = new List <FieldMetadata>(); foreach (var column in item.Mappings) { fields.Add(new StringFieldMetadata(column.SourceColumn.Key, column.SourceColumn.Key)); } recordMetadata.Fields = fields; recordMetadatas.Add(recordMetadata); } //if the database doesnt exist create it if (!SqlProvider.DatabaseExists(sqlServer, databaseName)) { SqlProvider.CreateDatabase(sqlServer, databaseName); } //ensure the source database contains tables/columns for our source mappings metadata var recordMetadataService = new SqlRecordMetadataService(new SqlServerAndDbSettings(sqlServer, databaseName), recordMetadatas); recordMetadataService.RefreshSource(); //configure synch data var recordsToCreate = 3; foreach (var tableMapping in request.Mappings) { //delete all in both var truncate = $"truncate table {tableMapping.SourceTable.Key}"; recordMetadataService.ExecuteSql(truncate); DeleteAll(tableMapping.TargetType.Key); //create data in the db for (var i = 1; i <= recordsToCreate; i++) { var newRecord = recordMetadataService.NewRecord(tableMapping.SourceTable.Key); foreach (var fieldMapping in tableMapping.Mappings) { newRecord.SetField(fieldMapping.SourceColumn.Key, i.ToString(), recordMetadataService); } recordMetadataService.Create(newRecord); } } //run the synch var app = CreateAndLoadTestApplication <ImportSqlModule>(); app.AddModule <ConsoleApplicationModule>(); //navigate to the dialog var dialog = app.NavigateToDialog <ImportSqlModule, ImportSqlDialog>(); var entryViewmodel = app.GetSubObjectEntryViewModel(dialog); app.EnterObject(request, entryViewmodel); entryViewmodel.SaveButtonViewModel.Invoke(); var completionScreen = app.GetCompletionViewModel(dialog); var importResponse = completionScreen.GetObject() as ImportSqlResponse; Assert.IsNotNull(importResponse); Assert.IsFalse(importResponse.ResponseItems.Any()); foreach (var tableMapping in request.Mappings) { var records = XrmRecordService.RetrieveAll(tableMapping.TargetType.Key, null); Assert.AreEqual(recordsToCreate, records.Count()); } //point the account field in the db to 3 var linkAllToAccount3 = $"update TestRecords set Account = 3"; recordMetadataService.ExecuteSql(linkAllToAccount3); dialog = app.NavigateToDialog <ImportSqlModule, ImportSqlDialog>(); entryViewmodel = app.GetSubObjectEntryViewModel(dialog); app.EnterObject(request, entryViewmodel); //okay here we generate a saved request and get the command line for it //to also run a console app after this second synch ClearSavedRequests(app, entryViewmodel); //trigger save request var saveRequestButton = entryViewmodel.GetButton("SAVEREQUEST"); saveRequestButton.Invoke(); //enter and save details including autoload var saveRequestForm = app.GetSubObjectEntryViewModel(entryViewmodel); var detailsEntered = new SaveAndLoadFields() { Name = "TestName" }; app.EnterAndSaveObject(detailsEntered, saveRequestForm); Assert.IsFalse(entryViewmodel.ChildForms.Any()); Assert.IsFalse(entryViewmodel.LoadingViewModel.IsLoading); //invoke load request dialog var loadRequestButton = entryViewmodel.GetButton("LOADREQUEST"); loadRequestButton.Invoke(); var loadRequestForm = app.GetSubObjectEntryViewModel(entryViewmodel); //verify there is a saved request and trigger the generate bat button var subGrid = loadRequestForm.GetEnumerableFieldViewModel(nameof(SavedSettings.SavedRequests)); Assert.IsTrue(subGrid.GridRecords.Count() == 1); subGrid.GridRecords.First().IsSelected = true; var generateBatButton = subGrid.DynamicGridViewModel.GetButton("GENERATEBAT"); generateBatButton.Invoke(); var testFiles = FileUtility.GetFiles(TestingFolder); Assert.AreEqual(1, testFiles.Count()); Assert.IsTrue(testFiles.First().EndsWith(".bat")); var batContent = File.ReadAllText(testFiles.First()); loadRequestForm.CancelButtonViewModel.Invoke(); Assert.IsFalse(entryViewmodel.ChildForms.Any()); Assert.IsFalse(entryViewmodel.LoadingViewModel.IsLoading); //okay we now have the bat args for later so lets run the update synch in the app entryViewmodel.SaveButtonViewModel.Invoke(); completionScreen = app.GetCompletionViewModel(dialog); importResponse = completionScreen.GetObject() as ImportSqlResponse; Assert.IsNotNull(importResponse); Assert.IsFalse(importResponse.ResponseItems.Any()); //verify all point to account 3 var updatedRecords = XrmRecordService.RetrieveAll(Entities.jmcg_testentity, null); Assert.AreEqual(3, updatedRecords.Count()); Assert.IsTrue(updatedRecords.All(r => r.GetLookupName(Fields.jmcg_testentity_.jmcg_account) == "3")); //okay lets fake run it for the console app args generated var args = ConsoleTestUtility.CommandLineToArgs(batContent) .Skip(1) .ToArray(); var arguments = ConsoleApplication.ParseCommandLineArguments(args); var applicationName = arguments.ContainsKey("SettingsFolderName") ? arguments["SettingsFolderName"] : "Unknown Console Context"; //okay need to create app var dependencyResolver = new DependencyContainer(); var controller = new ConsoleApplicationController(applicationName, dependencyResolver); var settingsManager = new DesktopSettingsManager(controller); var applicationOptions = new ApplicationOptionsViewModel(controller); var consoleApp = new ConsoleApplication(controller, applicationOptions, settingsManager); //load modules in folder path consoleApp.LoadModulesInExecutionFolder(); var connection = GetSavedXrmRecordConfiguration(); XrmConnectionModule.RefreshXrmServices(GetXrmRecordConfiguration(), app.Controller); app.Controller.RegisterInstance <ISavedXrmConnections>(new SavedXrmConnections { Connections = new[] { connection } }); //run app consoleApp.Run(args); //email created for each synch var emails = XrmRecordService.RetrieveAll(Entities.email, null); Assert.AreEqual(3, emails.Count()); Assert.IsTrue(emails.All(e => e.GetOptionKey(Fields.email_.statecode) == OptionSets.Email.ActivityStatus.Completed.ToString())); }
/// <summary> /// Processes the specified solution path. /// </summary> /// <param name="projectsViewModel">The projects view model.</param> /// <param name="applicationOptionsViewModel">The application options view model.</param> /// <param name="ninjaCoderOptionsViewModel">The ninja coder options view model.</param> /// <param name="applicationSamplesOptionsViewModel">The application samples options view model.</param> /// <param name="viewsViewModel">The views view model.</param> /// <param name="pluginsViewModel">The plugins view model.</param> /// <param name="nugetPackagesViewModel">The nuget packages view model.</param> /// <param name="xamarinFormsLabsViewModel">The xamarin forms labs view model.</param> internal void Process( ProjectsViewModel projectsViewModel, ApplicationOptionsViewModel applicationOptionsViewModel, NinjaCoderOptionsViewModel ninjaCoderOptionsViewModel, ApplicationSamplesOptionsViewModel applicationSamplesOptionsViewModel, ViewsViewModel viewsViewModel, PluginsViewModel pluginsViewModel, NugetPackagesViewModel nugetPackagesViewModel, XamarinFormsLabsViewModel xamarinFormsLabsViewModel) { TraceService.WriteLine("ProjectsController::Process"); foreach (SelectableItemViewModel <ProjectTemplateInfo> projectTemplateInfo in projectsViewModel.Projects) { TraceService.WriteLine(projectTemplateInfo.Item.Name + " project selected=" + projectTemplateInfo.IsSelected); } this.VisualStudioService.WriteStatusBarMessage(NinjaMessages.NinjaIsRunning); this.applicationService.SuspendResharperIfRequested(); this.projectsService.IsNewSolution = this.VisualStudioService.SolutionAlreadyCreated; //// create the solution if we don't have one! if (this.projectsService.IsNewSolution == false) { this.VisualStudioService.SolutionService.CreateEmptySolution(projectsViewModel.GetSolutionPath(), projectsViewModel.Project); } if (this.SettingsService.CreateTestProjectsSolutionFolder) { this.VisualStudioService.SolutionService.AddSolutionFolder(this.SettingsService.TestProjectsSolutionFolderName); this.VisualStudioService.DTEService.SaveAll(); } this.messages = this.projectsService.AddProjects( this.VisualStudioService, projectsViewModel.GetSolutionPath(), projectsViewModel.GetFormattedRequiredTemplates()) .ToList(); this.projectsService.SetStartUpProject(); //// there is a bug in the xamarin iOS code that means it doesnt apply a couple of xml elements //// in the info.plist - here we fix that issue. if (this.SettingsService.FixInfoPlist) { this.applicationService.FixInfoPList(projectsViewModel.GetFormattedRequiredTemplates() .FirstOrDefault(x => x.ProjectSuffix == this.SettingsService.iOSProjectSuffix)); } IEnumerable <string> viewNugetCommands = new List <string>(); if (this.SettingsService.FrameworkType != FrameworkType.NoFramework && viewsViewModel != null) { //// if we dont have a viewmodel and view in memory - add one //// user will have dont show views and viewmodel options selected. if (!viewsViewModel.Views.Any()) { viewsViewModel.Add(); } IEnumerable <string> viewModelMessages = this.viewModelViewsService.AddViewModelsAndViews(viewsViewModel.Views); this.messages.AddRange(viewModelMessages); viewNugetCommands = this.viewModelViewsService.GetNugetCommands(); } TraceService.WriteLine("ProjectsController::Process GetApplication Commands"); //// we need to get the post nuget commands that are now hosted in xml file that used to be in code CommandsList commandsList = this.applicationService.GetCommandsList(); if (commandsList != null) { this.postNugetCommands.AddRange(commandsList.Commands); this.postNugetFileOperations.AddRange(commandsList.FileOperations); } IEnumerable <ProjectTemplateInfo> projectTemplateInfos = projectsViewModel.GetFormattedRequiredTemplates(); this.commands += this.nugetService.GetNugetCommands(projectTemplateInfos); if (viewNugetCommands.Any()) { foreach (string viewNugetCommand in viewNugetCommands) { this.commands += viewNugetCommand + Environment.NewLine; } } this.PopulateNugetActions(applicationOptionsViewModel); this.PopulateNugetActions(ninjaCoderOptionsViewModel); this.PopulateNugetActions(applicationSamplesOptionsViewModel); this.PopulateNugetActions(pluginsViewModel); this.PopulateNugetActions(nugetPackagesViewModel); this.PopulateNugetActions(xamarinFormsLabsViewModel); this.cachingService.PostNugetCommands = this.postNugetCommands; this.cachingService.PostNugetFileOperations = this.postNugetFileOperations; //// a bit of (unnecessary) tidying up - replace double new lines! this.commands = this.commands.Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine); this.CreateReadMe(false, false); TraceService.WriteHeader("RequestedNugetCommands=" + this.commands); if (this.SettingsService.ProcessNugetCommands) { this.ProcessNugetCommands(); } TraceService.WriteLine("ProjectsController::Process END"); }