public void Initialize(InitializeOptions options = InitializeOptions.None) { try { NotificationCenter.Initialize(this); DocumentsStorage.Initialize((options & InitializeOptions.GenerateNewDatabaseId) == InitializeOptions.GenerateNewDatabaseId); TxMerger.Start(); ConfigurationStorage.Initialize(); if ((options & InitializeOptions.SkipLoadingDatabaseRecord) == InitializeOptions.SkipLoadingDatabaseRecord) { return; } long index; DatabaseRecord record; using (_serverStore.ContextPool.AllocateOperationContext(out TransactionOperationContext context)) using (context.OpenReadTransaction()) record = _serverStore.Cluster.ReadDatabase(context, Name, out index); if (record == null) { DatabaseDoesNotExistException.Throw(Name); } PeriodicBackupRunner = new PeriodicBackupRunner(this, _serverStore); _indexStoreTask = IndexStore.InitializeAsync(record); ReplicationLoader?.Initialize(record); EtlLoader.Initialize(record); DocumentTombstoneCleaner.Start(); try { _indexStoreTask.Wait(DatabaseShutdown); } finally { _indexStoreTask = null; } SubscriptionStorage.Initialize(); NotifyFeaturesAboutStateChange(record, index); } catch (Exception) { Dispose(); throw; } }
private void InitializeGlue() { // initialize Tick42 Interop Log("Initializing Glue42"); var initializeOptions = new InitializeOptions() { ApplicationName = "Hello Glue42 Imperative Duplex Chat", InitializeTimeout = TimeSpan.FromSeconds(5) }; Glue42.InitializeGlue(initializeOptions) .ContinueWith((glue) => { //unable to register glue if (glue.Status == TaskStatus.Faulted) { Log("Unable to initialize Glue42"); return; } _glue42 = glue.Result; // subscribe to interop connection status event _glue42.Interop.ConnectionStatusChanged += (sender, args) => { Log($"Glue connection is now {args.Status}"); }; _glue42.Interop.EndpointStatusChanged += InteropEndpointStatusChanged; _glue42.Interop.RegisterEndpoint(mdb => mdb.SetMethodName(_chatEndpointName), (method, context, caller, resultBuilder, asyncResponseCallback, cookie) => ThreadPool.QueueUserWorkItem(_ => { // simulate asynchronous work // grab the invocation context (e.g. take "id" from the input arguments) // we don't care about the id type, so get it as Value Value id = context.Arguments.GetValueByName("id", v => v); // we care about the message type - we take it as a string var message = context.Arguments.GetValueByName("message", v => v.AsString); Log($"Call from {caller} with id {id}: {message}"); // do slow job here with context and caller Thread.Sleep(500); // respond when ready asyncResponseCallback(resultBuilder.SetMessage(id + " processed") .SetContext(cb => cb.AddValue("id", id)).Build()); })); //Enable textbox for send of messages BeginInvoke((Action)(() => txtMsg_.Enabled = true)); Log("Initialized Glue."); }); }
/// <summary> /// Invoke /// </summary> public async Task InvokeAsync(InitializeOptions options) { Log.Info("The initialize utility will walk through the creation of the most basic Console recipe.\n"); // Use the current directory as the default names var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); var recipe = new Recipe( currentDirectory.Name) { Version = new SemanticVersion(1, 0, 0) }; Log.Info($"Name: ({recipe.Name}) "); var newName = Console.ReadLine(); if (!string.IsNullOrWhiteSpace(newName)) { recipe.Name = newName; } bool setVersion = false; while (!setVersion) { Log.Info($"Version: ({recipe.Version}) "); var newVersion = Console.ReadLine(); if (string.IsNullOrEmpty(newVersion)) { // Use the default setVersion = true; } else { if (SemanticVersion.TryParse(newVersion, out SemanticVersion value)) { recipe.Version = value; setVersion = true; } else { Log.Warning($"Invalid version: \"{newVersion}\""); } } } // Save the state of the recipe if it has changed await RecipeManager.SaveToFileAsync(recipe); }
/// <summary> /// Constructor /// </summary> /// <param name="inputDataProvider">DataProvider - factory, which can produce you IData type</param> public Searcher(IDataProvider inputDataProvider, IOutDataProvider outputDataProvider) { m_inputDataProvider = inputDataProvider; m_outputDataProvider = outputDataProvider; m_outputDataProvider.setResultList(m_outputList); m_tokOptions = new TokenizeOptions(new List<KeyValuePair<string, string>>(0), SharedTypes.CaseSensType.CIgnore); m_tokenizer = new Tokenizer(m_tokOptions); InitializeOptions<IData> initOptions; initOptions = new InitializeOptions<IData>(m_tokenizer, StringComparer.InvariantCultureIgnoreCase, (a, b) => { if (!a.UserData.Contains(b[0])) a.UserData.Add(b[0]); } , (rdr) => { return m_inputDataProvider.produce(rdr); }); m_finderEngine = new FinderEngine<IData>(initOptions); }
static void Main(string[] args) { Glue42 glue42 = null; var initializeOptions = new InitializeOptions() { ApplicationName = "Hello Glue42 Interop", InitializeTimeout = TimeSpan.FromSeconds(5) }; Glue42.InitializeGlue(initializeOptions) .ContinueWith((glue) => { //unable to register glue if (glue.Status == TaskStatus.Faulted) { Log("Unable to initialize Glue42"); return; } glue42 = glue.Result; // subscribe to interop connection status event glue42.Interop.ConnectionStatusChanged += InteropOnConnectionStatusChanged; // Register synchronous calling endpoint, called HelloGlue. // we could use the serverEndpoint returned by this method to later unregister it by calling glue.Interop.UnregisterEndpoint IServerMethod serverEndpoint = glue42.Interop.RegisterSynchronousEndpoint(mdb => mdb.SetMethodName("HelloGlue"), OnHelloWorldInvoked); Log($"Registered endpoint called {serverEndpoint.Definition.Name}"); Log("Initialized Glue."); }); string input; // start the main loop, take console inputs until '!q' is passed. // send each line as an invocation argument, if not empty while (!string.Equals(input = Console.ReadLine(), "!q", StringComparison.CurrentCultureIgnoreCase)) { if (glue42 == null) { return; } InteropSendOperation(glue42, input); } }
private void InitializeGlue() { // initialize Tick42 Interop Log("Initializing Glue42"); var initializeOptions = new InitializeOptions() { ApplicationName = "Hello Glue42 Advance Declarative Interop", AdvancedOptions = new Glue42.AdvancedOptions() { SynchronizationContext = SynchronizationContext.Current }, InitializeTimeout = TimeSpan.FromSeconds(5) }; Glue42.InitializeGlue(initializeOptions) .ContinueWith((glue) => { //unable to register glue if (glue.Status == TaskStatus.Faulted) { Log("Unable to initialize Glue42"); return; } _glue42 = glue.Result; // subscribe to interop connection status event _glue42.Interop.ConnectionStatusChanged += (sender, args) => { Log($"Glue connection is now {args.Status}"); }; _glue42.Interop.TargetStatusChanged += (sender, args) => Log($"{args.Status.State} target {args.Target}"); // force single target _service = _glue42.Interop.CreateServiceProxy <IServiceContract>(targetType: MethodTargetType.Any); // let's track the status of the service target - if anybody has implemented it. _glue42.Interop.CreateServiceSubscription( _service, (_, status) => Log($"{nameof(IServiceContract)} is now {(status ? string.Empty : "in")}active")); //Enable registration of ServiceContract BeginInvoke((Action)(() => btnRegister.Enabled = true)); Log("Initialized Glue Interop"); }); }
public void Set(InitializeOptions other) { if (other != null) { m_ApiVersion = PlatformInterface.InitializeApiLatest; m_AllocateMemoryFunction = other.AllocateMemoryFunction != null ? AllocateMemoryFunction : null; m_ReallocateMemoryFunction = other.ReallocateMemoryFunction != null ? ReallocateMemoryFunction : null; m_ReleaseMemoryFunction = other.ReleaseMemoryFunction != null ? ReleaseMemoryFunction : null; ProductName = other.ProductName; ProductVersion = other.ProductVersion; int[] reservedData = new int[] { 1, 1 }; System.IntPtr reservedDataAddress = System.IntPtr.Zero; Helper.TryMarshalSet(ref reservedDataAddress, reservedData); m_Reserved = reservedDataAddress; SystemInitializeOptions = other.SystemInitializeOptions; OverrideThreadAffinity = other.OverrideThreadAffinity; } }
private void InitializeGlue() { var initializeOptions = new InitializeOptions() { ApplicationName = "My Glue Streams Publisher Demo", InitializeTimeout = TimeSpan.FromSeconds(5) }; Glue42.InitializeGlue(initializeOptions) .ContinueWith((glue) => { //register glue successfuly if (glue.Status == TaskStatus.RanToCompletion) { var glueInstance = glue.Result; GetMainWindow()?.RegisterGlue(glueInstance); } }, TaskScheduler.FromCurrentSynchronizationContext()); }
/// <summary> /// First frame /// </summary> void Start() { _ins = this; var initializeOptions = new InitializeOptions(); initializeOptions.ProductName = productName; initializeOptions.ProductVersion = productVersion; var result = PlatformInterface.Initialize(initializeOptions); // * Unity Editor becomes AlreadyConfigured after the second time. if (result == Result.Success #if UNITY_EDITOR || result == Result.AlreadyConfigured #endif ) { var clientCredentials = new ClientCredentials(); clientCredentials.ClientId = clientId; clientCredentials.ClientSecret = clientSecret; var options = new Options(); options.ClientCredentials = clientCredentials; options.ProductId = productId; options.SandboxId = sandboxId; options.DeploymentId = deploymentId; m_platformInterface = PlatformInterface.Create(options); if (m_platformInterface == null) { throw new Exception("Failed to create platform"); } } else { throw new Exception("Failed to initialize platform:" + result); } Debug.Log($"Login:{result}"); }
private static void InitializeDatabase(String[] args, InitializeOptions options) { if (options.Debug) { WaitForDebugger(); } var configuration = BuildConfiguration(args, options, out _); var serviceCollection = new ServiceCollection(); var startup = new Startup(configuration); startup.ConfigureServices(serviceCollection); using var provider = serviceCollection.BuildServiceProvider(); var command = provider.GetRequiredService <InitializeCommand>(); // TODO: support cancellation when the user hits Ctrl+C or the process gets a kill signal command.InvokeAsync(options, CancellationToken.None).AwaitSynchronously(); }
protected override void OnShown(EventArgs e) { Log("Initializing Glue42"); var initializeOptions = new InitializeOptions() { ApplicationName = "Hello Glue42 Interop", InitializeTimeout = TimeSpan.FromSeconds(5) }; Glue42.InitializeGlue(initializeOptions) .ContinueWith((glue) => { //unable to register glue if (glue.Status == TaskStatus.Faulted) { Log("Unable to initialize Glue42"); return; } _glue42 = glue.Result; // subscribe to interop connection status event _glue42.Interop.ConnectionStatusChanged += (sender, args) => { Log($"Glue connection is now {args.Status}"); }; _glue42.Interop.TargetStatusChanged += (sender, args) => Log($"{args.Status.State} target {args.Target}"); _service = _glue42.Interop.CreateServiceProxy <IServiceContract>(); // let's track the status of the service target - if anybody has implemented it. _glue42.Interop.CreateServiceSubscription( _service, (_, status) => Log($"{nameof(IServiceContract)} is now {(status ? string.Empty : "in")}active")); BeginInvoke((Action)(() => btnRegister.Enabled = true)); Log("Initialized Glue Interop"); }); }
/// <summary> /// 開始 /// </summary> void Start() { _ins = this; var initializeOptions = new InitializeOptions(); initializeOptions.ProductName = settings.ProductName; initializeOptions.ProductVersion = settings.ProductVersion; var result = PlatformInterface.Initialize(initializeOptions); // ※ Unity Editor は AlreadyConfigured を飛ばさないとアプリが動かない。 if (result == Result.Success || result == Result.AlreadyConfigured) { var clientCredentials = new ClientCredentials(); clientCredentials.ClientId = settings.ClientId; clientCredentials.ClientSecret = settings.ClientSecret; var options = new Options(); options.ClientCredentials = clientCredentials; options.ProductId = settings.ProductId; options.SandboxId = settings.SandboxId; options.DeploymentId = settings.DeploymentId; m_platformInterface = PlatformInterface.Create(options); if (m_platformInterface == null) { throw new Exception("Failed to create platform"); } } else { throw new Exception("Failed to initialize platform:" + result); } Debug.Log($"Init:{result}"); }
private void InitializeGlue() { var initializeOptions = new InitializeOptions() { ApplicationName = "My Glue Notification Demo", InitializeTimeout = TimeSpan.FromSeconds(5) }; Glue42.InitializeGlue(initializeOptions) .ContinueWith((glue) => { //unable to register glue if (glue.Status == TaskStatus.Faulted) { ShowMainWindow(); return; } //register glue var glueInstance = glue.Result; GetMainWindow()?.RegisterGlue(glueInstance); }, TaskScheduler.FromCurrentSynchronizationContext()); }
void Awake() { IsConnecting = true; var initializeOptions = new InitializeOptions() { ProductName = epicProductName, ProductVersion = epicProductVersion }; var initializeResult = PlatformInterface.Initialize(initializeOptions); // This code is called each time the game is run in the editor, so we catch the case where the SDK has already been initialized in the editor. var isAlreadyConfiguredInEditor = Application.isEditor && initializeResult == Result.AlreadyConfigured; if (initializeResult != Result.Success && !isAlreadyConfiguredInEditor) { throw new System.Exception("Failed to initialize platform: " + initializeResult); } // The SDK outputs lots of information that is useful for debugging. // Make sure to set up the logging interface as early as possible: after initializing. LoggingInterface.SetLogLevel(LogCategory.AllCategories, LogLevel.VeryVerbose); LoggingInterface.SetCallback((LogMessage logMessage) => { Debug.Log(logMessage.Message); }); var options = new Options() { ProductId = epicProductId, SandboxId = epicSandboxId, DeploymentId = epicDeploymentId, ClientCredentials = new ClientCredentials() { ClientId = epicClientId, ClientSecret = epicClientSecret } }; EOS = PlatformInterface.Create(options); if (EOS == null) { throw new System.Exception("Failed to create platform"); } //Login to the Connect Interface Epic.OnlineServices.Connect.CreateDeviceIdOptions createDeviceIdOptions = new Epic.OnlineServices.Connect.CreateDeviceIdOptions(); createDeviceIdOptions.DeviceModel = "PC Windows 64bit"; EOS.GetConnectInterface().CreateDeviceId(createDeviceIdOptions, null, (Epic.OnlineServices.Connect.CreateDeviceIdCallbackInfo createDeviceIdCallbackInfo) => { if (createDeviceIdCallbackInfo.ResultCode == Result.Success || createDeviceIdCallbackInfo.ResultCode == Result.DuplicateNotAllowed) { var loginOptions = new Epic.OnlineServices.Connect.LoginOptions(); loginOptions.UserLoginInfo = new Epic.OnlineServices.Connect.UserLoginInfo(); loginOptions.UserLoginInfo.DisplayName = "Justin"; loginOptions.Credentials = new Epic.OnlineServices.Connect.Credentials(); loginOptions.Credentials.Type = Epic.OnlineServices.Connect.ExternalCredentialType.DeviceidAccessToken; loginOptions.Credentials.Token = null; EOS.GetConnectInterface().Login(loginOptions, null, (Epic.OnlineServices.Connect.LoginCallbackInfo loginCallbackInfo) => { if (loginCallbackInfo.ResultCode == Result.Success) { Debug.Log("Login succeeded"); string productIdString; Result result = loginCallbackInfo.LocalUserId.ToString(out productIdString); if (Result.Success == result) { Debug.Log("EOS User Product ID:" + productIdString); localUserProductIdString = productIdString; localUserProductId = loginCallbackInfo.LocalUserId; } Initialized = true; IsConnecting = false; } else { Debug.Log("Login returned " + loginCallbackInfo.ResultCode); } }); } else { Debug.Log("Device ID creation returned " + createDeviceIdCallbackInfo.ResultCode); } }); }
/// <summary> /// Initialize epic sdk. /// </summary> /// <returns>Returns back whether or not the engine initialized correctly.</returns> private void Initialize() { if (_enableDebugLogs) { DebugLogger.RegularDebugLog("[EpicManager] - Initializing epic services."); } InitializeOptions initializeOptions = new InitializeOptions { ProductName = _options.ProductName, ProductVersion = _options.ProductVersion }; Result initializeResult = PlatformInterface.Initialize(initializeOptions); // This code is called each time the game is run in the editor, so we catch the case where the SDK has already been initialized in the editor. bool isAlreadyConfiguredInEditor = Application.isEditor && initializeResult == Result.AlreadyConfigured; if (initializeResult != Result.Success && !isAlreadyConfiguredInEditor) { throw new Exception("[EpicManager] - Failed to initialize platform: " + initializeResult); } if (_enableDebugLogs) { LoggingInterface.SetLogLevel(LogCategory.AllCategories, _epicLoggingLevel); LoggingInterface.SetCallback(message => DebugLogger.EpicDebugLog(message)); } ClientCredentials clientCredentials = new ClientCredentials { ClientId = _options.ClientId, ClientSecret = _options.ClientSecret }; OnlineServices.Platform.Options options = new OnlineServices.Platform.Options { ProductId = _options.ProductId, SandboxId = _options.SandboxId, ClientCredentials = clientCredentials, IsServer = false, DeploymentId = _options.DeploymentId, TickBudgetInMilliseconds = (uint)_tickTime * 1000 }; Platform = PlatformInterface.Create(options); if (Platform != null) { if (_enableDebugLogs) { DebugLogger.RegularDebugLog("[EpicManager] - Initialization of epic services complete."); } // Process epic services in a separate task. _ = UniTask.Run(Tick); // If we use the Auth interface then only login into the Connect interface after finishing the auth interface login // If we don't use the Auth interface we can directly login to the Connect interface if (_authInterfaceLogin) { if (_authInterfaceCredentialType == LoginCredentialType.Developer) { _authInterfaceLoginCredentialId = $"localhost:{_devAuthToolPort}"; _authInterfaceCredentialToken = _devAuthToolName; } // Login to Auth Interface LoginOptions loginOptions = new LoginOptions { Credentials = new OnlineServices.Auth.Credentials { Type = _authInterfaceCredentialType, Id = _authInterfaceLoginCredentialId, Token = _authInterfaceCredentialToken }, ScopeFlags = AuthScopeFlags.BasicProfile | AuthScopeFlags.FriendsList | AuthScopeFlags.Presence }; AuthInterface.Login(loginOptions, null, OnAuthInterfaceLogin); } else { // Login to Connect Interface if (_connectInterfaceCredentialType == ExternalCredentialType.DeviceidAccessToken) { CreateDeviceIdOptions createDeviceIdOptions = new CreateDeviceIdOptions { DeviceModel = Application.platform.ToString() }; ConnectInterface.CreateDeviceId(createDeviceIdOptions, null, OnCreateDeviceId); } else { ConnectInterfaceLogin(); } } OnInitialized?.Invoke(); return; } DebugLogger.RegularDebugLog( $"[EpicManager] - Failed to create platform. Ensure the relevant {typeof(Options)} are set or passed into the application as arguments."); }
public void Initialize(InitializeOptions options = InitializeOptions.None) { try { _addToInitLog("Initializing NotificationCenter"); NotificationCenter.Initialize(this); _addToInitLog("Initializing DocumentStorage"); DocumentsStorage.Initialize((options & InitializeOptions.GenerateNewDatabaseId) == InitializeOptions.GenerateNewDatabaseId); _addToInitLog("Starting Transaction Merger"); TxMerger.Start(); _addToInitLog("Initializing ConfigurationStorage"); ConfigurationStorage.Initialize(); if ((options & InitializeOptions.SkipLoadingDatabaseRecord) == InitializeOptions.SkipLoadingDatabaseRecord) { return; } _addToInitLog("Loading Database"); long index; DatabaseRecord record; using (_serverStore.ContextPool.AllocateOperationContext(out TransactionOperationContext context)) using (context.OpenReadTransaction()) record = _serverStore.Cluster.ReadDatabase(context, Name, out index); if (record == null) { DatabaseDoesNotExistException.Throw(Name); } PeriodicBackupRunner = new PeriodicBackupRunner(this, _serverStore); _addToInitLog("Initializing IndexStore (async)"); _indexStoreTask = IndexStore.InitializeAsync(record); _addToInitLog("Initializing Replication"); ReplicationLoader?.Initialize(record); _addToInitLog("Initializing ETL"); EtlLoader.Initialize(record); DocumentTombstoneCleaner.Start(); try { _indexStoreTask.Wait(DatabaseShutdown); } finally { _addToInitLog("Initializing IndexStore completed"); _indexStoreTask = null; } SubscriptionStorage.Initialize(); _addToInitLog("Initializing SubscriptionStorage completed"); TaskExecutor.Execute((state) => { try { NotifyFeaturesAboutStateChange(record, index); } catch { // We ignore the exception since it was caught in the function itself } }, null); } catch (Exception) { Dispose(); throw; } }
protected void InitializeImplementation() { isConnecting = true; var initializeOptions = new InitializeOptions() { ProductName = epicProductName, ProductVersion = epicProductVersion }; var initializeResult = PlatformInterface.Initialize(initializeOptions); // This code is called each time the game is run in the editor, so we catch the case where the SDK has already been initialized in the editor. var isAlreadyConfiguredInEditor = Application.isEditor && initializeResult == Result.AlreadyConfigured; if (initializeResult != Result.Success && !isAlreadyConfiguredInEditor) { throw new System.Exception("Failed to initialize platform: " + initializeResult); } // The SDK outputs lots of information that is useful for debugging. // Make sure to set up the logging interface as early as possible: after initializing. LoggingInterface.SetLogLevel(LogCategory.AllCategories, epicLoggerLevel); LoggingInterface.SetCallback(message => Logger.EpicDebugLog(message)); var options = new Options() { ProductId = epicProductId, SandboxId = epicSandboxId, DeploymentId = epicDeploymentId, ClientCredentials = new ClientCredentials() { ClientId = epicClientId, ClientSecret = epicClientSecret }, TickBudgetInMilliseconds = tickBudgetInMilliseconds }; EOS = PlatformInterface.Create(options); if (EOS == null) { throw new System.Exception("Failed to create platform"); } if (checkForEpicLauncherAndRestart) { Result result = EOS.CheckForLauncherAndRestart(); // If not started through epic launcher the app will be restarted and we can quit if (result != Result.NoChange) { // Log error if launcher check failed, but still quit to prevent hacking if (result == Result.UnexpectedError) { Debug.LogError("Unexpected Error while checking if app was started through epic launcher"); } Application.Quit(); } } // If we use the Auth interface then only login into the Connect interface after finishing the auth interface login // If we don't use the Auth interface we can directly login to the Connect interface if (authInterfaceLogin) { if (authInterfaceCredentialType == Epic.OnlineServices.Auth.LoginCredentialType.Developer) { authInterfaceLoginCredentialId = "localhost:" + devAuthToolPort; authInterfaceCredentialToken = devAuthToolCredentialName; } // Login to Auth Interface Epic.OnlineServices.Auth.LoginOptions loginOptions = new Epic.OnlineServices.Auth.LoginOptions() { Credentials = new Epic.OnlineServices.Auth.Credentials() { Type = authInterfaceCredentialType, Id = authInterfaceLoginCredentialId, Token = authInterfaceCredentialToken }, ScopeFlags = Epic.OnlineServices.Auth.AuthScopeFlags.BasicProfile | Epic.OnlineServices.Auth.AuthScopeFlags.FriendsList | Epic.OnlineServices.Auth.AuthScopeFlags.Presence }; EOS.GetAuthInterface().Login(loginOptions, null, OnAuthInterfaceLogin); } else { // Login to Connect Interface if (connectInterfaceCredentialType == Epic.OnlineServices.Connect.ExternalCredentialType.DeviceidAccessToken) { Epic.OnlineServices.Connect.CreateDeviceIdOptions createDeviceIdOptions = new Epic.OnlineServices.Connect.CreateDeviceIdOptions(); createDeviceIdOptions.DeviceModel = deviceModel; EOS.GetConnectInterface().CreateDeviceId(createDeviceIdOptions, null, OnCreateDeviceId); } else { ConnectInterfaceLogin(); } } }
private void InitializeGlue() { // get the form's synchronization context (gui thread) to be able to pass it for marshalling the events SynchronizationContext synchronizationContext = SynchronizationContext.Current; // initialize Tick42 Interop Log("Initializing Glue42"); var initializeOptions = new InitializeOptions() { ApplicationName = "Hello Glue42 Advanced Imperative Interop", InitializeTimeout = TimeSpan.FromSeconds(5), AdvancedOptions = new Glue42.AdvancedOptions() { SynchronizationContext = synchronizationContext } }; Glue42.InitializeGlue(initializeOptions) .ContinueWith((glue) => { //unable to register glue if (glue.Status == TaskStatus.Faulted) { Log("Unable to initialize Glue42"); return; } _glue42 = glue.Result; // subscribe to interop connection status event _glue42.Interop.ConnectionStatusChanged += (s, args) => { Log($"Glue connection is now {args.Status}"); }; _glue42.Interop.EndpointStatusChanged += InteropEndpointStatusChanged; _glue42.Interop.RegisterEndpoint(mdb => mdb.SetMethodName(endpointName_), (method, context, caller, resultBuilder, asyncResponseCallback, cookie) => ThreadPool.QueueUserWorkItem(_ => { Log($"Call from {caller}"); Value transactionValue = context.Arguments.GetValueByName("transaction", v => v); // deserialize the transaction Transaction transaction = _glue42.Interop.AGM.AGMObjectSerializer.Deserialize <Transaction>(transactionValue); // prepare some values to get back to the caller as a result string transactionId = Guid.NewGuid().ToString(); // do slow job here with context and caller Thread.Sleep(500); // respond when ready asyncResponseCallback(resultBuilder .SetMessage("Transaction queued") .SetContext(cb => cb.AddValue("transactionId", transactionId)).Build()); })); Log("Initialized Glue."); }); }
public IContainer InitializeContainer(InitializeOptions options, ContainerBuilder builder) { RegisterModulesFromAssemblies(options, builder); RegisterIndividualModules(options, builder); return(builder.Build(options.BuildOptions)); }
public async Task InvokeAsync(InitializeOptions options, CancellationToken cancellationToken) { if (options.DropDatabase) { this.logger.LogInformation( "Dropping Database {DatabaseName} (Environment = {Environment}, Provider = {Provider})", this.dbConfiguration.Database, options.Environment, this.context.Database.ProviderName ); await context.Database.EnsureDeletedAsync(cancellationToken); } var result = await context.Database.EnsureCreatedAsync(cancellationToken); this.logger.LogInformation( result ? "Created Database {DatabaseName} (Environment = {Environment}, Provider = {Provider})" : "The Database {DatabaseName} Already Exists (Environment = {Environment}, Provider = {Provider})", this.dbConfiguration.Database, options.Environment, this.context.Database.ProviderName ); if (options.SeedDatabase) { this.logger.LogInformation( result ? "Attempting To Seed Database {DatabaseName} (Environment = {Environment}, Provider = {Provider})" : "Unable To Seed Existing Database {DatabaseName}. Seed Again Using Drop. (Environment = {Environment}, Provider = {Provider})", this.dbConfiguration.Database, options.Environment, this.context.Database.ProviderName ); if (!result) { return; } context.Projects.Add(new Project() { Active = true, Description = "This demo project uses the sample images uploaded by Paul and hosted by Google", Name = "Demo Project 1" }); context.Projects.Add(new Project() { Active = true, Description = "This demo project uses the sample images uploaded by Paul and hosted by Google", Name = "Demo Project 2" }); context.Projects.Add(new Project() { Active = false, Description = "description 3", Name = "Inactive Sample Project 3" }); context.Documents.Add(new Document() { ProjectId = 1, FileName = "ChineseArrivals_1878_01218.png", Status = DocumentStatus.PendingTranscription, DocumentImageUrl = "https://storage.googleapis.com/app-hiscribe-images/projects/1/ChineseArrivals_1878_01218.png" }); context.Documents.Add(new Document() { ProjectId = 1, FileName = "ChineseArrivals_1878_01289.png", Status = DocumentStatus.PendingTranscription, DocumentImageUrl = "https://storage.googleapis.com/app-hiscribe-images/projects/1/ChineseArrivals_1878_01289.png" }); context.Documents.Add(new Document() { ProjectId = 1, FileName = "ChineseArrivals_1878_01271.png", Status = DocumentStatus.PendingTranscription, DocumentImageUrl = "https://storage.googleapis.com/app-hiscribe-images/projects/1/ChineseArrivals_1878_01271.png" }); context.Documents.Add(new Document() { ProjectId = 2, FileName = "ChineseArrivals_1878_01238.png", Status = DocumentStatus.PendingTranscription, DocumentImageUrl = "https://storage.googleapis.com/app-hiscribe-images/projects/1/ChineseArrivals_1878_01238.png" }); context.Documents.Add(new Document() { ProjectId = 2, FileName = "ChineseArrivals_1878_01218.png", Status = DocumentStatus.PendingTranscription, DocumentImageUrl = "https://storage.googleapis.com/app-hiscribe-images/projects/1/ChineseArrivals_1878_01218.png" }); context.Documents.Add(new Document() { ProjectId = 2, FileName = "ChineseArrivals_1878_01289.png", Status = DocumentStatus.PendingTranscription, DocumentImageUrl = "https://storage.googleapis.com/app-hiscribe-images/projects/1/ChineseArrivals_1878_01289.png" }); context.Documents.Add(new Document() { ProjectId = 3, FileName = "ChineseArrivals_1878_01218.png", Status = DocumentStatus.PendingTranscription, DocumentImageUrl = "https://storage.googleapis.com/app-hiscribe-images/projects/1/ChineseArrivals_1878_01218.png" }); context.Documents.Add(new Document() { ProjectId = 3, FileName = "ChineseArrivals_1878_01289.png", Status = DocumentStatus.PendingTranscription, DocumentImageUrl = "https://storage.googleapis.com/app-hiscribe-images/projects/1/ChineseArrivals_1878_01289.png" }); var saveChanges = await context.SaveChangesAsync(); this.logger.LogInformation( saveChanges > 0 ? "Successfully Seeded Database {DatabaseName} (Environment = {Environment}, Provider = {Provider})" : "Failed To Seed The Database {DatabaseName} (Environment = {Environment}, Provider = {Provider})", this.dbConfiguration.Database, options.Environment, this.context.Database.ProviderName ); } }