Borrowing ParseLateBorrowing(string line) { // The Creator,Dejan Stojanović,10708,978-41-64944-2775,978-41-64944-2785,Josephine,Lichtenberg,9483,27.11.2016,,,false,Altenpleen K2 // Monks Pond: No. 1 1968,Thomas Merton,6185,978-41-64944-1615,978-41-64944-1625,Josephine,Lichtenberg,9483,27.11.2016,,,false,Aldersbach O6 var data = line.Split(','); var title = data[0]; var author = data[1]; var uid = data[2]; var isbn = data[3]; var ean = data[4]; var readername = data[5]; var surname = data[6]; var rid = data[7]; var from = data[8].Split('.'); var to = data[9].Split('.'); var archived = data[10]; var lib = data[11]; var fee = int.Parse(data[12]); var l = Libraries.SearchNode(new Library(lib), Libraries.Root); var book = new Book(author, title, isbn, ean, "", l.Data, int.Parse(uid), 0, 0); var b = BooksByUniqueId.SearchNode(book, BooksByUniqueId.Root); b.Data.TimeOfBorrow = new DateTime(int.Parse(from[2]), int.Parse(from[1]), int.Parse(from[0])); b.Data.IsArchived = archived.Equals("true"); var r = ReadersById.SearchNode(new Reader(int.Parse(rid), readername, surname), ReadersById.Root); Borrowing bor = new Borrowing(b.Data.Copy(), new Reader(int.Parse(rid), readername, surname)); bor.DateOfBorrow = new DateTime(int.Parse(from[2]), int.Parse(from[1]), int.Parse(from[0])); bor.DateOfReturn = new DateTime(int.Parse(to[2]), int.Parse(to[1]), int.Parse(to[0])); bor.Fee = fee; bor.FeeToPay = true; r.Data.LateBookReturns.Add(bor); return(bor); }
public void GenerateBorrowingData() { for (int i = 1; i < NumberOfBooks; i++) { var b = BooksByUniqueId.SearchNode(new Book("", "", "", "", "", null, i), BooksByUniqueId.Root); DateTime from = new DateTime(_generator.Next(2012, 2013), _generator.Next(1, 12), _generator.Next(1, 28)); DateTime to = from.AddDays(_generator.Next(5, 35)); for (int j = 0; j < 10000; j++) { var r = ReadersById.SearchNode(new Reader(1, "", ""), ReadersById.Root); var l = Libraries.SearchNode(new Library(libraryNames[_generator.Next(0, NumberOfLibraries)]), Libraries.Root); b.Data.Borrow(r.Data, from); b.Data.Return(l.Data, r.Data, to); from = to.AddDays(2); to = from.AddDays(_generator.Next(5, 35)); if (to > DateTime.Today) { return; } } } }
Borrowing ParsePreviousBorrowing(string line) { // Cables to the Ace,Thomas Merton,1826,978-41-64944-475,978-41-64944-485,Josephine,Lichtenberg, // 9483,27.11.2016,27.11.2016,false,Aldersbach O6,0 var data = line.Split(','); var title = data[0]; var author = data[1]; var uid = data[2]; var isbn = data[3]; var ean = data[4]; var readername = data[5]; var surname = data[6]; var rid = data[7]; var from = data[8].Split('.'); var to = data[9].Split('.'); var archived = data[10]; var lib = data[11]; var fee = int.Parse(data[12]); var l = Libraries.SearchNode(new Library(lib), Libraries.Root); var book = new Book(author, title, isbn, ean, "", l.Data, int.Parse(uid), 0, 0); var b = BooksByUniqueId.SearchNode(book, BooksByUniqueId.Root); b.Data.TimeOfBorrow = new DateTime(int.Parse(from[2]), int.Parse(from[1]), int.Parse(from[0])); b.Data.IsArchived = archived.Equals("true"); var r = ReadersById.SearchNode(new Reader(int.Parse(rid), readername, surname), ReadersById.Root); Borrowing bor = new Borrowing(b.Data.Copy(), new Reader(int.Parse(rid), readername, surname)); bor.DateOfBorrow = new DateTime(int.Parse(from[2]), int.Parse(from[1]), int.Parse(from[0])); bor.DateOfReturn = new DateTime(int.Parse(to[2]), int.Parse(to[1]), int.Parse(to[0])); bor.Fee = fee; bor.FeeToPay = true; r.Data.BooksBorrowedInPast.Add(bor); return(bor); }