Exemplo n.º 1
0
 static void BuildDawgFile(string file)
 {
     var rootPath = AppDomain.CurrentDomain.BaseDirectory.Replace(@"\test\bin\Debug\", "");
     var wordUtil = new WordUtil();
     //加载默认的词频
     using (var sr = new StreamReader(rootPath + @"\dict\cwsharp.freq", Encoding.UTF8))
     {
         string line = null;
         while ((line = sr.ReadLine()) != null)
         {
             if (line == string.Empty) continue;
             var array = line.Split(' ');
             wordUtil.Add(array[0], int.Parse(array[1]));
         }
     }
     //加载新的词典
     using (var sr = new StreamReader(rootPath + @"\dict\cwsharp.dic", Encoding.UTF8))
     {
         string line = null;
         while ((line = sr.ReadLine()) != null)
         {
             if (line == string.Empty) continue;
             wordUtil.Add(line);
         }
     }
     //保存新的dawg文件
     wordUtil.SaveTo(file);
 }
Exemplo n.º 2
0
 private void Create(int caretPosition, params string[] lines)
 {
     _textView = CreateTextView(lines);
     _textBuffer = _textView.TextBuffer;
     _wordUtilRaw = new WordUtil();
     _wordUtil = _wordUtilRaw;
 }
Exemplo n.º 3
0
        public void TestFromTxtFile(string file)
        {
            var wordUtil = new WordUtil();
            var expectWordCount = 0;
            using (var sr = new StreamReader(file, Encoding.UTF8))
            {
                string line = null;
                while ((line = sr.ReadLine()) != null)
                {
                    if (line == string.Empty) continue;
                    wordUtil.Add(line);
                    expectWordCount++;
                }
            }

            var watcher = new System.Diagnostics.Stopwatch();
            watcher.Start();
            var ms = new MemoryStream();
            wordUtil.SaveTo(ms);
            watcher.Stop();

            Console.WriteLine("build dawg elapsed time:" + watcher.Elapsed.TotalMilliseconds + "'ms");

            watcher.Reset();
            watcher.Start();
            ms.Position = 0;
            wordUtil = WordUtil.LoadFrom(ms);
            watcher.Stop();
            Console.WriteLine("load dawg file elapsed time:" + watcher.Elapsed.TotalMilliseconds + "'ms");
            Assert.AreEqual(expectWordCount, wordUtil.Count);
        }
Exemplo n.º 4
0
        public void SimpleTest()
        {
            var wordUtil = new WordUtil();
            var words = new string[] { "tap", "taps", "top", "tops" };
            var expectWordCount = words.Length;

            wordUtil.AddWords(words);
            Assert.AreEqual(expectWordCount, wordUtil.Count);
            var ms = new MemoryStream();

            wordUtil.SaveTo(ms);
            Assert.Greater(ms.Length, 0);

            ms.Position = 0;
            wordUtil = WordUtil.LoadFrom(ms);
            Assert.AreEqual(expectWordCount, wordUtil.Count);
        }
Exemplo n.º 5
0
 private void Create(int caretPosition, params string[] lines)
 {
     _textView = CreateTextView(lines);
     _textBuffer = _textView.TextBuffer;
     _wordUtilRaw = new WordUtil(_textBuffer, CreateTextStructureNavigator(_textBuffer, WordKind.NormalWord));
     _wordUtil = _wordUtilRaw;
 }
Exemplo n.º 6
0
 private void Create(int caretPosition, params string[] lines)
 {
     _textView = EditorUtil.CreateTextView(lines);
     _textBuffer = _textView.TextBuffer;
     _wordUtilRaw = new WordUtil(_textBuffer, EditorUtil.FactoryService.TextStructureNavigatorSelectorService.GetTextStructureNavigator(_textBuffer));
     _wordUtil = _wordUtilRaw;
 }
Exemplo n.º 7
0
 protected ITextStructureNavigator CreateTextStructureNavigator(ITextBuffer textBuffer, WordKind kind)
 {
     return(WordUtil.CreateTextStructureNavigator(kind, textBuffer.ContentType));
 }
        private void exportReportBtnClicked(object obj)
        {
            string folderPath = "";

            System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
            fbd.ShowDialog();
            if (!string.IsNullOrEmpty(fbd.SelectedPath))
            {
                folderPath = fbd.SelectedPath;
                if (string.IsNullOrEmpty(folderPath))
                {
                    MessageBox.Show("请正确选择需要保存到的目录!");
                    return;
                }
                List <DataModel> list = ((WindowMainViewModel)Model).SelectDataModelDict.Values.ToList();
                if (list.Count <= 0)
                {
                    MessageBox.Show("请正确选择需要打印报告的病人!");
                    return;
                }
                int counts = list.Count;
                int count  = 0;

                if (counts > 0)
                {
                    new Thread(() =>
                    {
                        foreach (DataModel dataTemp in list)
                        {
                            List <ProjectModel> projectModels = new List <ProjectModel>();
                            projectModels.AddRange(dataTemp.PList);
                            string date = "";
                            //创建word文档
                            while (dataTemp.PList.Count > 0)
                            {
                                DateTime dt         = DateTime.Now;
                                date                = dt.ToString("yyyy年MM月dd日HH时mm分ss秒");
                                string dateStr      = dt.ToString("yyyy-MM-dd HH:mm:ss");
                                dataTemp.ReportTime = dateStr;
                                WordUtil.CreateDocByTemplate(dataTemp, folderPath, date);
                                //Console.WriteLine(folderPath + "\\" + dataTemp.HospitalName + "\\" + dataTemp.PatientName + "_" + date + ".docx"+"  打印前" +DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff"));
                                //调用打印机打印
                                Thread.Sleep(3000);
                                PrintManager.Instance.Printword(folderPath + "\\" + dataTemp.HospitalName + "\\" + dataTemp.PatientName + "_" + date + ".docx");

                                //Console.WriteLine(folderPath + "\\" + dataTemp.HospitalName + "\\" + dataTemp.PatientName + "_" + date + ".docx" + "  打印后" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff"));
                            }
                            count++;
                            if (WindowTip.Instance != null)
                            {
                                WindowTip.Instance.model.UpdateValue(count, folderPath + "\\" + dataTemp.HospitalName + "\\" + dataTemp.PatientName + "_" + date + ".docx");
                            }
                            dataTemp.PList.AddRange(projectModels);
                        }

                        if (WindowTip.Instance != null)
                        {
                            App.Current.Dispatcher.Invoke((Action)(() =>
                            {
                                WindowTip.Instance.model.Vis = Visibility.Visible;
                                WindowTip.Instance.model.Message = "打印完成!";
                            }));
                        }
                    }).Start();
                    WindowTip wt = new WindowTip(counts);
                    wt.Owner = Application.Current.MainWindow;
                    wt.ShowDialog();
                }
                else
                {
                    MessageBox.Show("请添加数据后,在生成报告!");
                }
            }
        }
Exemplo n.º 9
0
        private void PintaTablaDimensionSerie(DocumentBuilder docBuilder, String valor, DocumentoInstanciaXbrlDto instancia, IndiceReporteDTO rolAExportar, ReporteXBRLDTO estructuraReporte, ConceptoReporteDTO concepto)
        {
            docBuilder.Writeln();
            // var listaConseptosReportes = estructuraReporte.Hipercubos;
            foreach (var dato in estructuraReporte.Hipercubos)
            {
                var      variable = dato;
                string[] d        = variable.Key.Split(new string[] { "Table" }, StringSplitOptions.None);
                string   conceptoHipercuboTable = (d[0]);

                if (conceptoHipercuboTable == valor && !Evaluador.Contains(variable.Key))
                {
                    ConceptoReporteDTO primerConcepto = null;

                    if (!estructuraReporte.Roles.ContainsKey(rolAExportar.Rol))
                    {
                        throw new IndexOutOfRangeException("No existe el rol [" + rolAExportar.Rol + "] dentro del listado de roles del reporte.");
                    }
                    if (estructuraReporte.Roles.ContainsKey(rolAExportar.Rol))
                    {
                        if (!concepto.Abstracto)
                        {
                            primerConcepto = concepto;
                            break;
                        }
                    }

                    var hipercubo = variable;


                    Table tablaActual = docBuilder.StartTable();
                    Color colorTitulo = Color.FromArgb(ColorTituloTabla[0], ColorTituloTabla[1], ColorTituloTabla[2]);
                    docBuilder.ParagraphFormat.SpaceAfter  = 0;
                    docBuilder.ParagraphFormat.SpaceBefore = 2;

                    //docBuilder.InsertCell();
                    // docBuilder.EndRow();
                    docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo;
                    docBuilder.Font.Color = Color.White;
                    docBuilder.Font.Size  = TamanioLetraContenidoTabla;

                    docBuilder.InsertCell();

                    docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo;
                    docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto;
                    docBuilder.Font.Color = Color.White;
                    establecerFuenteTituloCampo(docBuilder);
                    docBuilder.Font.Size = TamanioLetraTituloTabla;
                    docBuilder.Write("Serie [Eje]");
                    docBuilder.CellFormat.HorizontalMerge = CellMerge.None;

                    if (hipercubo.Value.Titulos.Count > 0)
                    {
                        for (var indexTitulo = 0; indexTitulo < hipercubo.Value.Titulos.Count; indexTitulo++)
                        {
                            var titulo = hipercubo.Value.Titulos[indexTitulo];
                            docBuilder.InsertCell();
                            docBuilder.Write(titulo);
                        }
                        docBuilder.EndRow();
                    }



                    establecerFuenteTituloCampo(docBuilder);
                    docBuilder.Font.Size = TamanioLetraTituloTabla;

                    int fila = 0;


                    if (concepto.Abstracto)
                    {
                        fila = +1;

                        for (int iCell = 0; iCell < fila; iCell++)
                        {
                            docBuilder.InsertCell();
                            docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
                        }
                    }
                    if (concepto.Abstracto)
                    {
                        docBuilder.Bold       = true;
                        docBuilder.Font.Color = Color.White;
                        docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo;

                        docBuilder.ParagraphFormat.LeftIndent = (concepto.Tabuladores < 0 ? concepto.Tabuladores : 0);
                        docBuilder.ParagraphFormat.Alignment  = ParagraphAlignment.Left;
                        docBuilder.Write(concepto.Valor);
                        docBuilder.InsertCell();
                        docBuilder.EndRow();
                        //  tituloAbstracto.Add(concepto.Valor);
                    }
                    else
                    {
                        docBuilder.Bold = false;
                    }


                    docBuilder.CellFormat.Shading.BackgroundPatternColor = Color.White;
                    docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto;
                    docBuilder.Font.Color = Color.Black;
                    docBuilder.Bold       = false;
                    foreach (var idConcepto in hipercubo.Value.Hechos.Keys)
                    {
                        var matrizPlantillaContexto = hipercubo.Value.Hechos[idConcepto];
                        docBuilder.InsertCell();
                        var nombreConcepto =
                            DesgloseDeCreditosHelper.obtenerEtiquetaDeConcepto(instancia.Taxonomia, idConcepto, "es", ReporteXBRLUtil.ETIQUETA_DEFAULT);
                        docBuilder.Write(nombreConcepto);
                        ConceptoHiper.Add(idConcepto);

                        foreach (var idPlantillaContexto in matrizPlantillaContexto.Keys)
                        {
                            docBuilder.CellFormat.WrapText       = true;
                            docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
                            var listaHechos = matrizPlantillaContexto[idPlantillaContexto];
                            for (var indexHecho = 0; indexHecho < listaHechos.Length; indexHecho++)
                            {
                                var hecho      = listaHechos[indexHecho];
                                var valorHecho = hecho.Valor;

                                docBuilder.InsertCell();
                                if (hecho.NoEsNumerico)
                                {
                                    docBuilder.CellFormat.WrapText       = true;
                                    docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
                                }
                                else
                                {
                                    docBuilder.CellFormat.WrapText       = false;
                                    docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
                                }


                                if ((hecho != null && !String.IsNullOrWhiteSpace(hecho.Valor)))
                                {
                                    if (hecho.TipoDato.Contains(TIPO_DATO_TEXT_BLOCK))
                                    {
                                        WordUtil.InsertHtml(docBuilder, hecho.IdConcepto + ":" + hecho.Id, PARRAFO_HTML_NOTAS_Texblock + valorHecho + "</p>", false, true);
                                    }
                                    else
                                    {
                                        docBuilder.Writeln(valorHecho);
                                    }
                                    ConceptoHiper.Add(valorHecho);
                                }
                            }
                        }

                        docBuilder.EndRow();
                    }


                    establecerBordesGrisesTabla(tablaActual);
                    docBuilder.EndTable();

                    docBuilder.Writeln();
                    Evaluador.Add(variable.Key);
                    break;
                }
            }
        }