コード例 #1
0
        private ArrayList SplitGiorniODT(string s)
        {
            string[]  Lines      = s.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.None);
            string    tempGiorno = "";
            string    l;
            ArrayList SplitG = new ArrayList();

            foreach (string CurLine in Lines)
            {
                l = CurLine.Trim();
                if (èInizioGiornoSettimana(l) || èInizioDomenica(l))
                {
                    if (tempGiorno.Length > 0)
                    {
                        SplitG.Add(tempGiorno);
                    }
                    NumGiorni++;
                    tempGiorno = l + Environment.NewLine;
                }
                else
                {
                    tempGiorno += l + Environment.NewLine;
                }
            }
            SplitG.Add(tempGiorno);
            NumGiorni++;
            return(SplitG);
        }
コード例 #2
0
    //-----------------------------------------------------------
    //	запись Tsv-текста в файл
    public bool    SaveToFile(string FileName)
    {
        int    I;
        bool   ContainsEmpty;
        string CurLine;

        string[] Columns;
        if (FileName == null)
        {
            return(false);
        }
        if ((Tsv == null) || (Tsv.Length == 0))
        {
            return(false);
        }
        string[] Lines = Tsv.ToString().Split(CCommon.Chr(13));
        if (Lines == null)
        {
            return(false);
        }
        if (Lines.Length == 0)
        {
            return(false);
        }
        bool        Result     = false;
        CTextWriter TextWriter = new   CTextWriter();

        if (!TextWriter.Create(FileName, CAbc.CHARSET_WINDOWS))
        {
            return(false);
        }

        for (I = 0; I < Lines.Length; I++)
        {
            Result  = true;
            CurLine = Lines[I].Replace(CAbc.BIG_UKR_I, "I").Replace(CAbc.SMALL_UKR_I, "i").Trim();
            if (CurLine.Trim().Length == 0)
            {
                continue;
            }
            ContainsEmpty = true;
            Columns       = CurLine.Split(CCommon.Chr(9));
            if (Columns == null)
            {
                ContainsEmpty = true;                                           // есть пустые ячейки ?
            }
            else if (Columns.Length < 2)
            {
                ContainsEmpty = true;
            }
            else
            {
                foreach (string Item in Columns)
                {
                    if (Item.Trim().Length != 0)
                    {
                        ContainsEmpty = false;
                    }
                }
            }
            if (!ContainsEmpty)
            {
                if (!TextWriter.Add(CurLine + CAbc.CRLF))
                {
                    Result = false;
                }
            }
        }
        TextWriter.Close();
        return(Result);
    }
コード例 #3
0
        private string PutTagOnDay(string s)
        {
            string[] Lines = s.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.None);
            //MessageBox.Show("linee:" + Convert.ToString(Lines.GetLength(0)));
            try
            {
                string l;

                foreach (string CurLine in Lines)
                {
                    lineNum++;
                    l = CurLine.Trim();
                    switch (sec)
                    {
                    //sezione GIORNO
                    case (int)Section.giorno:
                    {
                        switch (prog)
                        {
                        //inizio
                        case 0:
                        {
                            //riga vuota salto
                            if (l.Length == 0)
                            {
                                break;
                            }

                            //GIORNO da lun a sab
                            if (èInizioGiornoSettimana(l))
                            {
                                addInizioGiornoSettimana(l);
                            }
                            //GIORNO domenica
                            else if (èInizioDomenica(l))
                            {
                                addInizioDomenica(l);
                            }
                            else
                            {
                                addProblem("manca giorno");
                            }
                            sTemp = "";
                            break;
                        }

                        //GIORNO
                        case 1:
                        {
                            //riga vuota salto
                            if (l.Length == 0)
                            {
                                break;
                            }
                            //aggiungo santi --> tutti sulla stessa riga
                            addOutPQ("#02", l);
                            prog  = 2;
                            sTemp = "";
                            break;
                        }

                        //NOME SANTI
                        case 2:
                        {
                            //riga vuota salto
                            if (l.Length == 0)
                            {
                                break;
                            }
                            if (èInizioLettura(l))
                            {
                                addInizioLetturaOVangelo(l, Section.primaLettura); break;
                            }
                            //controllo se la stringa è lunga --> allora è la storia dei santi
                            if (l.Length > 90)
                            {
                                //l = AggiungiTagNomeSanti(l, dicPQTag[giornoCorrente]["#02"]);
                                addOutPQ("#03", l);
                                prog = 3;
                            }
                            else
                            {
                                if (èGiornataMondiale(l))
                                {
                                    addGiornataMondiale(l);
                                }
                                else
                                {
                                    //suppongo sia festività
                                    addOutPQ("#04", l);
                                    prog = 4;
                                }
                            }

                            break;
                        }

                        //VITA SANTI
                        case 3:
                        {
                            //riga vuota salto
                            if (l.Length == 0)
                            {
                                break;
                            }
                            if (èInizioLettura(l))
                            {
                                addInizioLetturaOVangelo(l, Section.primaLettura); break;
                            }

                            if (èGiornataMondiale(l))
                            {
                                addGiornataMondiale(l);
                            }
                            else
                            {
                                //suppongo sia festività
                                addOutPQ("#04", l);
                                prog = 4;
                            }
                            break;
                        }

                        // FESTA RELIGIOSA IMPORTANTE
                        case 4:
                        {
                            //riga vuota salto
                            if (l.Length == 0)
                            {
                                break;
                            }
                            if (èInizioLettura(l))
                            {
                                addInizioLetturaOVangelo(l, Section.primaLettura); break;
                            }

                            if (èGiornataMondiale(l))
                            {
                                addGiornataMondiale(l);
                            }
                            else
                            {
                                addProblem("parte non riconosciuta");
                            }
                            break;
                        }

                        // GIORNATA MONDIALE
                        case 5:
                        {
                            //riga vuota salto
                            if (l.Length == 0)
                            {
                                break;
                            }
                            if (èInizioLettura(l))
                            {
                                addInizioLetturaOVangelo(l, Section.primaLettura); break;
                            }

                            //suppongo sia testo altra festa
                            addOutPQ("#06", l);
                            //vado comunque avanti
                            prog = 6;
                            break;
                        }

                        // TESTO ALTRA FESTA
                        case 6:
                        {
                            //riga vuota salto
                            if (l.Length == 0)
                            {
                                break;
                            }
                            if (èInizioLettura(l))
                            {
                                addInizioLetturaOVangelo(l, Section.primaLettura); break;
                            }

                            //se arrivo qui è un problema ... non ho trovato la prma lettura
                            addProblem("manca prima lettura");
                            sec  = Section.primaLettura;
                            prog = 1;
                            break;
                        }

                        default:
                        {
                            addProblem("default .. non gestito!");
                            break;
                        }
                        }
                        break;
                    }

                    //PRIMA O seconda LETTURA o vangelo
                    case Section.vangelo:
                    case Section.primaLettura:
                    case Section.secondalettura:
                    case Section.vangeloOppure:
                    case Section.primaLetturaOppure:
                    case Section.secondaLetturaOppure:
                    {
                        switch (prog)
                        {
                        case -1:
                        {
                            // quando so che deve iniziare una lettura o vangelo ma non ho ancora trovato niente
                            if (l.Length == 0 && sTemp.Length == 0)
                            {
                                break;
                            }
                            if (èInizioLettura(l) || èInizioVangelo(l))
                            {
                                addInizioLetturaOVangelo(l, sec);
                                break;
                            }
                            else if (èAntifonaVangelo(l))
                            {
                                addInizioLetturaOVangelo(l, sec);
                                break;
                            }
                            else
                            {
                                sTemp += l;
                                addProblem("manca titolo e rif lettura");
                            }
                            break;
                        }

                        //titolo e riferimenti
                        case 1:
                        {
                            //riga vuota salto
                            if (l.Length == 0)
                            {
                                break;
                            }
                            AddTestoLettura(l);
                            break;
                        }

                        case 3:
                        {
                            //riga vuota salto
                            if (l.Length == 0)
                            {
                                break;
                            }
                            AddCommentoLettura(l);
                            break;
                        }

                        default:
                        {
                            addProblem("default .. non gestito!");
                            break;
                        }
                        }
                        break;
                    }

                    //SALMO
                    case Section.salmo:
                    {
                        switch (prog)
                        {
                        //titolo e riferimenti
                        case 0:
                        {
                            //riga vuota salto
                            if (l.Length == 0)
                            {
                                break;
                            }
                            Add1AntifonaSalmo(l);
                            break;
                        }

                        case 1:
                        {
                            if (l.Length == 0 && sTemp.Length == 0)
                            {
                                break;
                            }
                            if (l.Length == 0)
                            {
                                AddStrofaSalmo(sTemp, 6);
                                sTemp = "";
                                break;
                            }
                            if (èoppure(l))
                            {
                                Add1OppureSalmo(l);
                            }
                            else
                            {
                                if (sTemp.Length > 0)
                                {
                                    sTemp += Environment.NewLine + l;
                                }
                                else
                                {
                                    sTemp += l;
                                }
                            }
                            break;
                        }

                        case 2:
                        {
                            if (l.Length == 0)
                            {
                                break;
                            }
                            Add2AntifonaSalmo(l);
                            break;
                        }

                        case 3:
                        {
                            if (l.Length == 0 && sTemp.Length == 0)
                            {
                                break;
                            }
                            if (l.Length == 0)
                            {
                                AddStrofaSalmo(sTemp, 6);
                                sTemp = "";
                                break;
                            }
                            if (èoppure(l))
                            {
                                Add2OppureSalmo(l);
                            }
                            else
                            {
                                if (sTemp.Length > 0)
                                {
                                    sTemp += Environment.NewLine + l;
                                }
                                else
                                {
                                    sTemp += l;
                                }
                            }
                            break;
                        }

                        case 4:
                        {
                            if (l.Length == 0)
                            {
                                break;
                            }
                            Add3AntifonaSalmo(l);
                            break;
                        }

                        case 5:
                        case 6:
                        case 7:
                        case 8:
                        case 9:
                        case 10:             //'A' su rtf
                        case 11:             //'B'  su rtf
                        case 12:             //'C'  su rtf
                        case 13:             //'D'  su rtf
                        {
                            if (l.Length == 0 && sTemp.Length == 0)
                            {
                                break;
                            }
                            if (èInizioLettura(l))
                            {
                                if (sTemp.Length > 0)
                                {
                                    AddStrofaSalmo(sTemp, prog + 1);
                                    sTemp = "";
                                }
                                addInizioLetturaOVangelo(l, Section.secondalettura);
                                break;
                            }

                            if (èAntifonaVangelo(l))
                            {
                                if (sTemp.Length > 0)
                                {
                                    AddStrofaSalmo(sTemp, prog + 1);
                                    sTemp = "";
                                }
                                AddInizioPrimaAntifonaVangelo(l);
                                break;
                            }
                            if (l.Length == 0)
                            {
                                AddStrofaSalmo(sTemp, prog + 1);
                                sTemp = "";
                                break;
                            }
                            else if (sTemp.Length > 0)
                            {
                                sTemp += Environment.NewLine + l;
                            }
                            else
                            {
                                sTemp += l;
                            }
                            break;
                        }

                        default:
                        {
                            addProblem("default .. non gestito!");
                            break;
                        }
                        }
                        break;
                    }

                    case Section.antifonaVangelo:
                    {
                        switch (prog)
                        {
                        case 0:
                        {
                            if (l.Length == 0)
                            {
                                break;
                            }
                            if (èAntifonaVangelo(l))
                            {
                                addOutPQ("#41", sTemp);
                                sTemp = "";
                                addOutPQ("#42", l);
                                //sec = Section.vangelo;
                                //prog = -1;
                                prog = 2;
                            }
                            else if (sTemp.Length > 0)
                            {
                                sTemp += Environment.NewLine + l;
                            }
                            else
                            {
                                sTemp += l;
                            }
                            break;
                        }

                        case 2:
                        {
                            if (l.Length == 0)
                            {
                                break;
                            }
                            if (èoppure(l))
                            {
                                AddOppureAntifonaVangelo(l);
                            }
                            else if (èInizioVangelo(l))
                            {
                                addInizioLetturaOVangelo(l, Section.vangelo);
                            }
                            break;
                        }

                        case 3:
                        {
                            if (l.Length == 0)
                            {
                                break;
                            }
                            if (èAntifonaVangelo(l))
                            {
                                AddInizioSecondaAntifonaVangelo(l);
                            }
                            else
                            {
                                addProblem("manca seconda antifona vangelo");
                            }
                            break;
                        }

                        case 4:
                        {
                            if (l.Length == 0)
                            {
                                break;
                            }
                            if (èAntifonaVangelo(l))
                            {
                                addOutPQ("#45", sTemp);
                                sTemp = "";
                                addOutPQ("#46", l);
                                sec  = Section.vangelo;
                                prog = -1;
                            }
                            else if (sTemp.Length > 0)
                            {
                                sTemp += Environment.NewLine + l;
                            }
                            else
                            {
                                sTemp += l;
                            }
                            break;
                        }

                        default:
                        {
                            addProblem("default .. non gestito!");
                            break;
                        }
                        }
                        break;
                    }

                    default:
                    {
                        addProblem("default .. non gestito!");
                        break;
                    }
                    }
                }
                //aggiungo commento al vangelo
                if (sTemp.Length > 0)
                {
                    addOutPQ("#" + (int)sec + "4", sTemp);
                    sTemp = "";
                }
            }
            catch (System.Exception ex)
            {
                addProblem("eccezione: " + ex.Message);
            }

            return(outPQTag);
        }
コード例 #4
0
        private void LoadData(String Filename)
        {
            String CurLine;                                         // 存讀取器抓到的字串
            int    Section = 0;                                     // 設定變數存狀態,預設為0

            String[] Piecewise;                                     // 存字串陣列

            StreamReader TaskCSV = new StreamReader(Filename);      // 用資料流讀取器抓資料

            //-------讀檔,要做檢查跳出的判斷式-------//
            while ((CurLine = TaskCSV.ReadLine()) != null)
            {
                int fileEnd = 0;
                if (CurLine.ToUpper().Contains("DATA_TIME"))        // 先將字串矩陣轉大寫,在檢查裡面是否包含特定字串
                //if (CurLine.ToUpper().Contains("NUM1"))        // 先將字串矩陣轉大寫,在檢查裡面是否包含特定字串
                {
                    Section = 1;                                    // Section = 1,這行要跳過
                }
                else if (CurLine.ToUpper().Contains("0"))
                {
                    Section = 2;                                   // Section = 2,數值資料的部分
                }

                switch (Section)
                {
                case 1:
                    Piecewise    = CurLine.Trim().Split(',');
                    ItemsNumbers = Piecewise.Length;
                    break;

                case 2:
                    Piecewise = CurLine.Trim().Split(',');
                    //------判斷是否讀到空字串了------------//
                    if (Piecewise[0] == "" || Piecewise[0] == string.Empty || Piecewise[0] == null)
                    {
                        fileEnd = 1;
                        break;
                    }
                    else     //解析字串內容並存進矩陣
                    {
                        for (int j = 0; j < ItemsNumbers; j++)
                        {
                            //------把各項數值放進對應的List裡------//
                            if (j == 0)
                            {
                                Index.Add(Convert.ToDouble(Piecewise[j]));
                            }
                            else if (j == 1)
                            {
                                DataTime.Add(Convert.ToDouble(Piecewise[j]));
                            }
                            else if (j == 5)
                            {
                                Gap.Add(Convert.ToDouble(Piecewise[j]));
                            }
                            else if (j == 6)
                            {
                                Feed.Add(Convert.ToDouble(Piecewise[j]));
                            }
                            else if (j == 7)
                            {
                                Hipwr.Add(Convert.ToDouble(Piecewise[j]));
                            }
                            else if (j == 8)
                            {
                                WaterR.Add(Convert.ToDouble(Piecewise[j]));
                            }
                            //else if (j == 9) Label3.Add(Convert.ToDouble(Piecewise[j]));
                            else if (j == 10)
                            {
                                Label4.Add(Convert.ToDouble(Piecewise[j]));
                            }
                            else if (j == 11)
                            {
                                Label5.Add(Convert.ToDouble(Piecewise[j]));
                            }

                            /*
                             * if (j == 0) Gap.Add(Convert.ToDouble(Piecewise[j]));
                             * else if (j == 1) Feed.Add(Convert.ToDouble(Piecewise[j]));
                             * else if (j == 2) Hipwr.Add(Convert.ToDouble(Piecewise[j]));
                             * else if (j == 3) WaterR.Add(Convert.ToDouble(Piecewise[j]));
                             * else if (j == 4) Label5.Add(Convert.ToDouble(Piecewise[j]));
                             */
                        }
                    }
                    break;
                }
                if (fileEnd == 1)
                {
                    break;
                }
            }
        }