public int PutProperty(Evalue evalue) { Evalues.Add(evalue); // The index to be added must be the last index of Evalues PropStore.AddIndex(evalue.KomNr, evalue.EjdNr, Evalues.Count() - 1); return(0); }
public StatisticProperty CompareProperties(Evalue first, Evalue scnd) { // This can be removed if we decide to include nulls. // first should never be null. Just a sanity check. if (scnd == null || first == null) { return(null); } int komNr = first.KomNr; int ejdNr = first.EjdNr; long evalueOld = first.ModelVaerdi; long evalueNew = 0; long handelspris = 0; DateTime handelsDato = new DateTime(); // We already checked for this, but if we decide to include these in the stats, // we can just remove the null check above. if (scnd != null) { evalueNew = scnd.ModelVaerdi; handelspris = scnd.HandelsPris; handelsDato = scnd.HandelsDato; } Decimal evalueNewCompOld = 0; Decimal evalueNewCompHandelspris = 0; if (evalueNew != 0) { if (evalueOld != 0) { evalueNewCompOld = (Decimal)evalueNew / (Decimal)evalueOld; } if (handelspris != 0) { evalueNewCompHandelspris = (Decimal)evalueNew / (Decimal)handelspris; } } StatisticProperty statProp = new StatisticProperty(komNr, ejdNr, evalueOld, evalueNew, handelspris, handelsDato, evalueNewCompOld, evalueNewCompHandelspris); return(statProp); }
public List <StatisticProperty> BuildStats() { List <StatisticProperty> statList = new List <StatisticProperty>(); foreach (Evalue Ejendom in FirstFile.Evalues) { Evalue scndEjd = SecondFile.GetProperty(Ejendom.KomNr, Ejendom.EjdNr); StatisticProperty statProp = CompareProperties(Ejendom, scndEjd); if (statProp != null) { statList.Add(statProp); } } return(statList); }
// Without saving it in a statList basically public List <string> BuildStatStringDirectly() { // New list, just add the header List <string> output = new List <string> { Header }; foreach (Evalue Ejendom in FirstFile.Evalues) { Evalue scndEjd = SecondFile.GetProperty(Ejendom.KomNr, Ejendom.EjdNr); StatisticProperty statProp = CompareProperties(Ejendom, scndEjd); if (statProp != null) { output.Add(statProp.ToCsv()); } } return(output); }
public static string BuildOutputString(EvalueStorage firstFile, EvalueStorage secondFile) { // Just get the header from a new instance string output = new T().Header(); Random rand = new Random(); List <int> randoms = new List <int>(); int i = 0; // randoms < firstFile and secondFile to make sure we have enough properties to test. while (i < 5 && randoms.Count() < firstFile.Length() && randoms.Count() < secondFile.Length()) { int randIndex = rand.Next(secondFile.Length()); // If we already used this property if (randoms.Contains(randIndex)) { continue; } // we should probably get the second ejendom first, // since this one is filtered Evalue secondEjendom = secondFile.Evalues[randIndex]; Evalue firstEjendom = firstFile.GetProperty( secondEjendom.KomNr, secondEjendom.EjdNr); // If secondFile did not contain the property if (firstEjendom == null) { continue; } output += firstEjendom.ToCsv() + "\n" + secondEjendom.ToCsv() + "\n\n"; randoms.Add(randIndex); i++; } // Only get properties that are "i udbud" List <Evalue> ScndIUdbud = secondFile.Evalues.Where(ejd => ejd.ErIUdbud == 1).ToList(); // Just force it to 5, so we only get 5 where ErIUdbud == 1 if (i != 5) { i = 5; } // i should be 5 at this point, so we get 5 more properties here while (i < 10 && randoms.Count() < ScndIUdbud.Count()) { int randIndex = rand.Next(ScndIUdbud.Count); // If we already used this property we skip it // (we haven't necessarily used it, but chances are, // that this case won't be hit a lot anyway) if (randoms.Contains(randIndex)) { continue; } Evalue Ejendom = ScndIUdbud[randIndex]; output += Ejendom.ToCsv() + "\n"; randoms.Add(randIndex); i++; } return(output); }