protected InfoCategoty CreateCategory(DocumentItem rootDocItem, string title, string number) { try { InfoCategoty infoCategoty = new InfoCategoty(); infoCategoty.Title = title; //"Категория"; infoCategoty.Items = new List <InfoItem>(); var potentialRoot = _wordDbContext.DocumentItem.FirstOrDefault(f => f.Number == number && f.Parent == rootDocItem); infoCategoty.Items.Add(CreateItem(rootDocItem, number)); var innersCategory = _wordDbContext.DocumentItem.Where(f => f.Parent == potentialRoot); if (innersCategory != null && innersCategory.Count() > 0) { int index = 0; foreach (var item in innersCategory) { infoCategoty.Items.Add(CreateItem(potentialRoot, number + "." + (++index).ToString())); } } return(infoCategoty); } catch { return(new InfoCategoty() { Items = new List <InfoItem>(), Title = title }); } }
private async Task <IEnumerable <InfoDocument> > GetDocumentCategoryOtv(int userId) { using (var connection = new MySqlConnection(_dataBaseMain.ConntectionString)) { var docs = new List <InfoDocument>(); var queryRoot = await connection.QueryAsync <InfoRoot>(SqlQueryHelper.Query, new { userId }); foreach (var item in queryRoot.GroupBy(g => g.Razdel)) { var doc = new InfoDocument(); doc.Title = item.Key; doc.Items = new List <InfoCategoty>(); foreach (var root in item.GroupBy(g => g.Text.ToLower().Contains("уголов") ? "Уголовня ответственность" : "Иная ответственность")) { var itemCategory = new InfoCategoty(); itemCategory.Title = root.Key; itemCategory.Items = new List <InfoItem>(); foreach (var infoRoot in root.GroupBy(g => g.Text)) { var itemLine = new InfoItem(); itemLine.Title = infoRoot.Key; itemLine.ProfName = infoRoot.Select(s => s.ProfName).ToList(); itemCategory.Items.Add(itemLine); } doc.Items.Add(itemCategory); } docs.Add(doc); } return(docs); } }
private async Task <IEnumerable <InfoDocument> > GetDocumentCategoryDol(int userId) { using (var connection = new MySqlConnection(_dataBaseMain.ConntectionString)) { var docs = new List <InfoDocument>(); var queryRoot = await connection.QueryAsync <InfoRoot>(SqlQueryHelper.QueryGlagol, new { userId }); foreach (var item in queryRoot.GroupBy(g => g.Razdel)) { var doc = new InfoDocument(); doc.Title = item.Key; doc.Items = new List <InfoCategoty>(); foreach (var root in item.GroupBy(g => g.Category)) { var itemCategory = new InfoCategoty(); itemCategory.Title = root.Key; itemCategory.Items = new List <InfoItem>(); foreach (var infoRoot in root.GroupBy(g => g.Text)) { var itemLine = new InfoItem(); itemLine.Title = FirstLetterToUpper(infoRoot.Key.Trim(',', ' ')); itemLine.ProfName = infoRoot.Select(s => s.ProfName).ToList(); itemCategory.Items.Add(itemLine); } doc.Items.Add(itemCategory); } docs.Add(doc); } return(docs); } }
public InfoDocument CreateInfoDocument(DocumentItem rootDocItem) { InfoDocument infoDocument = new InfoDocument(); infoDocument.Title = rootDocItem.TextContent; InfoCategoty infoCategoty1 = CreateCategory(rootDocItem, "Категория", "1"); InfoCategoty infoCategoty2 = CreateCategory(rootDocItem, "Образование и стаж", "2"); InfoCategoty infoCategoty3 = CreateCategory(rootDocItem, "Назначение на должность", "3"); InfoCategoty infoCategoty4 = CreateCategory(rootDocItem, "Требования к знаниям", "4"); InfoCategoty infoCategoty5 = CreateCategory(rootDocItem, "Подчинение", "5"); InfoCategoty infoCategoty6 = CreateCategory(rootDocItem, "Правила замещения", "6"); infoDocument.Items = new List <InfoCategoty>(); infoDocument.Items.Add(infoCategoty1); infoDocument.Items.Add(infoCategoty2); infoDocument.Items.Add(infoCategoty3); infoDocument.Items.Add(infoCategoty4); infoDocument.Items.Add(infoCategoty5); infoDocument.Items.Add(infoCategoty6); return(infoDocument); }