コード例 #1
0
ファイル: Program.cs プロジェクト: hurginmixa/Buchalter
        public static List <Amount> LoadAmounts()
        {
            List <Amount> retValue = new List <Amount>();

            foreach (string line in File.ReadAllLines(AmountsFilePath, Encoding.UTF8))
            {
                string rline = line.Trim(' ', '\t');
                if (rline.Length == 0)
                {
                    break;
                }

                ParseString.Token[] tokens = ParseString.Parse(rline, '!', '|');

                if (tokens.Length < 2)
                {
                    throw new Exception("Invalid field number");
                }

                string sct    = tokens[0].Text.Trim();
                Sum    sum    = Sum.Parse(tokens[1].Text.Trim().Replace(',', '.'));
                Amount amount = new Amount(sct, sum);

                retValue.Add(amount);
            }

            return(retValue);
        }
コード例 #2
0
ファイル: VD004.cs プロジェクト: hurginmixa/Buchalter
        private static bool CheckIfExists(string[] checkParams, string testStrig)
        {
            bool b1 = false;

            for (int i = 0; !b1 && i < checkParams.Length; i++)
            {
                ParseString.Token[] tokens = ParseString.Parse(testStrig.ToLower(), ' ', '\t');

                b1 = tokens.Length > 0 && (tokens[0].Text.StartsWith(checkParams[i].ToLower()));
            }
            return(b1);
        }
コード例 #3
0
ファイル: Tools.cs プロジェクト: hurginmixa/Buchalter
        public static List <IWire> LoadWires(string wiresFileName)
        {
            List <IWire> retValue = new List <IWire>();

            string[] strings = File.ReadAllLines(wiresFileName, Encoding.UTF8);
            for (int i = 0; i < strings.Length; i++)
            {
                try
                {
                    string line = strings[i].Trim(' ', '\t');
                    if (line.Length == 0)
                    {
                        retValue.Add(null);
                        continue;
                    }

                    if (line == new string('=', line.Length))
                    {
                        retValue.Add(new WireDelimiter(line));
                        continue;
                    }

                    ParseString.Token[] tokens = ParseString.Parse(line, '!', '|');
                    if (tokens.Length < 4)
                    {
                        throw new Exception("Invalid field number");
                    }

                    Date   date   = Date.Parse(tokens[0].Text.Trim());
                    string debSct = tokens[1].Text.Trim();
                    string krdSct = tokens[2].Text.Trim();
                    Sum    summa  = Sum.Parse(tokens[3].Text.Trim().Replace(',', '.'));
                    string remark = (tokens.Length >= 5) ? tokens[4].Text.Trim() : String.Empty;

                    Wire wire = new Wire(date, debSct, krdSct, summa, remark, i);

                    retValue.Add(wire);
                }
                catch (Exception e)
                {
                    throw new Exception("Exception occure at " + i + " line", e);
                }
            }

            return(retValue);
        }