Example #1
0
        /// <summary>
        /// Gets toetspeilen and sets globalse and members for toetspeilen.
        /// </summary>
        /// <returns></returns>
        public double[] GetToetspeilen()
        {            
            if (ToetsPeilenDirectory != null)
            {
                Collection<string> toetspeilen = MyAccess.ReadFile(ToetsPeilenDirectory + "\\" + InitData.UniqueInstance.ToetsPeilenName);
                int lineCount = 0;
                m_TabelRelatieLocatieToetspeil = new Dictionary<string, int>();
                Tpeilen = new double[toetspeilen.Count];
                try
                {

                    foreach (var line in toetspeilen)
                    {
                        int index = lineCount;
                        StringParser items = new StringParser(line, "\t");
                        int mhw;
                        string substring = line.Substring(27, 3);
                        int.TryParse(substring, out mhw);
                        if (mhw == 0) throw new CheckedException(ErrorType.ParseFailure,
                                                                 string.Format("Toetspeil leesfout op regel {0}: {1}.\nGeen geldige of bestaande waarde ({2}).",
                                                                               lineCount, line, substring));
                        m_TabelRelatieLocatieToetspeil.Add(new KeyValuePair<string, int>(line.Substring(8, 19), index));
                        Tpeilen[lineCount] = mhw;
                        lineCount++;
                    }
                }
                catch(CheckedException)
                {
                    throw;
                }
                catch (System.Exception ex)
                {
                    throw new CheckedException(ErrorType.ParseFailure,
                                               string.Format("Toetspeil leesfout op regel {0}: \n{1}", lineCount, ex.Message));
                }
            }//else prototype => uses hardcoded array.
            return Tpeilen;
        }
Example #2
0
        public IGraphInfo GetGraphInfo(int projectId, string locatie, string root)
        {
            
            bool saf;
            bool sof;
            InitData.UniqueInstance.ProjectId = projectId;
            InitData.UniqueInstance.RootDirectory = root;
            using (DataClasses1DataContext context = new DataClasses1DataContext())
            {
                var project = (from aProject in context.Projects
                              where aProject.ProjectId == projectId
                              select aProject).FirstOrDefault();

                saf = project.GegevensSet.SafAanwezig;
                sof = project.GegevensSet.SofAanwezig;

                HandleBronPadenEnBestanden(projectId, root, sof, saf, false);
            }
            InitData.UniqueInstance.SetToetspeilenFileName();
            string toetspeilPath = Bronpaden[3];
            string toetspeilenFile = toetspeilPath + "\\" + InitData.UniqueInstance.ToetsPeilenName;
            InitData.UniqueInstance.ToetsPeilenDirectory = toetspeilPath ;
            

            Debug.Assert(File.Exists(toetspeilenFile));
            InitData.UniqueInstance.GetToetspeilen();

            string overschrijdingsFile = ProjectPath + "\\overschrijding_" + locatie + ".dat";
            Debug.Assert(File.Exists(overschrijdingsFile), "Overschrijdingsfile is niet gevonden.");

            string prestatiePeilFile = ProjectPath + "\\prestatiepeil.dat" ;
            Debug.Assert(File.Exists(prestatiePeilFile), "prestatiePeilFile is niet gevonden.");

            Collection<string> fileRef= ReadFile(overschrijdingsFile);
            Collection<string> fileRefOverschrijdingsKansen = new Collection<string>();            
            RemoveHeader(fileRef, fileRefOverschrijdingsKansen);

            Collection<string> fileRefPrestatiePeil = new Collection<string>(); 
            fileRef = ReadFile(prestatiePeilFile);
            RemoveHeader(fileRef, fileRefPrestatiePeil);

            DataGraph curve = new DataGraph();
            DataPoint prestatiepeilPunt;
            DataPoint toetspeilPunt;
            try
            {
                foreach (string line in fileRefOverschrijdingsKansen)
                {
                    //string locatieRemoved = Utility.Postfix(line, locatie);
                    StringParser parsedLine = new StringParser(line, "\t");

                    double x = Convert.ToDouble(parsedLine.LineItems[1]);
                    double y = Convert.ToDouble(parsedLine.LineItems[2]);
                    curve.Add(new DataPoint(x, y));
                }

                double prestatiepeil = 0d;
                foreach (string line in fileRefPrestatiePeil)
                {
                    StringParser parsedLine = new StringParser(line, "\t");
                   
                    if(parsedLine.LineItems[0].Equals(locatie))
                    {
                        double.TryParse(parsedLine.LineItems[1],NumberStyles.Any, CultureInfo.InvariantCulture,
                            out prestatiepeil);                            
                    }
                        
                }
                double y_waarde= curve[prestatiepeil].Y;
                prestatiepeilPunt = new DataPoint(prestatiepeil, y_waarde);

                int index = InitData.UniqueInstance.GetToetsPeilIndex(locatie);
                int toetspeil = Convert.ToInt32(InitData.UniqueInstance.Tpeilen[index]);

                toetspeilPunt = new DataPoint(toetspeil, y_waarde);
            }           
            catch (Exception ex)
            {                
                throw new CheckedException(ErrorType.ParseFailure, ex.Message);
            }
            ///NOTE: met GraphInfoSimple(curve, toetspeilPunt, prestatiepeilPunt) is loosely-coupling onmogelijk(assemblies scheiden).
            ///Gebruik minimaal een pattern.
            IGraphInfo result = new Factory<MyAccess>().CreateGraphInfo();
            result.OverschrijdingsKansen = curve;
            result.PrestatiePeil = prestatiepeilPunt;
            result.ToetsPeil = toetspeilPunt;
                
            return result;
        }