public void Process( Definition.Process definition, string trace, bool pass ) { IExecutionService service = new ExecutionService(); var process = definition.New(null); service.Execute(process); var index = 0; foreach (var c in trace) { var input = process.Processes .OfType <LabelledInput <char> >() .FirstOrDefault( i => i.Label == c && i.Status == Status.AwaitIO); if (index == trace.Length - 1 && !pass) { Assert.That(input, Is.Null); } else { Assert.That(input, Is.Not.Null); input.ExecuteInput(service); } index++; } }
public int ExecuteNonQuery(string description, bool isApplication, bool skipLog, bool applyTransformationsToParameters) { DateTime startTime = DateTime.Now; IDbTransaction trans = DriverCommand.Transaction; IDbConnection conn = DriverCommand.Connection; int result; try { if (applyTransformationsToParameters) { TransformParametersSyntax(); } Func <int> executeNonQuery = () => { return(ExecutionService.ExecuteNonQuery(DriverCommand)); }; result = DatabaseBehaviours.ExecuteWithoutRequestTimeout(executeNonQuery); IEnumerable parameters = DriverCommand.Parameters; foreach (IDbDataParameter parameter in parameters) { if (IsOutputParameter(parameter.Direction)) { parameter.Value = ExecutionService.TransformDatabaseToRuntimeValue(parameter.Value); } } } catch (DbException e) { HandleDatabaseException(e, null, conn, trans); throw; } if (!skipLog) { LogSlowQuery(startTime, description, isApplication); } return(result); }
public UIService(ConfigurationItems configurationItems, CommandService commandService, ExecutionService executionService, TelnetService telnetService) { _telnetService = telnetService; var entryAssembly = Assembly.GetEntryAssembly() ?? Assembly.GetCallingAssembly(); _systemId = entryAssembly.GetName().Name; Thread.CurrentThread.Name = _systemId; _trayContainer = new Container(); _notifyIcon = new NotifyIcon(_trayContainer) { ContextMenuStrip = new ContextMenuStrip(), Icon = GetIcon(entryAssembly, configurationItems.IconName), Text = _systemId, Visible = true }; _notifyIcon.ContextMenuStrip.Opening += Context_OnMenuOpen; _notifyIcon.DoubleClick += Context_TrayIcon_OnDoubleClick; _notifyIcon.ContextMenuStrip.Items.Clear(); _connectionCountTimer = new Timer { Enabled = _telnetService != null, Interval = 1000 }; _connectionCountTimer.Tick += Timer_ConnectionCount; _exitTimer = new Timer { Enabled = false, Interval = 500 }; _exitTimer.Tick += Timer_Exit; commandService.Init(); executionService.Init(); }
public virtual IDataReader ExecuteReader(string description, bool isApplication, bool applyTransformationsToParameters, bool skipLog) { DateTime startTime = DateTime.Now; IDbTransaction trans = DriverCommand.Transaction; IDbConnection conn = DriverCommand.Connection; IDataReader reader = null; try { if (applyTransformationsToParameters) { TransformParametersSyntax(); } Func <IDataReader> executeReader = () => { return(ExecutionService.ExecuteReader(DriverCommand)); }; reader = new DataReader(ExecutionService, this, DatabaseBehaviours.ExecuteWithoutRequestTimeout(executeReader)); } catch (DbException e) { HandleDatabaseException(e, reader, conn, trans); throw; } if (!skipLog) { LogSlowQuery(startTime, description, isApplication); } return(reader); }
public override IDataReader ExecuteReader(string description, bool isApplication, bool transformParameters, bool skipLog) { DateTime startTime = DateTime.Now; IDbTransaction trans = DriverCommand.Transaction; IDbConnection conn = DriverCommand.Connection; IDataReader reader = null; try { if (transformParameters) { TransformParametersSyntax(); } reader = new DataReader(ExecutionService, this, ExecutionService.ExecuteReader(DriverCommand)); // The transaction manager will release the data reader automatically in the future. Manager.AssociateReader(DriverCommand.Transaction, reader); } catch (DbException e) { HandleDatabaseException(e, reader, conn, trans); throw; } if (!skipLog) { LogSlowQuery(startTime, description, isApplication); } return(reader); }
public MessagesController( ExecutionService es, MessagesService messagesService ) { this.es = es; this.messagesService = messagesService; }
public AccountController( AccountService accountService, ExecutionService es, FileService fs ) { this.accountService = accountService; this.es = es; this.fs = fs; }
public DataParameter CreateParameter(string name, DbType dbType, object paramValue, bool transformLiteral) { if (transformLiteral) { paramValue = ExecutionService.TransformRuntimeToDatabaseValue(dbType, paramValue); } IDbDataParameter parameter = ExecutionService.CreateParameter(DriverCommand, name, dbType, paramValue); return(new DataParameter(ExecutionService, parameter)); }
public NewsProviderFactory( DataService ds, ExecutionService es, UtilsService us, LinksContext db ) { this.ds = ds; this.es = es; this.us = us; this.db = db; }
public HomeController( DataService ds, ExecutionService es, UtilsService us, IHttpContextAccessor httpContext ) { this.ds = ds; this.es = es; this.us = us; this.httpContext = httpContext; }
private T InnerGetValue <T>(T value) { IDbTransaction trans = Command.DriverCommand.Transaction; IDbConnection conn = Command.DriverCommand.Connection; try { return((T)ExecutionService.TransformDatabaseToRuntimeValue(value)); } catch (DbException e) { ITransactionManager manager = Command is ManagedCommand ? ((ManagedCommand)Command).Manager : null; ExecutionService.OnExecuteException(e, Command.DriverCommand, DriverReader, conn, trans, manager); throw; } }
internal void DoShutdown() { Clients.TryRemove(_instanceName, out _); DisposeAll(_onClientShutdownDisposables); // Statistics.Destroy(); ExecutionService.Shutdown(); ConnectionManager.Shutdown(); ProxyManager.Destroy(); InvocationService.Shutdown(); NearCacheManager.Shutdown(); ListenerService.Dispose(); SerializationService.Destroy(); CredentialsFactory.Dispose(); }
protected override void EndTransaction(TransactionInfo transInfo, bool commit, bool toFreeResources) { //Keep the request transaction open if possible if (!toFreeResources && RequestTransactionInfo != null && RequestTransactionInfo.Equals(transInfo)) { IDbCommand cmd = ExecutionService.CreateCommand(transInfo.Transaction, commit ? "COMMIT" : "ROLLBACK"); try { ExecutionService.ExecuteNonQuery(cmd); } catch (DbException e) { ExecutionService.OnExecuteException(e, cmd, null, transInfo.Connection, transInfo.Transaction, this); throw; } } else { base.EndTransaction(transInfo, commit, toFreeResources); } }
public PagesController( PagesService ps, NewsService newsService, FileService fs, IHostingEnvironment environment, AdService adService, ExecutionService es, AccountService accountService ) { this.ps = ps; this.newsService = newsService; this.fs = fs; this.environment = environment; this.adService = adService; this.es = es; this.accountService = accountService; }
private HazelcastClient(Configuration config) { Configuration = config; HazelcastProperties = new HazelcastProperties(config.Properties); if (config.InstanceName != null) { _instanceName = config.InstanceName; } else { _instanceName = "hz.client_" + _id; } LifecycleService = new LifecycleService(this); try { //TODO make partition strategy parametric var partitioningStrategy = new DefaultPartitioningStrategy(); SerializationService = new SerializationServiceBuilder().SetConfig(config.SerializationConfig) .SetPartitioningStrategy(partitioningStrategy) .SetVersion(IO.Serialization.SerializationService.SerializerVersion).Build(); } catch (Exception e) { throw ExceptionUtil.Rethrow(e); } ProxyManager = new ProxyManager(this); //TODO EXECUTION SERVICE ExecutionService = new ExecutionService(_instanceName); LoadBalancer = config.LoadBalancer ?? new RoundRobinLB(); PartitionService = new PartitionService(this); AddressProvider = new AddressProvider(Configuration.NetworkConfig, HazelcastProperties); ConnectionManager = new ConnectionManager(this); InvocationService = new InvocationService(this); ListenerService = new ListenerService(this); ClusterService = new ClusterService(this); LockReferenceIdGenerator = new ClientLockReferenceIdGenerator(); // Statistics = new Statistics(this); NearCacheManager = new NearCacheManager(this); CredentialsFactory = config.SecurityConfig.AsCredentialsFactory() ?? new StaticCredentialsFactory(new UsernamePasswordCredentials()); }
static void Main(string[] args) { // Register Services var collection = new ServiceCollection(); collection.AddScoped <IFileService, FileService>(); collection.AddSingleton <IFileProvider>(new PhysicalFileProvider("/")); // Build Service Provider var serviceProvider = collection.BuildServiceProvider(); var filePath = "/home/spartanroger/Firefox_wallpaper.png"; var routeService = serviceProvider.GetService <IFileService>(); var fileInfo = routeService.GetFileInfo(filePath); if (!fileInfo.Exists) { ExecutionService.ExecuteFromHardCoded(); } serviceProvider.Dispose(); }
private void SendMessage <T>(T messageType, BackgroundTaskDeferral deferral = null) where T : MessageTypeBase, new() { try { if (messageType is UpdateUnreadNotificationsCountMessageType uMsgType) { ExecutionService.RunActionInCoreWindow(() => { Messenger.Default?.Send(uMsgType); }); } if (messageType is UpdateParticipatingNotificationsCountMessageType pMsgType) { ExecutionService.RunActionInCoreWindow(() => { Messenger.Default?.Send(pMsgType); }); } if (messageType is UpdateAllNotificationsCountMessageType aMsgType) { ExecutionService.RunActionInCoreWindow(() => { Messenger.Default?.Send(aMsgType); }); } } catch (Exception ex) { ToastHelper.ShowMessage(ex.Message, ex.ToString()); } finally { if (deferral != null) { deferral.Complete(); } } }
private HazelcastClient(ClientConfig config) { ClientConfig = config; if (config.InstanceName != null) { _instanceName = config.InstanceName; } else { _instanceName = "hz.client_" + _id; } LifecycleService = new LifecycleService(this); try { //TODO make partition strategy parametric var partitioningStrategy = new DefaultPartitioningStrategy(); SerializationService = new SerializationServiceBuilder().SetConfig(config.GetSerializationConfig()) .SetPartitioningStrategy(partitioningStrategy) .SetVersion(IO.Serialization.SerializationService.SerializerVersion).Build(); } catch (Exception e) { throw ExceptionUtil.Rethrow(e); } ProxyManager = new ProxyManager(this); //TODO EXECUTION SERVICE ExecutionService = new ExecutionService(_instanceName, config.GetExecutorPoolSize()); LoadBalancer = config.GetLoadBalancer() ?? new RoundRobinLB(); PartitionService = new PartitionService(this); AddressProvider = new AddressProvider(ClientConfig); ConnectionManager = new ConnectionManager(this); InvocationService = new InvocationService(this); ListenerService = new ListenerService(this); ClusterService = new ClusterService(this); LockReferenceIdGenerator = new ClientLockReferenceIdGenerator(); // Statistics = new Statistics(this); NearCacheManager = new NearCacheManager(this); CredentialsFactory = InitCredentialsFactory(config); }
public object ExecuteScalar(string description, bool isApplication, bool skipLog, bool applyTransformationsToParameters) { DateTime startTime = DateTime.Now; IDbTransaction trans = DriverCommand.Transaction; IDbConnection conn = DriverCommand.Connection; object result; try { if (applyTransformationsToParameters) { TransformParametersSyntax(); } result = ExecutionService.TransformDatabaseToRuntimeValue(ExecutionService.ExecuteScalar(DriverCommand)); } catch (DbException e) { HandleDatabaseException(e, null, conn, trans); throw; } if (!skipLog) { LogSlowQuery(startTime, description, isApplication); } return(result); }
/// <summary> /// config.jsonを更新してバーチャルキャスト起動 /// </summary> public async void RunVirtualCast() { await ConfigJsonService.WriteToConfigJsonAsync(); ExecutionService.RunVirtualCast(); }
public AccountPanelViewModel() { SetNewPassword = ReactiveCommand.CreateFromObservable( () => SetNewPasswordImpl(_newPassword), this.WhenAnyValue(vm => vm.User, vm => vm.NewPassword, (user, password) => user != null && password.HasValue())); SetNewSimplePassword = ReactiveCommand.CreateFromObservable(SetNewSimplePasswordImpl); SetNewComplexPassword = ReactiveCommand.CreateFromObservable(SetNewComplexPasswordImpl); ExpirePassword = ReactiveCommand.CreateFromObservable(() => Messages.Handle(new MessageInfo(MessageType.Question, "Are you sure you want to expire the password?", "Expire password?", "Yes", "No")) .Where(result => result == 0) .SelectMany(_ => _adFacade.ExpirePassword(User.Principal.SamAccountName))); UnlockAccount = ReactiveCommand.CreateFromObservable(() => _adFacade.UnlockUser(User.Principal.SamAccountName)); RunLockoutStatus = ReactiveCommand.Create(() => ExecutionService.RunFileFromCache("LockoutStatus", "LockoutStatus.exe", $"-u:{_adFacade.CurrentDomain}\\{User.Principal.SamAccountName}")); OpenPermittedWorkstations = ReactiveCommand.CreateFromObservable(() => _dialogRequests.Handle(new DialogInfo(new PermittedWorkstationsDialog(), _user.Principal.SamAccountName))); ToggleEnabled = ReactiveCommand.CreateFromObservable(() => _adFacade.SetEnabled(User.Principal.SamAccountName, !User.Principal.Enabled ?? true)); OpenSplunk = ReactiveCommand.Create(() => { Process.Start(string.Format(Locator.Current.GetService <SettingsFacade>().SplunkUrl, _adFacade.CurrentDomainShortName, User.Principal.SamAccountName)); }); this.WhenActivated(disposables => { SetNewPassword .ObserveOnDispatcher() .Do(_ => NewPassword = "") .SelectMany(newPass => _messages.Handle(new MessageInfo(MessageType.Success, $"New password is: {newPass}", "Password set"))) .Subscribe() .DisposeWith(disposables); SetNewSimplePassword .ObserveOnDispatcher() .SelectMany(newPass => _messages.Handle(MessageInfo.PasswordSetMessageInfo(newPass))) .Subscribe() .DisposeWith(disposables); SetNewComplexPassword .ObserveOnDispatcher() .SelectMany(newPass => _messages.Handle(MessageInfo.PasswordSetMessageInfo(newPass))) .Subscribe() .DisposeWith(disposables); ExpirePassword .SelectMany(_ => _messages.Handle(new MessageInfo(MessageType.Success, "User must change password at next login", "Password expired"))) .Subscribe() .DisposeWith(disposables); UnlockAccount .SelectMany(_ => { MessageBus.Current.SendMessage(_user.CN, ApplicationActionRequest.Refresh); return(_messages.Handle(new MessageInfo(MessageType.Success, "Account unlocked"))); }) .Subscribe() .DisposeWith(disposables); ToggleEnabled .Subscribe(_ => MessageBus.Current.SendMessage(_user.CN, ApplicationActionRequest.Refresh)) .DisposeWith(disposables); Observable.Merge( SetNewPassword.ThrownExceptions, SetNewSimplePassword.ThrownExceptions, SetNewComplexPassword.ThrownExceptions) .SelectMany(ex => _messages.Handle(MessageInfo.PasswordSetErrorMessageInfo(ex.Message))) .Subscribe() .DisposeWith(disposables); Observable.Merge <(string Title, string Message)>( ExpirePassword.ThrownExceptions.Select(ex => ("Could not expire password", ex.Message)), UnlockAccount.ThrownExceptions.Select(ex => ("Could not unlock acount", ex.Message)), RunLockoutStatus.ThrownExceptions.Select(ex => ("Could not open LockOutStatus", ex.Message)), OpenPermittedWorkstations.ThrownExceptions.Select(ex => ("Could not open Permitted Workstations", ex.Message)), ToggleEnabled.ThrownExceptions.Select(ex => ("Could not toggle enabled status", ex.Message))) .SelectMany(dialogContent => _messages.Handle(new MessageInfo(MessageType.Error, dialogContent.Message, dialogContent.Title))) .Subscribe() .DisposeWith(disposables); }); }
protected override async void OnBackgroundActivated(BackgroundActivatedEventArgs args) { var taskInstance = args.TaskInstance; taskInstance.Canceled += TaskInstance_Canceled; base.OnBackgroundActivated(args); var triggerDetails = taskInstance.TriggerDetails; var taskName = taskInstance.Task.Name; switch (taskName) { case "AppTrigger": _AppTriggerDeferral = taskInstance.GetDeferral(); if (!(triggerDetails is ApplicationTriggerDetails appTriggerDetails)) { throw new InvalidOperationException(); } await _ExExecSession.RunActionAsExtentedAction(() => { ExecutionService.RunActionInUiThread(async() => { try { var appArgs = appTriggerDetails.Arguments; if (!appArgs.TryGetValue("action", out object action)) { throw new ArgumentNullException(nameof(action)); } if (!appArgs.TryGetValue("what", out object what)) { throw new ArgumentNullException(nameof(what)); } if (!appArgs.TryGetValue("type", out object type)) { throw new ArgumentNullException(nameof(type)); } if (!appArgs.TryGetValue("location", out object location)) { throw new ArgumentNullException(nameof(location)); } if (!appArgs.TryGetValue("filter", out object filter)) { throw new ArgumentNullException(nameof(filter)); } if (!appArgs.TryGetValue("sendMessage", out object sendMessage)) { throw new ArgumentNullException(nameof(type)); } if (!(action is string a) || StringHelper.IsNullOrEmptyOrWhiteSpace(a)) { throw new ArgumentException($"'{nameof(action)}' has an invalid value"); } if (!(what is string w) || StringHelper.IsNullOrEmptyOrWhiteSpace(w)) { throw new ArgumentException($"'{nameof(what)}' has an invalid value"); } if (!(type is string t) || StringHelper.IsNullOrEmptyOrWhiteSpace(t)) { throw new ArgumentNullException(nameof(type)); } if (!(location is string l) || StringHelper.IsNullOrEmptyOrWhiteSpace(l)) { throw new ArgumentException($"'{nameof(location)}' has an invalid value"); } if (!(filter is string f) || StringHelper.IsNullOrEmptyOrWhiteSpace(f)) { throw new ArgumentException($"'{nameof(filter)}' has an invalid value"); } if (!(sendMessage is bool sm)) { throw new ArgumentException($"'{nameof(sendMessage)}' has an invalid value"); } if (a == "sync") { if (w == "notifications") { var notifications = new ObservableCollection <Octokit.Notification>(); if (l == "online") { var filters = f.Split(','); bool isAll = false, isParticipating = false, isUnread = true; if (filter != null && filters.Length > 0) { isAll = filters.Contains("all", StringComparer.OrdinalIgnoreCase); isParticipating = filters.Contains("participating", StringComparer.OrdinalIgnoreCase); isUnread = filters.Contains("unread", StringComparer.OrdinalIgnoreCase); } notifications = await NotificationsService.GetAllNotificationsForCurrentUser(isAll, isParticipating); if (t == "toast") { if (sm) { if (isAll) { NotificationsViewmodel.AllNotifications = notifications; SendMessage(new UpdateAllNotificationsCountMessageType { Count = notifications?.Count ?? 0 }); } else if (isParticipating) { NotificationsViewmodel.ParticipatingNotifications = notifications; SendMessage(new UpdateParticipatingNotificationsCountMessageType { Count = notifications?.Count ?? 0 }); } else if (isUnread) { AppViewmodel.UnreadNotifications = notifications; SendMessage(new UpdateUnreadNotificationsCountMessageType { Count = notifications?.Count ?? 0 }); } } if (SettingsService.Get <bool>(SettingsKeys.IsToastEnabled)) { await AppViewmodel.UnreadNotifications?.ShowToasts(); } } else if (t == "tiles") { var tile = await notifications[0].BuildTiles(); TileUpdateManager .CreateTileUpdaterForApplication() .Update(tile); } } } } } catch (Exception ex) { ToastHelper.ShowMessage(ex.Message, ex.ToString()); } }); }, ExExecSession_Revoked, _AppTriggerDeferral); break; case "SyncNotifications": _SyncDeferral = taskInstance.GetDeferral(); await _ExExecSession.RunActionAsExtentedAction(() => { ExecutionService.RunActionInUiThread(async() => { await BackgroundTaskService.LoadUnreadNotifications(true); }); }, ExExecSession_Revoked, _SyncDeferral); break; case "ToastNotificationAction": _ToastDeferral = taskInstance.GetDeferral(); if (!(triggerDetails is ToastNotificationActionTriggerDetail toastTriggerDetails)) { throw new ArgumentException(); } await _ExExecSession.RunActionAsExtentedAction(() => { ExecutionService.RunActionInUiThread(async() => { try { var toastArgs = QueryString.Parse(toastTriggerDetails.Argument); var notificationId = toastArgs["notificationId"] as string; await NotificationsService.MarkNotificationAsRead(notificationId); await BackgroundTaskService.LoadUnreadNotifications(true); } catch (Exception ex) { ToastHelper.ShowMessage(ex.Message, ex.ToString()); } }); }, ExExecSession_Revoked, _ToastDeferral); break; //case "ToastNotificationChangedTask": //var toastChangedTriggerDetails = taskInstance.TriggerDetails as ToastNotificationHistoryChangedTriggerDetail; //var collectionId = toastChangedTriggerDetails.CollectionId; //var changedType = toastChangedTriggerDetails.ChangeType; //if (changedType == ToastHistoryChangedType.Removed) //{ //} //break; } }
protected override void HandleDatabaseException(DbException e, IDataReader reader, IDbConnection conn, IDbTransaction trans) { ExecutionService.OnExecuteException(e, DriverCommand, reader, conn, trans, Manager); }
protected virtual void HandleDatabaseException(DbException e, IDataReader reader, IDbConnection conn, IDbTransaction trans) { ExecutionService.OnExecuteException(e, DriverCommand, reader, conn, trans, null); }
public TranslateController(ExecutionService es, DataService dataService) { this.dataService = dataService; this.es = es; }
public void Setup() { _executionService = new ExecutionService("", 10); }
/// <summary> /// リリースページの表示 /// </summary> public void BrowseReleasePage() { ExecutionService.RunBrowser(ReleasePageUrl); }