static void Main1(string[] args) { log4net.Config.XmlConfigurator.Configure(); Log.Write("Test scheduling", "Current time=" + DateTime.Now, LogMessageType.Debug); Log.Write("Test scheduling", "Test 1234", LogMessageType.Debug); // create service env var envConfig = new ServiceEnvironmentConfiguration() { DefaultHostName = "Johnny", ConnectionString = "Data Source=bi_rnd;Initial Catalog=EdgeSystem;Integrated Security=true", SP_HostRegister = "Service_HostRegister", SP_HostUnregister = "Service_HostUnregister", SP_InstanceSave = "Service_InstanceSave", SP_InstanceGet = "Service_InstanceGet", SP_InstanceReset = "Service_InstanceReset", SP_ServicesExecutionStatistics = "Service_ExecutionStatistics_GetByPercentile", SP_InstanceActiveListGet = "Service_InstanceActiveList_GetByTime" }; var environment = ServiceEnvironment.Open(envConfig); // generate scheduler config, create scheduler and start it var schedulerConfig = GenerateConfigForScheduler(); var scheduler = new Scheduler(environment, schedulerConfig); scheduler.Start(); do { } while (Console.ReadLine() != "exit"); scheduler.Stop(); }
public void PrepareServiceEnvironment(string serviceName, ServiceEnvironment envType, string[] profilerEnvironment) { _serviceName = serviceName; _profilerEnvironment = profilerEnvironment; // this is a bit intricate - if the service is running as LocalSystem, we need to set the environment // variables in the registry for the service, otherwise it's better to temporarily set it for the account, // assuming we can find out the account SID // Network Service works better with environments is better on the service too var serviceAccountName = MachineQualifiedServiceAccountName(_serviceName); if (serviceAccountName != "LocalSystem") { _serviceAccountSid = LookupAccountSid(serviceAccountName); } if (_serviceAccountSid != null && envType != ServiceEnvironment.ByName) { SetAccountEnvironment(_serviceAccountSid, _profilerEnvironment); } else { _serviceAccountSid = null; string[] baseEnvironment = GetServicesEnvironment(); string[] combinedEnvironment = CombineEnvironmentVariables(baseEnvironment, _profilerEnvironment); SetEnvironmentVariables(_serviceName, combinedEnvironment); } }
public Scheduler(ServiceEnvironment environment, SchedulerConfiguration configuration) { Configuration = configuration; // set environment and register to env event for scheduling services (from workflow) Environment = environment; _listener = environment.ListenForEvents(ServiceEnvironmentEventType.ServiceRequiresScheduling); _listener.ServiceRequiresScheduling += Listener_ServiceRequiresScheduling; // init base service dictionary foreach (var serviceConfig in Configuration.ServiceConfigurationList) { _serviceBaseConfigurations.Add(serviceConfig.ServiceName, serviceConfig); } // add services to schedule foreach (var service in Configuration.Profiles.SelectMany(profile => profile.Services)) { _serviceConfigurationsToSchedule.Add(service); } LoadServiceExecutionStatistics(); LoadRecovery(); DebugStartupInfo(); }
static void Main() { log4net.Config.XmlConfigurator.Configure(); Log.Start(); // Create Environment and host var envConfig = new ServiceEnvironmentConfiguration { DefaultHostName = "Johnny", ConnectionString = "Data Source=bi_rnd;Initial Catalog=EdgeSystem;Integrated Security=true", SP_HostListGet = "Service_HostList", SP_HostRegister = "Service_HostRegister", SP_HostUnregister = "Service_HostUnregister", SP_InstanceSave = "Service_InstanceSave", SP_InstanceGet = "Service_InstanceGet", SP_InstanceReset = "Service_InstanceReset", SP_EnvironmentEventListenerListGet = "Service_EnvironmentEventListenerListGet", SP_EnvironmentEventListenerRegister = "Service_EnvironmentEventListenerRegister", SP_EnvironmentEventListenerUnregister = "Service_EnvironmentEventListenerUnregister", SP_ServicesExecutionStatistics = "Service_ExecutionStatistics_GetByPercentile", SP_InstanceActiveListGet = "Service_InstanceActiveList_GetByTime" }; var environment = ServiceEnvironment.Open("Environment Test", envConfig); var host = new ServiceExecutionHost(environment.EnvironmentConfiguration.DefaultHostName, environment); Log.Write("TestEnvironment", "Started Environment", LogMessageType.Debug); do { } while (Console.ReadLine() != "exit"); }
public void ClearAmbientTransactionAndServiceEnvironment() { try { if (this.resourceManager.IsBatchDirty) { this.ServiceProvider.AddResourceManager(this.resourceManager); } if (this.currentAtomicActivity != null) { TransactionalProperties properties = (TransactionalProperties)this.currentAtomicActivity.GetValue(WorkflowExecutor.TransactionalPropertiesProperty); properties.Transaction = null; if (properties.TransactionScope != null) { properties.TransactionScope.Complete(); properties.TransactionScope.Dispose(); properties.TransactionScope = null; } } } finally { ((IDisposable)this.serviceEnvironment).Dispose(); this.serviceEnvironment = null; } }
private void CreateEnvironment() { var envConfig = new ServiceEnvironmentConfiguration { DefaultHostName = "Johnny", ConnectionString = "Data Source=bi_rnd;Initial Catalog=EdgeSystem;Integrated Security=true", SP_HostListGet = "Service_HostList", SP_HostRegister = "Service_HostRegister", SP_HostUnregister = "Service_HostUnregister", SP_InstanceSave = "Service_InstanceSave", SP_InstanceGet = "Service_InstanceGet", SP_InstanceReset = "Service_InstanceReset", SP_EnvironmentEventListenerListGet = "Service_EnvironmentEventListenerListGet", SP_EnvironmentEventListenerRegister = "Service_EnvironmentEventListenerRegister", SP_EnvironmentEventListenerUnregister = "Service_EnvironmentEventListenerUnregister", SP_ServicesExecutionStatistics = "Service_ExecutionStatistics_GetByPercentile", SP_InstanceActiveListGet = "Service_InstanceActiveList_GetByTime" }; _environment = ServiceEnvironment.Open("Scheduler UI", envConfig); _listener = _environment.ListenForEvents(ServiceEnvironmentEventType.ScheduleUpdated); _listener.ScheduleUpdated += Listener_ScheduleUpdated; //_host = new ServiceExecutionHost(_environment.EnvironmentConfiguration.DefaultHostName, _environment); }
public void IsStaging_returns_true_if_environment_is_correct() { var environment = new ServiceEnvironment { EnvironmentName = "Staging" }; Assert.That(environment.IsStaging(), Is.True); }
public void IsDevelopment_returns_true_if_environment_is_correct() { var environment = new ServiceEnvironment { EnvironmentName = "Development" }; Assert.That(environment.IsDevelopment(), Is.True); }
public void IsProduction_returns_true_if_environment_is_correct() { var environment = new ServiceEnvironment { EnvironmentName = "Production" }; Assert.That(environment.IsProduction(), Is.True); }
public async Task <IActionResult> GetNamesAsync() { Application app = this.GetApplication(); ApplicationService serv = this.GetService(); ServiceEnvironment env = this.GetEnvironment(); return(Json(await _client.GetConfigNamesAsync(app.Key, serv.Key, env.Key))); }
public async Task <IActionResult> GetConfigs() { Application app = this.GetApplication(); ApplicationService serv = this.GetService(); ServiceEnvironment env = this.GetEnvironment(); IEnumerable <(string Name, string Value)> configs = await _client.GetConfigsAsync(app.Key, serv.Key, env.Key); return(Json(configs.Select(config => new { config.Name, config.Value }))); }
public void SetAmbientTransactionAndServiceEnvironment(Transaction transaction) { this.serviceEnvironment = new ServiceEnvironment(this.RootActivity); if ((transaction != null) && (this.currentAtomicActivity != null)) { TransactionalProperties properties = (TransactionalProperties)this.currentAtomicActivity.GetValue(WorkflowExecutor.TransactionalPropertiesProperty); properties.Transaction = transaction; properties.TransactionScope = new System.Transactions.TransactionScope(properties.Transaction, TimeSpan.Zero, EnterpriseServicesInteropOption.Full); } }
public void SetAmbientTransactionAndServiceEnvironment(Transaction transaction) { this.serviceEnvironment = new ServiceEnvironment(this.RootActivity); if (transaction != null && this.currentAtomicActivity != null) { TransactionalProperties transactionalProperties = (TransactionalProperties)this.currentAtomicActivity.GetValue(WorkflowExecutor.TransactionalPropertiesProperty); Debug.Assert(transactionalProperties != null, "The current atomic activity is missing transactional properties"); transactionalProperties.Transaction = transaction; transactionalProperties.TransactionScope = new System.Transactions.TransactionScope(transactionalProperties.Transaction, TimeSpan.Zero, EnterpriseServicesInteropOption.Full); } }
public Scheduler(ServiceEnvironment environment) { //Load services configurationfile string configFileName = EdgeServicesConfiguration.DefaultFileName; //if (args.Length > 0 && args[0].StartsWith("/") && args[0].Length > 1) //{ // configFileName = args[0].Substring(1); //} EdgeServicesConfiguration.Load(configFileName); //wcf for the scheduler to get the profiles host = new WebServiceHost(this, new Uri("http://localhost:9000/")); WebHttpBinding binding = new WebHttpBinding(); binding.MaxReceivedMessageSize = 2147483647; binding.MaxBufferSize = 2147483647; binding.MaxBufferPoolSize = 2147483647; binding.ReaderQuotas.MaxBytesPerRead = 2147483647; binding.ReaderQuotas.MaxArrayLength = 2147483647; binding.Name = "BLA"; ServiceEndpoint ep = host.AddServiceEndpoint(typeof(ISchedulerDataService), binding, "http://localhost:9500/"); DataContractSerializerOperationBehavior be = ep.Contract.Operations[0].Behaviors.Find <DataContractSerializerOperationBehavior>(); be.MaxItemsInObjectGraph = 2147483647; //todo: take care of exeptions, should it be here? host.Open(); Environment = environment; environment.ListenForEvents(ServiceEnvironmentEventType.ServiceScheduleRequested); environment.ServiceScheduleRequested += new EventHandler <ServiceScheduleRequestedEventArgs>(environment_ServiceScheduleRequested); _percentile = int.Parse(AppSettings.Get(this, "Percentile")); _neededScheduleTimeLine = TimeSpan.Parse(AppSettings.Get(this, "NeededScheduleTimeLine")); _intervalBetweenNewSchedule = TimeSpan.Parse(AppSettings.Get(this, "IntervalBetweenNewSchedule")); _findServicesToRunInterval = TimeSpan.Parse(AppSettings.Get(this, "FindServicesToRunInterval")); _timeToDeleteServiceFromTimeLine = TimeSpan.Parse(AppSettings.Get(this, "DeleteEndedServiceInterval")); _executionTimeCashTimeOutAfter = TimeSpan.Parse(AppSettings.Get(this, "DeleteEndedServiceInterval")); LoadServicesFromConfigurationFile(); }
public async Task <IActionResult> AddOrUpdateAsync([FromBody] AddConfigDto addConfigDto) { if (!ModelState.IsValid) { return(this.ValidationError()); } Application app = this.GetApplication(); ApplicationService serv = this.GetService(); ServiceEnvironment env = this.GetEnvironment(); await _client.AddConfigAsync(app.Key, serv.Key, env.Key, addConfigDto.ConfigName, addConfigDto.ConfigValue); return(Ok()); }
protected void CleanEnv(ServiceEnvironment environment) { // delete service events using (var connection = new SqlConnection(environment.EnvironmentConfiguration.ConnectionString)) { connection.Open(); var command = new SqlCommand("delete from [EdgeSystem].[dbo].ServiceEnvironmentEvent where TimeStarted >= '2013-01-01 00:00:00.000'", connection) { CommandType = CommandType.Text }; command.ExecuteNonQuery(); } }
internal TelekomClient(TelekomAuth authentication, ServiceEnvironment environment, string baseUrlTemplate) { if (authentication == null) { throw new ArgumentNullException("authentication"); } this.authentication = authentication; // Replace the placeholder for environment in baseUrlTemplate string environmentString = Enum.GetName(typeof(ServiceEnvironment), environment).ToLower(); ServiceBaseUrl = TelekomBaseUrl + string.Format(baseUrlTemplate, environmentString); }
public TTDriver(Action <string> onInit, WorkerDispatcher dispatcher) { this._dispatcher = dispatcher; _ttNetApiFunctions = new TTNetApiFunctions(onInit, this._dispatcher); // Add your app secret Key here. It looks like: 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000 string appSecretKey = "7f6d1dac-4e09-00a4-1a60-b227db734ba9:f29145c6-d8a1-5b88-1a6f-5770ac26211a"; //Set the environment the app needs to run in here ServiceEnvironment environment = ServiceEnvironment.ProdLive; this._apiConfig = new TTAPIOptions( environment, appSecretKey, 5000); }
protected ServiceEnvironment GetEnvironment(AuthorizationFilterContext filterContext) { if (!Guid.TryParse(filterContext.HttpContext.Request.Headers[EnvironmentKeyHeaderName], out Guid envKey)) { return(null); } ServiceEnvironment service = null; ExecuteActionWithContext(context => service = context.Environments .FirstOrDefault(env => env.Key == envKey)); return(service); }
public async Task <IActionResult> GetValueAsync(NameDto nameDto) { if (!ModelState.IsValid) { return(this.ValidationError()); } Application app = this.GetApplication(); ApplicationService serv = this.GetService(); ServiceEnvironment env = this.GetEnvironment(); try { return(Json(await _client.GetConfigValueAsync(app.Key, serv.Key, env.Key, nameDto.Name))); } catch (KeyVaultErrorException) { return(Json(ErrorDto.Create(ErrorCodes.ConfigNameNotFound))); } }
public Speech2TextResponse transcription(Speech2TextRequest request, ServiceEnvironment env) { //TODO: EnsureRequestValid(request); String uri = ServiceBaseUrl + "/{0}/transcriptions"; uri = string.Format(uri, Uri.EscapeDataString(Enum.GetName(typeof(ServiceEnvironment), env).ToLower())); Dictionary <string, string> headers = new Dictionary <string, string>(); headers.Add("Accept-Topic", request.AcceptTopic); headers.Add("Accept-Language", request.Language); headers.Add("Audio-File-Content-Type", request.AudioFileContentType); return(createAuthenticatedTranscriptionRequest <Speech2TextResponse>(uri, request) .ExecuteCustom(headers)); }
protected override ApplicationIdentity CreateIdentity(AuthorizationFilterContext filterContext) { Application application = GetApplication(filterContext); if (application == null) { return(null); } ApplicationService service = GetService(filterContext); if (service == null) { return(null); } ServiceEnvironment environment = GetEnvironment(filterContext); return(environment == null ? null : new EnvironmentIdentity(application, service, environment)); }
public void Send(String _targetNumber, String Message, String _sender, ServiceEnvironment SMSType = ServiceEnvironment.Premium) { targetNumber = "tel:" + _targetNumber; senderAddress = "tel:" + _sender; //! [client] SendSmsClient client = new SendSmsClient(authentication, SMSType); //! [prepare] List <String> receiverNumbers = new List <String>(); receiverNumbers.Add(targetNumber); SendSmsRequest request = new SendSmsRequest(); request.Numbers = receiverNumbers; request.Message = Message; request.SenderAddress = senderAddress; request.SMSType = OutboundSMSType.TEXT; request.Account = subAccountId; //! [prepare] //Console.Write("Sending SMS..."); //! [send] SmsResponse response = client.SendSms(request); if (!response.Success) { throw new Exception(string.Format("error {0}: {1} - {2}", response.requestError.policyException.messageId, response.requestError.policyException.text.Substring(0, response.requestError.policyException.text.Length - 2), response.requestError.policyException.variables[0])); } //! [send] //Console.WriteLine("ok"); //Console.WriteLine("End of demo. Press Enter to exit."); //Console.ReadLine(); }
public async Task <IActionResult> Remove([FromBody] KeyDto keyDto) { if (!ModelState.IsValid) { return(this.ValidationError()); } Application application = this.GetApplication(); ApplicationService service = this.GetService(); ServiceEnvironment environment = await _context.Environments.FirstOrDefaultAsync(env => env.Key == keyDto.Key); if (environment == null) { return(StatusCode((int)HttpStatusCode.Unauthorized)); } await _client.RemoveConfigsAsync(application.Key, service.Key, environment.Key); _context.Environments.Remove(environment); await _context.SaveChangesAsync(); return(Ok()); }
protected ServiceEnvironment CreateEnvironment() { // create service env var envConfig = new ServiceEnvironmentConfiguration { DefaultHostName = "Shira", ConnectionString = "Data Source=bi_rnd;Initial Catalog=EdgeSystem;Integrated Security=true", SP_HostListGet = "Service_HostList", SP_HostRegister = "Service_HostRegister", SP_HostUnregister = "Service_HostUnregister", SP_InstanceSave = "Service_InstanceSave", SP_InstanceGet = "Service_InstanceGet", SP_InstanceReset = "Service_InstanceReset", SP_EnvironmentEventListenerListGet = "Service_EnvironmentEventListenerListGet", SP_EnvironmentEventListenerRegister = "Service_EnvironmentEventListenerRegister", SP_EnvironmentEventListenerUnregister = "Service_EnvironmentEventListenerUnregister", SP_ServicesExecutionStatistics = "Service_ExecutionStatistics_GetByPercentile", SP_InstanceActiveListGet = "Service_InstanceActiveList_GetByTime" }; var environment = ServiceEnvironment.Open("Pipeline Test", envConfig); return(environment); }
public void Send(String _targetNumber,String Message, String _sender, ServiceEnvironment SMSType = ServiceEnvironment.Premium) { targetNumber = "tel:"+_targetNumber; senderAddress = "tel:"+_sender; //! [client] SendSmsClient client = new SendSmsClient(authentication, SMSType); //! [prepare] List<String> receiverNumbers = new List<String>(); receiverNumbers.Add(targetNumber); SendSmsRequest request = new SendSmsRequest(); request.Numbers = receiverNumbers; request.Message = Message; request.SenderAddress = senderAddress; request.SMSType = OutboundSMSType.TEXT; request.Account = subAccountId; //! [prepare] //Console.Write("Sending SMS..."); //! [send] SmsResponse response = client.SendSms(request); if (!response.Success) throw new Exception(string.Format("error {0}: {1} - {2}", response.requestError.policyException.messageId, response.requestError.policyException.text.Substring(0, response.requestError.policyException.text.Length - 2), response.requestError.policyException.variables[0])); //! [send] //Console.WriteLine("ok"); //Console.WriteLine("End of demo. Press Enter to exit."); //Console.ReadLine(); }
/// <summary> /// Constructs a Send SMS API client with specified authentication method and environment. /// </summary> /// <param name="authentication">Authentication instance</param> /// <param name="environment">Environment used for this client's service invocations</param> public SendMmsClient(TelekomAuth authentication, ServiceEnvironment environment) : base(authentication, environment, ServicePath) { }
public EnvironmentIdentity(Application application, ApplicationService service, ServiceEnvironment environment) : base(application, service) { Environment = environment; }
/// <summary> /// Constructs a Voice Call API client with specified authentication method and environment. /// </summary> /// <param name="authentication">Authentication instance</param> /// <param name="environment">Environment used for this client's service invocations</param> public VoiceCallClient(TelekomAuth authentication, ServiceEnvironment environment) : base(authentication, environment, ServicePath) { }
/// <summary> /// Constructs a Send SMS API Query Report client with specified authentication method and environment. /// </summary> /// <param name="authentication">Authentication instance</param> /// <param name="serviceEnvironment">Environment used for this client's service invocations</param> public ReceiveNotificationSubscribeClient(TelekomAuth authentication, ServiceEnvironment serviceEnvironment) : base(authentication, serviceEnvironment, ServicePath) { }
/// <summary> /// SericeConfigParameters egy új példányát hozza létre /// </summary> /// <date>2013.07.05</date> /// <author>VL</author> /// <param name="Environment"> sql környezet kiválasztása</param> /// <param name="UserValidationNeeded"> fussanak-e a user validálással kapcsolatos rutinok</param> /// <param name="TR_SubmitValidationNeeded"> fussanak-e a submit validálással kapcsolatos rutinok</param> public ServiceConfigParameters(ServiceEnvironment Environment, bool ExceptionLogNeeded = true, bool UserValidationNeeded = true, bool TR_SubmitValidationNeeded = true, bool GenerReportValidationNeeded = true) { _environment = Environment; _UserValidationNeeded = UserValidationNeeded; _TR_SubmitValidationNeeded = TR_SubmitValidationNeeded; _ExceptionLogNeeded = ExceptionLogNeeded; _GenerReportValidationNeeded = GenerReportValidationNeeded; }
/// <summary> /// Constructs a Send SMS API Query Report client with specified authentication method and environment. /// </summary> /// <param name="authentication">Authentication instance</param> /// <param name="serviceEnvironment">Environment used for this client's service invocations</param> public QueryReportClient(TelekomAuth authentication, ServiceEnvironment serviceEnvironment) : base(authentication, serviceEnvironment, ServicePath) { }
public SystemUserController(ServiceEnvironment serviceEnvironment) { this.serviceEnvironment = serviceEnvironment; }
/// <summary> /// Constructs a SMS Validation API client with specified authentication method and environment. /// </summary> /// <param name="authentication">Authentication instance</param> /// <param name="environment">Environment used for this client's service invocations</param> public SmsValidationClient(TelekomAuth authentication, ServiceEnvironment environment) : base(authentication, environment, ServicePath) { }