public string GetLocalFilePath(IComputer computer, string directory, string fileName, int compressionMode) { UriBuilder uri = new UriBuilder("file:///"); uri.Path = Path.Combine(computer.Directory, directory, fileName); uri.Query = "c=" + compressionMode; return uri.Uri.AbsoluteUri; }
public WmiProvider(IComputer computer) { activeInstances = new List<IWmiObject>(); foreach (IHardware hardware in computer.Hardware) ComputerHardwareAdded(hardware); computer.HardwareAdded += ComputerHardwareAdded; computer.HardwareRemoved += ComputerHardwareRemoved; }
public WmiProvider(IComputer computer) { activeInstances = new List<IWmiObject>(); DataManager.Initialize(); DataManager.BeginTransaction(); foreach (IHardware hardware in computer.Hardware) { ComputerHardwareAdded(hardware); } DataManager.EndTransaction(); computer.HardwareAdded += ComputerHardwareAdded; computer.HardwareRemoved += ComputerHardwareRemoved; }
/// <summary> /// Конструктор класса. /// </summary> /// <param name="device">Отображаемое устройство.</param> /// <param name="computer">Какой-то непонятный компьютер.</param> public DeviceListViewItem(IDevice device, IComputer computer) : base() { if (device == null) throw new ArgumentNullException("device"); if (computer == null) throw new ArgumentNullException("computer"); _device = device; _device.PropertyChanged += new EventHandler<DeviceEventArgs>(device_PropertyChanged); SetStatusImage(); _computer = computer; Text = _device.Name; }
/// <summary> /// Конструктор класса объекта-заместителя. /// </summary> /// <param name="computer">Объект, управляющий соединением.</param> public HostProxy(IComputer computer) : base() { if (computer == null) throw new ArgumentNullException("computer"); _computer = computer; _computer.ConnectionChanged += new EventHandler(_computer_ConnectionChanged); //Запускаем таймер _timer = new System.Threading.Timer(new System.Threading.TimerCallback( delegate{ UpdateData(); }), null, _timerPeriod, _timerPeriod); }
/// <summary> /// Конструктор класса. Объект создается со ссылкой на реальный объект. /// </summary> /// <param name="computer">Какой-то компьютер.</param> /// <param name="device">Родительский объект класса-заместителя.</param> /// <param name="partition">Реальный удаленный объект.</param> public PartitionProxy(IComputer computer, DeviceProxy device, IPartition partition) : base() { if (computer == null) throw new ArgumentNullException("computer"); if (device == null) throw new ArgumentNullException("device"); _computer = computer; _device = device; _computer.ConnectionChanged += new EventHandler(_computer_ConnectionChanged); Bind(partition); }
/// <summary> /// Конструктор класса. Объект создается со ссылкой на реальный объект. /// </summary> /// <param name="computer">Какой-то компьютер.</param> /// <param name="hostProxy">Объект-заместитель для интерфейса IHost.</param> /// <param name="device">Реальный удаленный объект.</param> public DeviceProxy(IComputer computer, HostProxy hostProxy, IDevice device) : base() { if (computer == null) throw new ArgumentNullException("computer"); if (hostProxy == null) throw new ArgumentNullException("hostProxy"); if (device == null) throw new ArgumentNullException("device"); _computer = computer; _host = hostProxy; _computer.ConnectionChanged += new EventHandler(_computer_ConnectionChanged); Bind(device); }
public string GetRemoteFilePath(IComputer computer, string directory, string fileName, int compressionMode) { IComputer runningComputer = scheduler.GetComputerAtHost(computer.Host); UriBuilder fileServer; if (runningComputer == null) { logger.Log("No currently known computer running at host " + computer.Host + " to read file " + directory + "/" + fileName); fileServer = new UriBuilder("http://noKnownProcessFor/" + computer.Host); } else { fileServer = new UriBuilder(runningComputer.FileServer); } fileServer.Path += Path.Combine(computer.Directory, directory, fileName); fileServer.Query = "c=" + compressionMode; return fileServer.Uri.AbsoluteUri; }
public CPU(IComputer computer) { cpu = FindCPU(computer); }
public bool TryGetComputer(string name, out IComputer computer) { return(DirectoryExtensions.TryGet(() => this.GetComputer(name), out computer)); }
public ExtraCores(IComputer computer) : base(computer) { }
public void De(IComputer computer) { _com = computer; }
public AddonDecorator(IComputer c) { computer = c; }
private void ToMatched(IComputer computer, long timestamp) { lock (this) { Debug.Assert(state == State.Queued); state = State.Matched; } watcher.OnMatched(computer, timestamp); }
private async Task<bool> Schedule(IComputer computer, Task interrupt) { logger.Log("Process " + Id + " scheduling itself as " + directory + " on computer " + computer.Name + " at " + computer.Host); ToMatched(computer, DateTime.Now.ToFileTimeUtc()); StringBuilder payload = new StringBuilder(); payload.AppendLine(CommandLine); payload.AppendLine(CommandLineArguments); Task<string> bail = interrupt.ContinueWith((t) => ""); Task<string> upload = PostRequest(computer, directory + "?op=create", Encoding.UTF8.GetBytes(payload.ToString())); Task<string> completed = await Task.WhenAny(bail, upload); if (completed == bail) { logger.Log("Process " + Id + " abandoned creation due to finishWaiter"); ToExited(ProcessExitState.ScheduleFailed, DateTime.Now.ToFileTimeUtc(), 1, "Service shut down while scheduling"); return false; } if (completed.Result == null) { logger.Log("Process " + Id + " got remote create process success for " + directory); ToCreated(DateTime.Now.ToFileTimeUtc()); return true; } else { logger.Log("Proces " + Id + " got remote create process failure " + completed.Result); ToExited(ProcessExitState.ScheduleFailed, DateTime.Now.ToFileTimeUtc(), 1, completed.Result); return false; } }
public LowEndComputerBuilder() { _computer = new Computer(); }
private IOptionsSnapshot <AuthorizationOptions> SetupOptionsForComputerTarget(AccessMask allowed, AccessMask denied, IComputer computer, ISecurityPrincipal trustee) { return(SetupOptions(CreateTarget(allowed, denied, computer, trustee))); }
public AccessPrice(IComputer newComputer) { computer = newComputer; }
public Logger(IComputer computer) { this.computer = computer; this.computer.HardwareAdded += HardwareAdded; this.computer.HardwareRemoved += HardwareRemoved; }
public void Execute(IStringBuilderPrinter printer, IComputer computer, byte parameter) { //var result = computer.ChargeBattery(parameter); //printer.AppendResult(result); }
// コンピュータとしての処理 public static void FuncComputer(IComputer computer) { computer.PlayGame(); // ゲームをする computer.BrowseWeb(); // ウェブを閲覧する }
/// <summary> /// set the computer where the process is running /// </summary> private void SetComputer(IComputer remote, Task remoteCancel, string suffix) { // use a lock here because computer can be accessed by other threads trying // to get process keys lock (this) { computer = remote; computerCancellation = remoteCancel; directory = suffix; } }
public SelectedComputerChangedEventArgs(IComputer computer) { NewSelectedComputer = computer; }
public async Task Kill(IComputer computer, Task interrupt) { logger.Log("Process " + Id + " sending remote kill to computer " + computer.Name + " on host " + computer.Host); Task<string> bail = interrupt.ContinueWith((t) => ""); Task<string> upload = PostRequest(computer, directory + "?op=kill", new byte[0]); Task<string> completed = await Task.WhenAny(bail, upload); if (completed == bail) { logger.Log("Process " + Id + " abandoned kill due to finishWaiter"); return; } if (completed.Result == null) { logger.Log("Process " + Id + " got successful response for kill"); } else { // if this failed, there's nothing much more we can do logger.Log("Process " + Id + " got failure response for kill " + completed.Result); } }
public AddFanComputerDecorator(IComputer computer) { _computer = computer; }
public HWManager(IComputer computer, StackPanel cpuStackPanel, StackPanel ramStackPanel, StackPanel gpuStackPanel) { BoardHW = App._computer.Hardware.Where(h => h.HardwareType == HardwareType.Mainboard).FirstOrDefault(); HasBoard = BoardHW != null; CPU = App._computer.Hardware.Where(h => h.HardwareType == HardwareType.CPU).Select(hw => new HWPanel(BoardHW, HWType.CPU, hw, cpuStackPanel)).ToArray(); HasCPU = CPU.Length > 0; RAM = App._computer.Hardware.Where(h => h.HardwareType == HardwareType.RAM).Select(hw => new HWPanel(BoardHW, HWType.RAM, hw, ramStackPanel)).ToArray(); HasRam = RAM.Length > 0; GPU = App._computer.Hardware.Where(h => new HardwareType[2] { HardwareType.GpuNvidia, HardwareType.GpuAti }.Contains(h.HardwareType)).Select(hw => new HWPanel(BoardHW, HWType.GPU, hw, gpuStackPanel)).ToArray(); HasGPU = GPU.Length > 0; }
private void AuditAuthZFailure(AccessRequestModel model, AuthorizationResponse authorizationResponse, IUser user, IComputer computer) { AuditableAction action = new AuditableAction { AuthzResponse = authorizationResponse, User = user, Computer = computer, IsSuccess = false, RequestedComputerName = model.ComputerName, RequestReason = model.UserRequestReason, Message = string.Format(LogMessages.AuthorizationFailed, user.MsDsPrincipalName, model.ComputerName), EventID = authorizationResponse.Code switch { AuthorizationResponseCode.NoMatchingRuleForComputer => EventIDs.AuthZFailedNoTargetMatch, AuthorizationResponseCode.NoMatchingRuleForUser => EventIDs.AuthZFailedNoReaderPrincipalMatch, AuthorizationResponseCode.ExplicitlyDenied => EventIDs.AuthZExplicitlyDenied, _ => EventIDs.AuthZFailed, } }; this.reporting.GenerateAuditEvent(action); }
public ExternalHD(IComputer c) : base(c) { }
private IActionResult GetAuthorizationResponse(AccessRequestModel model, IUser user, IComputer computer) { try { // Do authorization check first. AuthorizationResponse authResponse = this.authorizationService.GetAuthorizationResponse(user, computer, model.RequestType); if (!authResponse.IsAuthorized()) { this.AuditAuthZFailure(model, authResponse, user, computer); model.FailureReason = UIMessages.NotAuthorized; return(this.View("AccessRequest", model)); } // Do actual work only if authorized. if (authResponse.EvaluatedAccess == AccessMask.Laps) { return(this.GetLapsPassword(model, user, computer, (LapsAuthorizationResponse)authResponse)); } else if (authResponse.EvaluatedAccess == AccessMask.LapsHistory) { return(this.GetLapsPasswordHistory(model, user, computer, (LapsHistoryAuthorizationResponse)authResponse)); } else if (authResponse.EvaluatedAccess == AccessMask.Jit) { return(this.GrantJitAccess(model, user, computer, (JitAuthorizationResponse)authResponse)); } else { throw new AccessManagerException(@"The evaluated access response mask was not supported"); } } catch (AuditLogFailureException ex) { this.logger.LogEventError(EventIDs.AuthZFailedAuditError, string.Format(LogMessages.AuthZFailedAuditError, user.MsDsPrincipalName, model.ComputerName), ex); return(this.View("Error", new ErrorModel { Heading = UIMessages.AccessDenied, Message = UIMessages.AuthZFailedAuditError })); } catch (Exception ex) { this.logger.LogEventError(EventIDs.AuthZError, string.Format(LogMessages.AuthZError, user.MsDsPrincipalName, computer.MsDsPrincipalName), ex); return(this.View("Error", new ErrorModel { Heading = UIMessages.UnableToProcessRequest, Message = UIMessages.AuthZError })); } }
private void Dispose(bool disposing) { if (disposing) { _device.PropertyChanged -= device_PropertyChanged; _device = null; _computer = null; } }
private IActionResult GetLapsPasswordHistory(AccessRequestModel model, IUser user, IComputer computer, LapsHistoryAuthorizationResponse authResponse) { try { IList <PasswordEntry> history; try { history = this.passwordProvider.GetPasswordHistory(computer); if (history == null) { throw new NoPasswordException(); } } catch (NoPasswordException) { this.logger.LogEventError(EventIDs.NoLapsPasswordHistory, string.Format(LogMessages.NoLapsPasswordHistory, computer.MsDsPrincipalName, user.MsDsPrincipalName)); return(this.View("UnsuccessfulResponse", new ErrorModel { Heading = UIMessages.HeadingPasswordDetails, Message = UIMessages.NoLapsPasswordHistory })); } this.reporting.GenerateAuditEvent(new AuditableAction { AuthzResponse = authResponse, RequestedComputerName = model.ComputerName, RequestReason = model.UserRequestReason, IsSuccess = true, User = user, Computer = computer, EventID = EventIDs.ComputerPasswordHistoryAccessGranted }); return(this.View("PasswordHistory", new PasswordHistoryModel { ComputerName = computer.MsDsPrincipalName, PasswordHistory = history })); } catch (Exception ex) { this.logger.LogEventError(EventIDs.LapsPasswordHistoryError, string.Format(LogMessages.LapsPasswordHistoryError, computer.MsDsPrincipalName, user.MsDsPrincipalName), ex); return(this.View("Error", new ErrorModel { Heading = UIMessages.UnableToProcessRequest, Message = UIMessages.LapsPasswordHistoryError })); } }
public void SetComputer(IComputer computer) => Computer = computer; // Установить контекст
private IActionResult GetPreAuthorizationResponse(AccessRequestModel model, IUser user, IComputer computer) { try { AuthorizationResponse authResponse = this.authorizationService.GetPreAuthorization(user, computer); if (!authResponse.IsAuthorized()) { this.AuditAuthZFailure(model, authResponse, user, computer); return(this.View("Error", new ErrorModel { Heading = UIMessages.AccessDenied, Message = UIMessages.NotAuthorized })); } model.AllowedRequestTypes = authResponse.EvaluatedAccess; if (model.AllowedRequestTypes.HasFlag(AccessMask.Laps)) { model.RequestType = AccessMask.Laps; } else if (model.AllowedRequestTypes.HasFlag(AccessMask.LapsHistory)) { model.RequestType = AccessMask.LapsHistory; } else { model.RequestType = AccessMask.Jit; } return(this.View("Type", model)); } catch (Exception ex) { this.logger.LogEventError(EventIDs.PreAuthZError, string.Format(LogMessages.PreAuthZError, user.MsDsPrincipalName, computer.MsDsPrincipalName), ex); return(this.View("Error", new ErrorModel { Heading = UIMessages.UnableToProcessRequest, Message = UIMessages.PreAuthZError })); } }
public Test2(IComputer computer) { this.computer = computer; }
public IComputer Create(IComputer type) => type switch {
public MonitorManager(IComputer computer) { _computer = computer; _board = GetHardware(HardwareType.Mainboard).FirstOrDefault(); OHMMonitorsList = new List<OHMMonitor>(); _gpuMonitors = new List<GpuMonitor>(); _cpuMonitors = new List<CpuMonitor>(); _driveMonitors = new List<DriveMonitor>(); UpdateBoard(); SetupMainboardMonitor(); SetupDriveMonitors(); SetupCpuMonitors(); SetupRamMonitor(); SetupGpuMonitors(); SetupNetworkMonitor(); SetupDriveMonitor(); }
private void AddComputer(IComputer computer) { _computers.Add(computer.Name, computer); }
public void Execute(IStringBuilderPrinter printer, IComputer computer, byte parameter) { //var result = computer.GuessNumber(parameter); //printer.AppendResult(result); }
private async Task<string> PostRequest(IComputer computer, string requestString, byte[] payload) { string uri = computer.ProcessServer + requestString; IHttpRequest request = HttpClient.Create(uri); request.Timeout = 30 * 1000; // this should come back quickly. If it really takes a long time, something is wrong request.Method = "POST"; try { using (Stream upload = request.GetRequestStream()) { await upload.WriteAsync(payload, 0, payload.Length); } using (IHttpResponse response = await request.GetResponseAsync()) { // this succeeded but we don't care about the response: null indicates no error return null; } } catch (NotHttpException e) { string error = "Post " + uri + " failed message " + e.Message + " status " + e.Response.StatusCode + ": " + e.Response.StatusDescription; logger.Log(error); return error; } catch (Exception e) { string error = "Post " + uri + " failed message " + e.Message; logger.Log(error); return error; } }
public SensorGadget(IComputer computer, PersistentSettings settings, UnitManager unitManager) { this.unitManager = unitManager; this.settings = settings; computer.HardwareAdded += new HardwareEventHandler(HardwareAdded); computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved); this.darkWhite = new SolidBrush(Color.FromArgb(0xF0, 0xF0, 0xF0)); this.stringFormat = new StringFormat(); this.stringFormat.FormatFlags = StringFormatFlags.NoWrap; this.trimStringFormat = new StringFormat(); this.trimStringFormat.Trimming = StringTrimming.EllipsisCharacter; this.trimStringFormat.FormatFlags = StringFormatFlags.NoWrap; this.alignRightStringFormat = new StringFormat(); this.alignRightStringFormat.Alignment = StringAlignment.Far; this.alignRightStringFormat.FormatFlags = StringFormatFlags.NoWrap; if (File.Exists("gadget_background.png")) { try { Image newBack = new Bitmap("gadget_background.png"); back.Dispose(); back = newBack; } catch { } } if (File.Exists("gadget_image.png")) { try { image = new Bitmap("gadget_image.png"); } catch {} } if (File.Exists("gadget_foreground.png")) { try { fore = new Bitmap("gadget_foreground.png"); } catch { } } if (File.Exists("gadget_bar_background.png")) { try { Image newBarBack = new Bitmap("gadget_bar_background.png"); barBack.Dispose(); barBack = newBarBack; } catch { } } if (File.Exists("gadget_bar_foreground.png")) { try { Image newBarColor = new Bitmap("gadget_bar_foreground.png"); barFore.Dispose(); barFore = newBarColor; } catch { } } this.Location = new Point( settings.GetValue("sensorGadget.Location.X", 100), settings.GetValue("sensorGadget.Location.Y", 100)); LocationChanged += delegate(object sender, EventArgs e) { settings.SetValue("sensorGadget.Location.X", Location.X); settings.SetValue("sensorGadget.Location.Y", Location.Y); }; // get the custom to default dpi ratio using (Bitmap b = new Bitmap(1, 1)) { scale = b.HorizontalResolution / 96.0f; } SetFontSize(settings.GetValue("sensorGadget.FontSize", 7.5f)); Resize(settings.GetValue("sensorGadget.Width", Size.Width)); ContextMenu contextMenu = new ContextMenu(); MenuItem hardwareNamesItem = new MenuItem("Hardware Names"); contextMenu.MenuItems.Add(hardwareNamesItem); MenuItem fontSizeMenu = new MenuItem("Font Size"); for (int i = 0; i < 4; i++) { float size; string name; switch (i) { case 0: size = 6.5f; name = "Small"; break; case 1: size = 7.5f; name = "Medium"; break; case 2: size = 9f; name = "Large"; break; case 3: size = 11f; name = "Very Large"; break; default: throw new NotImplementedException(); } MenuItem item = new MenuItem(name); item.Checked = fontSize == size; item.Click += delegate(object sender, EventArgs e) { SetFontSize(size); settings.SetValue("sensorGadget.FontSize", size); foreach (MenuItem mi in fontSizeMenu.MenuItems) { mi.Checked = mi == item; } }; fontSizeMenu.MenuItems.Add(item); } contextMenu.MenuItems.Add(fontSizeMenu); contextMenu.MenuItems.Add(new MenuItem("-")); MenuItem lockItem = new MenuItem("Lock Position and Size"); contextMenu.MenuItems.Add(lockItem); contextMenu.MenuItems.Add(new MenuItem("-")); MenuItem alwaysOnTopItem = new MenuItem("Always on Top"); contextMenu.MenuItems.Add(alwaysOnTopItem); MenuItem opacityMenu = new MenuItem("Opacity"); contextMenu.MenuItems.Add(opacityMenu); Opacity = (byte)settings.GetValue("sensorGadget.Opacity", 255); for (int i = 0; i < 5; i++) { MenuItem item = new MenuItem((20 * (i + 1)).ToString() + " %"); byte o = (byte)(51 * (i + 1)); item.Checked = Opacity == o; item.Click += delegate(object sender, EventArgs e) { Opacity = o; settings.SetValue("sensorGadget.Opacity", Opacity); foreach (MenuItem mi in opacityMenu.MenuItems) { mi.Checked = mi == item; } }; opacityMenu.MenuItems.Add(item); } this.ContextMenu = contextMenu; hardwareNames = new UserOption("sensorGadget.Hardwarenames", true, hardwareNamesItem, settings); hardwareNames.Changed += delegate(object sender, EventArgs e) { Resize(); }; alwaysOnTop = new UserOption("sensorGadget.AlwaysOnTop", false, alwaysOnTopItem, settings); alwaysOnTop.Changed += delegate(object sender, EventArgs e) { this.AlwaysOnTop = alwaysOnTop.Value; }; lockPositionAndSize = new UserOption("sensorGadget.LockPositionAndSize", false, lockItem, settings); lockPositionAndSize.Changed += delegate(object sender, EventArgs e) { this.LockPositionAndSize = lockPositionAndSize.Value; }; HitTest += delegate(object sender, HitTestEventArgs e) { if (lockPositionAndSize.Value) { return; } if (e.Location.X < leftBorder) { e.HitResult = HitResult.Left; return; } if (e.Location.X > Size.Width - 1 - rightBorder) { e.HitResult = HitResult.Right; return; } }; SizeChanged += delegate(object sender, EventArgs e) { settings.SetValue("sensorGadget.Width", Size.Width); Redraw(); }; VisibleChanged += delegate(object sender, EventArgs e) { Rectangle bounds = new Rectangle(Location, Size); Screen screen = Screen.FromRectangle(bounds); Rectangle intersection = Rectangle.Intersect(screen.WorkingArea, bounds); if (intersection.Width < Math.Min(16, bounds.Width) || intersection.Height < Math.Min(16, bounds.Height)) { Location = new Point( screen.WorkingArea.Width / 2 - bounds.Width / 2, screen.WorkingArea.Height / 2 - bounds.Height / 2); } }; MouseDoubleClick += delegate(object obj, MouseEventArgs args) { SendHideShowCommand(); }; }
private async Task<bool> GetStatus(IComputer computer, Task interrupt) { logger.Log("Process " + Id + " getting status on computer " + computer.Name + " at " + computer.Host); // use a 2 minute heartbeat for now int timeout = 120000; StringBuilder sb = new StringBuilder(directory); sb.AppendFormat("?version={0}", statusVersion); sb.AppendFormat("&timeout={0}", timeout); Task<IHttpResponse> completed; try { IHttpRequest request = HttpClient.Create(computer.ProcessServer + sb.ToString()); request.Timeout = timeout + 30000; Task<IHttpResponse> bail = interrupt.ContinueWith((t) => null as IHttpResponse); completed = await Task.WhenAny(bail, request.GetResponseAsync()); if (completed == bail) { logger.Log("Process " + Id + " abandoned status due to finishWaiter"); ToExited(ProcessExitState.StatusFailed, DateTime.Now.ToFileTimeUtc(), 1, "Service stopped while waiting for status"); return true; } } catch (NotHttpException e) { string error = "Status fetch failed message " + e.Message + " status " + e.Response.StatusCode + ": " + e.Response.StatusDescription; logger.Log("Process " + Id + " got remote process status failure " + error); ToExited(ProcessExitState.StatusFailed, DateTime.Now.ToFileTimeUtc(), 1, error); return true; } catch (Exception e) { string error = "Status fetch failed message " + e.Message; logger.Log("Process " + Id + " got remote process status failure " + error); ToExited(ProcessExitState.StatusFailed, DateTime.Now.ToFileTimeUtc(), 1, error); return true; } using (IHttpResponse response = completed.Result) { try { // read the empty payload to the end to keep the protocol happy using (Stream payloadStream = response.GetResponseStream()) { } } catch (NotHttpException e) { string error = "Status fetch failed message " + e.Message + " status " + e.Response.StatusCode + ": " + e.Response.StatusDescription; logger.Log("Process " + Id + " got remote process status failure " + error); ToExited(ProcessExitState.StatusFailed, DateTime.Now.ToFileTimeUtc(), 1, error); return true; } catch (Exception e) { string error = "Status fetch failed message " + e.Message; logger.Log("Process " + Id + " got remote process status failure " + error); ToExited(ProcessExitState.StatusFailed, DateTime.Now.ToFileTimeUtc(), 1, error); return true; } return UpdateProcessStatus(response); } }
public ComputerClient(IComputer factory) { smartPhone = factory.GetSupremoComputer(); normalPhone = factory.GetNormalComputer(); }
public async Task Run(IComputer computer, int processId, Task computerInterrupt, string errorReason) { if (errorReason != null) { ToExited(ProcessExitState.ScheduleFailed, DateTime.Now.ToFileTimeUtc(), 1, errorReason); return; } // get a unique id for this process on this computer, and store the identifying // suffix that we will use to refer to it SetComputer(computer, computerInterrupt, processId.ToString()); logger.Log("Process " + Id + " matched to computer " + computer.Name + " on " + computer.Host); { Task interrupt = Task.WhenAny(computerInterrupt, AsyncCancelTask); bool exited = !(await Schedule(computer, interrupt)); while (!exited) { logger.Log("Process " + Id + " getting status from " + computer.Name + " on " + computer.Host); exited = await GetStatus(computer, interrupt); } } logger.Log("Process " + Id + " ensuring it is killed at " + computer.Name + " on " + computer.Host); // we shouldn't get here until the process has exited unless we got a cancellation, but just for belt // and braces we'll always try to make sure it's really dead at the other end await Kill(computer, computerInterrupt); logger.Log("Process " + Id + " finished running at " + computer.Name + " on " + computer.Host); }
public static ICloudOCRService Create(string providerName, string serviceUrl, string serviceKey, IComputer computer, ILogger logger, IEngineConfig config) { if (string.IsNullOrEmpty(providerName)) { return(null); } if (string.Equals(providerName, "azure", StringComparison.OrdinalIgnoreCase)) { return(CreateAzureOCR(serviceUrl, serviceKey, computer, logger, config)); } // Create other service here...l return(null); }
/// <summary> /// �������� ������ �� ��������� ��������� /// � ������. /// </summary> /// <param name="nodes">���������� � ������ ����.</param> /// <returns>true ������ ��������� �������� ������ /// � ��� ��� ����������. ����� false.</returns> public bool ChangeSelection(IList<Node> nodes) { if (nodes.Count != 1 || !(nodes[0] is IComputer)) { return false; } IComputer comp = nodes[0] as IComputer; if (comp == _computer) return true; if (_computer != null) { _computer.StateChanged -= _computer_StateChanged; _computer.ConnectionChanged -= _computer_ConnectionChanged; devicesListView.BeginUpdate(); foreach (DeviceListViewItem listItem in devicesListView.Items) listItem.Dispose(); devicesListView.Items.Clear(); devicesListView.EndUpdate(); } SetActiveDevice(null); foreach (DeviceDiagram diagram in _diagramMap.Values) diagram.Dispose(); _diagramMap.Clear(); devicesListView.BeginUpdate(); foreach (DeviceListViewItem listItem in devicesListView.Items) listItem.Dispose(); devicesListView.Items.Clear(); devicesListView.EndUpdate(); _computer = comp; _computer.StateChanged += new EventHandler(_computer_StateChanged); _computer.ConnectionChanged += new EventHandler(_computer_ConnectionChanged); // �������� ���������� ������� ��� ���������� ������ ���������. _computer_ConnectionChanged(_computer, new EventArgs()); return true; }
public void VisitComputer(IComputer computer) { computer.Traverse(this); }
public ArduinoReporter(IComputer computer, string portName, int baudRate) { this.computer = computer; this.portName = portName; this.baudRate = baudRate; }
public void VisitComputer(IComputer computer) { if (computer == null) throw new ArgumentNullException("computer"); computer.Traverse(this); }
public Director(IComputer builder) { Builder = builder; }
public Keyboard(IComputer c) : base(c) { }
public void AgeOutPasswordHistory(string computerName) { IComputer computer = directory.GetComputer(computerName); provider.ClearPassword(computer); provider.ClearPasswordHistory(computer); CollectionAssert.IsEmpty(provider.GetPasswordHistory(computer)); DateTime firstCreated = DateTime.UtcNow.AddDays(-8).Trim(TimeSpan.TicksPerSecond); DateTime firstExpiry = DateTime.UtcNow.AddDays(-5).Trim(TimeSpan.TicksPerSecond); string firstPassword = "******"; provider.UpdateCurrentPassword(computer, firstPassword, firstCreated, firstExpiry, 0); IReadOnlyList <ProtectedPasswordHistoryItem> history = provider.GetPasswordHistory(computer); ProtectedPasswordHistoryItem currentPassword = provider.GetCurrentPassword(computer, null); DateTime?currentExpiry = provider.GetExpiry(computer); Assert.IsNotNull(currentExpiry); Assert.AreEqual(0, history.Count); Assert.AreEqual(firstCreated, currentPassword.Created); Assert.AreEqual(null, currentPassword.Retired); Assert.AreEqual(firstPassword, currentPassword.EncryptedData); Assert.AreEqual(firstExpiry.Ticks, currentExpiry.Value.Ticks); Assert.AreEqual(firstExpiry, currentExpiry); DateTime secondCreated = DateTime.UtcNow.AddDays(-4).Trim(TimeSpan.TicksPerSecond); DateTime secondExpiry = DateTime.UtcNow.AddDays(-5).Trim(TimeSpan.TicksPerSecond); string secondPassword = "******"; provider.UpdateCurrentPassword(computer, secondPassword, secondCreated, secondExpiry, 30); history = provider.GetPasswordHistory(computer); currentPassword = provider.GetCurrentPassword(computer, null); currentExpiry = provider.GetExpiry(computer); Assert.IsNotNull(currentExpiry); Assert.AreEqual(1, history.Count); ProtectedPasswordHistoryItem firstHistoryItem = history.First(); Assert.AreEqual(firstCreated, firstHistoryItem.Created); Assert.AreEqual(firstPassword, firstHistoryItem.EncryptedData); Assert.AreEqual(secondCreated, firstHistoryItem.Retired); Assert.AreEqual(secondExpiry, currentExpiry); Assert.AreEqual(secondPassword, currentPassword.EncryptedData); Assert.AreEqual(secondCreated, currentPassword.Created); Assert.AreEqual(null, currentPassword.Retired); DateTime thirdCreated = DateTime.UtcNow.AddDays(-1).Trim(TimeSpan.TicksPerSecond); DateTime thirdExpiry = DateTime.UtcNow.AddDays(-5).Trim(TimeSpan.TicksPerSecond); string thirdPassword = "******"; provider.UpdateCurrentPassword(computer, thirdPassword, thirdCreated, thirdExpiry, 2); history = provider.GetPasswordHistory(computer); Assert.AreEqual(1, history.Count); firstHistoryItem = history.First(); Assert.AreEqual(secondCreated, firstHistoryItem.Created); Assert.AreEqual(secondPassword, firstHistoryItem.EncryptedData); Assert.AreEqual(thirdCreated, firstHistoryItem.Retired); }
public Disk(IComputer computer) { _computer = computer; }
private static ICloudOCRService CreateAzureOCR(string serviceUrl, string serviceKey, IComputer computer, ILogger logger, IEngineConfig config) { if (_azureService == null) { IOCRResultTextFinder textFinder = new AzureRecognizeTextFinder(); _azureService = new AzureOCRService(computer, textFinder, serviceUrl, serviceKey, logger, config); } return(_azureService); }
public DVDWriter(IComputer computer) { _computer = computer; }
public ComputerProxy(Computer computer) { _computer = computer; _realComputer = new RealComputer(); }
// what is wrapping public Monitor(IComputer computer) { _computer = computer; }
public void vw(IComputer computer) { computer.Name(); }
public SystemTray(IComputer computer, PersistentSettings settings, UnitManager unitManager) { this.computer = computer; this.settings = settings; this.unitManager = unitManager; computer.HardwareAdded += new HardwareEventHandler(HardwareAdded); computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved); this.mainIcon = new NotifyIconAdv(); ContextMenu contextMenu = new ContextMenu(); MenuItem hideShowItem = new MenuItem("Hide/Show"); hideShowItem.Click += delegate(object obj, EventArgs args) { SendHideShowCommand(); }; contextMenu.MenuItems.Add(hideShowItem); contextMenu.MenuItems.Add(new MenuItem("-")); MenuItem exitItem = new MenuItem("Exit"); exitItem.Click += delegate(object obj, EventArgs args) { SendExitCommand(); }; contextMenu.MenuItems.Add(exitItem); this.mainIcon.ContextMenu = contextMenu; this.mainIcon.DoubleClick += delegate(object obj, EventArgs args) { SendHideShowCommand(); }; this.mainIcon.Icon = EmbeddedResources.GetIcon("smallicon.ico"); this.mainIcon.Text = "Open Hardware Monitor"; }