protected virtual void Dispose(bool disposing) { if (disposing) { try { if (topicSubscriber != null) { RemoveListener(); ReturnCode status = topicSubscriber.DeleteContainedEntities(); status = currentTopic.Participant.DeleteSubscriber(topicSubscriber); ErrorHandler.CheckStatus( status, "Subscriber.TopicSubscribers.DeleteSubscriber (Dispose)"); topicSubscriber = null; } } catch (Exception e) { return; } } }
private void RemoveDataWriter() { if (DataWriter == null) { return; } ReturnCode status = topicPublisher.DeleteDataWriter(DataWriter); ErrorHandler.CheckStatus( status, "topicPublisher.DeleteDataWriter (RemoveDataWriter)"); }
public async Task <ActionResult <SPGetGymModel> > GetGymId([FromRoute] int id) { var resultId = await _context.Gym.FindAsync(id); if (resultId == null) { return(NotFound("Ginásio Indicado não se encontra Disponivel na BD")); } //METODO PARA SP COM PARAMETROS E RETORNO DE ERRO POR SP var ErrorCode = new ErrorHandler(); var result = new SPGetGymModel(); var SPConnection = new DatasetGeneratorFromSP(); var conn2 = new SqlConnection(); try { SqlParameter[] parameters = { new SqlParameter("@Id", id) }; conn2.ConnectionString = Configuration.GetConnectionString("MasterContext"); var DataSet = SPConnection.ConsumeSP("EXECUTE dbo.SP_GetGymId @id", parameters, conn2); var Status = JsonConvert.SerializeObject(DataSet.Tables[0]); var Validate = JsonConvert.DeserializeObject <List <Validate> >(Status); ErrorCode.CheckStatus(Validate); var ResultSp = DataSet.Tables[1].AsEnumerable(); result = ResultSp.Select(p => new SPGetGymModel { Id = p.Field <int>("GymId"), Adress = p.Field <string>("Adress"), Latitude = p.Field <string>("Latitude"), Longitude = p.Field <string>("Longitude"), Name = p.Field <string>("GymName"), Contact = p.Field <string>("Contact"), Email = p.Field <string>("Email"), Facebook = p.Field <string>("Facebook"), }).FirstOrDefault(); } catch (Exception ex) { return(BadRequest(ex.Message)); } return(result); }
/// <summary> /// Removes the listener. /// </summary> private void RemoveListener() { if (dataReader != null) { ReturnCode status = dataReader.DeleteContainedEntities(); ErrorHandler.CheckStatus( status, "Subscriber.DataReader.DeleteContainedEntities (RemoveListener)"); if (topicSubscriber != null) { status = topicSubscriber.DeleteDataReader(dataReader); ErrorHandler.CheckStatus(status, "Subscriber.TopicSubscribers.DeleteDataReader (RemoveListener)"); dataReader = null; } } }
private void CreateDataReader(AdapterReaderQos desiredQos, DataReaderListener <T> listener, int waitForHistoricalData) { if (partitionName.Contains("*")) { partitionName.Replace("*", string.Empty); } if (dataReader != null) { if (listener != null) { ReturnCode status = dataReader.SetListener( listener, StatusKind.DataAvailable | StatusKind.SampleLost | StatusKind.SampleRejected); ErrorHandler.CheckStatus(status, "Subscriber.SetListener (CreateDataReader)"); } } else { // Create a DataReader for the Topic // (using the appropriate QoS) and attach a listener to the data reader on new data available var dataReaderQos = new DataReaderQos(); topicSubscriber.CopyFromTopicQos(ref dataReaderQos, currentTopic.TopicQos); if (desiredQos != null) { dataReaderQos.Durability.Kind = desiredQos.PersistenceType.ConvertPersistence(); dataReaderQos.Reliability.Kind = desiredQos.MessageReliabilityType.ConvertReliability(); } dataReader = topicSubscriber.CreateDataReader( currentTopic.TopicMessageTopic, dataReaderQos, listener, StatusKind.DataAvailable); ErrorHandler.CheckHandle( dataReader, "Subscriber.CreateDatareader (CreateDataReader)"); dataReader.WaitForHistoricalData(new Duration(waitForHistoricalData, 0)); } }
public Publisher(Topic <T> topic, string partitionName, AdapterWriterQos desiredQos) { currentTopic = topic; IDomainParticipant participant = topic.Participant; var publisherQos = new PublisherQos(); ReturnCode status = participant.GetDefaultPublisherQos(ref publisherQos); ErrorHandler.CheckStatus(status, "Publisher.GetDefaultSubscriberQos (Publisher)"); publisherQos.Partition.Name = new string[1]; publisherQos.Partition.Name[0] = partitionName; // Create a Subscriber for the application. topicPublisher = participant.CreatePublisher(publisherQos); ErrorHandler.CheckHandle( topicPublisher, "Publisher.CreateSubscriber (Publisher)"); InitializeWriter(desiredQos); }
public Topic(string topicName, AdapterTopicQos requiredTopicQoS, TypeSupport clientTypeSupport) { if (clientTypeSupport == null) { throw new ArgumentNullException("clientTypeSupport"); } string domain = null; // just using the default partition, named after the topic name TopicName = topicName; TopicType = typeof(T).Name; // Create a DomainParticipantFactory and a DomainParticipant RegisterDomain(this, domain); ErrorHandler.CheckHandle(Participant, "DDS.DomainParticipantFactory.CreateParticipant"); // Register the required datatype. typeSupport = new TopicTypeSupport(clientTypeSupport); ReturnCode status = typeSupport.RegisterType(Participant, topicName); ErrorHandler.CheckStatus(status, "Topic.TopicMessageTypeSupport.RegisterType"); TopicQos topicQos = null; Participant.GetDefaultTopicQos(ref topicQos); ApplyQos(topicQos, requiredTopicQoS); TopicQos = topicQos; TopicMessageTopic = Participant.CreateTopic(topicName, topicName, topicQos); Participant.SetDefaultTopicQos(topicQos); if (TopicMessageTopic == null) { throw new Exception("QoS for topic " + TopicName + " FAILED!, please check QoS!"); } }
public Subscriber(Topic <T> topic, string partitionName, AdapterReaderQos desiredQos, DataReaderListener <T> listener, int waitForHistoricalData) { currentTopic = topic; this.partitionName = partitionName; this.listener = listener; IDomainParticipant participant = topic.Participant; var subQos = new SubscriberQos(); ReturnCode status = participant.GetDefaultSubscriberQos(ref subQos); ErrorHandler.CheckStatus( status, "Subscriber.GetDefaultSubscriberQos (Subscriber)"); subQos.Partition.Name = new string[1]; subQos.Partition.Name[0] = partitionName; // Create a Subscriber for the application. topicSubscriber = participant.CreateSubscriber(subQos); ErrorHandler.CheckHandle( topicSubscriber, "Subscriber.CreateSubscriber (Subscriber)"); CreateDataReader(desiredQos, listener, waitForHistoricalData); }
public ActionResult <IEnumerable <SPGetGymModel> > GetGym() { var ErrorCode = new ErrorHandler(); var result = new List <SPGetGymModel>(); var SPConnection = new DatasetGeneratorFromSP(); var conn2 = new SqlConnection(); try { conn2.ConnectionString = Configuration.GetConnectionString("MasterContext"); var DataSet = SPConnection.ConsumeSP("EXECUTE dbo.SP_GetGym", new SqlParameter[] { }, conn2); //1o metodo para converter DataSet para/de Json var Status = JsonConvert.SerializeObject(DataSet.Tables[0]); var Validate = JsonConvert.DeserializeObject <List <Validate> >(Status); ErrorCode.CheckStatus(Validate); // Verificar os Erros que vem da BD na Tabela 0 //2o metodo para converter DataSet para/de Json var ResultSp = DataSet.Tables[1].AsEnumerable(); result = ResultSp.Select(p => new SPGetGymModel { Id = p.Field <int>("GymId"), Latitude = p.Field <string>("Latitude"), Longitude = p.Field <string>("Longitude"), Name = p.Field <string>("GymName"), Contact = p.Field <string>("Contact"), Email = p.Field <string>("Email"), Facebook = p.Field <string>("Facebook"), Adress = p.Field <string>("Adress") }).ToList(); } catch (Exception ex) { return(BadRequest(ex.Message)); } return(result); }
protected virtual void Dispose(bool disposing) { if (disposing) { try { if (topicPublisher != null) { RemoveDataWriter(); ReturnCode status = topicPublisher.DeleteContainedEntities(); ErrorHandler.CheckStatus(status, "TopicPublisher.DeleteContainedEntities (Dispose)"); status = currentTopic.Participant.DeletePublisher(topicPublisher); ErrorHandler.CheckStatus(status, "TopicPublisher.DeletePublisher (Dispose)"); topicPublisher = null; } } catch (Exception e) { } } }