private bool Shutdown(int computerId, string delay) { var computer = _uow.ComputerRepository.GetById(computerId); if (computer == null) { return(false); } if (computer.CertificateId == -1) { return(false); } var compPreventShutdownGroups = _uow.ComputerRepository.GetComputerPreventShutdownGroups(computerId); if (compPreventShutdownGroups.Count > 0) { return(true); //computer is in a prevent shutdown group continue on } var socket = _uow.ActiveSocketRepository.GetFirstOrDefault(x => x.ComputerId == computer.Id); if (socket != null) { var deviceCertEntity = _uow.CertificateRepository.GetById(computer.CertificateId); var deviceCert = new X509Certificate2(deviceCertEntity.PfxBlob, new EncryptionServices().DecryptText(deviceCertEntity.Password), X509KeyStorageFlags.Exportable); var intercomKey = ServiceSetting.GetSettingValue(SettingStrings.IntercomKeyEncrypted); var decryptedKey = new EncryptionServices().DecryptText(intercomKey); var socketRequest = new DtoSocketRequest(); socketRequest.connectionIds.Add(socket.ConnectionId); socketRequest.action = "Shutdown"; socketRequest.message = delay; new APICall().ClientComServerApi.SendAction(socket.ComServer, "", decryptedKey, socketRequest); } return(true); }
public bool CollectInventory(int id) { var computer = _uow.ComputerRepository.GetById(id); if (computer == null) { return(false); } if (computer.CertificateId == -1) { return(false); } var socket = _uow.ActiveSocketRepository.GetFirstOrDefault(x => x.ComputerId == computer.Id); if (socket != null) { var deviceCertEntity = _uow.CertificateRepository.GetById(computer.CertificateId); var deviceCert = new X509Certificate2(deviceCertEntity.PfxBlob, new EncryptionServices().DecryptText(deviceCertEntity.Password), X509KeyStorageFlags.Exportable); var intercomKey = ServiceSetting.GetSettingValue(SettingStrings.IntercomKeyEncrypted); var decryptedKey = new EncryptionServices().DecryptText(intercomKey); var socketRequest = new DtoSocketRequest(); socketRequest.connectionIds.Add(socket.ConnectionId); socketRequest.action = "Collect_Inventory"; new APICall().ClientComServerApi.SendAction(socket.ComServer, "", decryptedKey, socketRequest); } return(true); }
public void SendAction(string url, string serverName, string interComKey, DtoSocketRequest socketRequest) { Request.Method = Method.POST; Request.Resource = "Socket/SendAction"; Request.AddJsonBody(socketRequest); var responseData = new ApiRequest(new Uri(url)).ExecuteHMACInterCom <DtoApiBoolResponse>(Request, serverName, interComKey); }
public void SendAction(DtoSocketRequest request) { var action = new DtoHubAction(); action.Action = request.action; action.Message = request.message; var context = GlobalHost.ConnectionManager.GetHubContext <ActionHub>(); context.Clients.Clients(request.connectionIds).ClientAction(action); }
public void SendAction(DtoSocketRequest socketRequest) { new ActionHub().SendAction(socketRequest); }