public Response DisableWebHook(int id) { var cache = new InMemoryRepositoryModelCache(); var computer = _computerRepository.Get(_user, id, cache); if (computer == null) { return(RpcComputerRepositoryHelpers.CreateNotFoundError()); } computer.DisableWebhook(); _computerRepository.Update(computer); return(Response.Empty()); }
public Persistence.Models.Task[] Run(Persistence.Models.Computer computer, TimeSpan?timeout, TimeSpan?pollInterval) { timeout = timeout ?? TimeSpan.FromSeconds(90); pollInterval = pollInterval ?? TimeSpan.FromSeconds(1 / 4); Persistence.Models.Task[] tasks = null; var endTime = DateTime.Now.Add(timeout.Value); while (true) { computer.UpdatePing(); _computerRepository.Update(computer); var now = DateTime.UtcNow; var cache = new InMemoryRepositoryModelCache(); tasks = _taskRepository.ForComputer(computer, now, cache); if (tasks.Length > 0 || DateTime.Now >= endTime) { foreach (var task in tasks) { task.MarkAsReceived(); _taskRepository.Update(task); } return(tasks); } System.Threading.Thread.Sleep(pollInterval.Value); } }
public async Task <BaseResponse <ComputerDto> > UpdateComputer(Guid computerId, UpdateComputer request) { var(errors, isValid) = EntityValidator.Validate(request); if (!isValid) { return(new BaseResponse <ComputerDto>((int)CustomHttpStatusCode.UnprocessableEntity, string.Join("", errors))); } if (!await _computerRepository.Exists(computerId)) { return(new BaseResponse <ComputerDto>((int)HttpStatusCode.NotFound)); } var computer = await _computerRepository.Get(computerId); computer.Update(request.Name, request.Price); await _computerRepository.Update(computer); return(new BaseResponse <ComputerDto>((int)HttpStatusCode.Created, _mapper.Map <ComputerDto>(computer))); }
public void Run(Persistence.Models.User user, Persistence.Models.Computer computer, string source, string scriptText, bool updateLastRunScript) { var script = Persistence.Models.Script.Create(false, scriptText); _scriptRepository.Add(script); var task = Persistence.Models.Task.Create(user, source, computer, script); _taskRepository.Add(task); if (updateLastRunScript) { computer.UpdateLastScript(task.Script); _computerRepository.Update(computer); } }
public Persistence.Models.Device[] Run(Persistence.Models.Computer computer, Persistence.Models.User user, Persistence.Models.Network network, IDeviceState[] sentDevices) { computer.UpdatePing(); _computerRepository.Update(computer); network.UpdatePing(computer); _networkRepository.Update(network); var existingDevices = _deviceRepository.Get(network); UpdateDevices(sentDevices, existingDevices, network); var devicesToRemove = GetRemovedDevices(sentDevices, existingDevices); RemoveDevices(devicesToRemove); return(existingDevices); }
public void Update(Model.Models.Computer computer) { computer.UpdatedDate = DateTime.Now; //producerType.UpdatedBy = ad //Todo: Add CreatedBy _computerRepository.Update(computer); }