public ContactsDiaryController(ContactsDiaryServices contactsDiaryServices, PropertiesServices propertyManager, CityServices cityManager, AgentServices agentServices) { _contactsDiaryServices = contactsDiaryServices; _propertyManager = propertyManager; _cityManager = cityManager; _agentServices = agentServices; }
private void Add() { Agent agent = new Agent(); if (agentmobileNoTextBox.Text.ToString() == "" || agentmobileNoTextBox.Text.ToString() == "01") { MessageBox.Show("Enter Agent Mobile Number"); } else { if (agentnameTextBox.Text.ToString() == "") { MessageBox.Show("Enter Agent Name"); } else { if (agentaddressTextBox.Text.ToString() == "") { MessageBox.Show("Enter agent Address"); } else { agent.Name = agentnameTextBox.Text; agent.Mobile_No = agentmobileNoTextBox.Text; agent.Address = agentaddressTextBox.Text; AgentServices agentservices = new AgentServices(); if (agentservices.Add(agent) == 1) { MessageBox.Show("Adding Complete"); } } } } }
/// <summary> /// EJECUTA CARGA DE DATOS MASIVA /// </summary> /// <returns></returns> public string ExecuteBulk() { string response = AgentServices.ListenBulkAgent(this); if (response != "success") { error = response; } return(response); }
private void deletepassengergridview_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { Agent agent = new Agent(); AgentServices agentservices = new AgentServices(); String mobileNo = deletepassengergridview.CurrentRow.Cells[1].Value.ToString(); agent.Mobile_No = mobileNo; if (agentservices.Remove(agent) == 1) { MessageBox.Show("Successfully Deleted"); } }
/// <summary> /// Ejecuta la consulta en la base de datos Informix /// </summary> /// <returns>"success" = consulta completada, en otro caso se envia en mensaje de error</returns> public string Execute() { try { table = AgentServices.ListenAgent(this); json = JsonConvert.SerializeObject(table, Formatting.Indented, json_settings); return("success"); } catch (Exception ex) { error = ex.Message; return(ex.Message); } }
/// <summary> /// Ejecuta la consulta segun el comando enviado y retorna directamente el objeto requerido, se recomienda utilizar 'try' con esta metodo /// Ademas los atributos algunos atributos del agente no estan disponibles con este metodo: /// .error, .table, .json /// </summary> /// <param name="command">comandos:table, json </param> /// <returns></returns> public T Execute <T>(string command = "") { if (typeof(T) == typeof(DataTable)) { table = AgentServices.ListenAgent(this); return((T)Convert.ChangeType(table, typeof(T))); } if (typeof(T) == typeof(string)) { json = JsonConvert.SerializeObject(AgentServices.ListenAgent(this)); return((T)Convert.ChangeType(json, typeof(T))); } return((T)Convert.ChangeType(null, typeof(T))); }
private void agentGridView_CellClick(object sender, DataGridViewCellEventArgs e) { Agent agent = new Agent(); AgentServices agentServices = new AgentServices(); String agentMobileNo = agentupdateGridView.CurrentRow.Cells[1].Value.ToString(); agent.Mobile_No = agentMobileNo; UpdateAgentDetails updateagentdetails = new UpdateAgentDetails(agentServices.GetByName(agent)); this.Hide(); updateagentdetails.Closed += (s, args) => this.Close(); updateagentdetails.Show(); }
private void updateAgent() { Agent agent = new Agent(); if (agentmobileNoTextBox.Text.ToString() == "") { MessageBox.Show("Enter Mobile No."); } else { if (agentnameTextBox.Text.ToString() == "") { MessageBox.Show("Enter Name"); } else { if (agentaddressTextBox.Text.ToString() == "") { MessageBox.Show("Enter Address"); } else { try { agent.Mobile_No = agentmobileNoTextBox.Text; } catch (Exception) { MessageBox.Show("Already Exist"); } agent.Address = agentaddressTextBox.Text; agent.Name = agentnameTextBox.Text; AgentServices agentservices = new AgentServices(); if (agentservices.Update(agent) == 1) { MessageBox.Show("Successfully Updated"); } else { MessageBox.Show("Update Failed"); } } } } }
public void ServiceResponseNotFoundTestMethod() { List <string> _log = new List <string>(); using (AgentServices _services = new AgentServices(new TestRepository(), new NetworkAgent(), -1, (x) => _log.Add(x))) { Assert.AreEqual <int>(2, _log.Count); using (HttpClient _client = new HttpClient()) { _client.BaseAddress = new Uri("http://localhost:3001"); HttpResponseMessage _message = _client.GetAsync("/wrong").Result; Assert.IsNotNull(_message); Assert.AreEqual <HttpStatusCode>(HttpStatusCode.BadRequest, _message.StatusCode); } } Assert.AreEqual <int>(2, _log.Count); }
/// <summary> /// Ejecuta la consulta de tipo MSSQL /// </summary> /// <returns>reportan "success" ejecucion completada, en otro caso devuelve el error</returns> public string Execute() { try { table = AgentServices.ListenAgent(this); json = JsonConvert.SerializeObject(table, Formatting.Indented, json_settings); return("success"); } catch (Exception ex) { if (handding_transaction) { transaction.Rollback(); connection.Close(); } error = ex.Message; return(ex.Message); } }
/// <summary> /// Creates an instance of the <see cref="AgentManager"/> class./> /// </summary> /// <remarks> /// The agent should be constructed as early as possible in order to perform /// initialization of the logging system. /// </remarks> private AgentManager() { _container = AgentServices.GetContainer(); AgentServices.RegisterServices(_container); // Resolve IConfigurationService (so that it starts listening to config changes) before loading newrelic.config _container.Resolve <IConfigurationService>(); var config = ConfigurationLoader.Initialize(); LoggerBootstrapper.ConfigureLogger(config.LogConfig); AssertAgentEnabled(config); EventBus <KillAgentEvent> .Subscribe(OnShutdownAgent); //Initialize the extensions loader with extensions folder based on the the install path ExtensionsLoader.Initialize(AgentInstallConfiguration.InstallPathExtensionsDirectory); // Resolve all services once we've ensured that the agent is enabled // The AgentApiImplementation needs to be resolved before the WrapperService, because // resolving the WrapperService triggers an agent connect but it doesn't instantiate // the CustomEventAggregator, so we need to resolve the AgentApiImplementation to // get the CustomEventAggregator instantiated before the connect process is triggered. // If that doesn't happen the CustomEventAggregator will not start its harvest timer // when the agent connect response comes back. The agent DI, startup, and connect // process really needs to be refactored so that it's more explicit in its behavior. var agentApi = _container.Resolve <IAgentApi>(); _wrapperService = _container.Resolve <IWrapperService>(); //We need to attempt to auto start the agent once all services have resolved _container.Resolve <IConnectionManager>().AttemptAutoStart(); AgentServices.StartServices(_container); // Setup the internal API first so that AgentApi can use it. InternalApi.SetAgentApiImplementation(agentApi); AgentApi.SetSupportabilityMetricCounters(_container.Resolve <IApiSupportabilityMetricCounters>()); Initialize(); _isInitialized = true; }
public AgentController() { unitOfWork = new UnitOfWork(); AgentServices = new AgentServices(unitOfWork); }
public AgentAnswersController(AgentServices agentServices, AgentAnswerServices agentAnswerService, AgentQuestionServices agentQuestionServices) { _agentServices = agentServices; _agentAnswerService = agentAnswerService; _agentQuestionServices = agentQuestionServices; }
public AgentQuestionsController(AgentQuestionServices agentQuestionServices, AgentServices agentServices) { _agentQuestionServices = agentQuestionServices; _agentServices = agentServices; }
public PartnersDiaryController(PartnerServices partnersManager, CityServices cityManager, AgentServices agentServices) { _partnersManager = partnersManager; _cityManager = cityManager; _agentServices = agentServices; }
public AgentMaterialsController(FileServices filesManager, FolderServices folderManager, AgentServices agentServices) { _filesManager = filesManager; _folderManager = folderManager; _agentServices = agentServices; }
public CompositeTestAgent(bool shouldAllowThreads, bool includeAsyncLocalStorage) { Log.Initialize(new Logger()); _shouldAllowThreads = shouldAllowThreads; // Create the fake classes necessary to construct services var mockFactory = Mock.Create <IContextStorageFactory>(); Mock.Arrange(() => mockFactory.CreateContext <IInternalTransaction>(Arg.AnyString)).Returns(_primaryTransactionContextStorage); var transactionContextFactories = new List <IContextStorageFactory> { mockFactory }; if (includeAsyncLocalStorage) { transactionContextFactories.Add(new AsyncLocalStorageFactory()); } var wrappers = Enumerable.Empty <IWrapper>(); var mockEnvironment = Mock.Create <IEnvironment>(); var dataTransportService = Mock.Create <IDataTransportService>(); var scheduler = Mock.Create <IScheduler>(); NativeMethods = Mock.Create <INativeMethods>(); _harvestActions = new List <Action>(); Mock.Arrange(() => scheduler.ExecuteEvery(Arg.IsAny <Action>(), Arg.IsAny <TimeSpan>(), Arg.IsAny <TimeSpan?>())) .DoInstead <Action, TimeSpan, TimeSpan?>((action, _, __) => { lock (_harvestActionsLockObject) { _harvestActions.Add(action); } }); var threadPoolStatic = Mock.Create <IThreadPoolStatic>(); _queuedCallbacks = new List <WaitCallback>(); Mock.Arrange(() => threadPoolStatic.QueueUserWorkItem(Arg.IsAny <WaitCallback>())) .DoInstead <WaitCallback>(callback => { lock (_queuedCallbacksLockObject) { _queuedCallbacks.Add(callback); } }); var configurationManagerStatic = Mock.Create <IConfigurationManagerStatic>(); Mock.Arrange(() => configurationManagerStatic.GetAppSetting("NewRelic.LicenseKey")) .Returns("Composite test license key"); // Construct services _container = AgentServices.GetContainer(); AgentServices.RegisterServices(_container); // Replace existing registrations with mocks before resolving any services _container.ReplaceRegistration(mockEnvironment); _container.ReplaceRegistration <IEnumerable <IContextStorageFactory> >(transactionContextFactories); _container.ReplaceRegistration <ICallStackManagerFactory>( new TestCallStackManagerFactory()); _container.ReplaceRegistration(wrappers); _container.ReplaceRegistration(dataTransportService); _container.ReplaceRegistration(scheduler); _container.ReplaceRegistration(NativeMethods); _container.ReplaceRegistration(Mock.Create <ICATSupportabilityMetricCounters>()); if (!_shouldAllowThreads) { _container.ReplaceRegistration(threadPoolStatic); } _container.ReplaceRegistration(configurationManagerStatic); InstrumentationService = _container.Resolve <IInstrumentationService>(); InstrumentationWatcher = _container.Resolve <InstrumentationWatcher>(); AgentServices.StartServices(_container); DisableAgentInitializer(); InternalApi.SetAgentApiImplementation(_container.Resolve <IAgentApi>()); AgentApi.SetSupportabilityMetricCounters(_container.Resolve <IApiSupportabilityMetricCounters>()); // Update configuration (will also start services) LocalConfiguration = GetDefaultTestLocalConfiguration(); ServerConfiguration = GetDefaultTestServerConfiguration(); SecurityConfiguration = GetDefaultSecurityPoliciesConfiguration(); InstrumentationWatcher.Start(); PushConfiguration(); _attribDefSvc = _container.Resolve <IAttributeDefinitionService>(); // Redirect the mock DataTransportService to capture harvested wire models Mock.Arrange(() => dataTransportService.Send(Arg.IsAny <IEnumerable <MetricWireModel> >())) .Returns(SaveDataAndReturnSuccess(Metrics)); Mock.Arrange(() => dataTransportService.Send(Arg.IsAny <IEnumerable <CustomEventWireModel> >())) .Returns(SaveDataAndReturnSuccess(CustomEvents)); Mock.Arrange(() => dataTransportService.Send(Arg.IsAny <IEnumerable <TransactionTraceWireModel> >())) .Returns(SaveDataAndReturnSuccess(TransactionTraces)); Mock.Arrange(() => dataTransportService.Send(Arg.IsAny <EventHarvestData>(), Arg.IsAny <IEnumerable <TransactionEventWireModel> >())) .Returns(SaveDataAndReturnSuccess(AdditionalHarvestData, TransactionEvents)); Mock.Arrange(() => dataTransportService.Send(Arg.IsAny <IEnumerable <ErrorTraceWireModel> >())) .Returns(SaveDataAndReturnSuccess(ErrorTraces)); Mock.Arrange(() => dataTransportService.Send(Arg.IsAny <IEnumerable <SqlTraceWireModel> >())) .Returns(SaveDataAndReturnSuccess(SqlTraces)); Mock.Arrange(() => dataTransportService.Send(Arg.IsAny <EventHarvestData>(), Arg.IsAny <IEnumerable <ErrorEventWireModel> >())) .Returns(SaveDataAndReturnSuccess(AdditionalHarvestData, ErrorEvents)); Mock.Arrange(() => dataTransportService.Send(Arg.IsAny <EventHarvestData>(), Arg.IsAny <IEnumerable <ISpanEventWireModel> >())) .Returns(SaveDataAndReturnSuccess(AdditionalHarvestData, SpanEvents)); EnableAggregators(); }