public static void DoCreateIndexFileEF() { if (BookIndexes != null) { return; } BookIndexes = new Dictionary <string, BookIndex>(); var bookdb = BookDataContext.Get(); var bookList = bookdb.Books .Include(b => b.People) .Include(b => b.Review) .Include(b => b.Notes) .Include(b => b.Notes.Notes) .ToList(); //var sb = new StringBuilder(); foreach (var bookData in bookList) { var index = BookIndex.FromBookData(bookData); BookIndexes.Add(index.BookId, index); //sb.Append(index.ToString()); //sb.Append('\n'); } //var fullIndex = sb.ToString(); ; }
public static BookIndex FromBookData(BookData bookData) { var sb = new StringBuilder(); Append(sb, bookData.Title); Append(sb, bookData.TitleAlternative); Append(sb, bookData.Review?.Tags); Append(sb, bookData.Review?.Review); Append(sb, bookData.BookSeries); Append(sb, bookData.Imprint); Append(sb, bookData.LCC); Append(sb, bookData.LCCN); Append(sb, bookData.LCSH); if (bookData.Notes != null) { foreach (var note in bookData.Notes.Notes) { Append(sb, note.Tags); Append(sb, note.Text); } } foreach (var people in bookData.People) { Append(sb, people.Aliases); Append(sb, people.Name); } var retval = new BookIndex() { BookId = bookData.BookId, Text = sb.ToString(), }; return(retval); }
static void Main(string[] args) { // var exStdIn = new System.IO.StreamReader("stdin.txt"); // Console.SetIn(exStdIn); string outputStr = ""; BookIndex bookIndex = new BookIndex(); while (true) { try { string[] inputStrs = (Console.ReadLine()).Split(); bookIndex.Add(inputStrs[0], int.Parse(inputStrs[1])); } catch (NullReferenceException nre) { string hoge = nre.ToString(); hoge += "hoge"; break; //throw; } } outputStr = bookIndex.ToString(); // exStdIn.Close(); Console.Write(outputStr); Console.ReadLine(); // System.Threading.Thread.Sleep(10000); }
public void TestSetup() { index01 = new BookIndex(partyOne, articleCode0, codeOrder01); index02 = new BookIndex(partyOne, articleCode0, codeOrder02); index03 = new BookIndex(partyOne, articleCode0, codeOrder03); index04 = new BookIndex(partyOne, articleCode0, codeOrder04); index05 = new BookIndex(partyOne, articleCode0, codeOrder05); index11 = new BookIndex(partyOne, articleCode1, codeOrder01); index12 = new BookIndex(partyOne, articleCode1, codeOrder02); index13 = new BookIndex(partyOne, articleCode1, codeOrder03); index14 = new BookIndex(partyOne, articleCode1, codeOrder04); index15 = new BookIndex(partyOne, articleCode1, codeOrder05); index16 = new BookIndex(partyOne, articleCode1, codeOrder06); index17 = new BookIndex(partyOne, articleCode1, codeOrder07); index21 = new BookIndex(partyOne, articleCode2, codeOrder01); index22 = new BookIndex(partyOne, articleCode2, codeOrder02); index23 = new BookIndex(partyOne, articleCode2, codeOrder03); index24 = new BookIndex(partyOne, articleCode2, codeOrder04); index25 = new BookIndex(partyOne, articleCode2, codeOrder05); index26 = new BookIndex(partyOne, articleCode2, codeOrder06); index27 = new BookIndex(partyOne, articleCode2, codeOrder07); index28 = new BookIndex(partyOne, articleCode2, codeOrder08); index29 = new BookIndex(partyOne, articleCode2, codeOrder09); }
public void TestSetup() { uint codeOrderOne = 1; uint codeOrderTwo = 1; BookParty partyOne = new BookParty(BookParty.UNKNOWN_CONTRACT, BookParty.UNKNOWN_POSITION); BookParty partyTwo = new BookParty(BookParty.UNKNOWN_CONTRACT, BookParty.UNKNOWN_POSITION); orderOne = new BookIndex(partyOne, (uint)ArticleSymbolCode.ARTICLE_INCOME_GROSS, codeOrderOne); orderTwo = new BookIndex(partyTwo, (uint)ArticleSymbolCode.ARTICLE_INCOME_GROSS, codeOrderTwo); }
public static ITargetStream CreateEmptyStream() { var targets = new Dictionary <IBookIndex, IBookTarget>(); var lastParty = BookParty.GetEmpty(); var lastIndex = BookIndex.GetEmpty(); return(new TargetStream(targets, lastParty, lastIndex)); }
public int CompareTo(BookBlockIndices other) { int result = BookIndex.CompareTo(other.BookIndex); if (result == 0) { result = BlockIndex.CompareTo(other.BlockIndex); } return(result); }
/// <summary> /// Override of object.Equal /// </summary> /// <param name="obj">Other object</param> /// <returns>True if their entity is equal</returns> public override bool Equals(object obj) { bool isEqual = false; if (obj != null && GetType() == obj.GetType()) { BookGenre other = (BookGenre)obj; return(BookIndex.Equals(other.BookIndex) && GenreIndex.Equals(other.GenreIndex)); } return(isEqual); }
public ActionResult Index() { List <BookIndex> booksIndex = new List <BookIndex>(); foreach (Book book in database.Books.ToList()) { BookIndex bookIndex = new BookIndex(); bookIndex.book = book; if (book.AuthorID != -1) { bookIndex.author = database.Authors.FirstOrDefault(z => z.Id == book.AuthorID); } booksIndex.Add(bookIndex); } return(View(booksIndex)); }
private static void AddFromTable(SqliteConnection connection, bool create, string commandText) { var command = connection.CreateCommand(); command.CommandText = commandText; using (var reader = command.ExecuteReader()) { while (reader.Read()) { var bookId = reader.GetString(0); var sb = new StringBuilder(); for (int i = 1; i < reader.FieldCount; i++) { if (!reader.IsDBNull(i)) { BookIndex.Append(sb, reader.GetString(i)); } } if (create) { var index = new BookIndex() { BookId = bookId, Text = sb.ToString() }; BookIndexes.Add(index.BookId, index); } else { try { var index = BookIndexes[bookId]; index.Text += sb.ToString(); } catch (Exception) { ; // Error; why doesn't the book exist? } } } } }
public ITargetStream CreateEvaluationStream(IProcessConfig configModule) { IBookParty[] contracts = CollectPartiesForContracts(); IBookParty[] positions = CollectPartiesForPositions(); var targetsInit = TargetStreamBuilder.BuildStreamCopy(__targets); var articleList = TargetStreamBuilder.BuildArticleStream(__targets); var targetsDict = articleList.Aggregate(targetsInit, (agr, article) => TargetStreamBuilder.BuildEvaluationStream(agr, contracts, positions, article, configModule)); var targetsEval = targetsDict.OrderBy(x => x.Value.Article()). ToDictionary(key => key.Key, val => val.Value); var lastParty = BookParty.GetEmpty(); var lastIndex = BookIndex.GetEmpty(); return(new TargetStream(targetsEval, lastParty, lastIndex)); }
protected override void SetUp() { base.SetUp(); bookIndex = new BookIndex(); InitializeIndex(); }