Ejemplo n.º 1
0
        private void ExtractOldID()
        {
            string extract = CommonTasks.Extract(otherContent, oldidStart, oldidEnd);

            if (extract != null)
            {
                oldid = extract;
            }
        }
Ejemplo n.º 2
0
        private void ExtractID()
        {
            string extract = CommonTasks.Extract(content, idStart, commonEnd);

            if (extract != null)
            {
                id = extract;
            }
        }
Ejemplo n.º 3
0
        private void Read()
        {
            pars.Clear();
            errors.Clear();
            if (filepaths == null) return;

            string line, linePrevious = "", extract;
            int count = 0, linePreviousPos = 0;
            Paper currentChapter = null;
            int currentChapterIndex = -1;
            Section currentSection = null;
            int currentSectionIndex = -1;
            string currentSectionID = "";
            Par currentPar = null;
            FileInfo fileinfo = null;

            progressBar.Value = 0;
            progressBar.Maximum = filepaths.Length;

            for (int f = 0; f < filepaths.Length; f++) {
                fileinfo = new FileInfo(filepaths[f]);
                StreamReader stream = new StreamReader(filepaths[f]);

                count = 0;
                linePreviousPos = 0;
                currentChapterIndex = -1;
                currentSectionIndex = -1;
                currentSectionID = "";

                while ((line = stream.ReadLine()) != null) {
                    if (line.StartsWith(paperStart)) {
                        //Si es un documento
                        extract = CommonTasks.Extract(line, paperStart, commonEnd);
                        if (extract == null) {
                            errors.Add(String.Format(errorString, fileinfo.Name, count,
                                "No se pudo extraer el inicio de documento"));
                        } else {
                            currentChapterIndex++;
                            currentChapter = new Paper(currentChapterIndex, extract);
                            papers.Add(currentChapter);
                            currentSection = null;
                            currentSectionIndex++;
                            currentSectionID = currentChapterIndex.ToString() + ":" +
                                currentSectionIndex.ToString();
                            currentSection = new Section(currentSectionIndex,
                                currentSectionID, "");
                            currentChapter.AddSection(currentSection);
                        }
                    } else if (line.StartsWith(sectionStart)) {
                        //Si es una seccion
                        extract = CommonTasks.Extract(line, sectionStart, commonEnd);
                        if (extract == null) {
                            errors.Add(String.Format(errorString, fileinfo.Name, count,
                                "No se pudo extraer el inicio de sección"));
                        } else {
                            currentSectionIndex++;
                            currentSectionID = currentChapterIndex.ToString() + ":" +
                                currentSectionIndex.ToString();
                            currentSection = new Section(currentSectionIndex,
                                currentSectionID, extract);
                            currentChapter.AddSection(currentSection);
                        }
                    } else if (line.StartsWith(oldidStart)) {
                        //Si es la línea con la antigua referencia
                        linePrevious = line;
                        linePreviousPos = count;
                    } else if (line.StartsWith(parStart)) {
                        //Si es un párrafo
                        if (linePreviousPos == count - 1) {
                            currentPar = new Par(line, linePrevious);
                            pars.Add(currentPar);
                            currentSection.AddPar(currentPar);
                        } else {
                            errors.Add(String.Format(errorString, fileinfo.Name, count,
                                "Línea previa incorrecta"));
                        }
                    } else if (line != "\\par" && line != "") {
                        errors.Add(String.Format(errorString, fileinfo.Name, count,
                            "Algo erróneo"));
                    }
                    count++;

                }
                stream.Close();
                progressBar.Value = f + 1;
            }
        }