public void RunJsonCalculatorTestForExternalTimeResolutionJsonFile()
 {
     Logger.Get().StartCollectingAllMessages();
     using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass()))
     {
         Directory.SetCurrentDirectory(wd.WorkingDirectory);
         using (DatabaseSetup db = new DatabaseSetup(Utili.GetCurrentMethodAndClass()))
         {
             string dbPath = wd.Combine("my.db3");
             File.Copy(db.FileName, dbPath);
             Logger.Info("DB File Path: " + dbPath);
             JsonCalcSpecification jcs = new JsonCalcSpecification();
             if (jcs.CalcOptions == null)
             {
                 throw new LPGException("Calcoptions was null");
             }
             jcs.DefaultForOutputFiles = OutputFileDefault.NoFiles;
             jcs.CalcOptions.Add(CalcOption.SumProfileExternalIndividualHouseholdsAsJson);
             jcs.StartDate = new DateTime(2019, 1, 1);
             jcs.EndDate   = new DateTime(2019, 1, 3);
             jcs.ExternalTimeResolution = "00:15:00";
             jcs.LoadTypePriority       = LoadTypePriority.RecommendedForHouses;
             Simulator      sim = new Simulator(db.ConnectionString);
             JsonCalculator jc  = new JsonCalculator();
             jc.StartHousehold(sim, jcs, sim.Houses[0].GetJsonReference(), null);
         }
         Directory.SetCurrentDirectory(wd.PreviousCurrentDir);
         wd.CleanUp();
     }
 }
        public void OnlyExternalTest()
        {
            Logger.Get().StartCollectingAllMessages();
            Logger.Info(Utili.GetCurrentAssemblyVersion());
            Config.SkipFreeSpaceCheckForCalculation = true;
            using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass()))
            {
                DirectoryInfo simengine = new DirectoryInfo(@"V:\Dropbox\LPG\SimulationEngine\bin\Debug\net472");
                foreach (FileInfo srcFile in simengine.GetFiles("*.*", SearchOption.AllDirectories))
                {
                    string relative = srcFile.FullName.Substring(simengine.FullName.Length);
                    while (relative.StartsWith("\\"))
                    {
                        relative = relative.Substring(1);
                    }

                    string   dstPath = Path.Combine(wd.WorkingDirectory, relative);
                    FileInfo dstFile = new FileInfo(dstPath);
                    if (dstFile.Directory != null && !(dstFile.Directory.Exists))
                    {
                        dstFile.Directory.Create();
                    }
                    srcFile.CopyTo(dstPath);
                }
                Directory.SetCurrentDirectory(wd.WorkingDirectory);
                using (DatabaseSetup db = new DatabaseSetup(Utili.GetCurrentMethodAndClass()))
                {
                    Simulator sim   = new Simulator(db.ConnectionString);
                    var       house = sim.Houses.FindFirstByName("CHR07 in HT04 with Car, 05 km to work, 3.7 kW Charging at home");
                    if (house == null)
                    {
                        throw new LPGException("house not found");
                    }

                    JsonCalcSpecification jcs = JsonCalcSpecification.MakeDefaultsForTesting();
                    jcs.OutputDirectory = Path.Combine(wd.WorkingDirectory, "Results");
                    jcs.DeleteSqlite    = true;
                    jcs.StartDate       = new DateTime(2019, 1, 1);
                    jcs.EndDate         = new DateTime(2019, 1, 7);
                    if (jcs.LoadtypesForPostprocessing == null)
                    {
                        jcs.LoadtypesForPostprocessing = new List <string>();
                    }
                    jcs.LoadtypesForPostprocessing.Add("Electricity");

                    jcs.DefaultForOutputFiles = OutputFileDefault.NoFiles;
                    if (jcs.CalcOptions == null)
                    {
                        jcs.CalcOptions = new List <CalcOption>();
                    }
                    jcs.CalcOptions.Add(CalcOption.SumProfileExternalEntireHouse);

                    JsonCalculator jc = new JsonCalculator();
                    jc.StartHousehold(sim, jcs, house.GetJsonReference(), null);
                    const string sqliteanalyizer = @"v:\dropbox\lpg\sqlite3_analyzer.exe";
                    if (File.Exists(sqliteanalyizer))
                    {
                        StreamWriter  sw       = new StreamWriter(Path.Combine(jcs.OutputDirectory, "analyzesqlite.cmd"));
                        DirectoryInfo resultDi = new DirectoryInfo(jcs.OutputDirectory);
                        var           fis      = resultDi.GetFiles("*.sqlite");
                        foreach (var fi in fis)
                        {
                            sw.WriteLine(sqliteanalyizer + " \"" + fi.FullName + "\" > " + fi.Name + ".analysis.txt");
                        }
                        sw.Close();
                    }
                    else
                    {
                        throw new LPGException("analyzer not found");
                    }
                }
            }
            // db.Cleanup();
        }