public async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, ILogger log) { string responseMessage = "Benny is the enw Gustavo"; SolutionService service = new SolutionService(); string path = @"C:\Users\Gustavo Melo\Documents\BGDoc\EXAMPLS\CleanArchitecture-master\CleanArchitecture.sln"; //string path = "/src/Solutions/CleanArchitecture-master/CleanArchitecture.sln"; var solution = service.LoadSolution(path); service.GetSolutionItems(solution); return(new OkObjectResult(responseMessage)); //log.LogInformation("C# HTTP trigger function processed a request."); // //string name = req.Query["name"]; // //string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); //dynamic data = JsonConvert.DeserializeObject(requestBody); //name = name ?? data?.name; // //string responseMessage = string.IsNullOrEmpty(name) // ? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response." // : $"Hello, {name}. This HTTP triggered function executed successfully."; }
public void StartJudge() { loop2: if (IsWork == false) { return; } try { RunIDService.Update(RunID); List <Solution> solutions = SolutionService.SelectByIsJudged(RunID); solCount = (uint)solutions.Count(); if (solCount == 0) { goto loop2; } foreach (Solution solution in solutions) { ParaPair pp = new ParaPair(); pp.dlg = StartJudge; pp.slt = solution; if (ojs[(int)solution.OJID - 1].IsWork) { ThreadPool.QueueUserWorkItem(Run, pp); } //Run(solution); } } catch (Exception e) { LogService.Insert(2, e); } }
public void TransparentTest() { Solution solution = SolutionService.NewRandom(10); Solution mutated = new MutatorTransparentService().Mutate(solution); Assert.AreEqual(solution, mutated); }
public void Dispose() { _logger.LogInformation("Test complete, closing solution."); SolutionService.SaveAndClose(); _pathContext.Dispose(); }
public void BinaryMutatorTest() { Solution solution = SolutionService.NewRandom(10); Solution mutated = new MutatorBinaryService(1).Mutate(solution); Assert.AreNotEqual(solution, mutated); }
public void Dispose() { SolutionService.Save(); SolutionService.Close(); _pathContext.Dispose(); }
public static void StartJudge() { loop2: try { RunIDService.Update(RunID); List <Solution> solutions = SolutionService.SelectByIsJudged(RunID); solCount = (uint)solutions.Count(); if (solCount == 0) { goto loop2; } foreach (Solution solution in solutions) { ParaPair pp = new ParaPair(); pp.dlg = StartJudge; pp.slt = solution; ThreadPool.QueueUserWorkItem(Run, pp); } } catch (Exception e) { LogService.Insert(2, e); } }
static void Main(string[] args) { var publisherService = new PublisherService(); var solutionService = new SolutionService(); var entityService = new EntityService(); Console.WriteLine($"Default publisher: {publisherService.RetrieveTheDefaultPublisher().FriendlyName}"); var solution = solutionService.RetrieveSolution("samplesolution"); Console.WriteLine($"{solution.FriendlyName} - {solution.Id}"); publisherService.CreatePublisher(); solutionService.CreateSolution("samplesolution", "Sample Solution"); solutionService.DeleteSolution("samplesolution"); solutionService.CreateSolution("samplesolution", "Sample Solution"); entityService.AddExistingEntity(new_order.EntityLogicalName, true, false); entityService.AddExistingEntity(new_order.EntityLogicalName, false, true); entityService.AddNewOptionSet(); Console.WriteLine("Press to exit.."); Console.ReadKey(); }
public void RandomizeSolutionTest() { const int size = 8; Solution solution1 = SolutionService.NewRandom(size); Solution solution2 = SolutionService.NewRandom(size); Assert.AreNotEqual(solution1, solution2); }
static void Main(string[] args) { var solutionFile = Path.GetFullPath("..\\..\\..\\R4T4.sln"); var solution = new SolutionService(solutionFile); var project = solution.GetProject("ExampleClasses"); var typeService = new ClassService(project); var classModel = typeService.GetByType("ExampleClasses.Models.Person"); var classAttributes = classModel.Attributes; }
static async Task <Solution> GetInitialOOPSolutionAsync(SolutionService service, Solution solution) { // set up initial solution var solutionChecksum = await solution.State.GetChecksumAsync(CancellationToken.None); await service.UpdatePrimaryWorkspaceAsync(solutionChecksum, solution.WorkspaceVersion, CancellationToken.None); // get solution in remote host return(await service.GetSolutionAsync(solutionChecksum, CancellationToken.None)); }
public void SolutionTest() { var input = new InputData <double>( 3, 3, 5, 3, 1, 1, 1.394448725, 0.51755435); var solutionService = new SolutionService(input); var output = solutionService.Solve(); Assert.AreEqual(4, output.X); Assert.AreEqual(5, output.Y); Assert.AreEqual(3.16, output.R1); }
public MainViewModel() { _solutionService = new SolutionService(); _notificationService = new NotificationService(); SolutionFolders = new RangeObservableCollection <StorageFolder>(); AddSolutionCommand = new DelegateCommand(AddSolution); CleanSolutionsCommand = new DelegateCommand <IList <object> >(CleanSolutions); RemoveSolutionsCommand = new DelegateCommand <IList <object> >(RemoveSolutions); ExitCommand = new DelegateCommand(ExitFromApplication); }
static ServiceFactory() { PeerReviewContext context = CreateContext(); AuthorizationService = new PeerReviewAuthService(context); MemberService = new MemberService(context); CourseService = new CourseService(context, MemberService); CourseTaskService = new CourseTaskService(context, MemberService); SolutionService = new SolutionService(context, MemberService); UserService = new PeerReviewUserService(context); ReviewService = new ReviewService(context); }
// Scans the solution and initializes. public async Task InitializeFromSolution() { var projects = await SolutionService.GetProjectsList(); projects.Insert(0, new ProjectModel("(current project)", null, null, ProjectKind.Project, null, null)); // Have to save and restore the project id because the XAML binding engine nulls it. var save = ProjectIdentifier; Projects = projects; ProjectIdentifier = save; }
public async Task <PostFileResponse> PostFile(string guid, IFormFile file, CancellationToken token) { if (string.IsNullOrEmpty(guid)) { throw new WebArgumentException(nameof(PostFile), nameof(guid), guid); } if (file.Length > Configuration.FileSize) { return(PostFileResponse.FileSizeError); } var solutionSet = await SolutionService.FetchSolutionSet(guid, token); if (solutionSet == null) { return(PostFileResponse.IdentificationError); } var problemSet = await ProblemService.FetchProblemAsync(solutionSet.ProblemId, token); if (problemSet == null) { return(PostFileResponse.ProblemIdentificationError); } if (file.Length > problemSet.SolutionSize) { return(PostFileResponse.FileSizeError); } using (var writer = new FileStream(Path.Combine(Configuration.FileLocation, file.FileName), FileMode.CreateNew)) { await file.CopyToAsync(writer, token); await writer.FlushAsync(token); } var result = await SolutionService.FinalizeSolutionSet(guid, token); if (result == SolutionServiceResult.Full) { return(PostFileResponse.Full); } if (result == SolutionServiceResult.Incomplete || result == SolutionServiceResult.StartOver) { return(PostFileResponse.Failure); } return(PostFileResponse.Success); }
private static int Execute(Options commandlineOptions) { var solutionName = commandlineOptions.Solution; var connStr = commandlineOptions.CdsConnectionString; var rulesFile = commandlineOptions.RuleFile; var ruleRepo = new RuleRepository(); Console.WriteLine($"Reading rules from file \"{rulesFile}\"."); var rules = ruleRepo.GetRules(rulesFile); Console.WriteLine($"Following {rules.Count} rules were found:"); for (int rule = 0; rule < rules.Count; rule++) { Console.WriteLine($" {rule + 1}: {rules[rule].Description}"); } using (var service = new CrmServiceClient(connStr)) { var solutionValidator = new SolutionService(service); var solutionEntitities = solutionValidator.GetSolutionEntities(solutionName); var results = solutionValidator.Validate(solutionEntitities, rules); foreach (var result in results) { Console.Write($"{result.Key.LogicalName}: "); if (result.Value.All(r => r.Passed)) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Passed validation."); Console.ResetColor(); continue; } Console.ForegroundColor = ConsoleColor.Red; Console.Write("Failed validation."); Console.ResetColor(); Console.WriteLine(" Failures are:"); var failures = result.Value .Where(r => !r.Passed); foreach (var failure in failures) { Console.WriteLine(" * " + failure.FormatValidationResult()); } } return(_EXIT_SUCCESS); } }
private void button3_Click(object sender, EventArgs e) { if (!IsDataSet) { MessageBox.Show("Не введены данные"); } else { _solutionService = new SolutionService(_inputData); var outputdata = _solutionService.Solve(); var outputForm = new OutputForm(outputdata); outputForm.Show(); } }
public FirstViewModel(ProductService productservice, SolutionService solutionservice, CarouselService sarouselService, NewService newService, VideoService videoservice) { //Location = location; whichSite = Common.Site.CompanyHeadquarter; ProductService = productservice; Solutionservice = solutionservice; NewService = newService; VideoService = videoservice; CarouselService = sarouselService; }
static void Main(string[] args) { ImportSolutionApp app = new ImportSolutionApp(); Logger logger = app.Logger; ExitCode exitCode = ExitCode.None; try { logger.Info("Application started."); CultureInfo.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB"); Options options = new Options(); Parser.Default.ParseArgumentsStrict(args, options, CommandLineOptions.ArgumentParsingFailed); Connection connection = null; if (string.IsNullOrWhiteSpace(options.ConnectionString)) { connection = new Connection(options.AuthorityUrl, options.OrganizationUrl, options.OrganizationUrlSuffix, options.TenantId, options.ServicePrincipalId, options.ServicePrincipalSecret, options.ConnectionRetries, options.ConnectionTimeout); } else { connection = new Connection(options.ConnectionString, options.ConnectionRetries, options.ConnectionTimeout); } using (CrmServiceContext organizationServiceContext = new CrmServiceContext(connection.OrganizationService)) using (CrmService crmService = new CrmService(organizationServiceContext, connection)) using (SolutionService solutionService = new SolutionService(organizationServiceContext, connection, crmService)) { solutionService.ImportSolution(options.SolutionName, options.InputFile, options.HoldingSolution.GetValueOrDefault(), options.OverwriteUnmanagedCustomizations.GetValueOrDefault(), options.PublishWorkflows.GetValueOrDefault(), options.SkipProductUpdateDependencies.GetValueOrDefault(), options.PollingInterval, options.PollingTimeout); exitCode = ExitCode.Success; } } catch (Exception ex) { exitCode = new ExceptionHandlingService(ex).GetExitCode(); } finally { logger.Info(CultureInfo.InvariantCulture, "Application exited with code: {0}", (int)exitCode); Environment.Exit((int)exitCode); } }
//when editing this function delete everything from this folder: 'C:\Users\YOUR_NAME\AppData\Local\Microsoft\VisualStudio\NUMBER_WITH_EXP_IN' //FYI: This will reset the whole VS experimental instance //or for only resetting the extension find it and delete the folder. protected override ITeamExplorerSection CreateViewModel(SectionInitializeEventArgs e) { var logger = new Logger(); var configHelper = new ConfigHelper(); var solutionService = new SolutionService(ServiceProvider, configHelper); var tfvcService = new TFVCService(ServiceProvider, solutionService); var teamService = new TeamService(ServiceProvider, tfvcService); var mergeService = new MergeService(ServiceProvider, tfvcService); var mergeOperation = new MergeOperation(mergeService, configHelper); return(base.CreateViewModel(e) ?? new TeamMergeViewModel(teamService, mergeOperation, configHelper, logger, solutionService)); }
private static async Task <SolutionService> GetSolutionServiceAsync(Solution solution, Dictionary <Checksum, object> map = null) { // make sure checksum is calculated await solution.State.GetChecksumAsync(CancellationToken.None); map = map ?? new Dictionary <Checksum, object>(); solution.AppendAssetMap(map); var sessionId = 0; var storage = new AssetStorage(); var source = new TestAssetSource(storage, map); var service = new SolutionService(new AssetService(sessionId, storage)); return(service); }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { base.Initialize(); _dte = (DTE2)GetGlobalService(typeof(DTE)); var service = new SolutionService(_dte); ((IServiceContainer)this).AddService(typeof(ISolutionService), service); _findSelectorModel = new FileSelectorViewModel(service, new FileGeneratorFactory()); GenerateTSClass.Initialize(this, _findSelectorModel); FileSelectorWindowCommand.Initialize(this); _monitorSelection = GetGlobalService(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection; _monitorSelection?.AdviseSelectionEvents(this, out _selectionHandle); }
protected override async Task InitializeAsync( CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await base.InitializeAsync(cancellationToken, progress); await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); InitializeLogging(); RegisterEditorFactory(new EditorFactory(this)); var dte = (DTE) await GetServiceAsync(typeof(DTE)); SolutionService = new SolutionService(dte); Log.Logger.Information("Avalonia Package initialized"); }
static void Main(string[] args) { UpdateSolutionVersionApp app = new UpdateSolutionVersionApp(); Logger logger = app.Logger; ExitCode exitCode = ExitCode.None; try { logger.Info("Application started."); CultureInfo.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB"); Options options = new Options(); Parser.Default.ParseArgumentsStrict(args, options, CommandLineOptions.ArgumentParsingFailed); Connection connection = null; if (string.IsNullOrWhiteSpace(options.ConnectionString)) { connection = new Connection(options.AuthorityUrl, options.OrganizationUrl, options.OrganizationUrlSuffix, options.TenantId, options.ServicePrincipalId, options.ServicePrincipalSecret, options.ConnectionRetries, options.ConnectionTimeout); } else { connection = new Connection(options.ConnectionString, options.ConnectionRetries, options.ConnectionTimeout); } using (CrmServiceContext organizationServiceContext = new CrmServiceContext(connection.OrganizationService)) using (CrmService crmService = new CrmService(organizationServiceContext, connection)) using (SolutionService solutionService = new SolutionService(organizationServiceContext, connection, crmService)) { solutionService.UpdateSolutionVersion(options.SolutionName, options.TimeZone, options.Version); exitCode = ExitCode.Success; } } catch (Exception ex) { exitCode = new ExceptionHandlingService(ex).GetExitCode(); } finally { logger.Info(CultureInfo.InvariantCulture, "Application exited with code: {0}", (int)exitCode); Environment.Exit((int)exitCode); } }
private void InitializeViewModel() { ThreadHelper.ThrowIfNotOnUIThread(); var outputWindow = GetService(typeof(SVsOutputWindow)) as IVsOutputWindow; AssumePresent(outputWindow); var outputService = new OutputWindowOutputService(ConsolePaneId, outputWindow, "Code Connections"); try { var dte = GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE; AssumePresent(dte); var documentsService = new DocumentsService(dte); SubscribeListeners(documentsService); var componentModel = GetService(typeof(SComponentModel)) as IComponentModel; AssumePresent(componentModel); var workspace = componentModel.GetService <VisualStudioWorkspace>(); var roslynService = new RoslynService(workspace).DisposeWith(_disposables); var solutionService = new SolutionService(dte); SubscribeListeners(solutionService); var gitService = new GitService(solutionService).DisposeWith(_disposables); var solutionPersistence = (IVsSolutionPersistence)GetService(typeof(SVsSolutionPersistence)); var solutionSettingsService = new SolutionSettingsService(solutionPersistence); var userSettingsService = new DialogUserSettingsService(CodeConnectionsPackage.UserOptionsDialog ?? throw new InvalidOperationException("User options unavailable")); if (Content is DependencyGraphToolWindowControl content) { content.DataContext = new DependencyGraphToolWindowViewModel(ThreadHelper.JoinableTaskFactory, documentsService, roslynService, gitService, solutionService, outputService, roslynService, solutionSettingsService, userSettingsService) .DisposeWith(_disposables); } } catch (Exception e) { outputService.WriteLine($"Failed to open Code Connections tool window."); outputService.WriteLine($"Error: {e}"); throw; } }
public async Task GetAllAsyncWhenNoSolutionsReturnsEmptyCollection() { //Arrange var mockSolutionRepository = GetDefaultISolutionRepositoryInstance(); var mockUnitOfWork = GetDefaultIUnitOfWorkInstance(); var solutionId = 200; mockSolutionRepository.Setup(r => r.FindById(solutionId)) .Returns(Task.FromResult <Solution>(null)); var service = new SolutionService(mockSolutionRepository.Object, mockUnitOfWork.Object); //Act SolutionResponse result = await service.GetByIdAsync(solutionId); var message = result.Message; //Assert message.Should().Be("Solution not found"); }
public async Task TestCreation() { var code = @"class Test { void Method() { } }"; using (var workspace = await TestWorkspace.CreateCSharpAsync(code)) { var solution = workspace.CurrentSolution; var solutionChecksum = await solution.State.GetChecksumAsync(CancellationToken.None); var map = solution.GetAssetMap(); var sessionId = 0; var storage = new AssetStorage(enableCleanup: false); var source = new MyAssetSource(storage, sessionId, map); var service = new SolutionService(new AssetService(sessionId, storage)); var synched = await service.GetSolutionAsync(solutionChecksum, CancellationToken.None); Assert.Equal(solutionChecksum, await synched.State.GetChecksumAsync(CancellationToken.None)); } }
private async void StartApplicationClicked(object sender, EventArgs e) { if (!Utils.HasInternet) { Utils.Alert_NoInternet(); return; } if (Vendor.BuildType == Enums.AppBuildType.Embedded) { EbLayout.ShowLoader(); try { ISolutionService service = new SolutionService(); ValidateSidResponse response = await service.ValidateSid(Vendor.SolutionURL); if (response != null && response.IsValid) { await service.CreateEmbeddedSolution(response, Vendor.SolutionURL); await Store.SetValueAsync(AppConst.FIRST_RUN, "true"); await App.Navigation.InitializeNavigation(); } } catch (Exception) { Utils.Toast("Unable to finish the request"); } EbLayout.HideLoader(); } else { await Store.SetValueAsync(AppConst.FIRST_RUN, "true"); await App.Navigation.InitializeNavigation(); } }
public async Task <RequestProblemSubmission> RequestSolutionSubmission(SolutionSubmission submission, CancellationToken token) { if (submission == null) { throw new WebArgumentException(nameof(submission), nameof(RequestProblemSubmission), null); } var guid = Guid.NewGuid().ToString(); var path = Path.Combine(Configuration.FileLocation, guid); if (!await ProblemService.Exists(submission.ProblemId, token)) { return new RequestProblemSubmission { Result = SolutionServiceResult.StartOver } } ; var solution = new Solution { Id = guid, ProblemId = submission.ProblemId, TimeStamp = (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds, FileLocation = path, User = User.Identity.Name, SolutionType = submission.SolutionType }; var result = await SolutionService.AddSolutionSet(guid, solution, token); var requestResult = new RequestProblemSubmission { Result = result }; if (result == SolutionServiceResult.Success) { requestResult.Guid = guid; } return(requestResult); }
public SolutionController() { _solutionService = new SolutionService(); }
public HomeController( SystemModuleService SystemModuleService,SolutionService solutionService,IMySession session) { MySession = session; _SystemModuleService = SystemModuleService; _solutionService = solutionService; }