// Чтение подкаталога с данным именем из корневого каталога
        // Создание соответствующей сборки (job-а).
        public void ReadDirectory(string fullName)
        {
            DirectoryInfo d = new DirectoryInfo(fullName);

            result = new ResultAssembly();

            // !Исправить! - подумать.
            result.Name = d.Name;

            ReadHeader(d.GetFiles()[0].FullName);

            FileInfo[] f = d.GetFiles();
            foreach (FileInfo fInfo in f)
            {
                AnalizeResult r = new AnalizeResult();
                ReadBody(r, fInfo.FullName);
                this.result.Results.Add(r);
            }
        }
 public void SetID(int ID)
 {
     this.ID = ID;
     Result = new AnalizeResult()
     {
         InstanceID = ID
     };
 }
        // Загрузка сборки по данному идентификатору сборки.
        public override ResultAssembly Load(Guid assemblyID)
        {
            log.Info("Loading assembly with ID " + assemblyID.ToString() + ".");

            log.Info("Loading common info of assembly.");

            ResultAssembly resultAssembly = new ResultAssembly();
            resultAssembly.ID = assemblyID;

            List<AnalizeResult> results = new List<AnalizeResult>();
            resultAssembly.Results = results;
            AnalizeResult result = null;
            XmlDocument xml = new XmlDocument();

            xml.Load(directory + assemblyID.ToString() + ".xml");
            resultAssembly.Name = xml.SelectSingleNode("/assembly/name").InnerText;
            resultAssembly.ModelType = GetModelType(int.Parse(xml.SelectSingleNode("/assembly/graphmodel").Attributes["id"].Value));

            log.Info("Loading generation parameters values of assembly.");
            foreach (XmlNode paramNode in xml.SelectNodes("/assembly/generationparams/generationparam"))
            {
                GenerationParam param = (GenerationParam)Enum.ToObject(typeof(GenerationParam), int.Parse(paramNode.Attributes["id"].Value));

                GenerationParamInfo paramInfo = (GenerationParamInfo)(param.GetType().GetField(param.ToString()).GetCustomAttributes(typeof(GenerationParamInfo), false)[0]);
                if (paramInfo.Type.Equals(typeof(Double)))
                {
                    resultAssembly.GenerationParams.Add(param, Convert.ToDouble(paramNode.Attributes["value"].Value, CultureInfo.InvariantCulture));
                }
                else if (paramInfo.Type.Equals(typeof(Int16)))
                {
                    resultAssembly.GenerationParams.Add(param, Convert.ToInt16(paramNode.Attributes["value"].Value));
                }
                else if (paramInfo.Type.Equals(typeof(Int32)))
                {
                    resultAssembly.GenerationParams.Add(param, Convert.ToInt32(paramNode.Attributes["value"].Value));
                }
                else if (paramInfo.Type.Equals(typeof(bool)))
                {
                    resultAssembly.GenerationParams.Add(param, Convert.ToBoolean(paramNode.Attributes["value"].Value));
                }
                else if (paramInfo.Type.Equals(typeof(String)))
                {
                    resultAssembly.GenerationParams.Add(param, Convert.ToString(paramNode.Attributes["value"].Value));
                }
            }

            log.Info("Loading analyze results.");

            int instanceNumber = 0, tempInt1, tempInt2;
            long tempLong;
            double tempDouble;
            foreach (XmlNode paramNode in xml.SelectNodes("/assembly/analyseresults/instance"))
            {
                log.Info("Loading analyze results for instance - " + instanceNumber.ToString() + ".");

                result = new AnalizeResult();
                results.Add(result);

                result.Size = int.Parse(paramNode.SelectSingleNode("size").InnerText);

                log.Info("Loading analyze results for global options.");
                foreach (XmlNode item in paramNode.SelectNodes("result/item"))
                {
                    AnalyseOptions option = (AnalyseOptions)Enum.Parse(typeof(AnalyseOptions),
                        item.Attributes["option"].Value, true);
                    result.Result.Add(option, double.Parse(item.InnerText));
                }

                log.Info("Loading analyze results for local options.");

                log.Info("Loading vertex degrees.");
                foreach (XmlNode item in paramNode.SelectNodes("vertexdegree/vd"))
                {
                    tempInt1 = int.Parse(item.Attributes["degree"].Value);
                    tempInt2 = int.Parse(item.Attributes["count"].Value);
                    result.VertexDegree.Add(tempInt1, tempInt2);
                }

                log.Info("Loading clustering coefficients.");
                foreach (XmlNode item in paramNode.SelectNodes("coefficients/coeff"))
                {
                    tempDouble = double.Parse(item.Attributes["coefficient"].Value);
                    tempInt1 = int.Parse(item.Attributes["count"].Value);
                    result.Coefficient.Add(tempDouble, tempInt1);
                }

                log.Info("Loading connected subgraphs.");
                foreach (XmlNode item in paramNode.SelectNodes("connsubgraphs/csub"))
                {
                    tempInt1 = int.Parse(item.Attributes["vx"].Value);
                    tempInt2 = int.Parse(item.Attributes["count"].Value);
                    result.Subgraphs.Add(tempInt1, tempInt2);
                }

                log.Info("Loading full subgraphs.");
                foreach (XmlNode item in paramNode.SelectNodes("fullsubgraphs/fsub"))
                {
                    tempInt1 = int.Parse(item.Attributes["vx"].Value);
                    tempInt2 = int.Parse(item.Attributes["count"].Value);
                    result.FullSubgraphs.Add(tempInt1, tempInt2);
                }

                log.Info("Loading distances between vertices.");
                foreach (XmlNode item in paramNode.SelectNodes("vertexdistance/vd"))
                {
                    tempInt1 = int.Parse(item.Attributes["distance"].Value);
                    tempInt2 = int.Parse(item.Attributes["count"].Value);
                    result.DistanceBetweenVertices.Add(tempInt1, tempInt2);
                }

                log.Info("Loading eigen values.");
                foreach (XmlNode item in paramNode.SelectNodes("eigenvalues/ev"))
                {
                    tempDouble = double.Parse(item.Attributes["eigenValue"].Value);
                    result.EigenVector.Add(tempDouble);
                }

                log.Info("Loading distances between eigen values.");
                foreach (XmlNode item in paramNode.SelectNodes("eigenvaluesdistance/ev"))
                {
                    tempDouble = double.Parse(item.Attributes["distance"].Value);
                    tempInt1 = int.Parse(item.Attributes["count"].Value);
                    result.DistancesBetweenEigenValues.Add(tempDouble, tempInt1);
                }

                log.Info("Loading cycles.");
                XmlNode it = paramNode.SelectSingleNode("cycles");
                resultAssembly.AnalyzeOptionParams[AnalyzeOptionParam.CyclesLow] =
                    Int16.Parse(it.Attributes["cycleslow"].Value);
                resultAssembly.AnalyzeOptionParams[AnalyzeOptionParam.CyclesHigh] =
                    Int16.Parse(it.Attributes["cycleshigh"].Value);
                foreach (XmlNode item in paramNode.SelectNodes("cycles/cs"))
                {
                    tempInt1 = int.Parse(item.Attributes["order"].Value);
                    tempLong = long.Parse(item.Attributes["count"].Value);
                    result.Cycles.Add(tempInt1, tempLong);
                }

                log.Info("Loading triangles.");
                foreach (XmlNode item in paramNode.SelectNodes("triangles/tc"))
                {
                    tempInt1 = int.Parse(item.Attributes["trianglecount"].Value);
                    tempInt2 = int.Parse(item.Attributes["count"].Value);
                    result.TriangleCount.Add(tempInt1, tempInt2);
                }

                log.Info("Loading triangle trajectory.");
                it = paramNode.SelectSingleNode("triangletrajectory");
                resultAssembly.AnalyzeOptionParams[AnalyzeOptionParam.TrajectoryMu] =
                    Double.Parse(it.Attributes["mu"].Value);
                resultAssembly.AnalyzeOptionParams[AnalyzeOptionParam.TrajectoryStepCount] =
                    BigInteger.Parse(it.Attributes["stepcount"].Value);
                foreach (XmlNode item in paramNode.SelectNodes("triangletrajectory/tt"))
                {
                    tempInt1 = int.Parse(item.Attributes["time"].Value);
                    tempDouble = double.Parse(item.Attributes["trianglecount"].Value);
                    result.TriangleTrajectory.Add(tempInt1, tempDouble);
                }

                log.Info("Loading motifs.");
                it = paramNode.SelectSingleNode("motives");
                resultAssembly.AnalyzeOptionParams[AnalyzeOptionParam.MotifsLow] =
                    Int16.Parse(it.Attributes["motivslow"].Value);
                resultAssembly.AnalyzeOptionParams[AnalyzeOptionParam.MotifsHigh] =
                    Int16.Parse(it.Attributes["motivshigh"].Value);
                foreach (XmlNode item in paramNode.SelectNodes("motives/mf"))
                {
                    tempInt1 = int.Parse(item.Attributes["id"].Value);
                    tempInt2 = int.Parse(item.Attributes["count"].Value);
                    result.MotivesCount.Add(tempInt1, tempInt2);
                }

                ++instanceNumber;
            }
            return resultAssembly;
        }
        // Чтение body-части из внешнего файла с данным именем.
        private void ReadBody(AnalizeResult res, string fileFullName)
        {
            // Получение пар значений из файлов данного каталога.
            using (StreamReader streamReader =
                new StreamReader(fileFullName, System.Text.Encoding.Default))
            {
                string contents;
                while (!(contents = streamReader.ReadLine()).Contains("Size=")) { }
                res.Size = Int32.Parse(contents.Substring(5));

                while (streamReader.ReadLine() != "-") { }

                while ((contents = streamReader.ReadLine()) != null)
                {
                    string first = "", second = "";
                    int j = 0;
                    while (contents[j] != ' ')
                    {
                        first += contents[j];
                        ++j;
                    }

                    second = contents.Substring(j);

                    // !Исправить! глобальный анализ для усредненного результата.
                    switch (this.result.AnalizeOptions)
                    {
                        case AnalyseOptions.DegreeDistribution:
                            {
                                if (this.realizationsCount == 1)
                                {
                                    res.VertexDegree.Add(int.Parse(first), int.Parse(second));
                                }
                                else
                                {
                                    this.result.VertexDegreeLocal.Add(double.Parse(first),
                                        double.Parse(second));
                                }
                                break;
                            }
                        case AnalyseOptions.ConnSubGraph:
                            {
                                if (this.realizationsCount == 1)
                                {
                                    res.Subgraphs.Add(int.Parse(first), int.Parse(second));
                                }
                                else
                                {
                                    this.result.SubgraphsLocal.Add(double.Parse(first),
                                        double.Parse(second));
                                }
                                break;
                            }
                        case AnalyseOptions.FullSubGraph:
                            {
                                if (this.realizationsCount == 1)
                                {
                                    res.FullSubgraphs.Add(int.Parse(first), int.Parse(second));
                                }
                                else
                                {
                                    // Не реализовано.
                                }
                                break;
                            }
                        case AnalyseOptions.MinPathDist:
                            {
                                if (this.realizationsCount == 1)
                                {
                                    res.DistanceBetweenVertices.Add(int.Parse(first), int.Parse(second));
                                }
                                else
                                {
                                    this.result.DistanceBetweenVerticesLocal.Add(double.Parse(first),
                                        double.Parse(second));
                                }
                                break;
                            }
                        case AnalyseOptions.TriangleCountByVertex:
                            {
                                if (this.realizationsCount == 1)
                                {
                                    res.TriangleCount.Add(int.Parse(first), int.Parse(second));
                                }
                                else
                                {
                                    // Не реализовано.
                                }
                                break;
                            }
                        case AnalyseOptions.ClusteringCoefficient:
                            {
                                if (this.realizationsCount == 1)
                                {
                                    res.Coefficient.Add(double.Parse(first), int.Parse(second));
                                }
                                else
                                {
                                    this.result.CoefficientsLocal.Add(double.Parse(first),
                                        double.Parse(second));
                                }
                                break;
                            }
                        case AnalyseOptions.DistEigenPath:
                            {
                                if (this.realizationsCount == 1)
                                {
                                    res.DistancesBetweenEigenValues.Add(double.Parse(first),
                                        int.Parse(second));
                                }
                                else
                                {
                                    this.result.DistancesBetweenEigenValuesLocal.Add(double.Parse(first),
                                        double.Parse(second));
                                }
                                break;
                            }
                        case AnalyseOptions.Cycles:
                            {
                                if (this.realizationsCount == 1)
                                {
                                    res.Cycles.Add(int.Parse(first), long.Parse(second));
                                }
                                else
                                {
                                    // Не реализовано.
                                }
                                break;
                            }
                        case AnalyseOptions.TriangleTrajectory:
                            {
                                if (this.realizationsCount == 1)
                                {
                                    res.TriangleTrajectory.Add(int.Parse(first), double.Parse(second));
                                }
                                else
                                {
                                    this.result.TriangleTrajectoryLocal.Add(double.Parse(first),
                                        double.Parse(second));
                                }
                                break;
                            }
                        default:
                            throw new SystemException("Not correct Analyze Option.");
                    }
                }
            }
        }
        private void LoadAnalyzeResults(DbConnection conn, ResultAssembly resultAssembly)
        {
            Guid assemblyID = resultAssembly.ID;

            log.Info("Loading data from table CoefficientsLocal.");
            using (DbCommand cmd = conn.CreateCommand())
            {
                string sqlQuery = "SELECT * FROM CoefficientsLocal WHERE AssemblyID=@AssemblyID";
                cmd.CommandText = sqlQuery;
                cmd.CommandType = CommandType.Text;

                DbParameter dpResultsID = provider.CreateParameter();
                dpResultsID.ParameterName = "AssemblyID";
                dpResultsID.Value = assemblyID;
                cmd.Parameters.Add(dpResultsID);

                using (DbDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        resultAssembly.CoefficientsLocal.Add(Convert.ToDouble(dr["Coefficient"]),
                            Convert.ToDouble(dr["Distribution"]));
                    }
                }
            }

            log.Info("Loading data from table VertexDegreeLocal.");
            using (DbCommand cmd = conn.CreateCommand())
            {
                string sqlQuery = "SELECT * FROM VertexDegreeLocal WHERE AssemblyID=@AssemblyID";
                cmd.CommandText = sqlQuery;
                cmd.CommandType = CommandType.Text;

                DbParameter dpResultsID = provider.CreateParameter();
                dpResultsID.ParameterName = "AssemblyID";
                dpResultsID.Value = assemblyID;
                cmd.Parameters.Add(dpResultsID);

                using (DbDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        resultAssembly.VertexDegreeLocal.Add(Convert.ToDouble(dr["Degree"]),
                            (double)dr["Distribution"]);
                    }
                }
            }

            log.Info("Loading data from table ConSubgraphsLocal.");
            using (DbCommand cmd = conn.CreateCommand())
            {
                string sqlQuery = "SELECT * FROM ConSubgraphsLocal WHERE AssemblyID=@AssemblyID";
                cmd.CommandText = sqlQuery;
                cmd.CommandType = CommandType.Text;

                DbParameter dpResultsID = provider.CreateParameter();
                dpResultsID.ParameterName = "AssemblyID";
                dpResultsID.Value = assemblyID;
                cmd.Parameters.Add(dpResultsID);

                using (DbDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        resultAssembly.SubgraphsLocal.Add(Convert.ToDouble(dr["VX"]), (double)dr["Distribution"]);
                    }
                }
            }

            log.Info("Loading data from table VertexDistanceLocal.");
            using (DbCommand cmd = conn.CreateCommand())
            {
                string sqlQuery = "SELECT * FROM VertexDistanceLocal WHERE AssemblyID=@AssemblyID";
                cmd.CommandText = sqlQuery;
                cmd.CommandType = CommandType.Text;

                DbParameter dpResultsID = provider.CreateParameter();
                dpResultsID.ParameterName = "AssemblyID";
                dpResultsID.Value = assemblyID;
                cmd.Parameters.Add(dpResultsID);

                using (DbDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        resultAssembly.DistanceBetweenVerticesLocal.Add(Convert.ToDouble(dr["Distance"]),
                            (double)dr["Distribution"]);
                    }
                }
            }

            log.Info("Loading data from table EigenValuesDistanceLocal.");
            using (DbCommand cmd = conn.CreateCommand())
            {
                string sqlQuery = "SELECT * FROM EigenValuesDistanceLocal WHERE AssemblyID=@AssemblyID";
                cmd.CommandText = sqlQuery;
                cmd.CommandType = CommandType.Text;

                DbParameter dpResultsID = provider.CreateParameter();
                dpResultsID.ParameterName = "AssemblyID";
                dpResultsID.Value = assemblyID;
                cmd.Parameters.Add(dpResultsID);

                using (DbDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        resultAssembly.DistancesBetweenEigenValuesLocal.Add((double)dr["Distance"],
                            (double)dr["Distribution"]);
                    }
                }
            }

            log.Info("Loading data from table TriangleTrajectoryLocal.");
            using (DbCommand cmd = conn.CreateCommand())
            {
                string sqlQuery = "SELECT * FROM TriangleTrajectoryLocal WHERE AssemblyID=@AssemblyID";
                cmd.CommandText = sqlQuery;
                cmd.CommandType = CommandType.Text;

                DbParameter dpResultsID = provider.CreateParameter();
                dpResultsID.ParameterName = "AssemblyID";
                dpResultsID.Value = assemblyID;
                cmd.Parameters.Add(dpResultsID);

                using (DbDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        resultAssembly.TriangleTrajectoryLocal.Add(Convert.ToDouble(dr["Time"]),
                            (double)dr["Distribution"]);
                    }
                }
            }

            log.Info("Loading analyze results data.");
            using (DbCommand mainCmd = conn.CreateCommand())
            {
                string sql = "SELECT ResultsID, NetworkSize FROM AssemblyResults WHERE AssemblyID=@AssemblyID";
                mainCmd.CommandText = sql;
                mainCmd.CommandType = CommandType.Text;

                DbParameter dpID = provider.CreateParameter();
                dpID.ParameterName = "AssemblyID";
                dpID.Value = assemblyID;
                mainCmd.Parameters.Add(dpID);

                List<KeyValuePair<int,int>> resultInfos = new List<KeyValuePair<int,int>>();
                using (DbDataReader mainReader = mainCmd.ExecuteReader())
                {
                    while (mainReader.Read())
                    {
                        resultInfos.Add(new KeyValuePair<int,int>((int)mainReader["ResultsID"],
                            (int)mainReader["NetworkSize"]));
                    }
                }

                foreach (KeyValuePair<int, int> info in resultInfos)
                {
                    AnalizeResult result = new AnalizeResult();
                    result.Size = info.Value;
                    resultAssembly.Results.Add(result);

                    using (DbCommand cmd = conn.CreateCommand())
                    {
                        string sqlQuery = "SELECT * FROM AnalyzeResults WHERE ResultsID=@ResultsID";
                        cmd.CommandText = sqlQuery;
                        cmd.CommandType = CommandType.Text;

                        DbParameter dpResultsID = provider.CreateParameter();
                        dpResultsID.ParameterName = "ResultsID";
                        dpResultsID.Value = info.Key;
                        cmd.Parameters.Add(dpResultsID);

                        using (DbDataReader dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                result.Result.Add((AnalyseOptions)Enum.ToObject(typeof(AnalyseOptions),
                                    dr["AnalyzeOptionID"]), Convert.ToDouble(dr["Result"]));
                            }
                        }
                    }

                    // Coefficient Global
                    using (DbCommand cmd = conn.CreateCommand())
                    {
                        string sqlQuery = "SELECT * FROM CoefficientsGlobal WHERE ResultsID=@ResultsID";
                        cmd.CommandText = sqlQuery;
                        cmd.CommandType = CommandType.Text;

                        DbParameter dpResultsID = provider.CreateParameter();
                        dpResultsID.ParameterName = "ResultsID";
                        dpResultsID.Value = info.Key;
                        cmd.Parameters.Add(dpResultsID);

                        using (DbDataReader dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                result.CoefficientGlobal = (double)dr["AvgCoefficient"];
                            }
                        }
                    }

                    // Degree Global
                    using (DbCommand cmd = conn.CreateCommand())
                    {
                        string sqlQuery = "SELECT * FROM VertexDegreeGlobal WHERE ResultsID=@ResultsID";
                        cmd.CommandText = sqlQuery;
                        cmd.CommandType = CommandType.Text;

                        DbParameter dpResultsID = provider.CreateParameter();
                        dpResultsID.ParameterName = "ResultsID";
                        dpResultsID.Value = info.Key;
                        cmd.Parameters.Add(dpResultsID);

                        using (DbDataReader dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                result.DegreeGlobal = (double)dr["AvgDegree"];
                            }
                        }
                    }

                    log.Info("Loading data from table FullSubgraphs.");
                    using (DbCommand cmd = conn.CreateCommand())
                    {
                        string sqlQuery = "SELECT * FROM FullSubgraphs  WHERE ResultsID=@ResultsID";
                        cmd.CommandText = sqlQuery;
                        cmd.CommandType = CommandType.Text;

                        DbParameter dpResultsID = provider.CreateParameter();
                        dpResultsID.ParameterName = "ResultsID";
                        dpResultsID.Value = info.Key;
                        cmd.Parameters.Add(dpResultsID);

                        using (DbDataReader dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                result.FullSubgraphs.Add(Convert.ToInt32(dr["VX"]), (int)dr["Count"]);
                            }
                        }
                    }

                    log.Info("Loading data from table EigenValue.");    // !проверить!
                    using (DbCommand cmd = conn.CreateCommand())
                    {
                        string sqlQuery = "SELECT * FROM EigenValues  WHERE ResultsID=@ResultsID";
                        cmd.CommandText = sqlQuery;
                        cmd.CommandType = CommandType.Text;

                        DbParameter dpResultsID = provider.CreateParameter();
                        dpResultsID.ParameterName = "ResultsID";
                        dpResultsID.Value = info.Key;
                        cmd.Parameters.Add(dpResultsID);

                        using (DbDataReader dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                result.EigenVector.Add(dr["EigenValue"]);
                            }
                        }
                    }

                    log.Info("Loading data from table Cycles.");    // !проверить!
                    using (DbCommand cmd = conn.CreateCommand())
                    {
                        string sqlQuery = "SELECT * FROM Cycles  WHERE ResultsID=@ResultsID";
                        cmd.CommandText = sqlQuery;
                        cmd.CommandType = CommandType.Text;

                        DbParameter dpResultsID = provider.CreateParameter();
                        dpResultsID.ParameterName = "ResultsID";
                        dpResultsID.Value = info.Key;
                        cmd.Parameters.Add(dpResultsID);

                        using (DbDataReader dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                result.Cycles.Add(Convert.ToInt32(dr["Order"]), (long)dr["Count"]);
                            }
                        }
                    }

                    log.Info("Loading data from table Triangles.");
                    using (DbCommand cmd = conn.CreateCommand())
                    {
                        string sqlQuery = "SELECT * FROM Triangles  WHERE ResultsID=@ResultsID";
                        cmd.CommandText = sqlQuery;
                        cmd.CommandType = CommandType.Text;

                        DbParameter dpResultsID = provider.CreateParameter();
                        dpResultsID.ParameterName = "ResultsID";
                        dpResultsID.Value = info.Key;
                        cmd.Parameters.Add(dpResultsID);

                        using (DbDataReader dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                result.TriangleCount.Add(Convert.ToInt32(dr["TriangleCount"]), (int)dr["Count"]);
                            }
                        }
                    }

                    log.Info("Loading data from table Motifs.");
                    using (DbCommand cmd = conn.CreateCommand())
                    {
                        string sqlQuery = "SELECT * FROM Motifs  WHERE ResultsID=@ResultsID";
                        cmd.CommandText = sqlQuery;
                        cmd.CommandType = CommandType.Text;

                        DbParameter dpResultsID = provider.CreateParameter();
                        dpResultsID.ParameterName = "ResultsID";
                        dpResultsID.Value = info.Key;
                        cmd.Parameters.Add(dpResultsID);

                        using (DbDataReader dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                result.MotivesCount.Add(Convert.ToInt32(dr["ID"]), float.Parse(dr["Count"].ToString()));
                            }
                        }
                    }
                }
            }
        }