Exemple #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        public OverviewViewModel()
        {
            mClient = CreateClient();

            Tree = new TreeViewModel();
            Tree.PropertyChanged += (o, args) => OnPropertyChangedAll();

            if (!string.IsNullOrEmpty(Properties.Settings.Default.AssemblyPath))
            {
                LoadAssembly(Properties.Settings.Default.AssemblyPath);
            }

            InstalledRevitVersions = RevitHelper.GetInstalledRevitApplications();

            Task.Run(() => mClient.StartRunnerStatusWatcher(CheckStatus, CancellationToken.None));
        }
Exemple #2
0
        /// <summary>
        /// Start a expolre request.
        /// </summary>
        public async Task <ExploreResponse> ExploreAssemblyAsync(string aAssemblyPath, string aRevitVersion, CancellationToken aCancellationToken)
        {
            ExploreResponse response = null;
            ExploreRequest  request  = new ExploreRequest {
                Timestamp     = DateTime.Now,
                Id            = GenerateId(),
                ClientName    = mClientName,
                ClientVersion = mClientVersion,
                AssemblyPath  = aAssemblyPath
            };

            RevitHelper.StartRevit(aRevitVersion);
            bool isRunnerAvailable = await IsRunnerAvailable(aCancellationToken);

            if (isRunnerAvailable)
            {
                string requestFilePath = FileNames.ExploreRequestFilePath(request.Id);
                JsonHelper.ToFile(requestFilePath, request);

                var responseDirectoryPath = await GetResponseDirectory(request.Id);

                if (Directory.Exists(responseDirectoryPath))
                {
                    while (response == null && !aCancellationToken.IsCancellationRequested)
                    {
                        string responseFile = Path.Combine(responseDirectoryPath, FileNames.ExploreResponseFileName);
                        response = JsonHelper.FromFile <ExploreResponse>(responseFile);

                        if (response == null)
                        {
                            await Task.Delay(500, aCancellationToken);
                        }
                    }
                }
                else
                {
                    FileHelper.DeleteWithLock(requestFilePath);
                }
            }

            return(response);
        }
Exemple #3
0
        /// <summary>
        /// Start a test run request.
        /// </summary>
        public async Task StartTestRunAsync(RunRequest aRequest, string aRevitVersion, Action <ProcessResult> aCallback, CancellationToken aCancellationToken)
        {
            aRequest.Timestamp     = DateTime.Now;
            aRequest.Id            = GenerateId();
            aRequest.ClientName    = mClientName;
            aRequest.ClientVersion = mClientVersion;

            var  revit             = RevitHelper.StartRevit(aRevitVersion);
            bool isRunnerAvailable = await IsRunnerAvailable(aCancellationToken);

            if (isRunnerAvailable)
            {
                string requestFilePath = FileNames.RunRequestFilePath(aRequest.Id);
                JsonHelper.ToFile(requestFilePath, aRequest);

                var responseDirectoryPath = await GetResponseDirectory(aRequest.Id);

                if (Directory.Exists(responseDirectoryPath))
                {
                    bool run = true;

                    while (run && !aCancellationToken.IsCancellationRequested)
                    {
                        var runResult = JsonHelper.FromFile <RunResult>(Path.Combine(responseDirectoryPath, FileNames.RunResult));

                        if (runResult != null)
                        {
                            bool          isCompleted = runResult.State == TestState.Passed || runResult.State == TestState.Failed;
                            ProcessResult result      = new ProcessResult(runResult, isCompleted);

                            aCallback(result);

                            run = !isCompleted;

                            if (run)
                            {
                                await Task.Delay(500, aCancellationToken);
                            }
                        }
                    }
                }
                else
                {
                    FileHelper.DeleteWithLock(requestFilePath);
                    aCallback(new ProcessResult(null, true)
                    {
                        Message = "Tests not executed! Service may not be running."
                    });
                }

                if (revit.IsNew)
                {
                    RevitHelper.KillRevit(revit.ProcessId);
                }
            }
            else
            {
                aCallback(new ProcessResult(null, true)
                {
                    Message = "Runner not available!"
                });
            }
        }