コード例 #1
0
        /// <summary>
        /// Construct a spider object. The options parameter
        /// specifies the options for this spider. The report
        /// parameter specifies the class that the spider is to
        /// report progress to.
        /// </summary>
        /// <param name="options">The configuration options for this spider.</param>
        /// <param name="report">A SpiderReportable class to report progress to</param>
        public Spider(SpiderOptions options, SpiderReportable report)
        {
            this.options = options;
            this.report  = report;

            this.workloadManager = (WorkloadManager)Assembly.GetExecutingAssembly().CreateInstance(this.options.WorkloadManager);

            this.workloadManager.Init(this);
            report.Init(this);

            // add filters
            if (options.Filter != null)
            {
                foreach (String name in options.Filter)
                {
                    SpiderFilter filter = (SpiderFilter)Assembly.GetExecutingAssembly().CreateInstance(name);
                    if (filter == null)
                    {
                        throw new SpiderException("Invalid filter specified: " + name);
                    }
                    this.filters.Add(filter);
                }
            }

            // perform startup
            if (String.Compare(options.Startup, SpiderOptions.STARTUP_RESUME) == 0)
            {
                this.workloadManager.Resume();
            }
            else
            {
                this.workloadManager.Clear();
            }
        }
コード例 #2
0
        public void Test2()
        {
            var testClientManager = new TestClientManager();
            var qwer = "qwer";
            var uiop = "uiop";

            testClientManager.AddClient(new TestHost(qwer), new TestClient(qwer));
            testClientManager.AddClient(new TestHost(uiop), new TestClient(uiop));
            var wlm  = new WorkloadManager();
            var yolo = wlm.MulticastAsync(new TestAbstractRequestInstructions(new TestRequest(new TestHost("requestASDF")), TimeSpan.FromMilliseconds(10000),
                                                                              TestResponseTransformer, Guid.NewGuid(), testClientManager), new List <IHost> {
                new TestHost(qwer), new TestHost(uiop)
            },
                                          new AscendingSortAggregator <string>()).Result;

            Assert.Equal(yolo.Count, 2);
            Assert.True(yolo.Contains($"{typeof(TestHost).FullName}_sklfjlksdjklflksdkflsldf_{uiop}_ResponseTransformed"));
            Assert.True(yolo.Contains($"{typeof(TestHost).FullName}_sklfjlksdjklflksdkflsldf_{qwer}_ResponseTransformed"));
        }
コード例 #3
0
        public void Test1()
        {
            var main          = new WorkloadManager();
            var clientManager = new HttpClientManager();

            clientManager.AddClient(new HttpHost(_client.BaseAddress.AbsoluteUri), new SgHttpClient(_client));
            var result = main.MulticastAsync(
                new HttpRequestInstructions <string>(new HttpRequestMessageWrapper(), TimeSpan.FromSeconds(30),
                                                     ResponseTransformer, Guid.NewGuid()),
                new List <IHost>()
            {
                new HttpHost("http://localhost:1111"),
                new HttpHost("http://localhost:51073"),
                new HttpHost("http://localhost:51073"),
                new HttpHost("http://localhost:1111"),
            }, new AscendingSortAggregator <string>()).Result;

            Assert.Equal(2, result.Count);
            Assert.True(result.All(x => x == "All is well"));
        }
コード例 #4
0
        public MainManager()
        {
            Database.SetInitializer(new MigrateDatabaseToLatestVersion <Context, Configuration>());
            _departmentsManager = new DepartmentsManager {
                SetWaiting = status => Waiting = status
            };
            _disciplinesManager = new DisciplinesManager {
                SetWaiting = status => Waiting = status
            };
            _employeesManager = new EmployeesManager {
                SetWaiting = status => Waiting = status
            };
            _facultiesManager = new FacultiesManager {
                SetWaiting = status => Waiting = status
            };
            _groupsManager = new GroupsManager {
                SetWaiting = status => Waiting = status
            };
            _specialitiesManager = new SpecialitiesManager {
                SetWaiting = status => Waiting = status
            };
            _disciplineWorkloadManager = new DisciplineWorkloadManager {
                SetWaiting = status => Waiting = status
            };
            _workloadManager = new WorkloadManager {
                SetWaiting = status => Waiting = status
            };

            ShowSemestersDialog        = new RelayCommand(OpenSettings);
            ImportCommand              = new RelayCommand(Import);
            ExportCommand              = new RelayCommand(Export);
            ImportSettingsCommand      = new RelayCommand(ImportSettings);
            ExportSettingsCommand      = new RelayCommand(ExportSettings);
            ShowSpecialPositionsDialog = new RelayCommand(ShowSpecialPositions);
            RefreshTabs();
        }
コード例 #5
0
        /// <summary>
        /// Construct a spider object. The options parameter
        /// specifies the options for this spider. The report
        /// parameter specifies the class that the spider is to
        /// report progress to.
        /// </summary>
        /// <param name="options">The configuration options for this spider.</param>
        /// <param name="report">A SpiderReportable class to report progress to</param>
        public Spider(SpiderOptions options, SpiderReportable report)
        {
            this.options = options;
            this.report = report;

            this.workloadManager = (WorkloadManager)Assembly.GetExecutingAssembly().CreateInstance(this.options.WorkloadManager);

            this.workloadManager.Init(this);
            report.Init(this);

            // add filters
            if (options.Filter != null)
            {
                foreach (String name in options.Filter)
                {
                    SpiderFilter filter = (SpiderFilter)Assembly.GetExecutingAssembly().CreateInstance(name);
                    if (filter == null)
                        throw new SpiderException("Invalid filter specified: " + name);
                    this.filters.Add(filter);
                }
            }

            // perform startup
            if (String.Compare(options.Startup, SpiderOptions.STARTUP_RESUME) == 0)
            {
                this.workloadManager.Resume();
            }
            else
            {
                this.workloadManager.Clear();
            }
        }