public override void PutSlice(Array sourceArray, int sliceLength) { ClearStatusVector(); DatabaseHandle dbHandle = _db.HandlePtr; TransactionHandle trHandle = _transaction.HandlePtr; IntPtr arrayDesc = ArrayDescMarshaler.MarshalManagedToNative(Descriptor); Type systemType = GetSystemType(); byte[] buffer = new byte[sliceLength]; if (systemType.GetTypeInfo().IsPrimitive) { Buffer.BlockCopy(sourceArray, 0, buffer, 0, buffer.Length); } else { buffer = EncodeSlice(Descriptor, sourceArray, sliceLength); } _db.FbClient.isc_array_put_slice( _statusVector, ref dbHandle, ref trHandle, ref _handle, arrayDesc, buffer, ref sliceLength); ArrayDescMarshaler.CleanUpNativeData(ref arrayDesc); _db.ProcessStatusVector(_statusVector); }
public override byte[] GetSlice(int sliceLength) { ClearStatusVector(); DatabaseHandle dbHandle = _db.HandlePtr; TransactionHandle trHandle = _transaction.HandlePtr; IntPtr arrayDesc = ArrayDescMarshaler.MarshalManagedToNative(Descriptor); byte[] buffer = new byte[sliceLength]; _db.FbClient.isc_array_get_slice( _statusVector, ref dbHandle, ref trHandle, ref _handle, arrayDesc, buffer, ref sliceLength); ArrayDescMarshaler.CleanUpNativeData(ref arrayDesc); _db.ProcessStatusVector(_statusVector); return(buffer); }
public EntityGroundVehicle(INETWISEDriverSink2 WISE, DatabaseHandle databaseHandle, ObjectHandle objectHandle, TransactionHandle transactionHandle) { this.WISE = WISE; this.Database = databaseHandle; this.Object = objectHandle; this.Transaction = transactionHandle; }
public EntityEquipment(INETWISEDriverSink2 WISE, DatabaseHandle databaseHandle, ObjectHandle objectHandle) { this.WISE = WISE; this.Database = databaseHandle; this.Object = objectHandle; this.Transaction = TransactionHandle.None; }
public EntityEquipmentSensorCBRNAP2Ce(INETWISEDriverSink2 WISE, DatabaseHandle databaseHandle, ObjectHandle objectHandle, TransactionHandle transactionHandle) { this.WISE = WISE; this.Database = databaseHandle; this.Object = objectHandle; this.Transaction = transactionHandle; }
public WISEObject(INETWISEDriverSink2 WISE, DatabaseHandle databaseHandle, ObjectHandle objectHandle, TransactionHandle transactionHandle) { this.WISE = WISE; this.Database = databaseHandle; this.Object = objectHandle; this.Transaction = transactionHandle; }
/// <summary> /// Close database and free all resources /// </summary> public void Dispose() { Close(); DatabaseHandle.Dispose(); DatabaseHandle = null; _functions = null; }
public FesDatabase(string dllName, Charset charset) { _fbClient = FbClientFactory.GetFbClient(dllName); _handle = new DatabaseHandle(); _charset = (charset != null ? charset : Charset.DefaultCharset); _dialect = 3; _packetSize = 8192; _statusVector = new IntPtr[IscCodes.ISC_STATUS_LENGTH]; }
public FesDatabase(string dllName, Charset charset) { _fbClient = FbClientFactory.Create(dllName); _handle = new DatabaseHandle(); Charset = charset ?? Charset.DefaultCharset; Dialect = 3; PacketSize = 8192; _statusVector = new IntPtr[IscCodes.ISC_STATUS_LENGTH]; }
private void ReleaseNativeObjects() { if (_handle == null || _handle.IsInvalid) { return; } _handle.Dispose(); _handle = null; }
/// <summary> /// Creates instance of EJDB. /// </summary> /// <param name="library"></param> public Database(Library library) { _functions = library.Functions.Database; DatabaseHandle = new DatabaseHandle(library); Library = library; StreamPool = new StreamPool(); Serializer = new JsonSerializer { NullValueHandling = NullValueHandling.Ignore, ContractResolver = NejdbContractResolver.Instance, }; Serializer.Converters.Add(ObjectIdConverter.Instance); }
private void Allocate() { ClearStatusVector(); DatabaseHandle dbHandle = _db.HandlePtr; _db.FbClient.isc_dsql_allocate_statement( _statusVector, ref dbHandle, ref _handle); _db.ProcessStatusVector(_statusVector); _allRowsFetched = false; _state = StatementState.Allocated; _statementType = DbStatementType.None; }
protected override void Open() { ClearStatusVector(); DatabaseHandle dbHandle = _db.HandlePtr; TransactionHandle trHandle = ((FesTransaction)_transaction).HandlePtr; _db.FbClient.isc_open_blob2( _statusVector, ref dbHandle, ref trHandle, ref _blobHandle, ref _blobId, 0, new byte[0]); _db.ProcessStatusVector(_statusVector); }
public override void PutSlice(System.Array sourceArray, int sliceLength) { // Clear the status vector ClearStatusVector(); DatabaseHandle dbHandle = _db.HandlePtr; TransactionHandle trHandle = _transaction.HandlePtr; IntPtr arrayDesc = ArrayDescMarshaler.MarshalManagedToNative(Descriptor); // Obtain the System of type of Array elements and // Fill buffer Type systemType = GetSystemType(); byte[] buffer = new byte[sliceLength]; #if NET40 if (systemType.IsPrimitive) #else if (systemType.GetTypeInfo().IsPrimitive) #endif { Buffer.BlockCopy(sourceArray, 0, buffer, 0, buffer.Length); } else { buffer = EncodeSlice(Descriptor, sourceArray, sliceLength); } _db.FbClient.isc_array_put_slice( _statusVector, ref dbHandle, ref trHandle, ref _handle, arrayDesc, buffer, ref sliceLength); // Free memory ArrayDescMarshaler.CleanUpNativeData(ref arrayDesc); _db.ProcessStatusVector(_statusVector); }
protected override void Create() { ClearStatusVector(); DatabaseHandle dbHandle = _db.HandlePtr; TransactionHandle trHandle = ((FesTransaction)_transaction).HandlePtr; _db.FbClient.isc_create_blob2( _statusVector, ref dbHandle, ref trHandle, ref _blobHandle, ref _blobId, 0, new byte[0]); _db.ProcessStatusVector(_statusVector); RblAddValue(IscCodes.RBL_create); }
public abstract WISE_RESULT CreateInstance(INETWISEDriverSink2 WISE, DatabaseHandle hDatabase, string objectName);
public static bool IsTypeOf(INETWISEDriverSink2 WISE, DatabaseHandle hDatabase, ObjectHandle hObject) { uint result = WISEError.WISE_ERROR; AttributeHandle hAttr = WISEConstants.WISE_INVALID_HANDLE; string strEntityType = string.Empty; if ((WISE == null) || (hObject == WISEConstants.WISE_INVALID_HANDLE)) { return false; } result = WISE.GetAttributeHandle(hDatabase, hObject, WISEConstants.WISE_TEMPLATE_OBJECT_TYPE, ref hAttr); if (WISEError.CheckCallFailed(result)) { return false; } result = WISE.GetAttributeValue(hDatabase, hObject, hAttr, ref strEntityType); return WISEError.CheckCallSucceeded(result) && IsTypeOf(strEntityType); }
protected override WISE_RESULT OnUpdateAttribute(DateTime timeStamp, DatabaseHandle hDatabase, ObjectHandle hObject, ClassHandle hClass, AttributeHandle hAttribute, object value, AttributeQualityCode quality, TransactionHandle hTransaction) { WISE_RESULT result = WISEError.WISE_OK; // Call base class implementation result = base.OnUpdateAttribute(timeStamp, hDatabase, hObject, hClass, hAttribute, value, quality, hTransaction); WISEError.CheckCallFailedEx(result); //string myValue = string.Empty; //AttributeHandle myAttributeHandle = AttributeHandle.Invalid; //this.WISE.GetAttributeHandle(hDatabase, hObject, "SomeAttribute", ref myAttributeHandle); //this.WISE.GetAttributeValue(hDatabase, hObject, myAttributeHandle, ref myValue); //global::CBRNSensors.EntityEquipmentSensorCBRNLCD stateObject = new global::CBRNSensors.EntityEquipmentSensorCBRNLCD(); //stateObject.CreateInstance(this.WISE, hDatabase); //stateObject.SensorState = //stateObject.AddToDatabase(hDatabase); return result; }
public Transactions(DatabaseHandle databaseHandle) { _databaseHandle = databaseHandle; }
protected override WISE_RESULT OnCreateDatabase(string strDatabaseName, DatabaseHandle hDatabase, DatabaseHandle hTemplateDatabase, DatabaseDistType eDatabaseDistType, DatabaseType eDatabaseType, OwnershipMode eModeOwnership, AttributeQualityMode eModeAttributeQuality, AttributeTimeMode eModeAttributeTime) { WISE_RESULT result = WISEError.WISE_OK; // Call base class implementation result = base.OnCreateDatabase(strDatabaseName, hDatabase, hTemplateDatabase, eDatabaseDistType, eDatabaseType, eModeOwnership, eModeAttributeQuality, eModeAttributeTime); WISEError.CheckCallFailedEx(result); if (eDatabaseType == DatabaseType.Application) { // // TODO: Open driver communication for the specified database. // Uri baseAddress = new Uri(string.Format("{0}:{1}", _baseAddress, _port)); IService service = new Service(this.WISE, hDatabase); _serviceHost = new WebServiceHost(service, baseAddress); ServiceEndpoint serviceEndpoint = _serviceHost.AddServiceEndpoint(typeof(IService), new WebHttpBinding(), ""); WebHttpBehavior webHttpBehavior = _serviceHost.Description.Behaviors.Find<WebHttpBehavior>(); if (webHttpBehavior != null) { webHttpBehavior.AutomaticFormatSelectionEnabled = true; } else { WebHttpBehavior webBehavior = new WebHttpBehavior(); webBehavior.AutomaticFormatSelectionEnabled = true; serviceEndpoint.Behaviors.Add(webBehavior); } // // Enable metadata // //ServiceMetadataBehavior metadataBehavior = new ServiceMetadataBehavior(); //metadataBehavior.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; //metadataBehavior.HttpGetEnabled = true; //_serviceHost.Description.Behaviors.Add(metadataBehavior); //_serviceHost.AddServiceEndpoint(typeof(IMetadataExchange), //MetadataExchangeBindings.CreateMexHttpBinding(), "mex"); //WebHttpBinding webHttpBinding = new WebHttpBinding(); //webHttpBinding. //_serviceHost.AddServiceEndpoint(typeof(IService), webHttpBinding, ""); // Initialize generated code. // TODO: handle error code Model.InitializeModel(this.WISE); _serviceHost.Open(); } return WISEError.WISE_OK; }
protected override WISE_RESULT OnSendEvent(DateTime timeStamp, DatabaseHandle hDatabase, EventHandle hEvent, ClassHandle hClass, TransactionHandle hTransaction) { WISE_RESULT result = WISEError.WISE_OK; // Call base class implementation result = base.OnSendEvent(timeStamp, hDatabase, hEvent, hClass, hTransaction); WISEError.CheckCallFailedEx(result); try { // // TODO: Send event on driver communication interface. // // This method typically needs to perform the following steps; // 1. Identify the type of event. // 2. Based on the event type, extract event attributes. // 3. Fill event attribute values into the protocol container associated with the event. // 4. Send the event on the underlying protocol. // #region Sample code: Check event type //ClassHandle hTestEventClass = ClassHandle.Invalid; //// Get handle corresponding to class "TEST_EVENT" (this can be done once and then cached) //result = this.WISETypeInfo.GetWISEClassHandle(hDatabase, "TEST_EVENT", ref hTestEventClass); //WISEError.CheckCallFailedEx(result); //if (hClass == hTestEventClass) //{ // #region Sample code: Access TEST_EVENT attributes // string stringAttributeValue = ""; // AttributeHandle hAttr = AttributeHandle.Invalid; // result = this.Sink.GetEventAttributeHandle(hDatabase, hEvent, "TEST_STRING", ref hAttr); // WISEError.CheckCallFailedEx(result); // result = this.Sink.GetEventAttributeValue(hDatabase, hEvent, hAttr, ref stringAttributeValue); // WISEError.CheckCallFailedEx(result); // #endregion //} #endregion } catch (WISEException ex) { result = ex.Error.ErrorCode; } return result; }
public uint CreateInstance(INETWISEDriverSink2 WISE, DatabaseHandle hDatabase, string objectName) { uint result = WISEError.WISE_ERROR; ObjectHandle objectHandle = this.Object; if (WISE == null) { result = WISEError.WISE_E_INVALID_ARG; return result; } if (objectHandle == WISEConstants.WISE_INVALID_HANDLE) { // Create object from template, if none exist. Dictionary<string, AttributeHandle> attributes = new Dictionary<string, AttributeHandle>(); // it's set from Template result = WISE.CreateObjectFromTemplate(hDatabase, objectName, EntityGroundVehicle.ClassName, ref objectHandle, ref attributes); } if (WISEError.CheckCallSucceeded(result)) { this.WISE = WISE; this.Database = WISEConstants.WISE_INVALID_HANDLE; this.Object = objectHandle; } return result; }
protected override WISE_RESULT OnCommitTransaction(System.DateTime timeStamp, DatabaseHandle hDatabase, TransactionHandle hTransaction, ObjectHandleList newObjects, ObjectHandleList removedObjects, Dictionary<ObjectHandle, List<AttributeHandle>> dictNewAttributes, Dictionary<ObjectHandle, List<AttributeHandle>> dictRemovedAttributes, Dictionary<ObjectHandle, List<AttributeHandle>> dictUpdatedAttributes, List<EventHandle> newEvents) { // // TODO: // If your protocol handles transactions, process the transaction data here. // Returning WISE_E_NOT_IMPL from this method will trigger the driver base class to use the // fallback behaviour where each change in the transaction is processed individually // through calls to OnAddObject, OnRemoveObject, OnNewAttribute, OnRemoveAttribute, // OnUpdateAttribute and OnSendEvent respectively. // return WISEError.WISE_E_NOT_IMPL; }
public uint AddToDatabase(DatabaseHandle databaseHandle) { uint result = WISEError.WISE_ERROR; ObjectHandle hObjectTemp = this.Object; if (this.WISE == null) { result = WISEError.WISE_E_INVALID_ARG; return result; } result = this.WISE.AddObjectToDatabase(databaseHandle, hObjectTemp); if (WISEError.CheckCallSucceeded(result)) { this.Database = databaseHandle; this.Object = hObjectTemp; } return result; }
public abstract WISE_RESULT AddToDatabase(DatabaseHandle databaseHandle);
public ConnectionArgs(string connectUserId, string roomId, PlayerData playerData, DatabaseHandle database) { this.ConnectUserId = connectUserId; this.RoomId = roomId; this.PlayerData = playerData; this.Database = database; }
public EntityGroundVehicle(INETWISEDriverSink2 WISE, DatabaseHandle databaseHandle, ObjectHandle objectHandle, TransactionHandle transactionHandle) : base(WISE, databaseHandle, objectHandle, transactionHandle) { }
void Start() { _dataServices = new List <IDataService>(); _databaseHandle = new DatabaseHandle(); }
public uint CreateInstance(INETWISEDriverSink2 WISE, DatabaseHandle hDatabase) { return CreateInstance(WISE, hDatabase, ""); }
public EntityEquipmentSensor(INETWISEDriverSink sink, DatabaseHandle databaseHandle, ObjectHandle objectHandle) { this.WISESink = sink; this.Database = databaseHandle; this.Handle = objectHandle; }
protected override WISE_RESULT OnCloseDatabase(DatabaseHandle hDatabase) { WISE_RESULT result = WISEError.WISE_OK; // Call base class implementation result = base.OnCloseDatabase(hDatabase); WISEError.CheckCallFailedEx(result); // // TODO: Close driver communication for the specified database. // _serviceHost.Close(); return WISEError.WISE_OK; }
public static bool IsTypeOf(INETWISEDriverSink sink, DatabaseHandle hDatabase, ObjectHandle hObject) { WISE_RESULT wResult = WISEError.WISE_OK; AttributeHandle hAttr = WISEConstants.WISE_INVALID_HANDLE; string strEntityType = string.Empty; if ((sink == null) || (hObject == WISEConstants.WISE_INVALID_HANDLE)) { return false; } // Initialize handle cache Initialize(sink as INETWISEStringCache); wResult = sink.GetAttributeHandle(hDatabase, hObject, WISEConstants.WISE_TEMPLATE_OBJECT_TYPE, ref hAttr, DataType.String); bool bResult = WISEError.CheckCallFailed(wResult); wResult = sink.GetAttributeValue(hDatabase, hObject, hAttr, ref strEntityType); bResult = WISEError.CheckCallSucceeded(wResult); return bResult && IsTypeOf(strEntityType); }
protected override WISE_RESULT OnConnectDatabase(string strDatabaseName, DatabaseHandle hDatabase, DatabaseDistType eDatabaseDistType, DatabaseType eDatabaseType, OwnershipMode eModeOwnership, AttributeQualityMode eModeAttributeQuality, AttributeTimeMode eModeAttributeTime) { WISE_RESULT result = WISEError.WISE_OK; // Implementation of this method is optional. // Call base class implementation result = base.OnConnectDatabase(strDatabaseName, hDatabase, eDatabaseDistType, eDatabaseType, eModeOwnership, eModeAttributeQuality, eModeAttributeTime); WISEError.CheckCallFailedEx(result); if (eDatabaseType == DatabaseType.Application) { // // TODO: Open driver communication for the specified database. // } return WISEError.WISE_OK; }
public WISE_RESULT CreateInstance(INETWISEDriverSink sink, DatabaseHandle hDatabase) { return CreateInstance(sink, hDatabase, ""); }
protected override WISE_RESULT OnRemoveObject(DateTime timeStamp, DatabaseHandle hDatabase, ObjectHandle hObject, ClassHandle hClass, TransactionHandle hTransaction) { WISE_RESULT result = WISEError.WISE_OK; // Call base class implementation result = base.OnRemoveObject(timeStamp, hDatabase, hObject, hClass, hTransaction); WISEError.CheckCallFailedEx(result); try { DatabaseType dbtype = DatabaseType.Unknown; result = this.Sink.GetDatabaseType(hDatabase, ref dbtype); if (dbtype == DatabaseType.Application) { // // TODO: Remove object on driver communication interface. // } } catch (WISEException ex) { result = ex.Error.ErrorCode; } return result; }
public CBRNLCDControl(INETWISEDriverSink2 WISE, DatabaseHandle databaseHandle, EventHandle eventHandle) { this.WISE = WISE; this.Database = databaseHandle; this.Handle = eventHandle; }
protected override WISE_RESULT OnAddObject(DateTime timeStamp, DatabaseHandle hDatabase, ObjectHandle hObject, ClassHandle hClass, string strObjectName, TransactionHandle hTransaction) { WISE_RESULT result = WISEError.WISE_OK; // Call base class implementation result = base.OnAddObject(timeStamp, hDatabase, hObject, hClass, strObjectName, hTransaction); WISEError.CheckCallFailedEx(result); try { DatabaseType dbtype = DatabaseType.Unknown; result = this.Sink.GetDatabaseType(hDatabase, ref dbtype); WISEError.CheckCallFailedEx(result); if (dbtype == DatabaseType.Application) { // Only process application database objects by default //if (global::CBRNSensors.EntityEquipment.IsTypeOf(this.WISE, hDatabase, hObject)) //{ // global::CBRNSensors.EntityEquipment myObject = new global::CBRNSensors.EntityEquipment(); //} // // TODO: Add object on driver communication interface. // // This method typically works in either of two ways. // If the underlying protocol requires us to send all object attributes // as a part of the object creation message; // 1. Identify the type of object. // 2. Based on the object type, extract its attributes. // 3. Fill object attribute values into the protocol container associated with object creation. // 4. the creation message on the underlying protocol. // // If the underlying protocol separates the create message from the initial attribute // update message; // 1. Fill object information into the protocol container associated with object creation. // 2. Send the creation message on the underlying protocol. // #region Sample code: Check object type //ClassHandle hTestObjectClass = ClassHandle.Invalid; //// Get handle corresponding to class "TEST_OBJECT" (this can be done once and then cached) //result = this.WISETypeInfo.GetWISEClassHandle(hDatabase, "TEST_OBJECT", ref hTestObjectClass); //WISEError.CheckCallFailedEx(result); //if (hClass == hTestObjectClass) //{ // #region Sample code: Access TEST_OBJECT attributes // string stringAttributeValue = ""; // AttributeHandle hAttr = AttributeHandle.Invalid; // result = this.Sink.GetAttributeHandle(hDatabase, hObject, "TEST_STRING", ref hAttr); // WISEError.CheckCallFailedEx(result); // result = this.Sink.GetAttributeValue(hDatabase, hObject, hAttr, ref stringAttributeValue); // WISEError.CheckCallFailedEx(result); // #endregion //} #endregion } } catch (WISEException ex) { result = ex.Error.ErrorCode; } return result; }
public uint SendEventToDatabase(DatabaseHandle databaseHandle) { uint result = WISEError.WISE_ERROR; if (this.WISE == null) { result = WISEError.WISE_E_INVALID_ARG; return result; } result = this.WISE.SendEvent(databaseHandle, this.Handle); if (WISEError.CheckCallSucceeded(result)) { this.Database = databaseHandle; } return result; }
public EntityEquipmentSensorCBRNI28(INETWISEDriverSink2 WISE, DatabaseHandle databaseHandle, ObjectHandle objectHandle) : base(WISE, databaseHandle, objectHandle) { }
public ConnectionArgs(DatabaseHandle database) { this.Database = database; }
public EntityGroundVehicle(INETWISEDriverSink sink, DatabaseHandle databaseHandle, ObjectHandle objectHandle) { this.WISESink = sink; this.Database = databaseHandle; this.Handle = objectHandle; }
public EntityEquipmentSensorCBRNLCD(INETWISEDriverSink2 WISE, DatabaseHandle databaseHandle, ObjectHandle objectHandle, TransactionHandle transactionHandle) : base(WISE, databaseHandle, objectHandle, transactionHandle) { }
public WISE_RESULT AddToDatabase(DatabaseHandle databaseHandle) { WISE_RESULT wResult = WISEError.WISE_OK; if (this.WISESink == null) { return CreateErrorCode(WISEError.WISE_NOT_INITIATED); } wResult = this.WISESink.AddObjectToDatabase(databaseHandle, this.Handle); if (WISEError.CheckCallSucceeded(wResult)) { this.Database = databaseHandle; } return wResult; }
public uint CreateInstance(INETWISEDriverSink2 WISE, DatabaseHandle hDatabase) { uint result = WISEError.WISE_ERROR; EventHandle eventHandle = this.Handle; if (WISE == null) { result = WISEError.WISE_E_INVALID_ARG; return result; } if (eventHandle == WISEConstants.WISE_INVALID_HANDLE) { // Create event from template, if none exist. Dictionary<string, AttributeHandle> attributes = new Dictionary<string, AttributeHandle>(); result = WISE.CreateEventFromTemplate(hDatabase, CBRNLCDControl.ClassName, ref eventHandle, ref attributes); } if (WISEError.CheckCallSucceeded(result)) { this.WISE = WISE; this.Database = WISEConstants.WISE_INVALID_HANDLE; this.Handle = eventHandle; } return result; }
public WISE_RESULT CreateInstance(INETWISEDriverSink sink, DatabaseHandle hDatabase, string objectName) { WISE_RESULT wResult = WISEError.WISE_OK; ObjectHandle objectHandle = this.Handle; if (sink == null) { return CreateErrorCode(WISEError.WISE_INVALID_ARG); } // Initialize handle cache Initialize(sink as INETWISEStringCache); if (objectHandle == WISEConstants.WISE_INVALID_HANDLE) { // Create object from template, if none exist. Dictionary<string, AttributeHandle> attributes = null; // it's set from Template wResult = sink.CreateObjectFromTemplate(hDatabase, objectName, EntityGroundVehicle.ClassName, ref objectHandle, ref attributes); } if (WISEError.CheckCallSucceeded(wResult)) { this.WISESink = sink; this.Database = WISEConstants.WISE_INVALID_HANDLE; this.Handle = objectHandle; } return wResult; }
public Events(DatabaseHandle databaseHandle) { _databaseHandle = databaseHandle; }