示例#1
0
        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);
            }
        }
示例#3
0
        public void TransparentTest()
        {
            Solution solution = SolutionService.NewRandom(10);
            Solution mutated  = new MutatorTransparentService().Mutate(solution);

            Assert.AreEqual(solution, mutated);
        }
示例#4
0
        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);
        }
示例#6
0
        public void Dispose()
        {
            SolutionService.Save();
            SolutionService.Close();

            _pathContext.Dispose();
        }
示例#7
0
        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);
            }
        }
示例#8
0
        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);
        }
示例#10
0
文件: Program.cs 项目: dmikov/R4T4
 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;
 }
示例#11
0
            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));
            }
示例#12
0
        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);
        }
示例#13
0
        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);
        }
示例#14
0
        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);
        }
示例#17
0
        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);
            }
        }
示例#18
0
 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();
     }
 }
示例#19
0
 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;
 }
示例#20
0
        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);
            }
        }
示例#21
0
        //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));
        }
示例#22
0
        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);
        }
示例#23
0
        /// <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);
        }
示例#24
0
        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");
        }
示例#25
0
        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);
            }
        }
示例#26
0
        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;
            }
        }
示例#27
0
            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");
            }
示例#28
0
        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;
 }