Exemplo n.º 1
0
        async Task KillDataAsync()
        {
            if (!Confirm())
            {
                return;
            }

            try
            {
                using (var db = new ResultDB())
                {
                    Application.Current.Dispatcher.Invoke(() => Status = "Loading...");

                    await db.TestStopwatches.TruncateAsync();

                    await db.TestMethods.TruncateAsync();

                    await db.TestRuns.TruncateAsync();
                }

                await RefreshDataAsync();
            }
            catch (Exception ex)
            {
                Application.Current.Dispatcher.Invoke(() =>
                                                      MessageBox.Show(ex.Message, "Exception", MessageBoxButton.OK, MessageBoxImage.Error));
            }

            Application.Current.Dispatcher.Invoke(() => Status = "");
        }
        public void ResetResultDB()
        {
            ResultDB resultDB = new ResultDB();

            resultDB.RunSQLScript("reset");
            Console.WriteLine("Resetted Result Database");
        }
        private void PrintMessage()
        {
            if (ResultDB == null)
            {
                return;
            }

            if (!SelectedNotEmpty())
            {
                messageTextBlock.Text = "";
            }

            if (!QuerySubmitted)
            {
                if (ResultDB.IsEmpty() && SelectedNotEmpty())
                {
                    messageTextBlock.Text = "No results containing all your search terms were found.";
                }
            }
            else
            {
                if (ResultDB.Count == 1)
                {
                    messageTextBlock.Text = "One row was found.";
                }
                else
                {
                    messageTextBlock.Text = $"{ResultDB.Count} rows were found.";
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Metodo para ejecutar un procedimiento almacenado en la bd
        /// </summary>
        /// <param name="parameter">Lista de parametros que se le va a asociar</param>
        /// <param name="query">Cadena con el query a ejecutar</param>
        public List <ResultDB> ExecuteStoredProcedure(string query, List <ParameterDB> parameters)
        {
            try
            {
                Connect();
                List <ResultDB> results = new List <ResultDB>();
                using (connection)
                {
                    command             = new SqlCommand(query, connection);
                    command.CommandType = CommandType.StoredProcedure;
                    AssignParameters(parameters);
                    if (connection.State == ConnectionState.Closed)
                    {
                        connection.Open();
                    }
                    command.ExecuteNonQuery();
                    if (command.Parameters != null)
                    {
                        foreach (SqlParameter parameter in command.Parameters)
                        {
                            if (parameter.Direction.Equals(ParameterDirection.Output))
                            {
                                ResultDB result = new ResultDB(parameter.ParameterName, parameter.Value.ToString());
                                results.Add(result);
                            }
                        }
                        if (results != null)
                        {
                            return(results);
                        }
                    }

                    return(null);
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                Disconnect();
            }
        }
        public void ProcessBatchFromSourceDBToResultDB(int amount)
        {
            int leftToDo = amount;
            int batch    = 50;

            SourceDB sourceDB             = new SourceDB();
            int      imageFilesInSourceDB = sourceDB.GetImageFilesCount();

            ResultDB resultDB             = new ResultDB();
            int      imageFilesInResultDB = resultDB.GetImageFilesCount();

            int diffResultDBandSourceDB = imageFilesInSourceDB - imageFilesInResultDB;

            if (diffResultDBandSourceDB == 0)
            {
                Console.WriteLine("No new images in sourceDB to process");
                return;
            }

            while (leftToDo > 0)
            {
                if (leftToDo <= batch)
                {
                    batch = leftToDo;
                }
                if (leftToDo > diffResultDBandSourceDB)
                {
                    batch = diffResultDBandSourceDB;
                }
                if (batch == 0)
                {
                    break;
                }

                CopyJpgFiles(ETLcontroller.sourceDBDataFolder, ETLcontroller.stageDBDataUnporssedFolder, batch);
                InsertDataIntoStageDBFromUnprocessed();
                ExtractMetadataIntoStageDB();
                ImageRegonitionPrediction();
                SortFilesInStageDBData();
                MoveFilesFromStageDBDataToResultDBData();

                LoadDataFromStageDBtoResultDB();
                ResetStageDB();

                leftToDo -= 50;
            }
        }
Exemplo n.º 6
0
        async Task DeleteDataAsync()
        {
            if (!Confirm())
            {
                return;
            }

            App.Root.ViewModel.Status = "Deleting...";

            try
            {
                using (var db = new ResultDB())
                {
                    var runs =
                        from r in db.TestRuns
                        where r.Platform == Platform && r.Name == Name
                        select r;

                    var methods =
                        from m in db.TestMethods
                        join r in runs on m.TestRunID equals r.ID
                        select m;

                    var watches =
                        from w in db.TestStopwatches
                        join m in methods on w.TestMethodID equals m.ID
                        select w;

                    await watches.DeleteAsync();

                    await methods.DeleteAsync();

                    await runs.DeleteAsync();
                }

                await App.Root.ViewModel.RefreshDataAsync();
            }
            catch (Exception ex)
            {
                Application.Current.Dispatcher.Invoke(() =>
                                                      MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK));
            }

            App.Root.ViewModel.Status = "";
        }
        private bool SatisfyFields()
        {
            if (SelectedNotEmpty())
            {
                Customer userInput;
                if (companyNameBox.IsEnabled)
                {
                    userInput = new Customer("", companyNameBox.Text, contactNameBox.Text, phoneNumberBox.Text);
                }
                else
                {
                    userInput = new Customer(customerIdBox.Text, "", "", "");
                }

                ResultDB = _db.Select(userInput);
                return(!ResultDB.IsEmpty());
            }
            return(false);
        }
Exemplo n.º 8
0
        async Task DeleteBestWorstDataAsync()
        {
            if (!Confirm())
            {
                return;
            }

            App.Root.ViewModel.Status = "Deleting...";

            var dataToDelete =
                (
                    from m in Methods
                    from t in m.Times
                    from d in t.GetBestWorst()
                    select new { ID = d }
                )
                .ToList();

            try
            {
                using (var db = new ResultDB())
                    // Need CreateTempTableAsync
                    using (var tmp = db.CreateTempTable("#tmp", dataToDelete))
                    {
                        var q =
                            from w in db.TestStopwatches
                            join t in tmp on w.ID equals t.ID
                            select w;

                        await q.DeleteAsync();
                    }

                await App.Root.ViewModel.RefreshDataAsync();
            }
            catch (Exception ex)
            {
                Application.Current.Dispatcher.Invoke(() =>
                                                      MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK));
            }

            App.Root.ViewModel.Status = "";
        }
        public void LoadDataFromStageDBtoResultDB()
        {
            List <ImageFile> imageFiles = new List <ImageFile>();
            List <ImageInfo> imageInfos = new List <ImageInfo>();

            StageDB  stageDB  = new StageDB();
            ResultDB resultDB = new ResultDB();


            imageFiles = stageDB.GetAllImageFiles();
            imageInfos = stageDB.GetAllImageInfos();


            foreach (ImageFile imageFile in imageFiles)
            {
                imageFile.FilePath.Replace("StageDBData", "ResultDBData");
                resultDB.InsertImageFile(imageFile);
            }

            foreach (ImageInfo imageInfo in imageInfos)
            {
                resultDB.InsertImageInfo(imageInfo);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Computes the influence of all configuration options and interactions based on the measurements of the given result db. It uses linear programming (simplex) and is an exact algorithm.
        /// </summary>
        /// <param name="nfp">The non-functional property for which the influences of configuration options are to be computed. If null, we use the property of the global model.</param>
        /// <param name="infModel">The influence model containing the variability model, all configuration options and interactions.</param>
        /// <param name="db">The result database containing the measurements.</param>
        /// <param name="evaluateFeatureInteractionsOnly">Only interactions are learned.</param>
        /// <param name="withDeviation">(Not used) We can specify whether learned influences must be greater than a certain value (e.g., greater than measurement bias).</param>
        /// <param name="deviation">(Not used) We can specify whether learned influences must be greater than a certain value (e.g., greater than measurement bias).</param>
        /// <returns>Returns the learned influences of each option in a map whereas the String (Key) is the name of the option / interaction.</returns>
        public Dictionary <String, double> computeOptionInfluences(NFProperty nfp, InfluenceModel infModel, ResultDB db, bool evaluateFeatureInteractionsOnly, bool withDeviation, double deviation)
        {
            //Initialization
            List <List <BinaryOption> > configurations = new List <List <BinaryOption> >();

            this.evaluateInteractionsOnly = evaluateFeatureInteractionsOnly;
            this.withStandardDeviation    = withDeviation;
            this.standardDeviation        = deviation;
            List <double> results = new List <double>();

            foreach (Configuration c in db.Configurations)
            {
                configurations.Add(c.getBinaryOptions(BinaryOption.BinaryValue.Selected));
                if (nfp != null)
                {
                    results.Add(c.GetNFPValue(nfp));
                }
                else
                {
                    results.Add(c.GetNFPValue());
                }
            }

            List <BinaryOption>         variables     = new List <BinaryOption>();
            Dictionary <String, double> featureValues = new Dictionary <string, double>();
            Dictionary <String, double> faultRates    = new Dictionary <string, double>();
            List <int> indexOfErrorMeasurements       = new List <int>();

            if (configurations.Count == 0)
            {
                return(null);
            }

            //For the case there is an empty base
            if (configurations.Count != 0)
            {
                if (configurations[0].Count == 0)
                {//Should never occur that we get a configuration with no option selected... at least the root must be there
                    BinaryOption root = infModel.Vm.Root;
                    //Element baseElement = new Element("base_gen", infModel.getID(), infModel);
                    //variables.Add(baseElement);
                    //  featureValues.Add(baseElement.getName(), 0);
                    foreach (List <BinaryOption> config in configurations)
                    {
                        if (!config.Contains(root))
                        {
                            config.Insert(0, root);
                        }
                    }
                }
            }
            //Building the variable list
            foreach (var elem in infModel.Vm.BinaryOptions)
            {
                variables.Add(elem);
                featureValues.Add(elem.Name, 0);
            }

            featureValues = solve(variables, results, configurations, null);

            return(featureValues);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Computes the influence of all configuration options based on the measurements of the given result db. It uses linear programming (simplex) and is an exact algorithm.
        /// </summary>
        /// <param name="nfp">The non-functional property for which the influences of configuration options are to be computed. If null, we use the property of the global model.</param>
        /// <param name="infModel">The influence model containing options and interactions. The state of the model will be changed by the result of the process</param>
        /// <param name="db">The result database containing the measurements.</param>
        /// <returns>A map of binary options to their computed influences.</returns>
        public Dictionary <BinaryOption, double> computeOptionInfluences(NFProperty nfp, InfluenceModel infModel, ResultDB db)
        {
            List <BinaryOption>         variables      = infModel.Vm.BinaryOptions;
            List <double>               results        = new List <double>();
            List <List <BinaryOption> > configurations = new List <List <BinaryOption> >();

            foreach (Configuration c in db.Configurations)
            {
                configurations.Add(c.getBinaryOptions(BinaryOption.BinaryValue.Selected));
                if (nfp != null)
                {
                    results.Add(c.GetNFPValue(nfp));
                }
                else
                {
                    results.Add(c.GetNFPValue());
                }
            }
            List <String> errorEqs = new List <string>();
            Dictionary <String, double> faultRates             = new Dictionary <string, double>();
            List <int> indexOfErrorMeasurements                = new List <int>();
            Dictionary <String, double> featureValuedAsStrings = solve(variables, results, configurations, infModel.InteractionInfluence.Keys.ToList());

            foreach (String current in featureValuedAsStrings.Keys)
            {
                BinaryOption temp = infModel.Vm.getBinaryOption(current);
                this.featureValues[temp] = featureValuedAsStrings[current];
                InfluenceFunction influence = new InfluenceFunction(temp.Name + " + " + featureValuedAsStrings[current].ToString(), infModel.Vm);
                if (infModel.BinaryOptionsInfluence.Keys.Contains(temp))
                {
                    infModel.BinaryOptionsInfluence[temp] = influence;
                }
                else
                {
                    infModel.BinaryOptionsInfluence.Add(temp, influence);
                }
            }
            return(this.featureValues);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Computes the influence of all configuration options and interactions based on the measurements of the given result db. It uses linear programming (simplex) and is an exact algorithm.
        /// </summary>
        /// <param name="nfp">The non-funcitonal property for which the influences of configuration options are to be computed. If null, we use the property of the global model.</param>
        /// <param name="infModel">The influence model containing the variability model, all configuration options and interactions.</param>
        /// <param name="db">The result database containing the measurements.</param>
        /// <param name="evaluateFeatureInteractionsOnly">Only interactions are learned.</param>
        /// <param name="withDeviation">(Not used) We can specifiy whether learned influences must be greater than a certain value (e.g., greater than measurement bias).</param>
        /// <param name="deviation">(Not used) We can specifiy whether learned influences must be greater than a certain value (e.g., greater than measurement bias).</param>
        /// <returns>Returns the learned infleunces of each option in a map whereas the String (Key) is the name of the option / interaction.</returns>
        public Dictionary <String, double> computeOptionInfluences(NFProperty nfp, InfluenceModel infModel, ResultDB db, bool evaluateFeatureInteractionsOnly, bool withDeviation, double deviation)
        {
            //Initialization
            List <List <BinaryOption> > configurations = new List <List <BinaryOption> >();

            this.evaluateInteractionsOnly = evaluateFeatureInteractionsOnly;
            this.withStandardDeviation    = withDeviation;
            this.standardDeviation        = deviation;
            List <double> results = new List <double>();

            foreach (Configuration c in db.Configurations)
            {
                configurations.Add(c.getBinaryOptions(BinaryOption.BinaryValue.Selected));
                if (nfp != null)
                {
                    results.Add(c.GetNFPValue(nfp));
                }
                else
                {
                    results.Add(c.GetNFPValue());
                }
            }

            List <BinaryOption>         variables     = new List <BinaryOption>();
            Dictionary <String, double> featureValues = new Dictionary <string, double>();
            Dictionary <String, double> faultRates    = new Dictionary <string, double>();
            List <int> indexOfErrorMeasurements       = new List <int>();

            if (configurations.Count == 0)
            {
                return(null);
            }

            //For the case there is an empty base
            if (configurations.Count != 0)
            {
                if (configurations[0].Count == 0)
                {//Should never occur that we get a configuration with no option selected... at least the root must be there
                    BinaryOption root = infModel.Vm.Root;
                    //Element baseElement = new Element("base_gen", infModel.getID(), infModel);
                    //variables.Add(baseElement);
                    //  featureValues.Add(baseElement.getName(), 0);
                    foreach (List <BinaryOption> config in configurations)
                    {
                        if (!config.Contains(root))
                        {
                            config.Insert(0, root);
                        }
                    }
                }
            }


            //Building the variable list
            foreach (var elem in infModel.Vm.BinaryOptions)
            {
                variables.Add(elem);
                featureValues.Add(elem.Name, 0);
            }

            //First run

            featureValues = solve(variables, results, configurations, null);


            //if (evaluateFeatureInteractionsOnly == false)
            return(featureValues);

            /*
             * //We might have some interactions here and cannot compute all values
             * //1. identify options that are only present in these equations
             * Dictionary<Element, int> featureCounter = new Dictionary<Element, int>();
             * for (int i = 0; i < indexOfErrorMeasurements.Count; i++)
             * {
             *
             * }
             *
             */
            /*Todo: get compute interactins from deviations / errors of the LP results
             * if (errorEqs != null)
             * {
             *  foreach (string eq in errorEqs)
             *  {
             *      double value = Double.Parse(eq.Substring(eq.IndexOf("==") + 2));
             *
             *      StringBuilder sb = new StringBuilder();
             *      List<Element> derivativeParents = new List<Element>();
             *      sb.Append("derivate_");
             *      string[] splittedEQ = eq.Split('+');
             *      foreach (string element in splittedEQ)
             *      {
             *          string name = element;
             *          if (name.Contains("=="))
             *              name = name.Substring(0, name.IndexOf("=="));
             *          if (name.Contains("yp") && name.Contains("-yn"))
             *              continue;
             *          // string featureName = name.Substring(0, name.IndexOf("_p-"));
             *          Element elem = infModel.getElementByNameUnsafe(name);
             *          if (elem == null)
             *              continue;
             *          sb.Append("_" + name);
             *          derivativeParents.Add(elem);
             *      }
             *      Element interaction = new Element(sb.ToString(), infModel.getID(), infModel);
             *      interaction.setType("derivative");
             *      interaction.addDerivativeParents(derivativeParents);
             *      infModel.addElement(interaction);
             *      this.featureValues.Add(interaction, value);
             *  }
             * }
             * return featureValues;*/
        }
Exemplo n.º 13
0
        /// <summary>
        /// This method searches for a corresponding methods in the dynamically loadeda assemblies and calls it if found. It prefers due to performance reasons the Microsoft Solver Foundation implementation.
        /// </summary>
        /// <param name="nfp">The non-funcitonal property for which the influences of configuration options are to be computed. If null, we use the property of the global model.</param>
        /// <param name="infModel">The influence model containing options and interactions. The state of the model will be changed by the result of the process</param>
        /// <param name="db">The result database containing the measurements.</param>
        /// <returns>A map of binary options to their computed influences.</returns>
        public Dictionary <BinaryOption, double> computeOptionInfluences(NFProperty nfp, InfluenceModel infModel, ResultDB db)
        {
            foreach (Lazy <ISolverLP, ISolverType> solver in solvers)
            {
                if (solver.Metadata.SolverType.Equals("MSSolverFoundation"))
                {
                    return(solver.Value.computeOptionInfluences(nfp, infModel, db));
                }
            }

            //If not MS Solver, take any solver. Should be changed when supporting more than 2 solvers here
            foreach (Lazy <ISolverLP, ISolverType> solver in solvers)
            {
                return(solver.Value.computeOptionInfluences(nfp, infModel, db));
            }

            return(null);
        }
Exemplo n.º 14
0
        /// <summary>
        /// This method searches for a corresponding methods in the dynamically loadeda assemblies and calls it if found. It prefers due to performance reasons the Microsoft Solver Foundation implementation.
        /// </summary>
        /// <param name="nfp">The non-funcitonal property for which the influences of configuration options are to be computed. If null, we use the property of the global model.</param>
        /// <param name="infModel">The influence model containing the variability model, all configuration options and interactions.</param>
        /// <param name="db">The result database containing the measurements.</param>
        /// <param name="evaluateFeatureInteractionsOnly">Only interactions are learned.</param>
        /// <param name="withDeviation">(Not used) We can specifiy whether learned influences must be greater than a certain value (e.g., greater than measurement bias).</param>
        /// <param name="deviation">(Not used) We can specifiy whether learned influences must be greater than a certain value (e.g., greater than measurement bias).</param>
        /// <returns>Returns the learned infleunces of each option in a map whereas the String (Key) is the name of the option / interaction.</returns>
        public Dictionary <string, double> computeOptionInfluences(NFProperty nfp, InfluenceModel infModel, ResultDB db, bool evaluateFeatureInteractionsOnly, bool withDeviation, double deviation)
        {
            foreach (Lazy <ISolverLP, ISolverType> solver in solvers)
            {
                if (solver.Metadata.SolverType.Equals("MSSolverFoundation"))
                {
                    return(solver.Value.computeOptionInfluences(nfp, infModel, db, evaluateFeatureInteractionsOnly, withDeviation, deviation));
                }
            }

            //If not MS Solver, take any solver. Should be changed when supporting more than 2 solvers here
            foreach (Lazy <ISolverLP, ISolverType> solver in solvers)
            {
                return(solver.Value.computeOptionInfluences(nfp, infModel, db, evaluateFeatureInteractionsOnly, withDeviation, deviation));
            }
            return(null);
        }
Exemplo n.º 15
0
        public async Task RefreshDataAsync()
        {
            try
            {
                using (var db = new ResultDB())
                {
                    Status = "Loading...";

                    var runs = await db.TestRuns.ToListAsync();

                    var methods = await db.TestMethods.ToListAsync();

                    var watches = await db.TestStopwatches.ToListAsync();

                    var ws =
                        (
                            from w in watches
                            group w by w.TestMethodID into g
                            select new { g.Key, Items = g.ToList() }
                        )
                        .ToDictionary(t => t.Key, t => t.Items);

                    var ms =
                        (
                            from m in methods
                            group m by m.TestRunID into g
                            select new
                    {
                        g.Key,
                        Items = g.Select(mt => new
                        {
                            Method = mt,
                            Watches = ws.ContainsKey(mt.ID) ? ws[mt.ID] : new List <TestStopwatch>()
                        }).ToList()
                    }
                        )
                        .ToDictionary(t => t.Key, t => t.Items);

                    var rs =
                        (
                            from r in runs
                            group r by new { r.Platform, r.Name } into g
                            //orderby g.Key.Platform, g.Key.Name
                            select new { g.Key, Items = g.Select(rt => new { Run = rt, Methods = ms[rt.ID] }).ToList() }
                        )
                        .ToDictionary(t => t.Key, t => t.Items);

                    var providers = ws.Values.SelectMany(w => w).Select(w => w.Provider).Distinct().OrderBy(p => p);

                    SolidColorBrush GetBrush(Color color, int delta)
                    {
                        return(new SolidColorBrush(Color.FromRgb(
                                                       (byte)Math.Min(Math.Max(color.R + delta, 0), 255),
                                                       (byte)Math.Min(Math.Max(color.G + delta, 0), 255),
                                                       (byte)Math.Min(Math.Max(color.B + delta, 0), 255))));
                    }

                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        ProviderBrushes = new Dictionary <string, Brush>
                        {
                            ["AdoNet"]   = new SolidColorBrush(Color.FromRgb(0xAA, 0x40, 0xFF)),
                            ["Dapper"]   = new SolidColorBrush(Color.FromRgb(0x63, 0x2F, 0x00)),
                            ["PetaPoco"] = new SolidColorBrush(Color.FromRgb(0xFF, 0x76, 0xBC)),

                            ["L2DB Sql"]      = GetBrush(Color.FromRgb(0x19, 0x99, 0x00), 0x1A),
                            ["L2DB Compiled"] = GetBrush(Color.FromRgb(0x19, 0x99, 0x00), 0x00),
                            ["L2DB Linq"]     = GetBrush(Color.FromRgb(0x19, 0x99, 0x00), -0x1A),

                            ["EF Core Sql"]      = GetBrush(Color.FromRgb(0xFF, 0x98, 0x1D), 0x1A),
                            ["EF Core Compiled"] = GetBrush(Color.FromRgb(0xFF, 0x98, 0x1D), 0x00),
                            ["EF Core Linq"]     = GetBrush(Color.FromRgb(0xFF, 0x98, 0x1D), -0x1A),

                            ["L2S Sql"]      = GetBrush(Color.FromRgb(0x1F, 0xAE, 0xFF), 0x1A),
                            ["L2S Compiled"] = GetBrush(Color.FromRgb(0x1F, 0xAE, 0xFF), 0x00),
                            ["L2S Linq"]     = GetBrush(Color.FromRgb(0x1F, 0xAE, 0xFF), -0x1A),

                            ["EF6 Sql"]      = GetBrush(Color.FromRgb(0xC1, 0x00, 0x4F), 0x1A),
                            ["EF6 Compiled"] = GetBrush(Color.FromRgb(0xC1, 0x00, 0x4F), 0x00),
                            ["EF6 Linq"]     = GetBrush(Color.FromRgb(0xC1, 0x00, 0x4F), -0x1A),

                            ["BLToolkit Sql"]      = GetBrush(Color.FromRgb(0x7F, 0x6E, 0x94), 0x1A),
                            ["BLToolkit Compiled"] = GetBrush(Color.FromRgb(0x7F, 0x6E, 0x94), 0x00),
                            ["BLToolkit Linq"]     = GetBrush(Color.FromRgb(0x7F, 0x6E, 0x94), -0x1A),
                        };

                        var colors = new[]
                        {
                            Color.FromRgb(0xFF, 0x2E, 0x12),
                            Color.FromRgb(0x25, 0x72, 0xEB),
                            Color.FromRgb(0x46, 0x17, 0xB4),
                            Color.FromRgb(0x72, 0x00, 0xAC),
                            Color.FromRgb(0xFE, 0x7C, 0x22),
                            Color.FromRgb(0xFF, 0x1D, 0x77),
                            Color.FromRgb(0x4F, 0x1D, 0x77),
                            Color.FromRgb(0x91, 0xD1, 0x00),
                            Color.FromRgb(0x77, 0xB9, 0x00),
                            Color.FromRgb(0x00, 0xC1, 0x3F),
                            Color.FromRgb(0xE1, 0xB7, 0x00),
                            Color.FromRgb(0xE1, 0xB7, 0xA0),
                            Color.FromRgb(0xF3, 0xB2, 0x00),
                            Color.FromRgb(0xFF, 0x98, 0x1D),
                            Color.FromRgb(0x56, 0xC5, 0xFF),
                            Color.FromRgb(0x56, 0x05, 0xFF),
                            Color.FromRgb(0x00, 0xD8, 0xCC),
                            Color.FromRgb(0x00, 0x82, 0x87),
                            Color.FromRgb(0x00, 0xA3, 0xA3),
                            Color.FromRgb(0x00, 0x6A, 0xC1),
                            Color.FromRgb(0x00, 0xA3, 0xA3),
                            Color.FromRgb(0x90, 0xA3, 0xA3),
                        };

                        var count = ProviderBrushes.Count;

                        foreach (var item in providers)
                        {
                            if (!ProviderBrushes.ContainsKey(item))
                            {
                                ProviderBrushes[item] = new SolidColorBrush(colors[ProviderBrushes.Count - count]);
                            }
                        }
                    });

                    foreach (var platform in Platforms)
                    {
                        foreach (var test in platform.Tests)
                        {
                            test.Test = null;
                        }
                    }

                    var tests = rs
                                .Select(r => new TestViewModel
                    {
                        Platform = r.Key.Platform,
                        Name     = r.Key.Name,
                        Methods  = new ObservableCollection <MethodViewModel>(
                            from rt in r.Value
                            from m  in rt.Methods
                            group new { rt, m } by new { m.Method.Name, m.Method.Repeat, m.Method.Take } into gr
                            select new MethodViewModel(
                                from t in gr
                                from w in t.m.Watches
                                group new { t, w } by w.Provider into g
                                select new TimeViewModel(g.Select(tw => tw.w))
                        {
                            Name = g.Key,
                        })
                        {
                            Name   = gr.Key.Name,
                            Repeat = gr.Key.Repeat,
                            Take   = gr.Key.Take,
                        })
                    })
                                .ToList();

                    for (var i = 0; i < tests.Count; i++)
                    {
                        var test = tests[i];
                        var idx  = Tests
                                   .Select((t, n) => new { t, n })
                                   .Where(t => t.t.Platform == test.Platform && t.t.Name == test.Name)
                                   .Select(t => (int?)t.n)
                                   .FirstOrDefault();

                        var platform = Platforms.FirstOrDefault(p => p.Name == test.Platform);

                        if (platform == null)
                        {
                            Application.Current.Dispatcher.Invoke(() => Platforms.Add(platform = new PlatformViewModel {
                                Name = test.Platform
                            }));
                        }

                        var platformTest = platform.Tests.FirstOrDefault(t => t.Name == test.Name);

                        if (platformTest == null)
                        {
                            platformTest = new PlatformTestViewModel {
                                Name = test.Name
                            };
                            Application.Current.Dispatcher.Invoke(() => platform.Tests.Add(platformTest));
                        }

                        if (idx == null)
                        {
                            platformTest.Test = test;
                            Application.Current.Dispatcher.Invoke(() => Tests.Insert(i, test));
                        }
                        else
                        {
                            if (i != idx)
                            {
                                Application.Current.Dispatcher.Invoke(() => Tests.Move(idx.Value, i));
                            }
                            platformTest.Test = Tests[i];
                            Tests[i].Merge(test);
                        }
                    }

                    foreach (var platform in Platforms.ToList())
                    {
                        foreach (var test in platform.Tests.ToList())
                        {
                            if (test.Test == null)
                            {
                                Application.Current.Dispatcher.Invoke(() => platform.Tests.Remove(test));
                            }
                        }

                        if (platform.Tests.Count == 0)
                        {
                            Application.Current.Dispatcher.Invoke(() => Platforms.Remove(platform));
                        }
                    }

                    while (Tests.Count > tests.Count)
                    {
                        Application.Current.Dispatcher.Invoke(() => Tests.RemoveAt(Tests.Count - 1));
                    }
                }
            }
            catch (Exception ex)
            {
                Application.Current.Dispatcher.Invoke(() =>
                                                      MessageBox.Show(ex.Message, "Exception", MessageBoxButton.OK, MessageBoxImage.Error));
            }

            Status = "";
        }