/// <summary> /// Writes an FSUIPC offset using data supplied in a VoiceAttack variable /// </summary> /// <param name="offsetAddress">address of offset</param> /// <param name="dataType">the data type to write</param> /// <param name="sourceVariable">VoiceAttack variable containing the data</param> public void writeOffset(int offsetAddress, Type dataType, string sourceVariable) { lock (m_connectionLock) { if (!m_isConnected) { writeErrorToLog("Not connected"); return; } } int numBytes = Utilities.numBytesFromType(dataType); if (numBytes < 1) { writeErrorToLog(dataType.Name + " is an unsupported type"); return; } IOffset offset = m_offsetFactory.createOffset(offsetAddress, numBytes, true); object value = Utilities.getVariableValueForOffset(dataType, sourceVariable, m_vaProxy); if (value != null) { offset.SetValue(value); m_fsuipc.Process(); } else { writeErrorToLog("Variable '" + sourceVariable + "' does not contain a value for type " + dataType.Name); } }
internal RawBrokerMessage(byte[] rawContent, IEnumerable <MessageHeader> headers, IEndpoint endpoint, IOffset offset) { RawContent = rawContent ?? throw new ArgumentNullException(nameof(rawContent)); Headers = new MessageHeaderCollection(headers); Endpoint = endpoint ?? throw new ArgumentNullException(nameof(endpoint)); Offset = offset; }
public void Store(IOffset offset) { lock (_uncommittedOffsets) { _uncommittedOffsets[offset.Key] = offset; } }
public int CompareTo(IOffset other) { var thisValue = long.Parse(Value); var otherValue = long.Parse(other.Value); return(thisValue.CompareTo(otherValue)); }
/// <summary> /// Reads an FSUIPC offset and updates a VoiceAttack variable /// </summary> /// <param name="offsetAddress">address of offset</param> /// <param name="dataType">the data type to read</param> /// <param name="sourceVariable">VoiceAttack variable which will be written to</param> public void readOffset(int offsetAddress, Type dataType, string destinationVariable) { lock (m_connectionLock) { if (!m_isConnected) { writeErrorToLog("Not connected"); return; } } int numBytes = Utilities.numBytesFromType(dataType); if (numBytes < 1) { writeErrorToLog(dataType.Name + " is an unsupported type"); return; } IOffset offset = m_offsetFactory.createOffset(offsetAddress, numBytes); m_fsuipc.Process(); if (!Utilities.setVariableValueFromOffset(dataType, offset, destinationVariable, m_vaProxy)) { writeErrorToLog("Failed to set '" + destinationVariable + "' with type " + dataType.Name); } }
/// <summary> /// Writes an offset which contains a string from a Text source variable /// </summary> /// <param name="offsetAddress">address of offset</param> /// <param name="length">the length of the string data</param> /// <param name="sourceVariable">the Text variable source in VoiceAttack</param> public void writeStringOffset(int offsetAddress, int length, string sourceVariable) { lock (m_connectionLock) { if (!m_isConnected) { writeErrorToLog("Not connected"); return; } } string value = m_vaProxy.GetText(sourceVariable); if (value != null) { IOffset offset = m_offsetFactory.createOffset(offsetAddress, value.Length, true); offset.SetValue(value); m_fsuipc.Process(); } else { writeErrorToLog("Variable '" + sourceVariable + "' does not contain a value for Text type"); } }
protected virtual async Task HandleMessageAsync( byte[]?message, IReadOnlyCollection <MessageHeader> headers, string sourceEndpointName, IOffset offset, IDictionary <string, string>?additionalLogData) { var envelope = new RawInboundEnvelope( message, headers, Endpoint, sourceEndpointName, offset, additionalLogData); _statusInfo.RecordConsumedMessage(offset); var consumerPipelineContext = new ConsumerPipelineContext( envelope, this, GetSequenceStore(offset), ServiceProvider); await ExecutePipelineAsync(consumerPipelineContext).ConfigureAwait(false); }
public static bool setVariableValueFromOffset(Type dataType, IOffset offset, string destination, dynamic vaProxy) { object value = offset.GetValue(dataType); if (dataType == typeof(float) || dataType == typeof(double)) { vaProxy.SetDecimal(destination, value); } else if (dataType == typeof(int) || dataType == typeof(uint) || dataType == typeof(short) || dataType == typeof(ushort) || dataType == typeof(char) || dataType == typeof(byte) || dataType == typeof(long) || dataType == typeof(ulong)) { vaProxy.SetInt(destination, Convert.ToInt32(value)); } else if (dataType == typeof(bool)) { vaProxy.SetBoolean(destination, value); } else { return(false); // Unspported data type } return(true); }
public MessageReceivedEventArgs(byte[] message, IEnumerable <MessageHeader> headers, IOffset offset, IEndpoint endpoint) { Message = message; Headers = headers; Offset = offset; Endpoint = endpoint; }
public void Not_Supported() { engine.Options.OffsetStyle = OffsetStyle.NotSupported; IOffset offset = sql.Offset(10); Exception ex = Assert.Throws <ClauseNotSupportedException>(() => engine.Compile(offset)); Assert.Equal("Offset clause is not supported in this engine.", ex.Message); }
public Task Store(IOffset offset) { lock (_uncommittedOffsets) { _uncommittedOffsets[offset.Key] = offset; } return(Task.CompletedTask); }
private static bool Patch(string filepath, PatchType type, IOffset offsets) { switch (type) { case PatchType.Farclip: return(ApplyPatch(filepath, offsets.SetFarclipPattern.Clone())); default: return(false); } }
public void Offset_Without_Parameters() { engine.Options.OffsetAsParameters = false; IOffset offset = sql.Offset(10).Fetch(20); QueryResult result = engine.Compile(offset); Assert.Equal("OFFSET 10 ROWS FETCH NEXT 20 ROWS ONLY", result.Sql); Assert.Equal(new Dictionary <string, object>(), result.Parameters); }
/// <summary> /// Returns the <see cref="ISequenceStore" /> to be used to store the pending sequences. /// </summary> /// <param name="offset"> /// The offset may determine which store is being used. For example a dedicated sequence store is used per /// each Kafka partition, since they may be processed concurrently. /// </param> /// <returns> /// The <see cref="ISequenceStore" />. /// </returns> protected virtual ISequenceStore GetSequenceStore(IOffset offset) { if (SequenceStores.Count == 0) { lock (SequenceStores) SequenceStores.Add(ServiceProvider.GetRequiredService <ISequenceStore>()); } return(SequenceStores.FirstOrDefault() ?? throw new InvalidOperationException("The sequence store is not initialized.")); }
public void Offset_Fetch_Overload() { IOffset offset = sql.Offset(10, 20); QueryResult result = engine.Compile(offset); Assert.Equal("OFFSET @p0 ROWS FETCH NEXT @p1 ROWS ONLY", result.Sql); Assert.Equal(new Dictionary <string, object>() { ["@p0"] = 10, ["@p1"] = 20 }, result.Parameters); }
public int CompareTo(IOffset obj) { if (ReferenceEquals(this, obj)) { return(0); } if (obj is null) { return(1); } return(obj is InMemoryOffset other?CompareTo(other) : throw new ArgumentException($"Object must be of type {nameof(InMemoryOffset)}")); }
public async Task TestPush(object message, MessageHeaderCollection headers, IOffset offset = null, IMessageSerializer serializer = null) { if (serializer == null) { serializer = new JsonMessageSerializer(); } var buffer = serializer.Serialize(message, headers); await TestPush(buffer, headers, offset); }
public static void SetOffset(IOffset offset, string value, ref string lineToParse, ref int lengthToSum) { int index = lineToParse.IndexOf(value); if (index != VALUE_NOT_FOUND) { offset.Offset = index + lengthToSum; offset.EndOffset = offset.Offset + value.Length; lineToParse = lineToParse.Remove(offset.Offset - lengthToSum, value.Length); lengthToSum += value.Length; } }
public InboundMessage(byte[] rawContent, IEnumerable <MessageHeader> headers, IOffset offset, IEndpoint endpoint, bool mustUnwrap) { if (headers != null) { Headers.AddRange(headers); } Offset = offset; Endpoint = endpoint; RawContent = rawContent; MustUnwrap = mustUnwrap; }
public void Limit_Without_Parameters() { engine.Options.OffsetStyle = OffsetStyle.Limit; engine.Options.OffsetAsParameters = false; IOffset offset = sql.Offset(10).Fetch(20); QueryResult result = engine.Compile(offset); Assert.Equal("LIMIT 20 OFFSET 10", result.Sql); Assert.Equal(new Dictionary <string, object>(), result.Parameters); }
public void Offset() { IOffset offset = sql.Offset(10); QueryResult result = engine.Compile(offset); Assert.Equal("OFFSET @p0 ROWS", result.Sql); Assert.Equal(new Dictionary <string, object> { ["@p0"] = 10 }, result.Parameters); }
public RawInboundEnvelope( Stream?rawMessage, IEnumerable <MessageHeader>?headers, IConsumerEndpoint endpoint, string actualEndpointName, IOffset offset, IDictionary <string, string>?additionalLogData = null) : base(rawMessage, headers, endpoint, additionalLogData) { ActualEndpointName = actualEndpointName; Offset = offset; }
private Dictionary <string, object> getMonitorContext() { Dictionary <string, object> context = new Dictionary <string, object>(); // Get the altimeter setting (feet/meters) IOffset <short> altimeterSetting = m_offsetFactory.createOffset <short>(OffsetValues.AltimeterSetting); m_fsuipc.Process(); context.Add("altimeterSetting", altimeterSetting.Value); return(context); }
public void Store(IOffset offset) { lock (_lock) { var entity = DbSet.Find(offset.Key) ?? DbSet.Add(new StoredOffset { Key = offset.Key }).Entity; entity.Offset = JsonConvert.SerializeObject(offset, typeof(IOffset), SerializerSettings); } }
internal static void RemoveOffset(IOffset Offset) { lock (FSUIPCConnection.dataGroups) { if (!FSUIPCConnection.dataGroups.ContainsKey(Offset.Group)) { return; } FSUIPCConnection.dataGroups[Offset.Group].Remove(Offset.ID); Offset.Connected = false; FSUIPCConnection.offsetGroupDictionary.Remove(Offset.ID); } }
public void Offset_Limit() { engine.Options.OffsetStyle = OffsetStyle.Limit; IOffset offset = sql.Offset(10); QueryResult result = engine.Compile(offset); Assert.Equal("LIMIT @p0 OFFSET @p1", result.Sql); Assert.Equal(new Dictionary <string, object>() { ["@p0"] = long.MaxValue, ["@p1"] = 10 }, result.Parameters); }
public void Fetch_Limit() { engine.Options.OffsetStyle = OffsetStyle.Limit; IOffset offset = sql.Fetch(20); QueryResult result = engine.Compile(offset); Assert.Equal("LIMIT @p0", result.Sql); Assert.Equal(new Dictionary <string, object> { ["@p0"] = 20 }, result.Parameters); }
public RawInboundEnvelope( byte[]?rawMessage, IEnumerable <MessageHeader>?headers, IConsumerEndpoint endpoint, string actualEndpointName, IOffset offset, IDictionary <string, string>?additionalLogData = null) : this( rawMessage != null ? new MemoryStream(rawMessage) : null, headers, endpoint, actualEndpointName, offset, additionalLogData) { }
/// <summary> /// Reads an offset which contains a string and updates a Text destination variable /// </summary> /// <param name="offsetAddress">address of offset</param> /// <param name="length">length the length of the string data</param> /// <param name="destinationVariable">the Text variable destination in VoiceAttack</param> public void readStringOffset(int offsetAddress, int length, string destinationVariable) { lock (m_connectionLock) { if (!m_isConnected) { writeErrorToLog("Not connected"); return; } } IOffset offset = m_offsetFactory.createOffset(offsetAddress, length); m_fsuipc.Process(); m_vaProxy.SetText(destinationVariable, offset.GetValue(typeof(string))); }
private void Log(ILogger logger, LogLevel logLevel, Exception exception, string logMessage, object message, IEndpoint endpoint, IOffset offset, int?failedAttempts, Guid?batchId, int?batchSize) { var properties = new List <(string, string, object)>(); if (offset != null) { properties.Add(("offset", "offset", $"{offset.Key}@{offset.Value}")); } if (endpoint != null) { properties.Add(("endpoint", "endpointName", endpoint.Name)); } if (message != null && !(message is byte[])) { properties.Add(("type", "messageType", message.GetType().Name)); var key = _messageKeyProvider.GetKey(message, false); if (key != null) { properties.Add(("id", "messageId", key)); } } if (failedAttempts != null && failedAttempts > 0) { properties.Add(("failedAttempts", "failedAttempts", failedAttempts)); } if (batchId != null) { properties.Add(("batchId", "batchId", batchId)); } if (batchSize != null) { properties.Add(("batchSize", "batchSize", batchSize)); } logger.Log( logLevel, exception, logMessage + " {{" + string.Join(", ", properties.Select(p => $"{p.Item1}={{{p.Item2}}}")) + "}}", properties.Select(p => p.Item3).ToArray()); }