public async Task Invoke(HttpContext httpContext, SyncProvider syncProvider) { httpContext.Response.OnStarting(state => { if (!syncProvider.IsSynchronized) { var httpContext = (HttpContext)state; var paths = new string[] { "blockgraph", "blockgraphs", "mempool", "Coin" }; var parts = httpContext.Request.Path.Value.Split('/'); var stop = paths.FirstOrDefault(parts.Contains); if (!string.IsNullOrEmpty(stop)) { httpContext.Response.Headers.Add("X-Response-Synchronized", new string[] { "false" }); httpContext.Response.StatusCode = StatusCodes.Status204NoContent; if (!syncProvider.IsRunning) { _ = Task.Factory.StartNew(async() => { await syncProvider.SynchronizeCheck(); }); } } } return(Task.CompletedTask); }, httpContext); await _next(httpContext); }
/// <summary> /// Send the all bubbling configuration /// </summary> /// <param name="channelId"> /// The Channel ID. /// </param> /// <param name="pointId"> /// The Point ID. /// </param> /// <returns> /// The <see cref="string"/>. /// </returns> public string SyncSendBubblingConfiguration(string channelId, string pointId) { try { if (Base.Configuration.DisableExternalEventsStreamEngine()) { LogEngine.WriteLog( Base.Configuration.EngineName, "Warning the Device Provider Interface is disable, the GrabCaster point will be able to work in local mode only.", Constant.DefconThree, Constant.TaskCategoriesError, null, EventLogEntryType.Warning); return ("Warning the Device Provider Interface is disable, the GrabCaster point will be able to work in local mode only."); } SyncProvider.SyncSendBubblingConfiguration(channelId, pointId); } catch (Exception ex) { LogEngine.WriteLog( Base.Configuration.EngineName, $"Error in {MethodBase.GetCurrentMethod().Name}", Constant.DefconOne, Constant.TaskCategoriesError, ex, EventLogEntryType.Error); return(ex.Message); } return($"Syncronization Executed at {DateTime.Now}."); }
public HttpResponseMessage Post(Purchase purchase) { try { var provider = new SyncProvider(DbInfo); var synched = provider.SyncPurchase(purchase); return(Request.CreateResponse(HttpStatusCode.OK, synched)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.OK, ex.Message)); } }
public HttpResponseMessage Post(FieldInspection inspection) { try { var provider = new SyncProvider(DbInfo); var synched = provider.SyncFieldInspection(inspection); return(Request.CreateResponse(HttpStatusCode.OK, synched)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.OK, ex.Message)); } }
public HttpResponseMessage Post(Certification certification) { try { var provider = new SyncProvider(DbInfo); var synched = false; synched = provider.SyncCertification(certification); return(Request.CreateResponse(HttpStatusCode.OK, synched)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.OK, ex.Message)); } }
/// <summary> /// Refresh the internal bubbling setting /// </summary> /// <returns> /// The <see cref="string"/>. /// </returns> /// http://localhost:8000/GrabCaster/RefreshBubblingSetting public string RefreshBubblingSetting() { try { SyncProvider.RefreshBubblingSetting(); } catch (Exception ex) { LogEngine.WriteLog( Base.Configuration.EngineName, $"Error in {MethodBase.GetCurrentMethod().Name}", Constant.DefconOne, Constant.TaskCategoriesError, ex, EventLogEntryType.Error); return(ex.Message); } return($"Syncronization Executed at {DateTime.Now}."); }
/// <summary> /// Return the complete configuration /// </summary> /// <returns> /// The <see cref="Stream"/>. /// </returns> /// http://localhost:8000/GrabCaster/Configuration public Stream Configuration() { try { return(SyncProvider.GetConfiguration()); } catch (Exception ex) { var docMain = new XmlDocument(); var errorTemplate = docMain.CreateElement(string.Empty, "Error", string.Empty); var errorText = docMain.CreateTextNode(ex.Message); errorTemplate.AppendChild(errorText); var currentWebContext = WebOperationContext.Current; if (currentWebContext != null) { currentWebContext.OutgoingResponse.ContentType = "text/xml"; } return(new MemoryStream(Encoding.UTF8.GetBytes(errorTemplate.OuterXml))); } }
//http://localhost:8000/GrabCaster/SyncPush?ChannelID=*&PointID=* public string SyncPush(string channelId, string pointId) { SyncProvider.SendSyncPush(channelId, pointId); return($"Syncronization bag sent to Channel ID {channelId} and Point ID {pointId} - {DateTime.Now}"); }
public static void ToString(SyncProvider obj, MethodReturnEventArgs<System.String> e) { e.Result = obj.Name; }
public static void IngestMessagge(object message) { string senderId; string senderDescription; byte[] eventDataByte = null; var skeletonMessage = (ISkeletonMessage)message; // ****************************IF MESSAGE TYPE = GRABCASTER************************* try { // Check message subscription, it must come from engine if (skeletonMessage.Properties[Configuration.GrabCasterMessageTypeName].ToString() != Configuration.GrabCasterMessageTypeValue) { LogEngine.ConsoleWriteLine( "Not GrabCaster message type received -DISCARED-", ConsoleColor.DarkYellow); return; } else { // Who sent the message senderId = skeletonMessage.Properties[Configuration.MessageDataProperty.SenderId.ToString()].ToString(); senderDescription = skeletonMessage.Properties[Configuration.MessageDataProperty.SenderDescriprion.ToString()].ToString(); //If using Guid pattern as string some system put an escape character like \ before the end brachet } // Who receive the message LogEngine.ConsoleWriteLine( $"Event received from Sender {senderId} Sender description {senderDescription}", ConsoleColor.DarkCyan); // ****************************IF SAME SENDER************************* if (senderId == Configuration.PointId()) { LogEngine.ConsoleWriteLine("Same sender ID event discared.", ConsoleColor.Green); return; } } } catch (Exception ex) { // If error then not message typeof (no property present.) LogEngine.WriteLog( Configuration.EngineName, $"Error in {MethodBase.GetCurrentMethod().Name} - Not GrabCaster message type received (Missing GrabCaster_MessageType_Name properties.) -DISCARED-", Constant.ErrorEventIdHighCritical, Constant.TaskCategoriesError, ex, EventLogEntryType.Error); return; } try { // ****************************GET FROM STORAGE IF REQUIRED************************* if ((bool)skeletonMessage.Properties[Configuration.MessageDataProperty.Persisting.ToString()]) { ParametersPersistEventFromBlob[0] = skeletonMessage.Properties[Configuration.MessageDataProperty.MessageId.ToString()]; var ret = methodPersistEventFromBlob.Invoke(classInstanceDpp, ParametersPersistEventFromBlob); eventDataByte = (byte[])ret; } else { eventDataByte = skeletonMessage.Body; } //******************************************************************* // 3 IF TYPES EVENT - CONSOLE - REST // first area events, second console, third rest //******************************************************************* // ****************************IF EVENT TYPE************************* if (skeletonMessage.Properties[Configuration.MessageDataProperty.MessageType.ToString()].ToString() == Configuration.MessageDataProperty.Event.ToString()) { // ****************************IF EMBEDED TYPE EXECUTE TRIGGER************************* if (skeletonMessage.Properties[Configuration.MessageDataProperty.Embedded.ToString()].ToString() == "true") { var recChannelId = skeletonMessage.Properties[Configuration.MessageDataProperty.ReceiverChannelId.ToString()].ToString(); var recPointId = skeletonMessage.Properties[Configuration.MessageDataProperty.ReceiverPointId.ToString()].ToString(); //If using Guid pattern as string some system put an escape character like \ before the end brachet } var reqAvailable = (recChannelId.Contains(Configuration.ChannelId()) && recPointId.Contains(Configuration.PointId())) || (recChannelId.Contains(Configuration.ChannelAll) && recPointId.Contains(Configuration.PointId())) || (recChannelId.Contains(Configuration.ChannelId()) && recPointId.Contains(Configuration.ChannelAll)) || (recChannelId.Contains(Configuration.ChannelAll) && recPointId.Contains(Configuration.ChannelAll)); if (!reqAvailable) { return; } string idConfiguration = skeletonMessage.Properties[Configuration.MessageDataProperty.IdConfiguration.ToString()].ToString(); string idComponent = skeletonMessage.Properties[Configuration.MessageDataProperty.IdComponent.ToString()].ToString(); try { var triggerSingleInstance = (from trigger in EventsEngine.BubblingTriggerConfigurationsSingleInstance where trigger.IdComponent == idComponent && trigger.IdConfiguration == idConfiguration select trigger).First(); var bubblingTriggerConfiguration = triggerSingleInstance; LogEngine.ConsoleWriteLine($"Execute trigger idConfiguration {idConfiguration} and idComponent {idComponent}", ConsoleColor.Green); EventsEngine.ExecuteTriggerConfiguration(bubblingTriggerConfiguration, skeletonMessage.Body); } catch (Exception ex) { LogEngine.WriteLog(Configuration.EngineName, $"Error in {MethodBase.GetCurrentMethod().Name} - ExecuteTriggerConfiguration Error - Missing the idConfiguration {idConfiguration} and idComponent {idComponent}", Constant.ErrorEventIdHighCritical, Constant.TaskCategoriesError, ex, EventLogEntryType.Error); } // ****************************IF EMBEDED RETURN HERE************************* return; } // ****************************CAST TO BUBBLING EVENT************************* var eventBubbling = (BubblingEvent)SerializationEngine.ByteArrayToObject(eventDataByte); // ****************************PERSIST MESSAGE IN FOLDER************************* PersistentProvider.PersistMessage(eventBubbling, PersistentProvider.CommunicationDiretion.OffRamp); if (Configuration.LoggingVerbose()) { var serializedEvents = JsonConvert.SerializeObject( eventBubbling.Events, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); LogEngine.ConsoleWriteLine( $"Event received from point id: {skeletonMessage.Properties[Configuration.MessageDataProperty.SenderId.ToString()]} -point name : {skeletonMessage.Properties[Configuration.MessageDataProperty.SenderDescriprion.ToString()]} - {serializedEvents}", ConsoleColor.Green); } // ****************************IF EXIST EVENT TO EXECUTE************************* var eventsAvailable = from eventbubble in eventBubbling.Events from channel in eventbubble.Channels from point in channel.Points where (channel.ChannelId == Configuration.ChannelId() && point.PointId == Configuration.PointId()) || (channel.ChannelId == Configuration.ChannelAll && point.PointId == Configuration.PointId()) || (channel.ChannelId == Configuration.ChannelId() && point.PointId == Configuration.PointAll) || (channel.ChannelId == Configuration.ChannelAll && point.PointId == Configuration.PointAll) select eventbubble; if (!eventsAvailable.Any()) { // ****************************NO EVENT RETURN************************* return; } // ****************************EVENT EXIST EXECUTE************************* EventsEngine.ExecuteBubblingActionEvent( eventBubbling, false, skeletonMessage.Properties[Configuration.MessageDataProperty.SenderId.ToString()].ToString()); return; } var receiverChannelId = skeletonMessage.Properties[Configuration.MessageDataProperty.ReceiverChannelId.ToString()].ToString(); var receiverPointId = skeletonMessage.Properties[Configuration.MessageDataProperty.ReceiverPointId.ToString()].ToString(); var requestAvailable = (receiverChannelId == Configuration.ChannelId() && receiverPointId == Configuration.PointId()) || (receiverChannelId == Configuration.ChannelAll && receiverPointId == Configuration.PointId()) || (receiverChannelId == Configuration.ChannelId() && receiverPointId == Configuration.PointAll) || (receiverChannelId == Configuration.ChannelAll && receiverPointId == Configuration.PointAll); if (!requestAvailable) { // ****************************NOT FOR ME************************* return; } // **************************** IF CONSOLE TYPE ************************* //Save in a string to simplify the reading and code string OperationTypRequested = skeletonMessage.Properties[Configuration.MessageDataProperty.MessageType.ToString()].ToString(); //******************* OPERATION CONF BAG- ALL THE CONF FILES AND DLLS **************************************************************** if (OperationTypRequested == Configuration.MessageDataProperty.ConsoleSendBubblingBag.ToString() || OperationTypRequested == Configuration.MessageDataProperty.ConsoleSendBubblingBagFromPoint.ToString()) { //If send or received operaion bool sendOperation = true && OperationTypRequested == Configuration.MessageDataProperty.ConsoleSendBubblingBag.ToString(); if (!Configuration.DisableDeviceProviderInterface()) { if (sendOperation) { OffRampEngineSending.SendMessageOnRamp( EventsEngine.bubblingBag, Configuration.MessageDataProperty.ConsoleSendBubblingBagFromPoint, skeletonMessage.Properties[Configuration.MessageDataProperty.ChannelId.ToString()].ToString(), skeletonMessage.Properties[Configuration.MessageDataProperty.SenderId.ToString()].ToString(), null, null); } else { setConsoleActionEventEmbedded( Configuration.MessageDataProperty.ReceiverPointId.ToString(), skeletonMessage); } } else { LogEngine.WriteLog( Configuration.EngineName, "Warning the Device Provider Interface is disable, the GrabCaster point will be able to work in local mode only.", Constant.ErrorEventIdHighCritical, Constant.TaskCategoriesError, null, EventLogEntryType.Warning); } } //******************* OPERATION CONF BAG- ALL THE CONF FILES AND DLLS **************************************************************** // **************************** REST SERVICE CALLS AREA ************************* //RICEVE I BUBBLINGS // ****************************WRITE THE TRIGGERS AND EVENTS CONFIGURATION FILES IN FOLDERS************************* if (skeletonMessage.Properties[Configuration.MessageDataProperty.MessageType.ToString()].ToString() == Configuration.MessageDataProperty.SyncSendBubblingConfiguration.ToString()) { // eventDataByte = NULL LogEngine.ConsoleWriteLine( $"SyncSendBubblingConfiguration from - {senderId} - {senderDescription}", ConsoleColor.Cyan); var syncConfigurationFilelIst = (List <SyncConfigurationFile>)SerializationEngine.ByteArrayToObject(eventDataByte); SyncProvider.SyncBubblingConfigurationFileList( syncConfigurationFilelIst, skeletonMessage.Properties[Configuration.MessageDataProperty.MessageType.ToString()].ToString(), skeletonMessage.Properties[Configuration.MessageDataProperty.SenderId.ToString()].ToString(), skeletonMessage.Properties[Configuration.MessageDataProperty.SenderName.ToString()].ToString(), skeletonMessage.Properties[Configuration.MessageDataProperty.SenderDescriprion.ToString()].ToString(), skeletonMessage.Properties[Configuration.MessageDataProperty.ChannelId.ToString()].ToString(), skeletonMessage.Properties[Configuration.MessageDataProperty.ChannelName.ToString()].ToString(), skeletonMessage.Properties[Configuration.MessageDataProperty.ChannelDescription.ToString()].ToString()); return; } //RICEVE LA CONF DAL PUNTO // ****************************WRITE THE POINT CONFIGURATION FILE IN FOLDERs************************* if (skeletonMessage.Properties[Configuration.MessageDataProperty.MessageType.ToString()].ToString() == Configuration.MessageDataProperty.SyncSendConfiguration.ToString()) { // EventDataByte = NULL LogEngine.ConsoleWriteLine( $"SyncSendConfiguration from - {senderId} - {senderDescription}", ConsoleColor.Cyan); SyncProvider.SyncWriteConfiguration( skeletonMessage.Properties[Configuration.MessageDataProperty.ChannelId.ToString()].ToString(), skeletonMessage.Properties[Configuration.MessageDataProperty.SenderId.ToString()].ToString(), eventDataByte); return; } //RICEVE E SCRIVE UN FILE DI CONFIGURAZIONE TRIGGER O EVENT NELLA BUBBLIG // ****************************WRITE THE SPECIFIC BUBBLING FILE IN FOLDERS************************* if (skeletonMessage.Properties[Configuration.MessageDataProperty.MessageType.ToString()].ToString() == Configuration.MessageDataProperty.SyncSendFileBubblingConfiguration.ToString()) { // EventDataByte = NULL LogEngine.ConsoleWriteLine( $"SyncSendFileBubblingConfiguration from - {senderId} - {senderDescription}", ConsoleColor.Cyan); var syncConfigurationFilelIst = (List <SyncConfigurationFile>)SerializationEngine.ByteArrayToObject(eventDataByte); SyncProvider.SyncLocalBubblingConfigurationFile(syncConfigurationFilelIst); return; } //SCRIVE UN COMP DLL IN EVENTO O TRIGGER FOLDER // ****************************UPDATE A DLL COMPONENT IN FILE IN FOLDERS************************* if (skeletonMessage.Properties[Configuration.MessageDataProperty.MessageType.ToString()].ToString() == Configuration.MessageDataProperty.SyncSendComponent.ToString()) { // EventDataByte = NULL LogEngine.ConsoleWriteLine( $"SyncSendComponent from - {senderId} - {senderDescription}", ConsoleColor.Cyan); var eventBubbling = (BubblingEvent)SerializationEngine.ByteArrayToObject(eventDataByte); SyncProvider.SyncUpdateComponent( skeletonMessage.Properties[Configuration.MessageDataProperty.ChannelId.ToString()].ToString(), skeletonMessage.Properties[Configuration.MessageDataProperty.SenderId.ToString()].ToString(), eventBubbling); return; } // Request to send the local configuration // Send the configuration if (skeletonMessage.Properties[Configuration.MessageDataProperty.MessageType.ToString()].ToString() == Configuration.MessageDataProperty.SyncSendRequestBubblingConfiguration.ToString()) { // EventDataByte = NULL LogEngine.ConsoleWriteLine( $"SyncSendBubblingConfiguration from - {senderId} - {senderDescription}", ConsoleColor.Cyan); SyncProvider.SyncSendBubblingConfiguration( skeletonMessage.Properties[Configuration.MessageDataProperty.ChannelId.ToString()].ToString(), skeletonMessage.Properties[Configuration.MessageDataProperty.SenderId.ToString()].ToString()); return; } // Request to send the configuration // Send the configuration if (skeletonMessage.Properties[Configuration.MessageDataProperty.MessageType.ToString()].ToString() == Configuration.MessageDataProperty.SyncSendRequestConfiguration.ToString()) { // EventDataByte = NULL LogEngine.ConsoleWriteLine( $"SyncSendRequestConfiguration from - {senderId} - {senderDescription}", ConsoleColor.Cyan); SyncProvider.SyncSendConfiguration(skeletonMessage.Properties[Configuration.MessageDataProperty.ChannelId.ToString()].ToString(), skeletonMessage.Properties[Configuration.MessageDataProperty.SenderId.ToString()].ToString()); return; } // Request to send back a component if (skeletonMessage.Properties[Configuration.MessageDataProperty.MessageType.ToString()].ToString() == Configuration.MessageDataProperty.SyncSendRequestComponent.ToString()) { // EventDataByte = NULL LogEngine.ConsoleWriteLine( $"SyncSendRequestComponent from - {senderId} - {senderDescription}", ConsoleColor.Cyan); SyncProvider.SyncSendComponent( skeletonMessage.Properties[Configuration.MessageDataProperty.ChannelId.ToString()].ToString(), skeletonMessage.Properties[Configuration.MessageDataProperty.SenderId.ToString()].ToString(), skeletonMessage.Properties[Configuration.MessageDataProperty.IdComponent.ToString()].ToString()); return; } } catch (Exception ex) { LogEngine.WriteLog(Configuration.EngineName, $"Error in {MethodBase.GetCurrentMethod().Name}", Constant.ErrorEventIdHighCritical, Constant.TaskCategoriesError, ex, EventLogEntryType.Error); } }
public static void ScheduleSyncNow(SyncProvider obj) { obj.NextSync = DateTime.Now; }
public SyncHub(ApplicationDbContext context, SyncProvider provider, ILogger <SyncHub> logger) { _context = context; _provider = provider; _logger = logger; }
public void Setup(ReplicatorType replicatorType = ReplicatorType.LevelInstance, ReplicatorCHType channelType = ReplicatorCHType.GameOrderCritical, S defaultState = null) { if (DoneSetup) { throw new ArgumentException("This replicator already has been setup"); } //Convert Type to LifeTime eSNetReplicatorLifeTime lifeTime; switch (replicatorType) { case ReplicatorType.LevelInstance: lifeTime = eSNetReplicatorLifeTime.DestroyedOnLevelReset; break; case ReplicatorType.Manager: lifeTime = eSNetReplicatorLifeTime.NeverDestroyed; break; default: throw new ArgumentException("Argument: replicatorType is Invalid!"); } //Convert Managed ChannelType into SNet_ChannelType SNet_ChannelType snet_channelType; switch (channelType) { case ReplicatorCHType.SessionOrderCritical: snet_channelType = SNet_ChannelType.SessionOrderCritical; break; case ReplicatorCHType.GameReceiveCritical: snet_channelType = SNet_ChannelType.GameReceiveCritical; break; case ReplicatorCHType.GameOrderCritical: snet_channelType = SNet_ChannelType.GameOrderCritical; break; case ReplicatorCHType.GameNonCritical: snet_channelType = SNet_ChannelType.GameNonCritical; break; default: throw new ArgumentException("Argument: channelType is Invalid!"); } //Create stuffs var guid = Guid.NewGuid().ToString() + "_CustomReplicator_" + UnityEngine.Random.Range(000, 999); var syncObj = new GameObject(guid); var syncInstance = syncObj.AddComponent <LG_Door_Sync>(); //Make object not be Destroy On Loaded if (lifeTime == eSNetReplicatorLifeTime.NeverDestroyed) { GameObject.DontDestroyOnLoad(syncObj); } //Cast Door_Sync to Provider SyncProvider = syncInstance; var provider = SyncProvider.Cast <ComplexStateReplicatorProvider>(); //Create Replicator var defaultStateStruct = defaultState?.ToOriginal() ?? default; OriginalReplicator = ComplexStateReplicator.Create(provider, lifeTime, defaultStateStruct, snet_channelType); InnerReplicator = OriginalReplicator.Replicator.Cast <SNet_Replicator>(); InnerIReplicator = OriginalReplicator.Replicator; //Remove Replicator from Official Manager Class var oldKey = InnerIReplicator.Key; switch (InnerIReplicator.Type) { case SNet_ReplicatorType.Manager: SNet_Replication.s_replicatorSlots[oldKey] = null; SNet_Replication.s_highestSlotUsed_Manager--; break; case SNet_ReplicatorType.SelfManaged: SNet_Replication.s_replicatorSlots[oldKey] = null; SNet_Replication.s_highestSlotUsed_SelfManaged--; break; } SNet.Replication.RemoveFromAssignedList(InnerIReplicator); //Register Replicator to Custom Manager CustomReplicatorManager.RegisterReplicator(InnerIReplicator, guid, OnStateChange_Cast, out var newKey); InnerReplicator.Key = newKey; InnerIReplicator.Key = newKey; //Set Packet ID to Custom Area SetPacketBytes(OriginalReplicator.m_statePacket, InnerIReplicator.KeyBytes); SetPacketBytes(OriginalReplicator.m_statePacket_Recall, InnerIReplicator.KeyBytes); SetPacketBytes(OriginalReplicator.m_interactionPacket, InnerIReplicator.KeyBytes); SyncProvider.m_stateReplicator = OriginalReplicator; SyncProvider.m_syncStruct = OriginalReplicator.GetProviderSyncStruct(); //Set Default Value State.FromOriginal(OriginalReplicator.State); SendState.FromOriginal(OriginalReplicator.State); DoneSetup = true; }
public SyncService(SyncProvider syncProvider, ILogger <SyncService> logger) { this.syncProvider = syncProvider; this.logger = logger; }
public SyncService(SyncProvider provider, IConfiguration configuration, ISyncSender sync, ILogger <SyncService> logger) { _provider = provider; _configuration = configuration; ConnectionString = _configuration.GetConnectionString("HUB"); _clientProvider = new SqliteSyncProvider("box.db"); _proxyClientProvider = new WebProxyClientProvider(new Uri(_configuration["ClaWebApiServer"] + "/sync/post")); _agent = new SyncAgent(_clientProvider, _proxyClientProvider); _agent.LocalProvider.InterceptConnectionOpen(args => { var connection = args.Connection as SqliteConnection; if (connection == null) { _logger.LogError("Couldn't convert db connection to SqliteConnection"); return; } var cmd = connection.CreateCommand(); var password = _configuration["SqlPassword"]; // Prevent SQL Injection cmd.CommandText = "SELECT quote($password);"; cmd.Parameters.AddWithValue("$password", password); var quotedPassword = (string)cmd.ExecuteScalar(); // Encrypt database cmd.CommandText = "PRAGMA key = " + quotedPassword; cmd.Parameters.Clear(); cmd.ExecuteNonQuery(); }); _sync = sync; _logger = logger; //_sync.ChangeDetect += async (sender, args) => { await _provider.UpdateServer(_hubConnection, _myJwt); }; _sync.ChangeDetect += (sender, args) => { _logger.LogInformation($"[SyncService] Change Registered. Debouncing for 5 seconds..."); _changeSubject.OnNext(true); }; _changeSubject .Throttle(TimeSpan.FromSeconds(5)) .Subscribe(async s => { try { _logger.LogInformation($"[SyncService] Debounce complete. Attempting to update."); if (_sync.GetConnectedStatus()) { await RequestSync(); } else { _logger.LogInformation($"[SyncService] Server connection offline. Not updating."); } } catch (Exception e) { _logger.LogError($"[ChangeDetect] Exception {e.Message}"); } }); _hubConnection = new HubConnectionBuilder() .WithUrl(_configuration["ClaWebApiServer"] + "/sync", options => { options.AccessTokenProvider = async() => _myJwt; }) .AddJsonProtocol(options => { options.PayloadSerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; }) .Build(); _boxUiHubConnection = new HubConnectionBuilder() .WithUrl("http://localhost:5001/signalr", options => { options.Transports = HttpTransportType.WebSockets; options.SkipNegotiation = true; }) .Build(); _registryManager = RegistryManager.CreateFromConnectionString(ConnectionString); }