Exemple #1
0
        public void StartWizard(Experiment experimentToBeBenchmarked)
        {
            if (experimentToBeBenchmarked == null)
            {
                throw new InvalidOperationException("Benchmark cannot be run with null experiment.");
            }

            //if webservice is set access webservice, and load benchmarks from there... on OnRetrieveListOfBenchmarksCallCompleted will load load also local benchmarks
            //and discover those that are online contests
            if (m_settings.WebserviceAddress != null)
            {
                m_webService = new WebserviceAccessor(m_settings.WebserviceAddress, true);

                if (m_webService != null)
                {
                    var listOfContestsCallback = new Callback <ListOfContestsResponse>();
                    listOfContestsCallback.CallCompleted += OnRetrieveListOfBenchmarksCallCompleted;
                    m_webService.RetrieveListOfContests(listOfContestsCallback);
                }
                else
                {
                    //load only local benchmarks
                    Benchmarks = BenchmarkLoader.LoadBenchmarksInfo(BenchmarksDirectory);
                }
            }
            else
            {
                //load only local benchmarks
                Benchmarks = BenchmarkLoader.LoadBenchmarksInfo(BenchmarksDirectory);
            }
            ExperimentToBeBenchmarked = experimentToBeBenchmarked;
        }
Exemple #2
0
        /// <summary>
        /// Called when [retrieve list of benchmarks call has been completed].
        /// It adds online contests to the list of Benchmarks.
        /// The contests that has been already downloaded and thus were loaded from local directery
        /// get their link to website updated and are marked as the online contests (so that user can compete in them)
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="responseArgs">The <see cref="TraceLab.Core.WebserviceAccess.CallCompletedEventArgs&lt;TraceLab.Core.WebserviceAccess.ListOfContestsResponse&gt;"/> instance containing the event data.</param>
        private void OnRetrieveListOfBenchmarksCallCompleted(object sender, CallCompletedEventArgs <ListOfContestsResponse> responseArgs)
        {
            //local Benchmarks has been loaded already
            var localBenchmarks     = BenchmarkLoader.LoadBenchmarksInfo(BenchmarksDirectory);;
            var newOnlineBenchmarks = new List <Benchmark>();

            if (responseArgs.Response.Status == ResponseStatus.STATUS_SUCCESS)
            {
                List <Contest> contests = responseArgs.Response.ListOfContests;

                foreach (Contest contest in contests)
                {
                    //assuming the joomla com_jtracelab components is used, determine the link to contest website
                    string joomlaSiteRootUrl = m_settings.WebserviceAddress.Substring(0, m_settings.WebserviceAddress.IndexOf("administrator"));
                    string linkToContest     = JoomlaLinks.GetContestWebpageLink(joomlaSiteRootUrl, contest.ContestIndex);

                    //check if there is already local benchmark with the same guid
                    var benchmark = localBenchmarks.Find((b) => { return(b.BenchmarkInfo.Id.Equals(contest.ContestGUID)); });
                    if (benchmark == null)
                    {
                        //if benchmark has not been found create new benchmark (note, its template component is empty at this moment)
                        var newOnlineBenchmark = new Benchmark(contest, linkToContest, BenchmarksDirectory);
                        newOnlineBenchmarks.Add(newOnlineBenchmark);
                    }
                    else
                    {
                        //if found, only update the link to website
                        benchmark.BenchmarkInfo.WebPageLink = new Uri(linkToContest);
                        //mark it as online contest so that wizard now if it should give option to user to publish results
                        benchmark.IsOnlineContest = true;
                    }
                }

                //all new benchmarks add to total list of benchmarks
                localBenchmarks.AddRange(newOnlineBenchmarks);
            }
            else
            {
                //log the error, and continue
                string error = String.Format(Messages.RetrievingListOfContestsFailedWarning, responseArgs.Response.ErrorMessage);
                NLog.LogManager.GetCurrentClassLogger().Warn(error);
                ErrorMessage = error;
            }

            Benchmarks = localBenchmarks;
        }