protected DocumentModel CreateDocument() { var item = RequestServices.LaySoLieuThongKe(YkcdCuaUbndTinh: true, tuNgay: TuNgay.Text.ToDateTime(), denNgay: DenNgay.Text.ToDateTime()); DocumentModel document = WordExtensions.Load($@"{AppSettings.UploadFolder}\MauVanBan\MauThongKeYKCDUBTinh.docx"); document.Content.Find("(TieuDe)")?.First()?.LoadText("TỔNG HỢP TÌNH HÌNH THỰC HIỆN Ý KIẾN CHỈ ĐẠO CỦA UBND TỈNH"); document.Content.Find("(ThoiDiemThongKe)")?.First()?.LoadText($"Thống kê từ ngày {TuNgay.Text} đến ngày {DenNgay.Text}"); document.Content.Find("(TenDonVi)")?.First().LoadText($@"{AppSettings.AGENCY_NAME}"); document.Content.Find("(NgayBaoCao)")?.First()?.LoadText($"{AppSettings.DateRegion}, ngày {DateTime.Now.Date.Day} tháng {DateTime.Now.Date.Month} năm {DateTime.Now.Date.Year}"); document.Content.Find("(SoBaoCao)")?.First()?.LoadText(""); var dataTable = document.GetChildElements(true, ElementType.Table).Cast <Table>().ToArray()[1]; dataTable.Rows.Insert(2, new TableRow(document, new TableCell(document, new Paragraph(document, item.NotPerformInTerm.ToString()).Center()), new TableCell(document, new Paragraph(document, item.NotPerformOutTerm.ToString()).Center()), new TableCell(document, new Paragraph(document, item.PerformingInTerm.ToString()).Center()), new TableCell(document, new Paragraph(document, item.PerformingOutTerm.ToString()).Center()), new TableCell(document, new Paragraph(document, item.WaitToConfirm.ToString()).Center()), new TableCell(document, new Paragraph(document, item.DoneInTerm.ToString()).Center()), new TableCell(document, new Paragraph(document, item.DoneOutTerm.ToString()).Center()) )); return(document); }
protected DocumentModel CreateDocument() { DocumentModel document = WordExtensions.Load($@"{AppSettings.UploadFolder}\MauVanBan\MauDanhSachYKCDGiaoViec.docx"); document.Content.Find("(NgayBaoCao)")?.First()?.LoadText($"{AppSettings.DateRegion}, ngày {DateTime.Now.Date.Day} tháng {DateTime.Now.Date.Month} năm {DateTime.Now.Date.Year}"); var dataTable = document.GetChildElements(true, ElementType.Table).Cast <GemBox.Document.Tables.Table>().ToArray()[1]; int stt = 1; int currentIndex = 1; foreach (var item in RequestServices.GetList(YkcdCuaUbndTinh: true, tuNgay: TuNgay.Text.ToDateTimeNullable(), denNgay: DenNgay.Text.ToDateTimeNullable()).Where(item => TrangThai.GetSelectedValues().Contains(item.Status)).OrderBy(item => item.RequiredDate).ToList()) { dataTable.Rows.Insert( currentIndex, new TableRow(document, new TableCell(document, new Paragraph(document, stt.ToString()).Center()), new TableCell(document, new Paragraph(document, item?.Document?.DocumentCode?.RemoveBreakLineCharacters()).Center()), new TableCell(document, new Paragraph(document, item?.Document?.ReleaseDate?.ToDateString())?.Center()), new TableCell(document, new Paragraph(document, item?.RequestContent?.RemoveBreakLineCharacters())), new TableCell(document, new Paragraph(document, item?.RequiredDate.ToDateString())?.Center()), new TableCell(document, item?.Performs.Select(i => i.DepartmentName).ToList().DisplayList(document)), new TableCell(document, item?.Reports?.Select(i => i.ReportContent).ToList().DisplayList(document)) )); stt++; currentIndex++; } return(document); }
//if it is my turn: //check the input handler //and submit/checkt the input public void SubmitInput() { if (turnHandler.isMyTurn) { string input = WordExtensions.CleanInput(inputHandler.InputChar); if (input != string.Empty && CheckIfInputIsValid(input)) { CheckAnswer(input); turnHandler.StopTurnOnSubmit(); inputHandler.ClearInputField(); } } }
protected DocumentModel CreateDocument() { DocumentModel document = WordExtensions.Load($@"{AppSettings.UploadFolder}\MauVanBan\MauThongKeYKCD.docx"); document.Content.Find("(TieuDe)")?.First()?.LoadText("BÁO CÁO TÌNH HÌNH THEO DÕI VIỆC THỰC HIỆN Ý KIẾN CHỈ ĐẠO CỦA UBND TỈNH"); document.Content.Find("(ThoiDiemThongKe)")?.First()?.LoadText($"Thống kê từ ngày {TuNgay.Text} đến ngày {DenNgay.Text}"); document.Content.Find("(TenDonVi)")?.First().LoadText(@"UBND TỈNH THỪA THIÊN HUẾ"); document.Content.Find("(NgayBaoCao)")?.First()?.LoadText($"TP Huế, ngày {DateTime.Now.Date.Day} tháng {DateTime.Now.Date.Month} năm {DateTime.Now.Date.Year}"); document.Content.Find("(SoBaoCao)")?.First()?.LoadText(""); var dataTable = document.GetChildElements(true, ElementType.Table).Cast <Table>().ToArray()[1]; int stt = 1; int currentIndex = 2; int currentGroup = 0; foreach (var item in RequestServices.ThongKeTheoTatCaChuyenVienTheoDoi(TuNgay.Text.ToDateTime()).Where(i => i.Total > 0).ToList()) { if (currentGroup != item.GroupID) { currentGroup = item.GroupID; dataTable.Rows.Insert(currentIndex, new TableRow(document, new TableCell(document, new Paragraph(document, item.GroupName).SetStyle(WordExtensions.BoldTextStyle)) { ColumnSpan = 9 })); currentIndex++; } dataTable.Rows.Insert( currentIndex, new TableRow(document, new TableCell(document, new Paragraph(document, stt.ToString()).Center()), new TableCell(document, new Paragraph(document, item.ObjectName)), new TableCell(document, new Paragraph(document, item.NotPerformInTerm.ToString()).Center()), new TableCell(document, new Paragraph(document, item.NotPerformOutTerm.ToString()).Center()), new TableCell(document, new Paragraph(document, item.PerformingInTerm.ToString()).Center()), new TableCell(document, new Paragraph(document, item.PerformingOutTerm.ToString()).Center()), new TableCell(document, new Paragraph(document, item.WaitToConfirm.ToString()).Center()), new TableCell(document, new Paragraph(document, item.DoneInTerm.ToString()).Center()), new TableCell(document, new Paragraph(document, item.DoneOutTerm.ToString()).Center()) )); stt++; currentIndex++; } return(document); }
protected DocumentModel CreateDocument() { DocumentModel document = WordExtensions.Load($@"{AppSettings.UploadFolder}\MauVanBan\MauDanhSachYKCD.docx"); document.Content.Find("(TieuDe)")?.First()?.LoadText("THỐNG KÊ VIỆC CẬP NHẬT VĂN BẢN CHỈ ĐẠO CỦA UBND TỈNH"); document.Content.Find("(ThoiDiemThongKe)")?.First()?.LoadText($"Thống kê từ ngày {TuNgay.Text} đến ngày {DenNgay.Text}"); document.Content.Find("(NgayBaoCao)")?.First()?.LoadText($"TP Huế, ngày {DateTime.Now.Date.Day} tháng {DateTime.Now.Date.Month} năm {DateTime.Now.Date.Year}"); var dataTable = document.GetChildElements(true, ElementType.Table).Cast <Table>().ToArray()[1]; int stt = 1; int currentIndex = 1; int currentGroup = 0; foreach (var item in DocumentServices.GetList(fromDate: TuNgay.Text.ToDateTime(), toDate: DenNgay.Text.ToDateTime()) .OrderBy(item => item.Writer.Department.DisplayOrder) .ThenBy(item => item.Writer.DepartmentID) .ThenBy(item => item.Writer.DisplayOrder) .ThenBy(item => item.WriterID)) { if (currentGroup != item.WriterID) { currentGroup = item.WriterID; dataTable.Rows.Insert(currentIndex, new TableRow(document, new TableCell(document, new Paragraph(document, item.WriterName).SetStyle(WordExtensions.BoldTextStyle)) { ColumnSpan = 6 })); currentIndex++; } dataTable.Rows.Insert( currentIndex, new TableRow(document, new TableCell(document, new Paragraph(document, stt.ToString()).Center()), new TableCell(document, new Paragraph(document, item.DocumentCode.RemoveBreakLineCharacters())), new TableCell(document, new Paragraph(document, item.ReleaseDate.ToDateString()).Center()), new TableCell(document, new Paragraph(document, item.CreatedTime.ToDateString()).Center()), new TableCell(document, new Paragraph(document, item.MainContent.RemoveBreakLineCharacters())), new TableCell(document, new Paragraph(document, new Run(document, ShowDocumentUpdateStatus(item.ReleaseDate, item.CreatedTime.Value.Date))).Center()) )); stt++; currentIndex++; } return(document); }
protected void btnList_OnClick(object sender, EventArgs e) { DocumentModel document = WordExtensions.Load($@"{AppSettings.UploadFolder}\MauVanBan\MauDanhSachYKCD_TheoDonVi.docx", fontSize: 11); var dataTable = document.GetChildElements(true, ElementType.Table).Cast <Table>().ToArray()[0]; int stt = 1; int currentIndex = 1; int currentGroup = 0; foreach (var department in DepartmentServices.GetList(NhomDonVi.SelectedValue.ToInteger())) { var ykcdAll = RequestServices.GetList(MaDonViThucHien: department.DepartmentID, tuNgay: TuNgay.Text.ToDateTimeNullable()); if (ykcdAll?.Count > 0) { var chuaThucHien = ykcdAll.Where(item => item.Status == 0).ToList(); var chuaThucHienTrongHan = chuaThucHien.Where(item => item.RequiredDate >= DateTime.Now.Date).ToList(); var chuaThucHienQuaHan = chuaThucHien.Where(item => item.RequiredDate < DateTime.Now.Date).ToList(); var dangThucHien = ykcdAll.Where(item => item.Status == 1).ToList(); var dangThucHienTrongHan = dangThucHien.Where(item => item.RequiredDate >= DateTime.Now.Date).ToList(); var dangThucHienQuaHan = dangThucHien.Where(item => item.RequiredDate < DateTime.Now.Date).ToList(); var daHoanThanh = ykcdAll.Where(item => item.Status == 2).ToList(); var daHoanThanhTrongHan = daHoanThanh.Where(item => item.RequiredDate >= item.FinishedOnDate).ToList(); var daHoanThanhQuaHan = daHoanThanh.Where(item => item.RequiredDate < item.FinishedOnDate).ToList(); dataTable.Rows.Insert( currentIndex, new TableRow(document, new TableCell(document, new Paragraph(document, new Run(document, department.DepartmentName.ToUpper()), new Run(document, " (Chưa thực hiện: ") { CharacterFormat = new CharacterFormat() { Bold = true } }, new Run(document, $"Quá hạn: {chuaThucHienQuaHan.Count}, Chưa đến hạn: {chuaThucHienTrongHan.Count}; ") { CharacterFormat = new CharacterFormat() { Bold = false } }, new Run(document, " (Đang thực hiện: ") { CharacterFormat = new CharacterFormat() { Bold = true } }, new Run(document, $"Quá hạn: {dangThucHienQuaHan.Count}, Chưa đến hạn: {dangThucHienTrongHan.Count}; ") { CharacterFormat = new CharacterFormat() { Bold = false } }, new Run(document, " (Đã hoàn thành: ") { CharacterFormat = new CharacterFormat() { Bold = true } }, new Run(document, $"Trễ hạn: {daHoanThanhQuaHan.Count}, Đúng hạn: {daHoanThanhTrongHan.Count}) ") { CharacterFormat = new CharacterFormat() { Bold = false } }) .SetStyle(WordExtensions.BoldTextStyle)) { ColumnSpan = 6, CellFormat = new TableCellFormat() { BackgroundColor = new Color(251, 212, 180) } })); currentIndex++; if (chuaThucHien?.Count > 0) { if (chuaThucHienQuaHan?.Count > 0) { stt = 1; dataTable.Rows.Insert(currentIndex, new TableRow(document, new TableCell(document, new Paragraph(document, "CHƯA THỰC HIỆN") .SetStyle(WordExtensions.BoldTextStyle) .Center()) { RowSpan = chuaThucHien.Count + 1 + (chuaThucHienTrongHan?.Count > 0 ? 1 : 0), CellFormat = new TableCellFormat { TextDirection = TableCellTextDirection.BottomToTop, BackgroundColor = new Color(217, 149, 148) } }, new TableCell(document, new Paragraph(document, "Quá hạn").SetStyle(WordExtensions.BoldTextStyle)) { ColumnSpan = 5, CellFormat = new TableCellFormat { BackgroundColor = new Color(217, 149, 148) } })); currentIndex++; foreach (var item in chuaThucHienQuaHan) { AddYkcdRow(ref dataTable, item, currentIndex, stt); currentIndex++; stt++; } } if (chuaThucHienTrongHan?.Count > 0) { stt = 1; if (chuaThucHienQuaHan.Count == 0) { dataTable.Rows.Insert(currentIndex, new TableRow(document, new TableCell(document, new Paragraph(document, "CHƯA THỰC HIỆN").Center() .SetStyle(WordExtensions.BoldTextStyle)) { RowSpan = chuaThucHien.Count + 1, CellFormat = new TableCellFormat { TextDirection = TableCellTextDirection.BottomToTop, BackgroundColor = new Color(217, 149, 148) } }, new TableCell(document, new Paragraph(document, "Chưa đến hạn").SetStyle(WordExtensions.BoldTextStyle)) { ColumnSpan = 5, CellFormat = new TableCellFormat { BackgroundColor = new Color(194, 214, 155) } })); } else { dataTable.Rows.Insert(currentIndex, new TableRow(document, new TableCell(document, new Paragraph(document, "Chưa đến hạn").SetStyle(WordExtensions.BoldTextStyle)) { ColumnSpan = 5, CellFormat = new TableCellFormat { BackgroundColor = new Color(194, 214, 155) } })); } currentIndex++; foreach (var item in chuaThucHienTrongHan) { AddYkcdRow(ref dataTable, item, currentIndex, stt); currentIndex++; stt++; } } } if (dangThucHien?.Count > 0) { if (dangThucHienQuaHan?.Count > 0) { stt = 1; dataTable.Rows.Insert(currentIndex, new TableRow(document, new TableCell(document, new Paragraph(document, "ĐANG THỰC HIỆN").Center() .SetStyle(WordExtensions.BoldTextStyle)) { RowSpan = dangThucHien.Count + 1 + (dangThucHienTrongHan?.Count > 0 ? 1 : 0), CellFormat = new TableCellFormat { TextDirection = TableCellTextDirection.BottomToTop, BackgroundColor = new Color(194, 214, 155) } }, new TableCell(document, new Paragraph(document, "Quá hạn").SetStyle(WordExtensions.BoldTextStyle)) { ColumnSpan = 5, CellFormat = new TableCellFormat { BackgroundColor = new Color(217, 149, 148) } })); currentIndex++; foreach (var item in dangThucHienQuaHan) { AddYkcdRow(ref dataTable, item, currentIndex, stt); currentIndex++; stt++; } } if (dangThucHienTrongHan?.Count > 0) { stt = 1; if (dangThucHienQuaHan == null || dangThucHienQuaHan.Count == 0) { dataTable.Rows.Insert(currentIndex, new TableRow(document, new TableCell(document, new Paragraph(document, "ĐANG THỰC HIỆN").Center() .SetStyle(WordExtensions.BoldTextStyle)) { RowSpan = dangThucHien.Count + 1, CellFormat = new TableCellFormat { TextDirection = TableCellTextDirection.BottomToTop, BackgroundColor = new Color(194, 214, 155) } }, new TableCell(document, new Paragraph(document, "Chưa đến hạn").SetStyle(WordExtensions.BoldTextStyle)) { ColumnSpan = 5, CellFormat = new TableCellFormat { BackgroundColor = new Color(194, 214, 155) } })); } else { dataTable.Rows.Insert(currentIndex, new TableRow(document, new TableCell(document, new Paragraph(document, "Chưa đến hạn").SetStyle(WordExtensions.BoldTextStyle)) { ColumnSpan = 5, CellFormat = new TableCellFormat { BackgroundColor = new Color(194, 214, 155) } })); } currentIndex++; foreach (var item in dangThucHienTrongHan) { AddYkcdRow(ref dataTable, item, currentIndex, stt); currentIndex++; stt++; } } } if (daHoanThanh?.Count > 0) { if (daHoanThanhQuaHan?.Count > 0) { stt = 1; dataTable.Rows.Insert(currentIndex, new TableRow(document, new TableCell(document, new Paragraph(document, "ĐÃ HOÀN THÀNH").Center() .SetStyle(WordExtensions.BoldTextStyle)) { RowSpan = daHoanThanh.Count + 1 + (daHoanThanhTrongHan?.Count > 0 ? 1 : 0), CellFormat = new TableCellFormat { TextDirection = TableCellTextDirection.BottomToTop, BackgroundColor = new Color(194, 214, 155) } }, new TableCell(document, new Paragraph(document, "Trễ hạn").SetStyle(WordExtensions.BoldTextStyle)) { ColumnSpan = 5, CellFormat = new TableCellFormat { BackgroundColor = new Color(217, 149, 148) } })); currentIndex++; foreach (var item in daHoanThanhQuaHan) { AddYkcdRow(ref dataTable, item, currentIndex, stt); currentIndex++; stt++; } } if (daHoanThanhTrongHan?.Count > 0) { stt = 1; if (daHoanThanhQuaHan.Count == 0) { dataTable.Rows.Insert(currentIndex, new TableRow(document, new TableCell(document, new Paragraph(document, "ĐÃ HOÀN THÀNH").Center() .SetStyle(WordExtensions.BoldTextStyle)) { RowSpan = daHoanThanh.Count + 1, CellFormat = new TableCellFormat { TextDirection = TableCellTextDirection.BottomToTop, BackgroundColor = new Color(194, 214, 155) } }, new TableCell(document, new Paragraph(document, "Đúng hạn").SetStyle(WordExtensions.BoldTextStyle)) { ColumnSpan = 5, CellFormat = new TableCellFormat { BackgroundColor = new Color(194, 214, 155) } })); } else { dataTable.Rows.Insert(currentIndex, new TableRow(document, new TableCell(document, new Paragraph(document, "Đúng hạn").SetStyle(WordExtensions.BoldTextStyle)) { ColumnSpan = 5, CellFormat = new TableCellFormat { BackgroundColor = new Color(194, 214, 155) } })); } currentIndex++; foreach (var item in daHoanThanhTrongHan) { AddYkcdRow(ref dataTable, item, currentIndex, stt); currentIndex++; stt++; } } } } } document.Save(Response, "DanhSachYKCD.docx", SaveOptions.DocxDefault); }
public void Should_count_katakana_words() { Assert.Equal(3, WordExtensions.WordCount("カラテ カラテ カラテ")); }
public void Should_count_cjk_words() { Assert.Equal(3, WordExtensions.WordCount("空手道")); }
public void Should_count_cjk_and_english_words() { Assert.Equal(7, WordExtensions.WordCount("Makes probably no sense: 空手道")); }
public void Should_count_english_words_with_extra_whitespaces() { Assert.Equal(4, WordExtensions.WordCount("You can't do that. ")); }
public void Should_count_english_words_with_punctuation() { Assert.Equal(5, WordExtensions.WordCount("You can't do that, Mister.")); }
public void Should_count_with_digits() { Assert.Equal(2, WordExtensions.WordCount("Hello 123")); }
public void Should_count_english_words() { Assert.Equal(4, WordExtensions.WordCount("You can't do that")); }
public void Should_count_zero_words_for_whitspace_text() { Assert.Equal(0, WordExtensions.WordCount(" ")); }
public void Should_count_zero_words_for_empty_text() { Assert.Equal(0, WordExtensions.WordCount(string.Empty)); }