private async void AddNewAsset() { string result = await MatDialogService.PromptAsync("Tilføj et nyt asset vha. serienummer:"); if (string.IsNullOrWhiteSpace(result)) { return; } Computer asset = new Computer(result) { PcName = "-" }; ComputerService.AddAsset(asset); bool assetIsInDatabase = ComputerService.GetAssetBySerialNumber(asset.SerialNumber) != null; if (assetIsInDatabase) { await MatDialogService.AlertAsync("Asset tilføjet."); } else { await MatDialogService.AlertAsync("Asset blev ikke tilføjet."); } }
public string SaveCommandInLaboratory(List <Command> commands) { string executeIn = string.Empty; foreach (Command command in commands) { try { Command commandSaved = commandRepository.SaveCommand(command); if (commandSaved != null) { ComputerService computerService = new ComputerService(); if (computerService.IsComputerOnline(command.IdComputer)) { executeIn += $"Comando enviado para o computador {command.IdComputer}{Environment.NewLine}"; } else { executeIn += $"O Computador {command.IdComputer} não está online, mas o comando será executado assim que o mesmo estiver.{Environment.NewLine}"; } } } catch (Exception ex) { throw ex; } } return(executeIn); }
public ActionResult EditComputerSetting(long id) { var computerService = new ComputerService(AuthenticatedUser.SessionToken); var model = computerService.GetComputerSetting(id); return(View(model)); }
private Command GetCommandExecuted(Command command) { bool find = false; Command commandExecuted = null; while (!find) { ComputerService computerService = new ComputerService(); Command commandSearchExecuted = SearchCommandExecuted(command.IdCommand); if (computerService.IsComputerOnline(command.IdComputer)) { if (commandSearchExecuted != null) { commandExecuted = commandSearchExecuted; find = true; } else { Thread.Sleep(500); } } else { var commandToExecute = GetCommand(command.IdCommand); commandToExecute.ComplementCommandFinish("O computador não está online."); commandExecuted = commandToExecute; break; } } return(commandExecuted); }
protected override async Task OnInitializedAsync() { asset = ComputerService.GetAssetById(AssetDbId.ToString()); navigator = new PageNavigator <IAssetRecord>(AssetRecords, out pageAssetRecords, AssetRecordsPerPage); navigator.PageChanged += GetAssetRecords; }
public ActionResult SearchComputers(string sidx, string sord, int page, int rows, string name, long?districtID) { var computerService = new ComputerService(AuthenticatedUser.SessionToken); var filters = new List <FilterModel>(); if (!string.IsNullOrWhiteSpace(name)) { filters.Add(new FilterModel { PropertyName = "Name", Operation = Operation.StartsWith, Value = name }); } if (districtID.HasValue) { filters.Add(new FilterModel { PropertyName = "DistrictID", Operation = Operation.Equals, Value = districtID.Value }); } var paginatedList = computerService.GetPaginatedList(filters, FilterJoin.And, true, "Name", page, rows); var totalPages = Math.Ceiling((float)paginatedList.TotalCount / (float)rows); var jsonData = new { total = totalPages, page, records = paginatedList.TotalCount, rows = paginatedList.Models }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); }
public ActionResult CreateComputer(ComputerModel model) { var configurationService = new ConfigurationService(AuthenticatedUser.SessionToken); var filters = new List <FilterModel>(); ViewBag.Districts = configurationService.GetDistrictPaginatedList(filters, FilterJoin.And, true, "BranchName", 1, 1000000).Models; if (!ModelState.IsValid) { return(View(model)); } try { var computerService = new ComputerService(AuthenticatedUser.SessionToken); computerService.CreateComputer(model); } catch (GatewayException ex) { ModelState.AddModelError(string.Empty, ex.Message); return(View(model)); } return(RedirectToAction("Computers")); }
public ActionResult Get(string username) { if (!UserService.Exists(username)) { return(BadRequest("user with the given username does not exist.")); } return(Ok(ComputerService.GetComputersForUser(username))); }
public ActionResult Post([FromBody] Computer value) { if (value is null) { return(BadRequest(new { error = "not able to create computer object." })); } ComputerService.AddComputer(value); return(Ok()); }
public async Task <ActionResult> OnPostAsync(string computerToWake, CancellationToken cancellationToken) { Computers = await ComputerService.GetComputersAsync(cancellationToken); //Use a discard since we don't need to await the wake up since it will not start up fast enough to reply to the next ping anyway _ = Computers[computerToWake].WakeUp(); TempData["Message"] = $"Magic packet sent to computer {computerToWake}. It can take some time before it wakes up since it needs to boot first."; return(RedirectToPage("/Index")); }
public ActionResult Put(string computername, [FromBody] Computer value) { if (!ComputerService.Exist(computername)) { return(BadRequest(new { error = "computer with the given name does not exist." })); } ComputerService.UpdateComputer(computername, value); return(Ok()); }
public ActionResult Delete(string computername) { if (!ComputerService.Exist(computername)) { return(BadRequest(new { error = "computer with given name does not exist." })); } ComputerService.RemoveComputer(computername); return(Ok()); }
public void test_open_outlook_email() { ComputerService service = new ComputerService(); service.OpenMailInOutlook("test", "cect est un test", new List <MailAttachement>() { new MailAttachement(@"C:\Users\H264376\AppData\Local\Temp\2c147147-1058-410c-81ec-f7f512196820.rtf", "convention") }); }
public async Task <ActionResult> OnPostAsync(CancellationToken cancellationToken) { if (string.IsNullOrWhiteSpace(Computer.Name) || string.IsNullOrWhiteSpace(Computer.IP) || string.IsNullOrWhiteSpace(Computer.MAC) || string.IsNullOrWhiteSpace(Computer.SubnetMask)) { TempData["Message"] = "You must fill out all fields."; return(Page()); } await ComputerService.AddOrUpdateComputerAsync(Computer, cancellationToken); return(RedirectToPage("/Index")); }
public ActionResult EditComputer(long id) { var configurationService = new ConfigurationService(AuthenticatedUser.SessionToken); var filters = new List <FilterModel>(); ViewBag.Districts = configurationService.GetDistrictPaginatedList(filters, FilterJoin.And, true, "BranchName", 1, 1000000).Models; var computerService = new ComputerService(AuthenticatedUser.SessionToken); var model = computerService.GetComputer(id); return(View(model)); }
private async Task DeleteAssetPrompt() { string initialMessage = $"Er du sikker på, at du vil slette {asset.AssetId}?"; string secondMessage = $"Er du helt sikker på, at du vil slette {asset.AssetId}?\n" + $"Advarsel! Denne handling er permanent og kan ikke fortrydes."; if (await RunPrompt(initialMessage) && await RunPrompt(secondMessage)) { ComputerService.DeleteAsset(asset); ClosePage(); } }
public void AddComputerView() { Console.WriteLine("Enter brand: "); string brand = Console.ReadLine(); Console.WriteLine("Enter price"); string price = Console.ReadLine(); ComputerService.AddComputer(new Computer { Brand = brand, Price = Int32.Parse(price) }); }
/// <summary> /// Opens the details page for an asset in a new page. /// </summary> /// <param name="asset">IAsset to open details for</param> private async Task NavigateToDetails(Computer asset) { if (ComputerService.GetAssetById(asset.Id) == null) { await MatDialogService.AlertAsync("Asset does not exist."); return; } string url = $"{NavigationManager.BaseUri}AssetDetails/{asset.Id}"; await JSRuntime.InvokeAsync <object>("open", new object[] { url, "_blank" }); }
public ActionResult EditComputer(ComputerModel model) { if (!ModelState.IsValid) { var configurationService = new ConfigurationService(AuthenticatedUser.SessionToken); var filters = new List <FilterModel>(); ViewBag.Districts = configurationService.GetDistrictPaginatedList(filters, FilterJoin.And, true, "BranchName", 1, 1000000).Models; return(View(model)); } var computerService = new ComputerService(AuthenticatedUser.SessionToken); computerService.UpdateComputer(model); return(RedirectToAction("Computers")); }
public ActionResult EditComputerSetting(ComputerConfigSettingModel model) { if (!ModelState.IsValid) { return(View(model)); } try { var computerService = new ComputerService(AuthenticatedUser.SessionToken); computerService.UpdateComputerSetting(model); } catch (GatewayException ex) { ModelState.AddModelError(string.Empty, ex.Message); return(View(model)); } return(RedirectToAction("ViewComputer", new { id = model.ComputerID })); }
public void print_test() { var service = new ComputerService(); service.Print("C:\\Users\\H264376\\AppData\\Local\\Temp\\6c92b5c6-01b7-42b0-ab30-c60a5dac92e5.rtf"); }
public ComputerController(AppContextModel context) { _context = context; computerService = new ComputerService(_context); }
public IndexModel(ComputerService computerService) { ComputerService = computerService; }
public async Task OnGetAsync(CancellationToken cancellationToken) { Computers = await ComputerService.GetComputersAsync(cancellationToken); await PingAllComputers(Computers.Values); }
public void Test_UpdateComputer() { ComputerService service = new ComputerService(); Assert.AreEqual(true, service.UpdateComputer(new Core.Models.Computer())); }
public ActionResult GetUnassigned() { return(Ok(ComputerService.GetAllUnAssignedComputers())); }
public ActionResult Get() { return(Ok(ComputerService.GetAllComputers())); }
public CreateModel(ComputerService computerService) { ComputerService = computerService; }