Example #1
0
    public IGraphInfo GetGraphInfo(int projectId, string locatie, string root)
    {

        DataGraph distribution = new DataGraph();
        DataPoint prestatiepeilPunt;
        DataPoint toetspeilPunt;
        try
        {
            // Get a random number generator
            Random rand = new Random();
            double x;
            double y;
            for (int i = 0; i < 1000; i++)
            {
                MathNet.Numerics.Distributions.NormalDistribution bin = new NormalDistribution(0, 1000);
                y = bin.CumulativeDistribution(i);

                distribution.Add(new DataPoint(i, y));
            }

            x = rand.NextDouble() * 20.0 + 1;
            y = Math.Log(10.0 * (x - 1.0) + 1.0) * (rand.NextDouble() * 0.2 + 0.9);
            prestatiepeilPunt = new DataPoint(x, y);

            x = rand.NextDouble() * 20.0 + 1;
            y = Math.Log(10.0 * (x - 1.0) + 1.0) * (rand.NextDouble() * 0.2 + 0.9);
            toetspeilPunt = new DataPoint(x, y);
        }
        catch (Exception ex)
        {
            throw new CheckedException(ErrorType.ParseFailure, ex.Message);
        }
        ///NOTE: met GraphInfoSimple(distribution, toetspeilPunt, prestatiepeilPunt) is loosely-coupling onmogelijk
        ///(assemblies scheiden zonder interfaces te kopieren in de de bussiness layer).
        ///Gebruik minimaal een pattern.
        IGraphInfo result = new Factory<MyAccess>().CreateGraphInfo();
        result.OverschrijdingsKansen = distribution;
        result.PrestatiePeil = prestatiepeilPunt;
        result.ToetsPeil = toetspeilPunt;
                
        return result;
    }
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;
        }