Ejemplo n.º 1
0
        private List <RiverPart> ReadFile()
        {
            var FullRiver  = new List <RiverPart>();
            var startPoint = GetFileStart() + 1;

            if (startPoint == 1)
            {
                return(null);
            }

            for (int i = startPoint; i < outFile.Length; i++)
            {
                var lineWithNoSpaces = outFile[i].Replace(" ", string.Empty);
                var items            = lineWithNoSpaces.Split(';');

                if (int.TryParse(items[0], out int n))
                {
                    var river = FullRiver.FirstOrDefault(x => x.Name == items[4]);
                    if (river == null)
                    {
                        river = new RiverPart(items[4]);
                        FullRiver.Add(river);
                    }

                    var month         = MonthToNum.GetMonthId(items[1]);
                    var curDateStart  = new DateTime(Convert.ToInt32(items[0]), month, Convert.ToInt32(items[2]));
                    var curDateFinish = new DateTime(Convert.ToInt32(items[0]), month, Convert.ToInt32(items[3]));

                    var curInterval = new Interval(curDateStart, curDateFinish);
                    for (int j = 5; j < items.Length; j++)
                    {
                        if (!string.IsNullOrEmpty(items[j]))
                        {
                            curInterval.IntervalValue.Add(j + 1, Convert.ToDouble(items[j]));
                        }
                    }

                    river.Intervals.Add(curInterval);
                }
            }
            return(FullRiver);
        }
Ejemplo n.º 2
0
        private void GetFileIntervals()
        {
            intervals = new List <IntervalInfo>();
            years     = new List <int>();
            int st;
            int fn;

            var startPoint = GetFileStart() + 1;

            if (startPoint == 1)
            {
                return;
            }

            for (int i = startPoint; i < outFile.Length; i++)
            {
                var lineWithNoSpaces = outFile[i].Replace(" ", string.Empty);
                var items            = lineWithNoSpaces.Split(';');

                if (int.TryParse(items[0], out int n))
                {
                    if (!years.Contains(n))
                    {
                        years.Add(n);
                    }

                    var month = MonthToNum.GetMonthId(items[1]);

                    st = Convert.ToInt32(items[2]);
                    fn = Convert.ToInt32(items[3]);
                    var interval = intervals.FirstOrDefault(x => x.MonthId == month && x.StDay == st);
                    if (interval == null)
                    {
                        intervals.Add(new IntervalInfo(month, st, fn));
                    }
                }
            }
        }