public StepVM(ComputerModel model, int column) { _model = model; _column = column; _model.Steps[_column].Gates.CollectionChanged += Gates_CollectionChanged; _gates = CreateGatesFromModel(); }
public IHttpActionResult Post([FromBody] ComputerModel model) { using (var dbContext = new DataContext()) { var computer = dbContext.Computers.SingleOrDefault(f => f.Name.ToUpper() == model.Name.ToUpper()); if (computer != null) { model.ID = computer.ID; model.IPAddress = computer.IPAddress; model.DistrictID = computer.DistrictID; return(Ok(model)); } computer = new Computer(); computer.Name = model.Name; computer.IPAddress = model.IPAddress; computer.DistrictID = model.DistrictID; dbContext.Computers.Add(computer); dbContext.SaveChanges(); model.ID = computer.ID; return(Ok(model)); } }
public ComputerModel BuildModel(Assembly asm) { // Reset previous registers QuantumParser.QuantumComputer localComp = QuantumParser.QuantumComputer.GetInstance(); ComputerModel emptyModel = ComputerModel.CreateModelForParser(); localComp.Reset(emptyModel); // Get the method Main MethodInfo method = asm.EntryPoint; try { // Call the static method Main to generate circuit method.Invoke(null, null); } catch (Exception ex) { StringBuilder builder = new StringBuilder("Circuit builder errors:\n\n"); builder.Append(ex.InnerException.GetType().ToString()).Append(": ").AppendLine(ex.InnerException.Message); throw new Exception(builder.ToString()); } ComputerModel generatedModel = localComp.GetModel(); generatedModel.AddStepAfter(generatedModel.Steps.Count - 1); return(generatedModel); }
public void Init(bool show) { Show = show; ComputerModel.Init(); TotalHits = ComputerModel.TotalHits; OnInputLineChanged += new EventHandler(inputLineChanged); }
internal Register(ComputerModel compModel, Quantum.Register reg, RegisterModel regModel, int offsetToModel = 0) { _compModel = compModel; _register = reg; _model = regModel; _offsetToModel = offsetToModel; }
public bool PowerOff(int id) { ApplicationDbContext db = new ApplicationDbContext(); ComputerModel model = db.Computers.SingleOrDefault(x => x.Id == id); // Event SysEvent ev = new SysEvent(); ev.Action = Enums.Action.Power; ev.Description = "Powered off: " + model.Name; try { bool result = Core.Actions.PowerOff(model); ev.ActionStatus = ActionStatus.OK; LogsController.AddEvent(ev, User.Identity.GetUserId()); return(result); } catch (Exception ex) { ev.ActionStatus = ActionStatus.Error; ev.Exception = ex.ToString(); LogsController.AddEvent(ev, User.Identity.GetUserId()); } return(false); }
public ComputerModel UpdateComputer(ComputerModel model) { _context.Computers.Attach(model); _context.Entry(model).State = EntityState.Modified; _context.SaveChanges(); return(model); }
public void Update(Computer computer) { var model = ComputerModel.FromRepositoryType(computer); var sql = @" UPDATE ComputerModels SET AccessKey = @AccessKey, Address = @Address, EncryptionKey = @EncryptionKey, LastPing = @LastPing, LastScript_Id = @LastScript_Id, Name = @Name, Owner_Id = @Owner_Id WHERE Id = @Id "; var parameters = new { AccessKey = model.AccessKey, Address = model.Address, EncryptionKey = model.EncryptionKey, Id = model.Id, LastPing = model.LastPing, LastScript_Id = model.LastScript_Id, Name = model.Name, Owner_Id = model.Owner_Id, }; _connection.Execute(sql, parameters); }
private static void UpdateComputer(int id) { ApplicationDbContext db = new ApplicationDbContext(); ComputerModel computer = db.Computers.Single(x => x.Id == id); if (computer != null) { // Ping computer computer.IsOnline = Core.Actions.Ping(computer); // Get Info (but only if it is online) if (computer.IsOnline) { computer.LastSeen = DateTime.Now; computer.IP = Core.Actions.GetIP(computer); computer.MAC = Core.Actions.GetMAC(computer); } else { if (computer.LastSeen.Year < 1990) { computer.LastSeen = computer.PurchaseDate; } } // Update Database db.Computers.AddOrUpdate(computer); db.SaveChanges(); // Call SignalR var context = GlobalHost.ConnectionManager.GetHubContext <LiveUpdatesHub>(); string lastSeen = computer.LastSeen.ToShortDateString() + " " + computer.LastSeen.ToShortTimeString(); context.Clients.All.UpdateListView(id, computer.IsOnline, computer.IP, computer.MAC, lastSeen); context.Clients.All.UpdateOverview(id, computer.IsOnline, computer.IP, computer.MAC, lastSeen); context.Clients.All.UpdateComputers(id, computer.IsOnline, computer.IP, computer.MAC, lastSeen); } }
public ActionResult ResultGetPassword([FromBody] string computername) { //ComputerModel.ShowResultGetPassword = false; ComputerModel = getComputerModel(computername); logger.Info("User {0} requesed localadmin password for computer {1}", ControllerContext.HttpContext.User.Identity.Name, ComputerModel.adpath); var passwordRetuned = getLocalAdminPassword(ComputerModel.adpath); if (string.IsNullOrEmpty(passwordRetuned)) { ComputerModel.Result = "Not found"; Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(new { success = false, errorMessage = ComputerModel.Result })); } else { Func <string, string, string> appendColor = (string x, string color) => { return("<font color=\"" + color + "\">" + x + "</font>"); }; string passwordWithColor = ""; foreach (char c in passwordRetuned) { var color = "green"; if (char.IsNumber(c)) { color = "blue"; } passwordWithColor += appendColor(c.ToString(), color); } ComputerModel.Result = "<code>" + passwordWithColor + "</code><br /> Password will expire in 8 hours"; Response.StatusCode = (int)HttpStatusCode.OK; return(Json(new { success = true, message = ComputerModel.Result })); } }
public string UpFileByDataBase(string ip, string folderName, string fileName) { ComputerModel computer = _ComputerAppService.GetComputerByIp(ip); string mess = ""; if (computer != null) { FolderModel folder = _FolderAppService.GetFolderByComputerAndName(computer.Id, folderName); if (folder != null) { string fromPath = string.Format("\\\\{0}\\{1}\\{2}.bak", ip, folderName, fileName); string toPath = string.Format("{0}\\DataBase", masterPath); this.CheckDir(toPath); mess = TransFile(computer.UserName, computer.Pwd, ip, fromPath, toPath + "\\" + fileName + ".bak"); } else { mess = string.Format("结果:false;此IP({0})的终端下此共享目录不存在", ip); } } else { mess = string.Format("结果:false;此IP({0})的终端在数据库中不存在", ip); } return(mess); }
/// <summary> /// HangFire | Gets the MAC address. /// </summary> /// <param name="computer"></param> /// <returns></returns> public static string GetMAC(ComputerModel computer) { try { // Parse IP IPAddress address = IPAddress.Parse(computer.IP); // Get INT int intAddress = BitConverter.ToInt32(address.GetAddressBytes(), 0); byte[] macAddr = new byte[6]; int macAddrLen = (int)macAddr.Length; if (SendARP(intAddress, 0, macAddr, ref macAddrLen) != 0) { return(computer.MAC); } StringBuilder macAddressString = new StringBuilder(); for (int i = 0; i < macAddr.Length; i++) { if (macAddressString.Length > 0) { macAddressString.Append(":"); } macAddressString.AppendFormat("{0:x2}", macAddr[i]); } return(macAddressString.ToString().ToUpper()); } catch (Exception) { return(computer.MAC); } }
public string DownFileByDataBase(string ip, string folderName, string fileName) { ComputerModel computer = _ComputerAppService.GetComputerByIp(ip); string mess = ""; if (computer != null) { FolderModel folder = _FolderAppService.GetFolderByComputerAndName(computer.Id, folderName); if (folder != null) { string toPath = string.Format("\\\\{0}\\{1}\\{2}.bak", ip, folderName, fileName); string fromPath = string.Format("{0}\\DataBase\\{1}.bak", masterPath, fileName); if (System.IO.File.Exists(fromPath) == false) { mess = string.Format("结果:false;还未有此路径文件的备份({0})", fileName); } else { mess = TransFile(computer.UserName, computer.Pwd, ip, fromPath, toPath); } } else { mess = string.Format("结果:false;此IP({0})的终端下此共享目录不存在", ip); } } else { mess = string.Format("结果:false;此IP({0})的终端在数据库中不存在", ip); } return(mess); }
private void MainViewModel_OnUpdate(ComputerModel e) { AllCpus = computerInformation.Update(AllCpus); CoreSpeed = $"{AllCpus.Cpus.RootCpu.CpuClocks.CoreSpeed} MHz"; BusSpeed = $"{AllCpus.Cpus.RootCpu.CpuClocks.BusSpeed} MHz"; Multiplier = AllCpus.Cpus.RootCpu.CpuClocks.Multiplier; }
static void Main(string[] args) { GameView gameView = new GameView(); UserModel userModel = new UserModel(); ComputerModel computerModel = new ComputerModel(); GameController gameController = new GameController(); gameView.GameTitlesView(); while (true) { gameView.GameRound(); string player_choice = userModel.PlayerChoice(); string computer_choice = computerModel.ComputerChoice(); if (player_choice == "quit") { gameView.GameFinalScore(gameController.player_score, gameController.computer_score); break; } string whoWin = gameController.WhoWinRound(player_choice, computer_choice); gameView.PlayersChoiceView(player_choice, computer_choice); gameView.RoundResult(whoWin); gameView.GameScoreView(gameController.player_score, gameController.computer_score); gameView.EndOfRoundView(); } }
public Computer(ComputerModel computerModel) { Name = computerModel.Name; Price = computerModel.Price; IsAvailable = computerModel.IsAvailable; Description = computerModel.Description; ProducerId = computerModel.ProducerId; ManufacturerId = computerModel.ManufacturerId; MaterialValue = computerModel.Material; ColorValue = computerModel.Color; AmountOfRAM = computerModel.AmountOfRAM; CPUFrequency = computerModel.CPUFrequency; Length = computerModel.Length; Height = computerModel.Height; Width = computerModel.Width; HaveFloppyDrives = computerModel.HaveFloppyDrives; SSDMemory = computerModel.SSDMemory; HardDiskMemory = computerModel.HardDiskMemory; CPUSocketTypeValue = computerModel.CPUSocketType; NumberOfCores = computerModel.NumberOfCores; if (HaveFloppyDrives) { FloppyDrivesCount = computerModel.FloppyDrivesCount; } if (computerModel.UserId != null && computerModel.UserId != new Guid()) { UserId = computerModel.UserId; } }
public ActionResult Edit(CreateComputerViewModel model) { if (ModelState.IsValid) { // Save primitive type to 'local' first without committing to DB. db.Computers.AddOrUpdate(model.Computer); // Get model back into context including dependencie objects (color,type,location) and primitive types saved above. ComputerModel computer = db.Computers.Single(x => x.Id == model.Computer.Id); computer.Type = db.ComputerTypes.SingleOrDefault(x => x.Name == model.SelectedType); computer.Color = db.Colors.SingleOrDefault(x => x.Name == model.SelectedColor); computer.Location = db.Locations.SingleOrDefault(x => x.Location == model.SelectedLocation); // Check friendly name if (model.Computer.Name == null) { computer.Name = model.Computer.Hostname.ToUpper(); } db.Computers.AddOrUpdate(computer); db.SaveChanges(); return(RedirectToAction("Index", "Computer")); } // If NOT valid // Send lists of items for dropdowns. ViewBag.Colors = db.Colors.ToList(); ViewBag.Locations = db.Locations.ToList(); ViewBag.Types = db.ComputerTypes.ToList(); // Return model with errors. return(View(model)); }
public ActionResult MoveOU_Click([FromBody] string computername) { ComputerModel = ComputerModel = getComputerModel(computername); moveOU(ControllerContext.HttpContext.User.Identity.Name, ComputerModel.adpath); Response.StatusCode = (int)HttpStatusCode.OK; return(Json(new { success = true, message = "OU moved for" + computername })); }
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 RegisterVM(ComputerModel model, int registerIndex) { _model = model; _registerIndex = registerIndex; _model.Registers[_registerIndex].Qubits.CollectionChanged += Qubits_CollectionChanged; _model.StepChanged += _model_StepChanged; }
/// <summary> /// 登入頁面 /// </summary> /// <param name="cv"></param> public ActionResult Login(ComputerViewModels cv) { ComputerModel cm = new ComputerModel(); cv.AGE = cm.GetAge(cv); return(View(cv)); }
public ActionResult Delete(int id) { ComputerModel model = db.Computers.Single(x => x.Id == id); db.Computers.Remove(model); db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult Submit(ComputerModel model) { if (!ModelState.IsValid) { return(View("Index", model)); } return(View(model)); }
public void DetermineNextFreeComputerCode3_Test() { string[] list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray().Select(c => c.ToString()).ToArray(); var sut = new ComputerModel(); sut.DetermineNextFreeComputerCode(list).ShouldEqual("AA"); }
/// <summary> /// Odstraní počítač z databáze. /// </summary> /// <param name="model">Počítač k odstranění.</param> public void RemoveComputer(ComputerModel model) { List <ComputerModel> computers = ComputersFile.FullFilePath().LoadFile().ConvertToComputerModels(); computers.RemoveAll(m => m.Id == model.Id); computers.SaveToComputerFile(ComputersFile); }
public async Task <ComputerModel> UpdateComputerAsync(ComputerModel model) { _context.Computers.Attach(model); _context.Entry(model).State = EntityState.Modified; await _context.SaveChangesAsync(); return(model); }
public IActionResult Index(ComputerModel model) { if (!ModelState.IsValid) { return(View(model)); } return(View("Submission", model)); }
public void DetermineNextFreeComputerCode_Test() { var list = new[] { "A", "B" }; var sut = new ComputerModel(); sut.DetermineNextFreeComputerCode(list).ShouldEqual("C"); }
// GET: Admin/Delete/5 public ActionResult Delete(int id) { List <ComputerModel> computers = DbDataAccess.GetData <ComputerModel>("GetAllComputers", null).ToList(); ComputerModel computer = computers.Where(c => c.Id == id).First(); return(View(computer)); }
public QubitVM(ComputerModel model, int registerIndex, int rowIndex) { _model = model; _registerIndex = registerIndex; _rowIndex = rowIndex; _model.StepChanged += _model_CurrentStepChanged; _deleteRegister = new DelegateCommand(DeleteRegister, x => model.Registers.Count > 1); }