コード例 #1
0
 public SyncService(
     IBackgroundJobClient backgroundJobClient,
     IRealtimeService realtimeService)
 {
     _backgroundJobClient = backgroundJobClient;
     _realtimeService     = realtimeService;
 }
コード例 #2
0
        public static async Task <Attempt <T> > TryGetSnapshotAsync <T>(this IRealtimeService realtimeService, string id)
            where T : IIdentifiable
        {
            T entity = await realtimeService.QuerySnapshots <T>().FirstOrDefaultAsync(e => e.Id == id);

            return(new Attempt <T>(entity != null, entity));
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: daveh551/web-xforge
        /// <summary> Selects the SF projects to clone and clones the projects. </summary>
        public static async Task SelectProjectsAndClone(IWebHost webHost, string mode)
        {
            string           cloneSubset   = Environment.GetEnvironmentVariable("CLONE_SET");
            HashSet <string> projectSubset = null;

            try
            {
                if (cloneSubset != null)
                {
                    projectSubset = new HashSet <string>(cloneSubset.Split(' '));
                }
            }
            catch
            {
                Log($"There was a problem parsing the CLONE_SET SF project ids "
                    + $"environment variable. Rethrowing.");
                throw;
            }
            IRealtimeService realtimeService = webHost.Services.GetService <IRealtimeService>();
            List <SFProject> projectsToClone = realtimeService.QuerySnapshots <SFProject>().ToList <SFProject>();

            if (projectSubset != null)
            {
                projectsToClone.RemoveAll((SFProject sfProject) => !projectSubset.Contains(sfProject.Id));
                string ids   = string.Join(' ', projectsToClone.Select((SFProject sfProject) => sfProject.Id));
                int    count = projectsToClone.Count;
                Log($"Only working on the subset of projects (count {count}) with these SF project ids: {ids}");
            }

            ICloneAllService cloneTool = webHost.Services.GetService <ICloneAllService>();
            await cloneTool.CloneSFProjects(mode, projectsToClone);
        }
コード例 #4
0
 public UserService(IRealtimeService realtimeService, IOptions <SiteOptions> siteOptions,
                    IRepository <UserSecret> userSecrets, IAuthService authService, IProjectService projectService)
 {
     _realtimeService = realtimeService;
     _siteOptions     = siteOptions;
     _userSecrets     = userSecrets;
     _authService     = authService;
     _projectService  = projectService;
 }
コード例 #5
0
 public SFTextCorpusFactory(IOptions <DataAccessOptions> dataAccessOptions, IRealtimeService realtimeService,
                            IOptions <SiteOptions> siteOptions, IFileSystemService fileSystemService)
 {
     _dataAccessOptions = dataAccessOptions;
     _mongoClient       = new MongoClient(dataAccessOptions.Value.ConnectionString);
     _realtimeService   = realtimeService;
     _siteOptions       = siteOptions;
     _fileSystemService = fileSystemService;
 }
コード例 #6
0
 public ProjectService(IRealtimeService realtimeService, IOptions <SiteOptions> siteOptions,
                       IAudioService audioService, IRepository <TSecret> projectSecrets, IFileSystemService fileSystemService)
 {
     RealtimeService   = realtimeService;
     SiteOptions       = siteOptions;
     _audioService     = audioService;
     ProjectSecrets    = projectSecrets;
     FileSystemService = fileSystemService;
 }
コード例 #7
0
ファイル: SyncAllService.cs プロジェクト: daveh551/web-xforge
 public SyncAllService(Func <IParatextSyncRunner> syncRunnerFactory, IRealtimeService realtimeService,
                       IParatextService paratextService,
                       IRepository <UserSecret> userSecretRepo, IProgramLogger logger)
 {
     _syncRunnerFactory = syncRunnerFactory;
     _realtimeService   = realtimeService;
     _paratextService   = paratextService;
     _userSecretRepo    = userSecretRepo;
     _logger            = logger;
 }
コード例 #8
0
        public static async Task <T> GetSnapshotAsync <T>(this IRealtimeService realtimeService, string id)
            where T : IIdentifiable
        {
            Attempt <T> attempt = await realtimeService.TryGetSnapshotAsync <T>(id);

            if (attempt.Success)
            {
                return(attempt.Result);
            }
            return(default(T));
        }
コード例 #9
0
 public CloneAllService(Func <IPTDDSyncRunner> syncRunnerFactory, IRealtimeService realtimeService,
                        IOptions <SiteOptions> siteOptions, IParatextService paratextService, IRepository <UserSecret> userSecretRepo,
                        IFileSystemService fileSystemService)
 {
     _syncRunnerFactory = syncRunnerFactory;
     _realtimeService   = realtimeService;
     _siteOptions       = siteOptions;
     _paratextService   = paratextService;
     _userSecretRepo    = userSecretRepo;
     _fileSystemService = fileSystemService;
 }
コード例 #10
0
 public ShitheadGameEngine(
     CardsDbContext dbContext,
     IDeckFactory deckFactory,
     IShitheadPileLogic shitheadPileLogic,
     IRealtimeService realtimeService)
 {
     _dbContext         = dbContext;
     _deckFactory       = deckFactory;
     _shitheadPileLogic = shitheadPileLogic;
     _realtimeService   = realtimeService;
 }
コード例 #11
0
 public TaskRunnerActor(
     ILoggerFactory loggerFactory,
     IProvider persistenceProvider,
     IRealtimeService realtimeService,
     IProcessFactory processFactory) :
     base(loggerFactory, persistenceProvider)
 {
     _realtimeService = realtimeService;
     _processFactory  = processFactory;
     _slidingLog      = new SlidingLog(1000);
 }
コード例 #12
0
 public ProjectImportedHandler(IOptions <ApplicationOptions> applicationOptions,
                               IOptions <VSTSServiceOptions> vstsOptions,
                               IOptions <FakeAccountServiceOptions> vstsFakeOptions,
                               Func <ConfigurationManagementService, IProjectHandlerService> projectHandlerService,
                               IHttpClientWrapperService httpClientWrapperService,
                               IRealtimeService realtimeService) : base(httpClientWrapperService, applicationOptions, realtimeService)
 {
     _applicationOptions       = applicationOptions;
     _vstsOptions              = vstsOptions;
     _vstsFakeOptions          = vstsFakeOptions;
     _projectHandlerService    = projectHandlerService;
     _httpClientWrapperService = httpClientWrapperService;
 }
コード例 #13
0
        public BaseHandler(IHttpClientWrapperService httpClientWrapperService,
                           IOptions <ApplicationOptions> applicationOptions,
                           IRealtimeService realtimeService)
        {
            _httpClientWrapperService = httpClientWrapperService;
            _applicationOptions       = applicationOptions;
            this._realtimeService     = realtimeService;

            var oAuthToken = _httpClientWrapperService.GetTokenFromClientCredentials($"{_applicationOptions.Value.Url}/connect/token", _applicationOptions.Value.ClientId, _applicationOptions.Value.ClientSecret, _applicationOptions.Value.Scope).GetAwaiter().GetResult();

            InternalAuthCredentials        = new HttpClientWrapperAuthorizationModel();
            InternalAuthCredentials.Schema = "Bearer";
            InternalAuthCredentials.Value  = oAuthToken.access_token;
        }
 public ProjectFeatureServiceCreatedHandler(IOptions <VSTSServiceOptions> vstsOptions,
                                            IOptions <FakeAccountServiceOptions> fakeAccountOptions,
                                            IOptions <ApplicationOptions> applicationOptions,
                                            Func <ConfigurationManagementService, IProjectServiceHandlerService> projectServiceHandlerService,
                                            IPipelineSpaceManagerService pipelineSpaceManagerService,
                                            IHttpClientWrapperService httpClientWrapperService,
                                            IRealtimeService realtimeService) : base(httpClientWrapperService, applicationOptions, realtimeService)
 {
     _vstsOptions                  = vstsOptions;
     _applicationOptions           = applicationOptions;
     _fakeAccountOptions           = fakeAccountOptions;
     _projectServiceHandlerService = projectServiceHandlerService;
     _pipelineSpaceManagerService  = pipelineSpaceManagerService;
     _httpClientWrapperService     = httpClientWrapperService;
 }
コード例 #15
0
 public ParatextSyncRunner(IRepository <UserSecret> userSecrets, IRepository <SFProjectSecret> projectSecrets,
                           ISFProjectService projectService, IEngineService engineService, IParatextService paratextService,
                           IRealtimeService realtimeService, IDeltaUsxMapper deltaUsxMapper, IParatextNotesMapper notesMapper,
                           ILogger <ParatextSyncRunner> logger)
 {
     _userSecrets     = userSecrets;
     _projectSecrets  = projectSecrets;
     _projectService  = projectService;
     _engineService   = engineService;
     _paratextService = paratextService;
     _realtimeService = realtimeService;
     _logger          = logger;
     _deltaUsxMapper  = deltaUsxMapper;
     _notesMapper     = notesMapper;
 }
コード例 #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ObjectMigrator" /> class.
 /// </summary>
 /// <param name="dataAccessOptions">The data access options.</param>
 /// <param name="deltaUsxMapper">The delta USX mapper.</param>
 /// <param name="mongoClient">The mongo client.</param>
 /// <param name="paratextService">The paratext service.</param>
 /// <param name="projectService">The project service.</param>
 /// <param name="realtimeService">The realtime service.</param>
 /// <param name="userSecrets">The user secrets repository.</param>
 public ObjectMigrator(
     IOptions <DataAccessOptions> dataAccessOptions,
     IDeltaUsxMapper deltaUsxMapper,
     IMongoClient mongoClient,
     IParatextService paratextService,
     ISFProjectService projectService,
     IRealtimeService realtimeService,
     IRepository <UserSecret> userSecrets)
 {
     this._database        = mongoClient.GetDatabase(dataAccessOptions.Value.MongoDatabaseName);
     this._deltaUsxMapper  = deltaUsxMapper;
     this._paratextService = paratextService;
     this._projectService  = projectService;
     this._realtimeService = realtimeService;
     this._userSecrets     = userSecrets;
 }
コード例 #17
0
ファイル: PtdaSyncRunner.cs プロジェクト: daveh551/web-xforge
 public PtdaSyncRunner(IOptions <SiteOptions> siteOptions, IRepository <UserSecret> userSecrets,
                       IRepository <SFProjectSecret> projectSecrets, ISFProjectService projectService, IEngineService engineService,
                       IParatextService paratextService, IRealtimeService realtimeService, IFileSystemService fileSystemService,
                       IDeltaUsxMapper deltaUsxMapper, IParatextNotesMapper notesMapper, ILogger <PtdaSyncRunner> logger)
 {
     _siteOptions       = siteOptions;
     _userSecrets       = userSecrets;
     _projectSecrets    = projectSecrets;
     _projectService    = projectService;
     _engineService     = engineService;
     _paratextService   = paratextService;
     _realtimeService   = realtimeService;
     _fileSystemService = fileSystemService;
     _logger            = logger;
     _deltaUsxMapper    = deltaUsxMapper;
     _notesMapper       = notesMapper;
 }
コード例 #18
0
 public ParatextSyncRunner(IOptions <SiteOptions> siteOptions, IRepository <UserEntity> users,
                           IRepository <SyncJobEntity> jobs, IRepository <SFProjectEntity> projects, IRepository <TextEntity> texts,
                           IEngineService engineService, IParatextService paratextService, IRealtimeService realtimeService,
                           IFileSystemService fileSystemService, ILogger <ParatextSyncRunner> logger)
 {
     _siteOptions       = siteOptions;
     _users             = users;
     _jobs              = jobs;
     _projects          = projects;
     _texts             = texts;
     _engineService     = engineService;
     _paratextService   = paratextService;
     _realtimeService   = realtimeService;
     _fileSystemService = fileSystemService;
     _logger            = logger;
     _deltaUsxMapper    = new DeltaUsxMapper();
 }
コード例 #19
0
 public SFProjectService(IRealtimeService realtimeService, IOptions <SiteOptions> siteOptions,
                         IAudioService audioService, IEmailService emailService, IRepository <SFProjectSecret> projectSecrets,
                         ISecurityService securityService, IFileSystemService fileSystemService, IEngineService engineService,
                         ISyncService syncService, IParatextService paratextService, IRepository <UserSecret> userSecrets,
                         IRepository <TranslateMetrics> translateMetrics, IStringLocalizer <SharedResource> localizer,
                         ITransceleratorService transceleratorService)
     : base(realtimeService, siteOptions, audioService, projectSecrets, fileSystemService)
 {
     _engineService         = engineService;
     _syncService           = syncService;
     _paratextService       = paratextService;
     _userSecrets           = userSecrets;
     _translateMetrics      = translateMetrics;
     _emailService          = emailService;
     _securityService       = securityService;
     _localizer             = localizer;
     _transceleratorService = transceleratorService;
 }
コード例 #20
0
        public ParatextService(IWebHostEnvironment env, IOptions <ParatextOptions> paratextOptions,
                               IRepository <UserSecret> userSecretRepository, IRealtimeService realtimeService,
                               IExceptionHandler exceptionHandler, IOptions <SiteOptions> siteOptions, IFileSystemService fileSystemService,
                               ILogger <ParatextService> logger, IJwtTokenHelper jwtTokenHelper, IParatextDataHelper paratextDataHelper,
                               IInternetSharedRepositorySourceProvider internetSharedRepositorySourceProvider,
                               ISFRestClientFactory restClientFactory)
        {
            _paratextOptions      = paratextOptions;
            _userSecretRepository = userSecretRepository;
            _realtimeService      = realtimeService;
            _exceptionHandler     = exceptionHandler;
            _siteOptions          = siteOptions;
            _fileSystemService    = fileSystemService;
            _logger             = logger;
            _jwtTokenHelper     = jwtTokenHelper;
            _paratextDataHelper = paratextDataHelper;
            _internetSharedRepositorySourceProvider = internetSharedRepositorySourceProvider;
            _restClientFactory = restClientFactory;

            _httpClientHandler = new HttpClientHandler();
            _registryClient    = new HttpClient(_httpClientHandler);
            if (env.IsDevelopment() || env.IsEnvironment("DevelopmentBeta") || env.IsEnvironment("Testing") || env.IsEnvironment("TestingBeta"))
            {
                _httpClientHandler.ServerCertificateCustomValidationCallback
                    = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
                // This should be paratext-qa.thedigitalbiblelibrary.org, but it's broken as of 2021-04 and
                // qa.thedigitalbiblelibrary.org should be just as good, at least for the time being.
                _dblServerUri               = "https://qa.thedigitalbiblelibrary.org/";
                _registryServerUri          = "https://registry-dev.paratext.org";
                _registryClient.BaseAddress = new Uri(_registryServerUri);
                _sendReceiveServerUri       = InternetAccess.uriDevelopment;
            }
            else
            {
                _registryClient.BaseAddress = new Uri(_registryServerUri);
            }
            _registryClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            ScrTextCollection = new LazyScrTextCollection();
            HgWrapper         = new HgWrapper();

            SharingLogicWrapper = new SharingLogicWrapper();
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
        }
コード例 #21
0
 public SFTextCorpusFactory(IOptions <DataAccessOptions> dataAccessOptions, IRealtimeService realtimeService)
 {
     _dataAccessOptions = dataAccessOptions;
     _mongoClient       = new MongoClient(dataAccessOptions.Value.ConnectionString);
     _realtimeService   = realtimeService;
 }
コード例 #22
0
 public TestProjectService(IRealtimeService realtimeService, IOptions <SiteOptions> siteOptions,
                           IAudioService audioService, IRepository <TestProjectSecret> projectSecrets,
                           IFileSystemService fileSystemService)
     : base(realtimeService, siteOptions, audioService, projectSecrets, fileSystemService)
 {
 }
コード例 #23
0
ファイル: MainWindow.xaml.cs プロジェクト: Flayed/ryora
        public MainWindow()
        {
            InitializeComponent();
            MouseMoveThrottleTimer.Start();
            MousePointer.Source = GetMousePointerImage();
            RealtimeService = new UdpRealtimeService(Channel);
            ScreenshotService = new ScreenshotService();

            RealtimeService.ClientResolutionChanged += (o, e) =>
            {
                var ea = e as ClientResolutionChangedEventArgs;
                if (ea?.ScreenWidth == 0 || ea?.ScreenHeight == 0) return;
                ScreenshotService.SetBitmapSize(ea.ScreenWidth, ea.ScreenHeight);
            };

            Closing += async (o, e) =>
            {
                await RealtimeService.EndConnection(Channel);
            };

            Timer imageTimer = new Timer(ImageTimerTick);
            imageTimer.Elapsed += (s, e) =>
            {
                try
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        var images = RealtimeService.CompletedImages.ToList();
                        if (!images.Any()) return;
                        var source = ScreenshotService.ProcessBitmaps(images);
                        Screenshot.Source = source;
                    });
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            };
            imageTimer.Start();

            RealtimeService.Disconnect += (s, reconnect) =>
            {
                if (reconnect)
                {
                    Task.Run(async () =>
                    {
                        await
                            RealtimeService.StartConnection(Channel, ScreenshotService.ScreenWidth,
                                ScreenshotService.ScreenHeight);
                    });
                }
            };

            RealtimeService.MouseMove += (o, e) =>
            {
                if (MouseMoveThrottleTimer.ElapsedMilliseconds < MouseMoveThrottle) return;
                MouseMoveThrottleTimer.Restart();
                var ea = e as MouseMoveEventArgs;
                if (ea == null) return;
                Application.Current.Dispatcher.Invoke(() =>
                {
                    if (!Screenshot.IsInitialized) return;
                    double tx = Screenshot.ActualWidth / ea.ScreenWidth;
                    double ty = Screenshot.ActualHeight / ea.ScreenHeight;

                    double x = ((double)ea.X * tx - (double)Screenshot.ActualWidth / 2) + 5;
                    double y = ((double)ea.Y * ty - (double)Screenshot.ActualHeight / 2) + 9;

                    if (!MousePointer.IsVisible) MousePointer.Visibility = Visibility.Visible;

                    TranslateTransform trans = new TranslateTransform();
                    MousePointer.RenderTransform = trans;
                    DoubleAnimation anim1 = new DoubleAnimation(LastPoint.Y, y, TimeSpan.FromMilliseconds(100));
                    DoubleAnimation anim2 = new DoubleAnimation(LastPoint.X, x, TimeSpan.FromMilliseconds(100));
                    trans.BeginAnimation(TranslateTransform.YProperty, anim1);
                    trans.BeginAnimation(TranslateTransform.XProperty, anim2);
                    LastPoint = new System.Windows.Point(x, y);
                });
            };

            RealtimeService.Sharing += (o, isSharing) =>
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    if (!isSharing)
                    {
                        PausedOverlay.Visibility = Visibility.Visible;
                        PausedText.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        PausedOverlay.Visibility = Visibility.Hidden;
                        PausedText.Visibility = Visibility.Hidden;
                    }

                });
            };

            MouseMove += async (s, e) => { await MouseEvent(s, e); };
            MouseDown += async (s, e) => { await MouseEvent(s, e); };
            MouseUp += async (s, e) => { await MouseEvent(s, e); };
            MouseWheel += async (s, e) => { await MouseEvent(s, e, e.Delta); };

            KeyDown += async (s, e) => { await KeyboardEvent(true, e); };
            KeyUp += async (s, e) => { await KeyboardEvent(false, e); };

            Task.Run(async () =>
            {
                await RealtimeService.StartConnection(Channel, ScreenshotService.ScreenWidth, ScreenshotService.ScreenHeight);
                Application.Current.Dispatcher.Invoke(() =>
                {
                    Title = $"Technician View [Connection Type: {RealtimeService.Transport}]";
                });
            });
        }
コード例 #24
0
 /// <summary>
 /// Constructor method.
 /// </summary>
 public RealtimeController(IRealtimeService realtimeService)
 {
     _realtimeService = realtimeService ?? throw new ArgumentNullException(nameof(realtimeService), nameof(RealtimeController));
 }
コード例 #25
0
 public MachineAuthorizationHandler(IRealtimeService realtimeService)
 {
     _realtimeService = realtimeService;
 }
コード例 #26
0
 public TextService(IJsonApiContext jsonApiContext, IMapper mapper, IUserAccessor userAccessor,
                    IRepository <TextEntity> entities, IRepository <SFProjectEntity> projects, IRealtimeService realtimeService)
     : base(jsonApiContext, mapper, userAccessor, entities, projects)
 {
     _realtimeService = realtimeService;
 }
コード例 #27
0
 public SFBuildHandler(IRealtimeService realtimeService)
 {
     _realtimeService = realtimeService;
 }