示例#1
0
 public virtual TEntity FirstOrDefault(object id)
 {
     return(AsyncUtil.RunSync(() => FirstOrDefaultAsync(id)));
 }
 /// <summary>
 /// Retrieve Jobcodes.
 /// </summary>
 /// <remarks>
 /// Retrieves a list of all jobcodes associated with your company,
 /// with optional filters to narrow down the results.
 /// </remarks>
 /// <param name="filter">
 /// An instance of the <see cref="JobcodeFilter"/> class, for narrowing down the results.
 /// </param>
 /// <returns>
 /// An enumerable set of <see cref="Jobcode"/> objects, along with an output
 /// instance of the <see cref="ResultsMeta"/> class containing additional data.
 /// </returns>
 public (IList <Jobcode>, ResultsMeta) GetJobcodes(
     JobcodeFilter filter)
 {
     return(AsyncUtil.RunSync(() => GetJobcodesAsync(filter)));
 }
 /// <summary>
 /// Create Jobcodes.
 /// </summary>
 /// <remarks>
 /// Add one or more jobcodes to your company.
 /// </remarks>
 /// <param name="jobcodes">
 /// The set of <see cref="Jobcode"/> objects to be created.
 /// </param>
 /// <returns>
 /// The set of the <see cref="Jobcode"/> objects that were created, along with
 /// an output instance of the <see cref="ResultsMeta"/> class containing additional data.
 /// </returns>
 public (IList <Jobcode>, ResultsMeta) CreateJobcodes(IEnumerable <Jobcode> jobcodes)
 {
     return(AsyncUtil.RunSync(() => CreateJobcodesAsync(jobcodes)));
 }
        public void InitializeStateExecutionServices(long accountId, byte[] secretKey, Func <long, IStateTransactionsService, IStateClientCryptoService, CancellationToken, IUpdater> updaterFactory = null)
        {
            lock (_statePersistencyItems)
            {
                if (_statePersistencyItems.ContainsKey(accountId))
                {
                    _logger.Info($"[{accountId}]: Account with id {accountId} already registered at StatePersistency");
                    return;
                }

                _logger.Info($"[{accountId}]: {nameof(InitializeStateExecutionServices)} for account with id {accountId}");

                try
                {
                    IWitnessPackagesProvider  packetsProvider       = _witnessPackagesProviderRepository.GetInstance(_restApiConfiguration.WitnessProviderName);
                    IStateTransactionsService transactionsService   = ActivatorUtilities.CreateInstance <StateTransactionsService>(_serviceProvider);
                    IStateClientCryptoService clientCryptoService   = ActivatorUtilities.CreateInstance <StateClientCryptoService>(_serviceProvider);
                    IWalletSynchronizer       walletSynchronizer    = ActivatorUtilities.CreateInstance <StateWalletSynchronizer>(_serviceProvider);
                    StatePacketsExtractor     statePacketsExtractor = ActivatorUtilities.CreateInstance <StatePacketsExtractor>(_serviceProvider);

                    CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();

                    packetsProvider.Initialize(accountId, cancellationTokenSource.Token);
                    clientCryptoService.Initialize(secretKey);
                    transactionsService.AccountId = accountId;
                    ulong lastBlockHeight = AsyncUtil.RunSync(() => _gatewayService.GetLastBlockHeight(ConfidentialAssetsHelper.GetPublicKey(Ed25519.SecretKeyFromSeed(secretKey))));
                    transactionsService.Initialize(clientCryptoService, lastBlockHeight);
                    transactionsService.PipeOutTransactions.LinkTo(_gatewayService.PipeInTransactions);
                    statePacketsExtractor.Initialize(clientCryptoService);
                    statePacketsExtractor.AccountId = accountId;

                    IUpdater updater = updaterFactory != null?updaterFactory(accountId, transactionsService, clientCryptoService, cancellationTokenSource.Token) : CreateStateUpdater(accountId, transactionsService, clientCryptoService, cancellationTokenSource.Token);

                    walletSynchronizer.Initialize(accountId, clientCryptoService);

                    packetsProvider.PipeOut.LinkTo(statePacketsExtractor.PipeIn);
                    statePacketsExtractor.PipeOutPackets.LinkTo(walletSynchronizer.PipeInPackets);
                    statePacketsExtractor.PipeOutProcessed.LinkTo(walletSynchronizer.PipeInPackage);
                    walletSynchronizer.PipeOutPackets.LinkTo(updater.PipeIn);

                    packetsProvider.Start();

                    var state = new StatePersistency
                    {
                        AccountId               = accountId,
                        PacketsProvider         = packetsProvider,
                        TransactionsService     = transactionsService,
                        PacketsExtractor        = statePacketsExtractor,
                        ClientCryptoService     = clientCryptoService,
                        WalletSynchronizer      = walletSynchronizer,
                        CancellationTokenSource = cancellationTokenSource
                    };

                    _statePersistencyItems.Add(accountId, state);
                }
                catch (Exception ex)
                {
                    _logger.Error($"[{accountId}]: Failure during {nameof(InitializeStateExecutionServices)} for account with id {accountId}", ex);
                    throw;
                }
            }
        }
示例#5
0
 public override IAsyncEnumerable <Path> ComputePaths(EvaluationContext ctx)
 {
     return(AsyncUtil.Empty <Path>());
 }
 /// <summary>
 /// Retrieve Users.
 /// </summary>
 /// <remarks>
 /// Retrieves a list of all users associated with your company,
 /// with optional filters to narrow down the results.
 /// </remarks>
 /// <returns>
 /// An enumerable set of <see cref="User"/> objects, along with an output
 /// instance of the <see cref="ResultsMeta"/> class containing additional data.
 /// </returns>
 public (IList <User>, ResultsMeta) GetUsers()
 {
     return(AsyncUtil.RunSync(() => GetUsersAsync()));
 }
 /// <summary>
 /// Retrieve Users.
 /// </summary>
 /// <remarks>
 /// Retrieves a list of all users associated with your company,
 /// with optional filters to narrow down the results.
 /// </remarks>
 /// <param name="filter">
 /// An instance of the <see cref="UserFilter"/> class, for narrowing down the results.
 /// </param>
 /// <param name="options">
 /// An instance of the <see cref="RequestOptions"/> class, for customizing method processing.
 /// </param>
 /// <returns>
 /// An enumerable set of <see cref="User"/> objects, along with an output
 /// instance of the <see cref="ResultsMeta"/> class containing additional data.
 /// </returns>
 public (IList <User>, ResultsMeta) GetUsers(
     UserFilter filter,
     RequestOptions options)
 {
     return(AsyncUtil.RunSync(() => GetUsersAsync(filter, options)));
 }
 /// <summary>
 /// Retrieve Project Report.
 /// </summary>
 /// <remarks>
 /// Retrieves a project report with filters to narrow down the results.
 /// </remarks>
 /// <param name="filter">
 /// An instance of the <see cref="ProjectReportFilter"/> class, for narrowing down the results.
 /// </param>
 /// <returns>
 /// An instance of the <see cref="ProjectReport"/> class, along with
 /// an output instance of the <see cref="ResultsMeta"/> class containing additional data.
 /// </returns>
 public (ProjectReport, ResultsMeta) GetProjectReport(ProjectReportFilter filter)
 {
     return(AsyncUtil.RunSync(() => GetProjectReportAsync(filter)));
 }
 /// <summary>
 /// Retrieve Current Totals Report.
 /// </summary>
 /// <remarks>
 /// Retrieves a snapshot report for the current totals (shift and day) along with additional
 /// information provided for those who are currently on the clock.
 /// </remarks>
 /// <param name="filter">
 /// An instance of the <see cref="CurrentTotalsReportFilter"/> class, for narrowing down the results.
 /// </param>
 /// <returns>
 /// An instance of the <see cref="CurrentTotalsReport"/> class, along with
 /// an output instance of the <see cref="ResultsMeta"/> class containing additional data.
 /// </returns>
 public (CurrentTotalsReport, ResultsMeta) GetCurrentTotalsReport(CurrentTotalsReportFilter filter)
 {
     return(AsyncUtil.RunSync(() => GetCurrentTotalsReportAsync(filter)));
 }
示例#10
0
 public static IDbConnection GetConnection(string connectionStringOrKey, bool connectionStringIsConfigKey = false, string providerName = null)
 {
     return(AsyncUtil.CallSync(GetConnectionAsync, connectionStringOrKey, connectionStringIsConfigKey, providerName));
 }
 /// <summary>
 /// Retrieve Payroll by Jobcode Report.
 /// </summary>
 /// <remarks>
 /// Retrieves a payroll report, broken down by jobcode,
 /// with filters to narrow down the results.
 /// </remarks>
 /// <param name="filter">
 /// An instance of the <see cref="PayrollByJobcodeReportFilter"/> class, for narrowing down the results.
 /// </param>
 /// <returns>
 /// An instance of the <see cref="PayrollByJobcodeReport"/> class, along with
 /// an output instance of the <see cref="ResultsMeta"/> class containing additional data.
 /// </returns>
 public (PayrollByJobcodeReport, ResultsMeta) GetPayrollByJobcodeReport(PayrollByJobcodeReportFilter filter)
 {
     return(AsyncUtil.RunSync(() => GetPayrollByJobcodeReportAsync(filter)));
 }
示例#12
0
 public static int ExecuteCommand(string commandText, IDbConnection connection, int commandTimeout = 30)
 {
     return(AsyncUtil.CallSync(ExecuteCommandAsync, commandText, connection, commandTimeout));
 }
示例#13
0
 public static TResult GetScalarResult <TResult>(string commandText, IDbConnection connection, int commandTimeout = 30)
 {
     return(AsyncUtil.CallSync(GetScalarResultAsync <TResult>, commandText, connection, commandTimeout));
 }
示例#14
0
 public static IDataReader GetReader(string commandText, IDbConnection connection, CommandBehavior behavior = CommandBehavior.CloseConnection, int commandTimeout = 30)
 {
     return(AsyncUtil.CallSync(GetReaderAsync, commandText, connection, behavior, commandTimeout));
 }
 /// <summary>
 /// Retrieve Schedule Events.
 /// </summary>
 /// <remarks>
 /// Retrieves a list of all schedule events associated with your employees
 /// or company, with optional filters to narrow down the results.
 /// </remarks>
 /// <param name="filter">
 /// An instance of the <see cref="ScheduleEventFilter"/> class, for narrowing down the results.
 /// </param>
 /// <param name="options">
 /// An instance of the <see cref="RequestOptions"/> class, for customizing method processing.
 /// </param>
 /// <returns>
 /// An enumerable set of <see cref="ScheduleEvent"/> objects, along with an output
 /// instance of the <see cref="ResultsMeta"/> class containing additional data.
 /// </returns>
 public (IList <ScheduleEvent>, ResultsMeta) GetScheduleEvents(
     ScheduleEventFilter filter,
     RequestOptions options)
 {
     return(AsyncUtil.RunSync(() => GetScheduleEventsAsync(filter, options)));
 }
示例#16
0
        public IEnumerator Setup() => UniTask.ToCoroutine(async() =>
        {
            serverGo      = new GameObject("server", typeof(NetworkSceneManager), typeof(ServerObjectManager), typeof(NetworkServer));
            clientGo      = new GameObject("client", typeof(NetworkSceneManager), typeof(ClientObjectManager), typeof(NetworkClient));
            testTransport = serverGo.AddComponent <LoopbackTransport>();

            await UniTask.Delay(1);

            server = serverGo.GetComponent <NetworkServer>();
            client = clientGo.GetComponent <NetworkClient>();

            server.Transport = testTransport;
            client.Transport = testTransport;

            serverSceneManager        = serverGo.GetComponent <NetworkSceneManager>();
            clientSceneManager        = clientGo.GetComponent <NetworkSceneManager>();
            serverSceneManager.Server = server;
            clientSceneManager.Client = client;
            serverSceneManager.Start();
            clientSceneManager.Start();

            serverObjectManager        = serverGo.GetComponent <ServerObjectManager>();
            serverObjectManager.Server = server;
            serverObjectManager.NetworkSceneManager = serverSceneManager;
            serverObjectManager.Start();

            clientObjectManager        = clientGo.GetComponent <ClientObjectManager>();
            clientObjectManager.Client = client;
            clientObjectManager.NetworkSceneManager = clientSceneManager;
            clientObjectManager.Start();

            ExtraSetup();

            // create and register a prefab
            playerPrefab             = new GameObject("serverPlayer", typeof(NetworkIdentity), typeof(T));
            NetworkIdentity identity = playerPrefab.GetComponent <NetworkIdentity>();
            identity.AssetId         = Guid.NewGuid();
            clientObjectManager.RegisterPrefab(identity);

            // wait for client and server to initialize themselves
            await UniTask.Delay(1);

            // start the server
            var started = new UniTaskCompletionSource();
            server.Started.AddListener(() => started.TrySetResult());
            server.StartAsync().Forget();

            await started.Task;

            // now start the client
            await client.ConnectAsync("localhost");

            await AsyncUtil.WaitUntilWithTimeout(() => server.Players.Count > 0);

            // get the connections so that we can spawn players
            connectionToClient = server.Players.First();
            connectionToServer = client.Player;

            // create a player object in the server
            serverPlayerGO  = Object.Instantiate(playerPrefab);
            serverIdentity  = serverPlayerGO.GetComponent <NetworkIdentity>();
            serverComponent = serverPlayerGO.GetComponent <T>();
            serverObjectManager.AddCharacter(connectionToClient, serverPlayerGO);

            // wait for client to spawn it
            await AsyncUtil.WaitUntilWithTimeout(() => connectionToServer.Identity != null);

            clientIdentity  = connectionToServer.Identity;
            clientPlayerGO  = clientIdentity.gameObject;
            clientComponent = clientPlayerGO.GetComponent <T>();
        });
 /// <summary>
 /// Create Schedule Events.
 /// </summary>
 /// <remarks>
 /// Add one or more schedule events.
 /// </remarks>
 /// <param name="scheduleEvents">
 /// The set of <see cref="ScheduleEvent"/> objects to be created.
 /// </param>
 /// <returns>
 /// The set of the <see cref="ScheduleEvent"/> objects that were created, along with
 /// an output instance of the <see cref="ResultsMeta"/> class containing additional data.
 /// </returns>
 public (IList <ScheduleEvent>, ResultsMeta) CreateScheduleEvents(IEnumerable <ScheduleEvent> scheduleEvents)
 {
     return(AsyncUtil.RunSync(() => CreateScheduleEventsAsync(scheduleEvents)));
 }
示例#18
0
        public IEnumerator <IYield> Invoke(Plug plug, string verb, XUri uri, DreamMessage request, Result <DreamMessage> response)
        {
            var match = GetBestMatch(uri);

            yield return(AsyncUtil.Fork(() => match.Invoke(plug, verb, uri, MemorizeAndClone(request), response), new Result(TimeSpan.MaxValue)));
        }
 /// <summary>
 /// Retrieve Users.
 /// </summary>
 /// <remarks>
 /// Retrieves a list of all users associated with your company,
 /// with optional filters to narrow down the results.
 /// </remarks>
 /// <param name="filter">
 /// An instance of the <see cref="UserFilter"/> class, for narrowing down the results.
 /// </param>
 /// <returns>
 /// An enumerable set of <see cref="User"/> objects, along with an output
 /// instance of the <see cref="ResultsMeta"/> class containing additional data.
 /// </returns>
 public (IList <User>, ResultsMeta) GetUsers(
     UserFilter filter)
 {
     return(AsyncUtil.RunSync(() => GetUsersAsync(filter)));
 }
 /// <summary>
 /// Retrieve Groups.
 /// </summary>
 /// <remarks>
 /// Retrieves a list of groups associated with your company, with
 /// optional filters to narrow down the results.
 /// </remarks>
 /// <returns>
 /// An enumerable set of <see cref="Group"/> objects, along with an output
 /// instance of the <see cref="ResultsMeta"/> class containing additional data.
 /// </returns>
 public (IList <Group>, ResultsMeta) GetGroups()
 {
     return(AsyncUtil.RunSync(() => GetGroupsAsync()));
 }
 /// <summary>
 /// Create Users.
 /// </summary>
 /// <remarks>
 /// Add one or more users to your company.
 /// </remarks>
 /// <param name="users">
 /// The set of <see cref="User"/> objects to be created.
 /// </param>
 /// <returns>
 /// The set of the <see cref="User"/> objects that were created, along with
 /// an output instance of the <see cref="ResultsMeta"/> class containing additional data.
 /// </returns>
 public (IList <User>, ResultsMeta) CreateUsers(IEnumerable <User> users)
 {
     return(AsyncUtil.RunSync(() => CreateUsersAsync(users)));
 }
 /// <summary>
 /// Retrieve Groups.
 /// </summary>
 /// <remarks>
 /// Retrieves a list of groups associated with your company, with
 /// optional filters to narrow down the results.
 /// </remarks>
 /// <param name="filter">
 /// An instance of the <see cref="GroupFilter"/> class, for narrowing down the results.
 /// </param>
 /// <returns>
 /// An enumerable set of <see cref="Group"/> objects, along with an output
 /// instance of the <see cref="ResultsMeta"/> class containing additional data.
 /// </returns>
 public (IList <Group>, ResultsMeta) GetGroups(
     GroupFilter filter)
 {
     return(AsyncUtil.RunSync(() => GetGroupsAsync(filter)));
 }
示例#23
0
 public void Clear()
 {
     AsyncUtil.RunSync(() => _videoRam.Initialise());
 }
 /// <summary>
 /// Retrieve Groups.
 /// </summary>
 /// <remarks>
 /// Retrieves a list of groups associated with your company, with
 /// optional filters to narrow down the results.
 /// </remarks>
 /// <param name="filter">
 /// An instance of the <see cref="GroupFilter"/> class, for narrowing down the results.
 /// </param>
 /// <param name="options">
 /// An instance of the <see cref="RequestOptions"/> class, for customizing method processing.
 /// </param>
 /// <returns>
 /// An enumerable set of <see cref="Group"/> objects, along with an output
 /// instance of the <see cref="ResultsMeta"/> class containing additional data.
 /// </returns>
 public (IList <Group>, ResultsMeta) GetGroups(
     GroupFilter filter,
     RequestOptions options)
 {
     return(AsyncUtil.RunSync(() => GetGroupsAsync(filter, options)));
 }
 /// <summary>
 /// Retrieve Jobcodes.
 /// </summary>
 /// <remarks>
 /// Retrieves a list of all jobcodes associated with your company,
 /// with optional filters to narrow down the results.
 /// </remarks>
 /// <returns>
 /// An enumerable set of <see cref="Jobcode"/> objects, along with an output
 /// instance of the <see cref="ResultsMeta"/> class containing additional data.
 /// </returns>
 public (IList <Jobcode>, ResultsMeta) GetJobcodes()
 {
     return(AsyncUtil.RunSync(() => GetJobcodesAsync()));
 }
 /// <summary>
 /// Create Groups.
 /// </summary>
 /// <remarks>
 /// Add one or more groups to your company.
 /// </remarks>
 /// <param name="groups">
 /// The set of <see cref="Group"/> objects to be created.
 /// </param>
 /// <returns>
 /// The set of the <see cref="Group"/> objects that were created, along with
 /// an output instance of the <see cref="ResultsMeta"/> class containing additional data.
 /// </returns>
 public (IList <Group>, ResultsMeta) CreateGroups(IEnumerable <Group> groups)
 {
     return(AsyncUtil.RunSync(() => CreateGroupsAsync(groups)));
 }
 /// <summary>
 /// Retrieve Jobcodes.
 /// </summary>
 /// <remarks>
 /// Retrieves a list of all jobcodes associated with your company,
 /// with optional filters to narrow down the results.
 /// </remarks>
 /// <param name="filter">
 /// An instance of the <see cref="JobcodeFilter"/> class, for narrowing down the results.
 /// </param>
 /// <param name="options">
 /// An instance of the <see cref="RequestOptions"/> class, for customizing method processing.
 /// </param>
 /// <returns>
 /// An enumerable set of <see cref="Jobcode"/> objects, along with an output
 /// instance of the <see cref="ResultsMeta"/> class containing additional data.
 /// </returns>
 public (IList <Jobcode>, ResultsMeta) GetJobcodes(
     JobcodeFilter filter,
     RequestOptions options)
 {
     return(AsyncUtil.RunSync(() => GetJobcodesAsync(filter, options)));
 }
 /// <summary>
 /// Retrieve Schedule Events.
 /// </summary>
 /// <remarks>
 /// Retrieves a list of all schedule events associated with your employees
 /// or company, with optional filters to narrow down the results.
 /// </remarks>
 /// <param name="filter">
 /// An instance of the <see cref="ScheduleEventFilter"/> class, for narrowing down the results.
 /// </param>
 /// <returns>
 /// An enumerable set of <see cref="ScheduleEvent"/> objects, along with an output
 /// instance of the <see cref="ResultsMeta"/> class containing additional data.
 /// </returns>
 public (IList <ScheduleEvent>, ResultsMeta) GetScheduleEvents(
     ScheduleEventFilter filter)
 {
     return(AsyncUtil.RunSync(() => GetScheduleEventsAsync(filter)));
 }
示例#29
0
 public IEnumerator ClientNotNullAfterSpawnInStarted() => UniTask.ToCoroutine(async() =>
 {
     await AsyncUtil.WaitUntilWithTimeout(() => (testIdentity.Client as NetworkClient) == client);
 });
示例#30
0
 public virtual void Delete(TEntity entity)
 {
     AsyncUtil.RunSync(() => DeleteAsync(entity));
 }