private void Button_Click(object sender, RoutedEventArgs e) { try { Model1 db = new Model1(); Computers cmp = new Computers { problem = problem.Text, brand = brand.Text, name = equipment.Text, model = model.Text, description = description.Text }; db.Computers.Add(cmp); db.SaveChanges(); MessageBox.Show("Техника добавлена!"); ComputerView cv = new ComputerView(); cv.Show(); Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// 1. Get list of testbed titles // 2. Get list of computers for each testbed // 3. Add each list and its contents to the tree // 4. Add all of the computers in the DB to the master tree private void WindowListBrowserWindow_Loaded(object sender, RoutedEventArgs e) { DataTable allTestbeds = new Testbeds().SelectAll(); foreach (DataRow row_testbed in allTestbeds.Rows) { // Loop through each testbed Testbed testbed = new Testbed((int)row_testbed["ID"], (string)row_testbed["Title"]); // Find all of the relations for this testbed ID DataTable testbedRelations = new TestbedRelations().FindByTestbedID((int)row_testbed["ID"]); foreach (DataRow row_relation in testbedRelations.Rows) { // Get the computer information for this ID DataTable table_computer = new Computers().Find((int)row_relation["ComputerID"]); foreach (DataRow row_computer in table_computer.Rows) { testbed.Add(new RemoteComputer(row_computer)); } } listTree.AddList((string)row_testbed["Title"], testbed); } DisplayAllInMasterList(); }
public void LoadComputers(Computers computers) { for (int i = 0; i < computers.PlayerComputers.Count; i++) { Computer computer = computers.PlayerComputers[i]; _ = AssemblyList.Items.Add(computer.Name); } }
private void UpdateAssignedEquipmentData(string[] selectedEquipment, Computers computerToUpdate) { if (selectedEquipment == null) { computerToUpdate.AdditionalEquipment = new List <AdditionalEquipment>(); return; } var selectedEquipmentHS = new HashSet <string>(selectedEquipment); var computersEquipment = new HashSet <int>(computerToUpdate.AdditionalEquipment.Select(a => a.AdditionalEquipmentId)); foreach (var part in db.AdditionalEquipment) { if (selectedEquipmentHS.Contains(part.AdditionalEquipmentId.ToString())) { if (!computersEquipment.Contains(part.AdditionalEquipmentId)) { computerToUpdate.AdditionalEquipment.Add(part); } } else { if (computersEquipment.Contains(part.AdditionalEquipmentId)) { computerToUpdate.AdditionalEquipment.Remove(part); } } } }
public JsonResult SearchModify() { //Log日志要记录的用户名 string domain = Request.Form["domain"].Trim().ToString(); string searchcriteria = Request.Form["searchcriteria"].Trim().ToString(); string searchkeyword = Request.Form["searchkeyword"].Trim().ToString(); Computers ad_computer = HttpContext.Application["ad_computer"] as Computers; List <ComputerDTO> col; if (searchkeyword.Trim() != "") { col = ad_computer.SearchAllComputersDTO(searchkeyword, domain, Int32.Parse(searchcriteria)); } else { col = ad_computer.SearchAllComputersDTO(searchkeyword, domain, 0); } string con = "<table id = \"example\" class=\"display\" cellspacing=\"0\" width=\"100%\"><thead><tr><th>ID</th><th>Name</th><th>OUName</th><th>OperatingSystem</th></tr></thead><tbody>"; for (int i = 0; i < col.Count; i++) { ComputerDTO cd = col.ElementAt(i); con += "<tr" + " " + "onclick=\"computer_detail(this)\"><td>" + i + "</td><td>" + cd.Name + "</td><td>" + cd.OUName + "</td><td>" + cd.operatingSystem + "</td></tr>";//数据行,字段对应数据库查询字段 } con += " </tbody></table>"; return(Json(new JsonData(con))); }
public ActionResult Create([Bind(Include = "Name,ComputerType,Manufacturer,Model,SerialNumber,Cpu,Ram,VideoCard,ApplicationUserId")] Computers computers, string[] selectedEquipment) { try { if (selectedEquipment != null) { computers.AdditionalEquipment = new List <AdditionalEquipment>(); foreach (var course in selectedEquipment) { var partToAdd = db.AdditionalEquipment.Find(int.Parse(course)); computers.AdditionalEquipment.Add(partToAdd); } } if (ModelState.IsValid) { db.Computers.Add(computers); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DataException) { ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.\nCheck if Serial Number is unique."); } ViewBag.ApplicationUserId = new SelectList(db.Users, "Id", "FirstName", computers.ApplicationUserId); PopulateAssignedEquipmentData(computers); return(View(computers)); }
public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } string sql = $@" select c.Id, c.DatePurchased, c.DecommissionedDate, c.Manufacturer, c.Make from Computers c WHERE c.Id = {id}"; using (IDbConnection conn = Connection) { Computers Computers = (await conn.QueryAsync <Computers>(sql)).ToList().Single(); if (Computers == null) { return(NotFound()); } return(View(Computers)); } }
public void Userods_CheckUserAndPassoword_UpdateFailedAttemptsFromOtherMethods() { //First, setup the test scenario. long group1 = UserGroupT.CreateUserGroup("usergroup1"); Userod myUser = UserodT.CreateUser(MethodBase.GetCurrentMethod().Name + DateTime.Now.Ticks, "reallystrongpassword", userGroupNumbers: new List <long>() { group1 }); Security.CurUser = myUser; Security.PasswordTyped = "passwordguess#1"; CredentialsFailedAfterLoginEvent.Fired += CredentialsFailedAfterLoginEvent_Fired1; RunTestsAgainstMiddleTier(new OpenDentBusiness.WebServices.OpenDentalServerMockIIS(user: myUser.UserName, password: myUser.Password)); //try once with the wrong password. Failed attempt should get incremented to 1. ODException.SwallowAnyException(() => { Userods.CheckUserAndPassword(myUser.UserName, "passwordguess#1", false); }); //Get our updated user from the DB. RunTestsAgainstDirectConnection(); myUser = Userods.GetUserByNameNoCache(myUser.UserName); //Assert that we only have 1 failed attempt. Assert.AreEqual(1, myUser.FailedAttempts); //now wait for another method to get called RunTestsAgainstMiddleTier(new OpenDentBusiness.WebServices.OpenDentalServerMockIIS(user: myUser.UserName, password: myUser.Password)); ODException.SwallowAnyException(() => { Computers.UpdateHeartBeat(Environment.MachineName, false); }); RunTestsAgainstDirectConnection(); //Get our updated user from the DB. myUser = Userods.GetUserByNameNoCache(myUser.UserName); //Assert that we only have 1 failed attempt. Assert.AreEqual(1, myUser.FailedAttempts); }
public ActionResult Create(Computers computers) { db.Computers.Add(computers); db.SaveChanges(); return(RedirectToAction("Index")); }
private async void SetActiveDirectoryObjectComputers(bool IsCheck) { Debug.WriteLine("Start SetActiveDirectoryObjectComputers"); //Debug.WriteLine(Environment.StackTrace); ComputerCircularProgressBar = IsCheck; Computers.Clear(); Debug.WriteLine("Computers.Clear()"); if (IsCheck) { TxtComputerCount = null; AllComputers = await _ComputerCommandsviewModel.GetAllComputers(); Debug.WriteLine(AllComputers.Count); AllComputers = AllComputers.OrderBy(a => a.SamAccountName).ToList(); foreach (Principal item in AllComputers) { computers.Add(item.Name); } } else { TxtComputerCount = null; Computers.Clear(); } TxtComputerCount = Computers.Count.ToString(); Debug.WriteLine("End SetActiveDirectoryObjectComputers"); }
public async Task <IActionResult> Create([Bind("Id, DatePurchased, Manufacturer, Make ")] Computers Computers) { if (ModelState.IsValid) { string sql = $@" INSERT INTO Computers ( Id, DatePurchased, Manufacturer, Make) VALUES ( '{Computers.Id}' , '{Computers.DatePurchased}' , '{Computers.Manufacturer}' , '{Computers.Make}' ) "; using (IDbConnection conn = Connection) { int rowsAffected = await conn.ExecuteAsync(sql); if (rowsAffected > 0) { return(RedirectToAction(nameof(Index))); } } } return(View(Computers)); }
private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { Project.Dispose(); tasker.Dispose(); relations.Dispose(); computers.Dispose(); computerIPs.Dispose(); files.Dispose(); Ips.Dispose(); computerDomains.Dispose(); lstLimits.Dispose(); domains.Dispose(); plugins.Dispose(); } Project = null; tasker = null; computerDomains = null; lstLimits = null; domains = null; relations = null; computers = null; files = null; Ips = null; plugins = null; disposedValue = true; } }
public IHttpActionResult PutComputer(int id, Computers computer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != computer.Index) { return(BadRequest()); } db.Entry(computer).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ComputerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public MainWindow() { InitializeComponent(); BindingOperations.EnableCollectionSynchronization(Computers, _computersLock); ComputersTable.ItemsSource = Computers; Computers.LoadComputers(); var dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += (sender, args) => { foreach (var computer in Computers) { computer.UpdateDataAsync(TimeSpan.FromSeconds(10)); computer.InternetConnectionStatus.UpdateStatusAsync(TimeSpan.FromSeconds(10)); } }; dispatcherTimer.Interval = TimeSpan.FromSeconds(10); dispatcherTimer.Start(); string path = Path.GetDirectoryName(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); string scriptsPath = Path.Combine(path, "scripts" + Path.DirectorySeparatorChar); Directory.CreateDirectory(scriptsPath); ActionsList.ItemsSource = from file in Directory.GetFiles(scriptsPath) select GetActionEntry(file); }
public void Add(Computer computer, int?quantity = 1) { for (var i = 0; i < quantity; i++) { Computers.Add(computer); } }
public void CreateNewItem() { var target = Substitute.For <ILi <ITodoItem> >(); var targetAsWrite = new List <ITodoItem>(); var nextId = Substitute.For <IEl <int> >(); var newItem = Substitute.For <IMultiOp <string> >(); var deleteCompletedItems = Substitute.For <IOp <Empty> >(); var deleteItem = Substitute.For <IMultiOp <string> >(); var itemFactory = Substitute.For <ITodoItemFactory>(); var newItem1 = Substitute.For <ITodoItem>(); var newItem2 = Substitute.For <ITodoItem>(); target.AsWrite().Returns(targetAsWrite); nextId.Read().Returns(2); newItem.Read().Returns(new List <string> { "hello", "bye" }); Empty tmp; deleteCompletedItems.TryRead(out tmp).Returns(true); deleteItem.Read().Returns(new List <string>()); itemFactory.Create("2", "hello").Returns(newItem1); itemFactory.Create("3", "bye").Returns(newItem2); Computers.Items(target, nextId, newItem, deleteCompletedItems, deleteItem, itemFactory); Assert.AreEqual(new List <ITodoItem> { newItem1, newItem2 }, targetAsWrite); }
public JsonResult Delete() { string Operator = ""; if (Session["username"].ToString() != null) { Operator = Session["username"].ToString(); } //Log日志要记录的用户名 string computername = Request.Form["computername"].Trim().ToString(); string domain = Request.Form["domain"].Trim().ToString(); Computers ad_computer = HttpContext.Application["ad_computer"] as Computers; List <ComputerDTO> col = ad_computer.SearchAllComputersDTO(computername, domain, (int)SearchPattern.Equals); ComputerDTO cd = col.ElementAt(0); string m; if (ad_computer.DeleteComputerDTO(cd)) { m = "Delete success"; LogHelper.WriteLog(typeof(ComputerManagementController), Operator, "Delete%a%Computer%named%" + computername, true); } else { m = "Delete failed"; LogHelper.WriteLog(typeof(ComputerManagementController), Operator, "Delete%a%Computer%named%" + computername, false); } return(Json(new JsonData(m))); }
public async Task ScanAsync(string[] folders) { if (folders != null) { foreach (string path in folders) { DirectoryInfo root = new DirectoryInfo(path).Root; Computer computer; bool isNetworkShare = Drive.IsNetworkPath(path); if (isNetworkShare) { string machineName = Drive.GetMachineName(path); computer = Computers.SingleOrDefault(c => c.NameEquals(machineName)); if (computer == null) { computer = new Computer() { Name = machineName }; computer.Folders = new List <Folder>(); Computers.Add(computer); } } else { computer = _localComputer; } bool isDrive = root.FullName.Equals(path, StringComparison.OrdinalIgnoreCase); DriveModel drive = computer.Drives.SingleOrDefault(f => f.NameEquals(root.Name)); bool isNew = drive == null; if (isNew) { string name; DriveType driveType; if (isNetworkShare) { name = Drive.GetDriveLetter(path); driveType = Drive.NETWORK_SHARE; } else { name = root.Name; driveType = DriveType.Network; } drive = new DriveModel(computer, name, DateTime.UtcNow, driveType); drive.Folders.Clear(); computer.Folders.Add(drive); computer.Folders = new List <Folder>(computer.Folders); computer.RaiseItemChanges(); } if (!isDrive) { drive.Load(); } await ScanAsync(path, isDrive, drive, computer); } } }
public ActionResult DeleteConfirmed(int id) { Computers computers = db.Computers.Find(id); db.Computers.Remove(computers); db.SaveChanges(); return(RedirectToAction("Index")); }
public SETIProgram() : base(60) { Name = "SETI Program"; RequiredTech = new Computers(); ObsoleteTech = null; SetSmallIcon(0, 5); Type = Wonder.SETIProgram; }
private void RemoveObject() { Connectors.Where(x => x.IsNew).ToList().ForEach(x => Connectors.Remove(x)); Computers.Where(x => x.IsNew).ToList().ForEach(x => Computers.Remove(x)); Switches.Where(x => x.IsNew).ToList().ForEach(x => Switches.Remove(x)); }
public void AddRange(Computer[] coms) { foreach (Computer computer in coms) { frameSended += computer.Received; } Computers.AddRange(coms); }
public JsonResult Update_Computer() { string Operator = ""; if (Session["username"].ToString() != null) { Operator = Session["username"].ToString(); } //Log日志要记录的用户名 string name = Request.Form["name"].ToString(); string computername = Request.Form["computername"].Trim().ToString(); string site = Request.Form["site"].Trim().ToString(); string oupath = Request.Form["oupath"].ToString(); string description = Request.Form["Description"].Trim().ToString(); string domain = Request.Form["domain"].Trim().ToString(); string manageby = Request.Form["manageby"].ToString(); Computers ad_computer = HttpContext.Application["ad_computer"] as Computers; List <ComputerDTO> col = ad_computer.SearchAllComputersDTO(name, domain, (int)SearchPattern.Equals); ComputerDTO cd = col.ElementAt(0); cd.site = site; cd.Name = computername; cd.managedBy = manageby; cd.Description = description; string m; if (oupath != "") { if (ad_computer.UpdateComputerDTO(cd) && ad_computer.MoveComputerIntoNewOU(cd, oupath)) { m = "Successful modification!"; LogHelper.WriteLog(typeof(ComputerManagementController), Operator, "Modify%the%information%of%" + computername.Replace(" ", ""), true); return(Json(new JsonData(m, true))); } else { m = "Modify failed!"; LogHelper.WriteLog(typeof(ComputerManagementController), Operator, "Modify%the%information%of%" + computername.Replace(" ", ""), false); return(Json(new JsonData(m, false))); } } else { if (ad_computer.UpdateComputerDTO(cd)) { m = "Successful modification!"; LogHelper.WriteLog(typeof(ComputerManagementController), Operator, "Modify%the%information%of%" + computername.Replace(" ", ""), true); return(Json(new JsonData(m, true))); } else { m = "Modify failed!"; LogHelper.WriteLog(typeof(ComputerManagementController), Operator, "Modify%the%information%of%" + computername.Replace(" ", ""), false); return(Json(new JsonData(m, false))); } } }
private static void AddAllComputersTo() { DataTable table = new Computers().SelectAll(); foreach (DataRow row in table.Rows) { ActiveTestbed.Add(new RemoteComputer(row)); } }
// Get all the hostnames in the DB and display them on the right pane. private void DisplayAllInMasterList() { DataTable all = new Computers().SelectAll(); foreach (DataRow row in all.Rows) { masterList.Items.Add(row["Hostname"]); } }
public void Start() { var idleConsecutive = 0; var timesIdle = 0; while (Computers.Values.Any(i => i.Status != ComputerStatus.Halted)) { var outputTotal = 0; var emptyInputTotal = 0; var inputTotal = 0; var inputCount = Computers.Sum(i => i.Value.Input.Count); foreach (var intComputer in Computers) { intComputer.Value.Execute(); if (intComputer.Value.Status == ComputerStatus.Output) { outputTotal++; } if (intComputer.Value.Status == ComputerStatus.EmptyQueue) { emptyInputTotal++; } if (intComputer.Value.Status == ComputerStatus.Input) { inputTotal++; } } ShareMemory(); if (outputTotal == 0 && inputTotal == 0 && inputCount == 0 && Memory.Count == 0 && emptyInputTotal != 0) { timesIdle++; } else { timesIdle = 0; } if (timesIdle > 1000) { //if (NatX == 0 && NatY == 0) Computers[0].Input.Enqueue(-1); if (PrevNatYSend != 0 && PrevNatYSend == NatY) { Console.WriteLine($"Part2: {NatY}"); break; } Computers[0].Input.Enqueue(NatX); Computers[0].Input.Enqueue(NatY); PrevNatYSend = NatY; } } }
private void BtnOKClick(object sender, EventArgs e) { var triggerButton = (ButtonX)sender; Trace.WriteInformation("({0})", Trace.GetMethodName(), CLASSNAME, triggerButton.Name); EnableDisableButtons(true); if (!triggerButton.Enabled) { Trace.WriteInformation("Action was not allowed. (Button='{0}')", Trace.GetMethodName(), CLASSNAME, triggerButton.Name); DisplayWarning(TranslationKey.CommonMessage_JustModified); return; } try { ShowBusyBox = true; var modifiedComputer = CheckConstraints(); if (modifiedComputer == null) { return; } if (_modify && (Confirm(TranslationKey.Confirm_Computer_Modify, "Modify Computer", "Are you sure to modify this user computer?", MessageBoxButtons.YesNo) == DialogResult.Yes)) { new Computers().Modify(modifiedComputer); AddHistoryAction(TranslationKey.History_ComputerManagementForm_Modified, "Computer '{0}' modified.", modifiedComputer.HostName); Trace.WriteInformation("Computer modified: HostName={0}", Trace.GetMethodName(), CLASSNAME, modifiedComputer.HostName); } else if (_add) { new Computers().Add(modifiedComputer); modifiedComputer = new Computers().GetByHostName(modifiedComputer.HostName); AddHistoryAction(TranslationKey.History_ComputerManagementForm_Added, "Computer '{0}' added.", modifiedComputer.HostName); Trace.WriteInformation("Computer added: hostName={0}", Trace.GetMethodName(), CLASSNAME, modifiedComputer.HostName); } _add = false; _modify = false; _computerACIList = null; RefreshComputersGrid(modifiedComputer); SetChangeSettings(); } catch (Exception ex) { Trace.WriteError("()", Trace.GetMethodName(), CLASSNAME, ex); DisplayError(Trace.GetMethodName(), TranslationKey.CommonMessage_InternalError, ex); } finally { ShowBusyBox = false; } }
public void Page_Load(object sender, EventArgs e) { computerBasePage = Page as Computers; Computer = computerBasePage.Computer; if (Computer == null) { Response.Redirect("~/", true); } }
public ActionResult Delete(int id) { Computers b = db.Computers.Find(id); if (b == null) { return(HttpNotFound()); } return(View(b)); }
public ActionResult Edit([Bind(Include = "Index,Model,Price,CPU,RAM")] Computers computers) { if (ModelState.IsValid) { db.Entry(computers).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(computers)); }
public MainForm() { InitializeComponent(); computers = new Computers(); CreatePythonEngine(); }