public async void AddBug(Bug aBug) { await _bugCollection.InsertOneAsync(aBug); }
private void attach_Bugs(Bug entity) { this.SendPropertyChanging(); entity.Tester = this; }
private void detach_Bugs(Bug entity) { this.SendPropertyChanging(); entity.Tester = null; }
partial void UpdateBug(Bug instance);
partial void DeleteBug(Bug instance);
public static void Update(Bug bug) { DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext(); Bug bugToUpdate = db.Bugs.Single(t => t.BugId == bug.BugId); bugToUpdate.Description = bug.Description; bugToUpdate.Priority = bug.Priority; bugToUpdate.Status = bug.Status; db.SubmitChanges(); }
partial void InsertBug(Bug instance);
public static int Insert(Bug bug) { DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext(); db.Bugs.InsertOnSubmit(bug); db.SubmitChanges(); return bug.BugId; }
/// <summary> /// Создание детей в случае гибели всех жуков /// </summary> public static void CreateChildsBugs() { KillBugs(); SortBugs(); if (Bug.Generation % 50 == 0) { PrintInFile(); } Bug[] child = new Bug[MaxNumberBugs]; CurrentNumberBugs = 0; int cellRndX = 0; int cellRndY = 0; for (int indexParent = 0; indexParent < 8; indexParent++) { for (int childIndex = 0; childIndex < 8; childIndex++) { int[] childGenom = new int [Bug.PublicLengthGenom]; for (int indexGenom = 0; indexGenom < Bug.PublicLengthGenom; indexGenom++) { childGenom[indexGenom] = Bugs[MaxNumberBugs - indexParent - 1].Genom[indexGenom]; } if (childIndex > 4) { int rndParent = Rnd.Next(0, 8); for (int indexGenom = 0; indexGenom < Bug.PublicLengthGenom; indexGenom++) { if (Bugs[MaxNumberBugs - indexParent - 1].Genom[indexGenom] == Bugs[MaxNumberBugs - rndParent - 1].Genom[indexGenom]) { childGenom[indexGenom] = Bugs[MaxNumberBugs - indexParent - 1].Genom[indexGenom]; } else { if (Rnd.Next(0, 2) == 0) { childGenom[indexGenom] = Bugs[MaxNumberBugs - rndParent - 1].Genom[indexGenom]; } else { childGenom[indexGenom] = Bugs[MaxNumberBugs - indexParent - 1].Genom[indexGenom]; } } } int rndKol = Rnd.Next(0, 3); for (int i = 0; i < rndKol; i++) { childGenom[Rnd.Next(0, Bug.PublicLengthGenom)] = Rnd.Next(0, Bug.PublicLengthGenom); } } while (Field[cellRndY, cellRndX].PublicContent != 0) { cellRndY = Rnd.Next(0, SizeMapY); cellRndX = Rnd.Next(0, SizeMapX); } child[CurrentNumberBugs] = new Bug(cellRndX, cellRndY, childGenom, Rnd.Next(0, 8)); Field[cellRndY, cellRndX].PublicContent = Bug.PublicTypeCell; CurrentNumberBugs++; } } Bugs = child; Bug.Generation++; FileStream bugsFile = new FileStream("SaveGeneration\\Bugs.bin", FileMode.OpenOrCreate); BinaryFormatter binForm = new BinaryFormatter(); binForm.Serialize(bugsFile, child); bugsFile.Close(); }