// Конструктор, которому передается хранилище данных, тип генерации и режим трассировки. public AbstractGraphManager(IResultStorage storage) { DataStorage = storage; Assembly = new ResultAssembly(); GraphTables = new List<GraphTable>(); }
// Чтение подкаталога с данным именем из корневого каталога // Создание соответствующей сборки (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); } }
// Сохранение сборки в xml файле. public override void Save(ResultAssembly assembly) { using (XmlTextWriter writer = new XmlTextWriter(directory + assembly.ID.ToString() + ".xml", Encoding.ASCII)) { // Сохранение общей информации для данной сборки. log.Info("Saving common info of assembly."); writer.Formatting = Formatting.Indented; writer.WriteStartDocument(true); writer.WriteStartElement("assembly"); writer.WriteElementString("id", assembly.ID.ToString()); writer.WriteElementString("name", assembly.Name); writer.WriteElementString("date", DateTime.Now.ToString()); writer.WriteStartElement("graphmodel"); writer.WriteAttributeString("id", GetModelID(assembly.ModelType).ToString()); writer.WriteAttributeString("modelname", assembly.ModelType.Name); writer.WriteEndElement(); // Сохранение значений параметров генерации для данной сборки. log.Info("Saving generation parameters values of assembly."); writer.WriteStartElement("generationparams"); if (assembly.GenerationParams != null) { foreach (GenerationParam genParameter in assembly.GenerationParams.Keys) { writer.WriteStartElement("generationparam"); writer.WriteAttributeString("id", Convert.ToInt32(genParameter).ToString()); writer.WriteAttributeString("parametername", Enum.GetName(typeof(GenerationParam), genParameter)); writer.WriteAttributeString("value", assembly.GenerationParams[genParameter].ToString()); writer.WriteEndElement(); } } writer.WriteEndElement(); // Сохранение результатов анализа для данной сборки. log.Info("Saving analyze results."); writer.WriteStartElement("analyseresults"); int instanceNumber = 1; foreach (AnalizeResult result in assembly.Results) { log.Info("Saving analyze results for instance - " + instanceNumber.ToString() + "."); writer.WriteStartElement("instance"); writer.WriteElementString("size", result.Size.ToString()); // Сохранение результатов анализа для глобальных свойств. log.Info("Saving analyze results for global options."); writer.WriteStartElement("result"); foreach (AnalyseOptions analyseOption in result.Result.Keys) { writer.WriteStartElement("item"); writer.WriteAttributeString("option", analyseOption.ToString()); writer.WriteString(result.Result[analyseOption].ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); log.Info("Saving analyze results for local options."); log.Info("Saving results for vertex degrees."); writer.WriteStartElement("vertexdegree"); foreach (int degree in result.VertexDegree.Keys) { writer.WriteStartElement("vd"); writer.WriteAttributeString("degree", degree.ToString()); writer.WriteAttributeString("count", result.VertexDegree[degree].ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); log.Info("Saving results for clustering coefficients."); writer.WriteStartElement("coefficients"); foreach (double coefficient in result.Coefficient.Keys) { writer.WriteStartElement("coeff"); writer.WriteAttributeString("coefficient", coefficient.ToString()); writer.WriteAttributeString("count", result.Coefficient[coefficient].ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); log.Info("Saving results for connected subgraphs."); writer.WriteStartElement("connsubgraphs"); foreach (int sub in result.Subgraphs.Keys) { writer.WriteStartElement("csub"); writer.WriteAttributeString("vx", sub.ToString()); writer.WriteAttributeString("count", result.Subgraphs[sub].ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); log.Info("Saving results for full subgraphs."); writer.WriteStartElement("fullsubgraphs"); foreach (int sub in result.FullSubgraphs.Keys) { writer.WriteStartElement("fsub"); writer.WriteAttributeString("vx", sub.ToString()); writer.WriteAttributeString("count", result.FullSubgraphs[sub].ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); log.Info("Saving results for distances between vertices."); writer.WriteStartElement("vertexdistance"); foreach (int sub in result.DistanceBetweenVertices.Keys) { writer.WriteStartElement("vd"); writer.WriteAttributeString("distance", sub.ToString()); writer.WriteAttributeString("count", result.DistanceBetweenVertices[sub].ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); log.Info("Saving results for eigen values."); writer.WriteStartElement("eigenvalues"); foreach (double sub in result.EigenVector) { writer.WriteStartElement("ev"); writer.WriteAttributeString("eigenValue", sub.ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); log.Info("Saving results for distances between eigen values."); writer.WriteStartElement("eigenvaluesdistance"); foreach (double sub in result.DistancesBetweenEigenValues.Keys) { writer.WriteStartElement("ev"); writer.WriteAttributeString("distance", sub.ToString()); writer.WriteAttributeString("count", result.DistancesBetweenEigenValues[sub].ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); log.Info("Saving results for cycles."); writer.WriteStartElement("cycles"); writer.WriteAttributeString("cycleslow", assembly.AnalyzeOptionParams[AnalyzeOptionParam.CyclesLow].ToString()); writer.WriteAttributeString("cycleshigh", assembly.AnalyzeOptionParams[AnalyzeOptionParam.CyclesHigh].ToString()); foreach (int sub in result.Cycles.Keys) { writer.WriteStartElement("cs"); writer.WriteAttributeString("order", sub.ToString()); writer.WriteAttributeString("count", result.Cycles[sub].ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); log.Info("Saving results for triangles."); writer.WriteStartElement("triangles"); foreach (int count in result.TriangleCount.Keys) { writer.WriteStartElement("tc"); writer.WriteAttributeString("trianglecount", count.ToString()); writer.WriteAttributeString("count", result.TriangleCount[count].ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); log.Info("Saving results for triangle trajectory."); writer.WriteStartElement("triangletrajectory"); writer.WriteAttributeString("mu", assembly.AnalyzeOptionParams[AnalyzeOptionParam.TrajectoryMu].ToString()); writer.WriteAttributeString("stepcount", assembly.AnalyzeOptionParams[AnalyzeOptionParam.TrajectoryStepCount].ToString()); foreach (int count in result.TriangleTrajectory.Keys) { writer.WriteStartElement("tt"); writer.WriteAttributeString("time", count.ToString()); writer.WriteAttributeString("trianglecount", result.TriangleTrajectory[count].ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); log.Info("Saving results for motivs."); writer.WriteStartElement("motives"); writer.WriteAttributeString("motivslow", assembly.AnalyzeOptionParams[AnalyzeOptionParam.MotifsLow].ToString()); writer.WriteAttributeString("motivshigh", assembly.AnalyzeOptionParams[AnalyzeOptionParam.MotifsHigh].ToString()); foreach (int sub in result.MotivesCount.Keys) { writer.WriteStartElement("mf"); writer.WriteAttributeString("id", sub.ToString()); writer.WriteAttributeString("count", result.MotivesCount[sub].ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndElement(); ++instanceNumber; } writer.WriteEndElement(); writer.WriteEndElement(); } }
// Загрузка всех сборок. public override List<ResultAssembly> LoadAllAssemblies() { List<ResultAssembly> assemblies = new List<ResultAssembly>(); ResultAssembly assembly = null; foreach (string file in Directory.GetFiles(directory, "*.xml", SearchOption.TopDirectoryOnly)) { assembly = new ResultAssembly(); assemblies.Add(assembly); using (XmlTextReader reader = new XmlTextReader(file)) { try { reader.WhitespaceHandling = WhitespaceHandling.None; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.Name == "id") { assembly.ID = new Guid(reader.ReadElementString()); } if (reader.Name == "name") { assembly.Name = reader.ReadElementString(); } if (reader.Name == "graphmodel") { reader.MoveToAttribute("modelname"); assembly.ModelName = reader.ReadContentAsString(); break; } // !исправить! } } } catch (SystemException) { continue; } } } return assemblies; }
public AnalyzeEventArgs(ResultAssembly assembly) { Assembly = assembly; }
private void constructGraph(string modelName) { try { XMLResultStorage resultStorage = new XMLResultStorage(""); goldResult = resultStorage.LoadXML(goldenOutPath.Text); } catch (Exception e) { MessageBox.Show(this, "Unable load XML file", e.Message); } switch (modelName) { case "Barabasi-Albert": BAContainer baContainer = new BAContainer(); baContainer.SetMatrix(inputMatrixPath.Text); BAModelTest(baContainer); break; case "ERModel": ERContainer erContainer = new ERContainer(); erContainer.SetMatrix(inputMatrixPath.Text); ERModelTest(erContainer); break; case "Watts-Strogatz": WSContainer wsContainer = new WSContainer(); wsContainer.SetMatrix(inputMatrixPath.Text); WSModelTest(wsContainer); break; default: Console.WriteLine("Default case"); break; } }
// Абстрактный метод для сохранения результатов анализа (сборки) в хранилище данных. public abstract void Save(ResultAssembly assembly);
private void SaveAnalyzeParameters(DbConnection conn, ResultAssembly assembly) { // !исправить! ???? log.Info("Saving analyze option params values in DB."); using (DbCommand cmd = conn.CreateCommand()) { string sqlQuery = "INSERT INTO AnalyzeOptionParamValues(AssemblyID,AnalyzeOptionParamID,Value) " + "VALUES(@AssemblyID,@AnalyzeOptionParamID,@Value)"; cmd.CommandText = sqlQuery; cmd.CommandType = CommandType.Text; DbParameter dpAssemblyID = provider.CreateParameter(); dpAssemblyID.ParameterName = "AssemblyID"; dpAssemblyID.Value = assembly.ID; cmd.Parameters.Add(dpAssemblyID); DbParameter dpGenerationParamID = provider.CreateParameter(); dpGenerationParamID.ParameterName = "AnalyzeOptionParamID"; dpGenerationParamID.Value = 5; cmd.Parameters.Add(dpGenerationParamID); DbParameter dpValue = provider.CreateParameter(); dpValue.ParameterName = "Value"; dpValue.Value = assembly.AnalyzeOptionParams[AnalyzeOptionParam.TrajectoryMu].ToString(); cmd.Parameters.Add(dpValue); cmd.ExecuteNonQuery(); } using (DbCommand cmd = conn.CreateCommand()) { string sqlQuery = "INSERT INTO AnalyzeOptionParamValues(AssemblyID,AnalyzeOptionParamID,Value) " + "VALUES(@AssemblyID,@AnalyzeOptionParamID,@Value)"; cmd.CommandText = sqlQuery; cmd.CommandType = CommandType.Text; DbParameter dpAssemblyID = provider.CreateParameter(); dpAssemblyID.ParameterName = "AssemblyID"; dpAssemblyID.Value = assembly.ID; cmd.Parameters.Add(dpAssemblyID); DbParameter dpGenerationParamID = provider.CreateParameter(); dpGenerationParamID.ParameterName = "AnalyzeOptionParamID"; dpGenerationParamID.Value = 6; cmd.Parameters.Add(dpGenerationParamID); DbParameter dpValue = provider.CreateParameter(); dpValue.ParameterName = "Value"; dpValue.Value = assembly.AnalyzeOptionParams[AnalyzeOptionParam.TrajectoryStepCount].ToString(); cmd.Parameters.Add(dpValue); cmd.ExecuteNonQuery(); } }
// Сохранение сборки в БД. public override void Save(ResultAssembly assembly) { log.Info("Saving analyze results int DB."); log.Info("Openning connection."); using (DbConnection conn = provider.CreateConnection()) { conn.ConnectionString = GetConnectionString(); try { conn.Open(); } catch (Exception) { log.Info("Could not open a connection with DB."); return; } SaveAssembliesTable(conn, assembly); SaveGenerationParameters(conn, assembly); SaveAnalyzeParameters(conn, assembly); SaveAnalyzeResults(conn, assembly); conn.Close(); } }
// Загрузка всех сборок по имени модели (информация из таблицы Assemblies). public override List<ResultAssembly> LoadAssembliesByModel(string modelName) { List<ResultAssembly> results = new List<ResultAssembly>(); using (DbConnection conn = provider.CreateConnection()) { conn.ConnectionString = GetConnectionString(); conn.Open(); ResultAssembly result = null; using (DbCommand cmd = conn.CreateCommand()) { string sqlQuery = "SELECT * FROM Assemblies WHERE ModelID=@ModelID"; cmd.CommandText = sqlQuery; cmd.CommandType = CommandType.Text; DbParameter dpResultsID = provider.CreateParameter(); dpResultsID.ParameterName = "ModelID"; dpResultsID.Value = GetModelID(GetModelType(modelName)); cmd.Parameters.Add(dpResultsID); using (DbDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { result = new ResultAssembly(); results.Add(result); result.ID = (Guid)dr["AssemblyID"]; result.ModelType = GetModelType((int)dr["ModelID"]); result.ModelName = result.ModelType.Name; result.Name = (string)dr["Name"]; } } } conn.Close(); } return results; }
// Загрузка сборки по данному идентификатору сборки. public override ResultAssembly Load(Guid assemblyID) { log.Info("Loading assembly with ID " + assemblyID.ToString() + "."); ResultAssembly resultAssembly = new ResultAssembly(); resultAssembly.ID = assemblyID; log.Info("Openning connection."); using (DbConnection conn = provider.CreateConnection()) { conn.ConnectionString = GetConnectionString(); try { conn.Open(); } catch (Exception) { log.Info("Could not open a connection with DB."); return new ResultAssembly(); } LoadAssemblyInformation(conn, resultAssembly); LoadAnalyzeResults(conn, resultAssembly); conn.Close(); } return resultAssembly; }
private void SaveGenerationParameters(DbConnection conn, ResultAssembly assembly) { log.Info("Saving generation params values in DB."); foreach (GenerationParam genParameter in assembly.GenerationParams.Keys) { using (DbCommand cmd = conn.CreateCommand()) { string sqlQuery = "INSERT INTO GenerationParamValues(AssemblyID,GenerationParamID,Value) " + "VALUES(@AssemblyID,@GenerationParamID,@Value)"; cmd.CommandText = sqlQuery; cmd.CommandType = CommandType.Text; DbParameter dpAssemblyID = provider.CreateParameter(); dpAssemblyID.ParameterName = "AssemblyID"; dpAssemblyID.Value = assembly.ID; cmd.Parameters.Add(dpAssemblyID); DbParameter dpGenerationParamID = provider.CreateParameter(); dpGenerationParamID.ParameterName = "GenerationParamID"; dpGenerationParamID.Value = Convert.ToInt32(genParameter); cmd.Parameters.Add(dpGenerationParamID); DbParameter dpValue = provider.CreateParameter(); dpValue.ParameterName = "Value"; dpValue.Value = assembly.GenerationParams[genParameter].ToString(); cmd.Parameters.Add(dpValue); cmd.ExecuteNonQuery(); } } }
private void SaveAssembliesTable(DbConnection conn, ResultAssembly assembly) { log.Info("Saving data to Assemblies table."); using (DbCommand cmd = conn.CreateCommand()) { string sqlQuery = "INSERT INTO Assemblies(AssemblyID,ModelID,Name,Date)" + "VALUES(@AssemblyID,@ModelID,@Name,getDate())"; cmd.CommandText = sqlQuery; cmd.CommandType = CommandType.Text; DbParameter dpID = provider.CreateParameter(); dpID.ParameterName = "AssemblyID"; dpID.Value = assembly.ID; cmd.Parameters.Add(dpID); DbParameter dpModelID = provider.CreateParameter(); dpModelID.ParameterName = "ModelID"; dpModelID.Value = GetModelID(assembly.ModelType); cmd.Parameters.Add(dpModelID); DbParameter dpName = provider.CreateParameter(); dpName.ParameterName = "Name"; dpName.Value = assembly.Name; cmd.Parameters.Add(dpName); cmd.ExecuteNonQuery(); } }
private void SaveAnalyzeResults(DbConnection conn, ResultAssembly assembly) { log.Info("Saving data to AssemblyResults table."); foreach (AnalizeResult result in assembly.Results) { int resultsID = 0; using (DbCommand cmd = conn.CreateCommand()) { string sqlQuery = "INSERT INTO AssemblyResults(AssemblyID,NetworkSize) VALUES(@AssemblyID,@NetworkSize) " + "SELECT ResultsID FROM AssemblyResults WHERE ResultsID=SCOPE_IDENTITY()"; cmd.CommandText = sqlQuery; cmd.CommandType = CommandType.Text; DbParameter dpAssemblyID = provider.CreateParameter(); dpAssemblyID.ParameterName = "AssemblyID"; dpAssemblyID.Value = assembly.ID; cmd.Parameters.Add(dpAssemblyID); DbParameter dpNetworkSize = provider.CreateParameter(); dpNetworkSize.ParameterName = "NetworkSize"; dpNetworkSize.Value = result.Size; cmd.Parameters.Add(dpNetworkSize); resultsID = (int)cmd.ExecuteScalar(); } log.Info("Saving data to AnalyzeResults table."); foreach (AnalyseOptions analyseOption in result.Result.Keys) { using (DbCommand cmd = conn.CreateCommand()) { string sqlQuery = "INSERT INTO AnalyzeResults(ResultsID,AnalyzeOptionID,Result) " + "VALUES(@ResultsID,@AnalyzeOptionID,@Result)"; cmd.CommandText = sqlQuery; cmd.CommandType = CommandType.Text; DbParameter dpResultsID = provider.CreateParameter(); dpResultsID.ParameterName = "ResultsID"; dpResultsID.Value = resultsID; cmd.Parameters.Add(dpResultsID); DbParameter dpAnalyseOptionID = provider.CreateParameter(); dpAnalyseOptionID.ParameterName = "AnalyzeOptionID"; dpAnalyseOptionID.Value = Convert.ToInt32(analyseOption); cmd.Parameters.Add(dpAnalyseOptionID); DbParameter dpResult = provider.CreateParameter(); dpResult.ParameterName = "Result"; dpResult.Value = result.Result[analyseOption]; cmd.Parameters.Add(dpResult); cmd.ExecuteNonQuery(); } } SqlBulkCopy cp = new SqlBulkCopy(GetConnectionString(), SqlBulkCopyOptions.CheckConstraints); log.Info("Saving data to VertexDegree table."); DataTable commonTable = new DataTable(); commonTable.Columns.Add("ResultsID", typeof(Int32)); commonTable.Columns.Add("Degree", typeof(Int32)); commonTable.Columns.Add("Count", typeof(Int32)); foreach (int degree in result.VertexDegree.Keys) { DataRow r = commonTable.NewRow(); r[0] = resultsID; r[1] = degree; r[2] = result.VertexDegree[degree]; commonTable.Rows.Add(r); } cp.DestinationTableName = "VertexDegree"; cp.WriteToServer(commonTable); log.Info("Saving data to VertexDegreeLocal table."); commonTable.Rows.Clear(); commonTable.Columns.Clear(); commonTable.Columns.Add("AssemblyID", typeof(Guid)); commonTable.Columns.Add("Degree", typeof(Int32)); commonTable.Columns.Add("Distribution", typeof(Double)); foreach (int degree in assembly.VertexDegreeLocal.Keys) { DataRow r = commonTable.NewRow(); r[0] = assembly.ID; r[1] = degree; r[2] = assembly.VertexDegreeLocal[degree]; commonTable.Rows.Add(r); } cp.DestinationTableName = "VertexDegreeLocal"; cp.WriteToServer(commonTable); log.Info("Saving data to Coefficients table."); commonTable.Rows.Clear(); commonTable.Columns.Clear(); commonTable.Columns.Add("ResultsID", typeof(Int32)); commonTable.Columns.Add("Coefficient", typeof(Double)); commonTable.Columns.Add("Count", typeof(Int32)); foreach (double coefficient in result.Coefficient.Keys) { DataRow r = commonTable.NewRow(); r[0] = resultsID; r[1] = coefficient; r[2] = result.Coefficient[coefficient]; commonTable.Rows.Add(r); } cp.DestinationTableName = "Coefficients"; cp.WriteToServer(commonTable); log.Info("Saving data to CoefficientsLocal table."); commonTable.Rows.Clear(); commonTable.Columns.Clear(); commonTable.Columns.Add("AssemblyID", typeof(Guid)); commonTable.Columns.Add("Coefficient", typeof(Double)); commonTable.Columns.Add("Distribution", typeof(Double)); foreach (double coeff in assembly.CoefficientsLocal.Keys) { DataRow r = commonTable.NewRow(); r[0] = assembly.ID; r[1] = coeff; r[2] = assembly.CoefficientsLocal[coeff]; commonTable.Rows.Add(r); } cp.DestinationTableName = "CoefficientsLocal"; cp.WriteToServer(commonTable); log.Info("Saving data to ConSubgraphs table."); commonTable.Rows.Clear(); commonTable.Columns.Clear(); commonTable.Columns.Add("ResultsID", typeof(Int32)); commonTable.Columns.Add("VX", typeof(Int32)); commonTable.Columns.Add("Count", typeof(Int32)); foreach (int subgraph in result.Subgraphs.Keys) { DataRow r = commonTable.NewRow(); r[0] = resultsID; r[1] = subgraph; r[2] = result.Subgraphs[subgraph]; commonTable.Rows.Add(r); } cp.DestinationTableName = "ConSubgraphs"; cp.WriteToServer(commonTable); log.Info("Saving data to ConSubgraphsLocal table."); commonTable.Rows.Clear(); commonTable.Columns.Clear(); commonTable.Columns.Add("AssemblyID", typeof(Guid)); commonTable.Columns.Add("VX", typeof(int)); commonTable.Columns.Add("Distribution", typeof(Double)); foreach (int vx in assembly.SubgraphsLocal.Keys) { DataRow r = commonTable.NewRow(); r[0] = assembly.ID; r[1] = vx; r[2] = assembly.SubgraphsLocal[vx]; commonTable.Rows.Add(r); } cp.DestinationTableName = "ConSubgraphsLocal"; cp.WriteToServer(commonTable); log.Info("Saving data to FullSubgraphs table."); commonTable.Rows.Clear(); commonTable.Columns.Clear(); commonTable.Columns.Add("ResultsID", typeof(Int32)); commonTable.Columns.Add("VX", typeof(Int32)); commonTable.Columns.Add("Count", typeof(Int32)); foreach (int subgraph in result.FullSubgraphs.Keys) { DataRow r = commonTable.NewRow(); r[0] = resultsID; r[1] = subgraph; r[2] = result.FullSubgraphs[subgraph]; commonTable.Rows.Add(r); } cp.DestinationTableName = "FullSubgraphs"; cp.WriteToServer(commonTable); log.Info("Saving data to VertexDistance table."); commonTable.Rows.Clear(); commonTable.Columns.Clear(); commonTable.Columns.Add("ResultsID", typeof(Int32)); commonTable.Columns.Add("Distance", typeof(Int32)); commonTable.Columns.Add("Count", typeof(Int32)); foreach (int dist in result.DistanceBetweenVertices.Keys) { DataRow r = commonTable.NewRow(); r[0] = resultsID; r[1] = dist; r[2] = result.DistanceBetweenVertices[dist]; commonTable.Rows.Add(r); } cp.DestinationTableName = "VertexDistance"; cp.WriteToServer(commonTable); cp.DestinationTableName = "ConSubgraphs"; cp.WriteToServer(commonTable); log.Info("Saving data to VertexDistanceLocal table."); commonTable.Rows.Clear(); commonTable.Columns.Clear(); commonTable.Columns.Add("AssemblyID", typeof(Guid)); commonTable.Columns.Add("Distance", typeof(int)); commonTable.Columns.Add("Distribution", typeof(Double)); foreach (int dist in assembly.DistanceBetweenVerticesLocal.Keys) { DataRow r = commonTable.NewRow(); r[0] = assembly.ID; r[1] = dist; r[2] = assembly.DistanceBetweenVerticesLocal[dist]; commonTable.Rows.Add(r); } cp.DestinationTableName = "VertexDistanceLocal"; cp.WriteToServer(commonTable); log.Info("Saving data to EigenValues table."); commonTable.Rows.Clear(); commonTable.Columns.Clear(); commonTable.Columns.Add("ResultsID", typeof(Int32)); commonTable.Columns.Add("EigenValue", typeof(Double)); foreach (double value in result.EigenVector) { DataRow r = commonTable.NewRow(); r[0] = resultsID; r[1] = value; commonTable.Rows.Add(r); } cp.DestinationTableName = "EigenValues"; cp.WriteToServer(commonTable); log.Info("Saving data to EigenValuesDistance table."); commonTable.Rows.Clear(); commonTable.Columns.Clear(); commonTable.Columns.Add("ResultsID", typeof(Int32)); commonTable.Columns.Add("Distance", typeof(Double)); commonTable.Columns.Add("Count", typeof(Int32)); foreach (double dist in result.DistancesBetweenEigenValues.Keys) { DataRow r = commonTable.NewRow(); r[0] = resultsID; r[1] = dist; r[2] = result.DistancesBetweenEigenValues[dist]; commonTable.Rows.Add(r); } cp.DestinationTableName = "EigenValuesDistance"; cp.WriteToServer(commonTable); log.Info("Saving data to Cycles table."); commonTable.Rows.Clear(); commonTable.Columns.Clear(); commonTable.Columns.Add("ResultsID", typeof(Int32)); commonTable.Columns.Add("Order", typeof(Int32)); commonTable.Columns.Add("Count", typeof(long)); foreach (int order in result.Cycles.Keys) { DataRow r = commonTable.NewRow(); r[0] = resultsID; r[1] = order; r[2] = result.Cycles[order]; commonTable.Rows.Add(r); } log.Info("Saving data to EigenValuesDistanceLocal table."); commonTable.Rows.Clear(); commonTable.Columns.Clear(); commonTable.Columns.Add("AssemblyID", typeof(Guid)); commonTable.Columns.Add("Distance", typeof(Double)); commonTable.Columns.Add("Distribution", typeof(Double)); foreach (double dist in assembly.DistancesBetweenEigenValuesLocal.Keys) { DataRow r = commonTable.NewRow(); r[0] = assembly.ID; r[1] = dist; r[2] = assembly.DistancesBetweenEigenValuesLocal[dist]; commonTable.Rows.Add(r); } cp.DestinationTableName = "EigenValuesDistanceLocal"; cp.WriteToServer(commonTable); cp.DestinationTableName = "Cycles"; cp.WriteToServer(commonTable); log.Info("Saving data to Triangles table."); commonTable.Rows.Clear(); commonTable.Columns.Clear(); commonTable.Columns.Add("ResultsID", typeof(Int32)); commonTable.Columns.Add("TriangleCount", typeof(Int32)); commonTable.Columns.Add("Count", typeof(Int32)); foreach (int tr in result.TriangleCount.Keys) { DataRow r = commonTable.NewRow(); r[0] = resultsID; r[1] = tr; r[2] = result.TriangleCount[tr]; commonTable.Rows.Add(r); } cp.DestinationTableName = "Triangles"; cp.WriteToServer(commonTable); log.Info("Saving data to TriangleTrajectory table."); commonTable.Rows.Clear(); commonTable.Columns.Clear(); commonTable.Columns.Add("ResultsID", typeof(Int32)); commonTable.Columns.Add("Time", typeof(Int32)); commonTable.Columns.Add("TriangleCount", typeof(Double)); foreach (int time in result.TriangleTrajectory.Keys) { DataRow r = commonTable.NewRow(); r[0] = resultsID; r[1] = time; r[2] = result.TriangleTrajectory[time]; commonTable.Rows.Add(r); } cp.DestinationTableName = "TriangleTrajectory"; cp.WriteToServer(commonTable); log.Info("Saving data to TriangleTrajectoryLocal table."); commonTable.Rows.Clear(); commonTable.Columns.Clear(); commonTable.Columns.Add("AssemblyID", typeof(Guid)); commonTable.Columns.Add("Time", typeof(int)); commonTable.Columns.Add("Distribution", typeof(Double)); foreach (int time in assembly.TriangleTrajectoryLocal.Keys) { DataRow r = commonTable.NewRow(); r[0] = assembly.ID; r[1] = time; r[2] = assembly.TriangleTrajectoryLocal[time]; commonTable.Rows.Add(r); } cp.DestinationTableName = "TriangleTrajectoryLocal"; cp.WriteToServer(commonTable); log.Info("Saving data to Motifs table."); commonTable.Rows.Clear(); commonTable.Columns.Clear(); commonTable.Columns.Add("ResultsID", typeof(Int32)); commonTable.Columns.Add("ID", typeof(Int32)); commonTable.Columns.Add("Count", typeof(float)); foreach (int id in result.MotivesCount.Keys) { DataRow r = commonTable.NewRow(); r[0] = resultsID; r[1] = id; r[2] = result.MotivesCount[id]; commonTable.Rows.Add(r); } cp.DestinationTableName = "Motifs"; cp.WriteToServer(commonTable); cp.Close(); } }
// Загрузка сборки по данному идентификатору сборки. 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; }
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())); } } } } } }
private void LoadAssemblyInformation(DbConnection conn, ResultAssembly resultAssembly) { log.Info("Loading data from tables Assemblies, GenerationParamValues, AnalyzeOptionParamValues."); using (DbCommand cmd = conn.CreateCommand()) { string sqlQuery = "SELECT Assemblies.[Name], Assemblies.ModelID, GenerationParamValues.* FROM Assemblies " + "LEFT JOIN GenerationParamValues ON GenerationParamValues.AssemblyID=Assemblies.AssemblyID " + "WHERE Assemblies.AssemblyID=@AssemblyID ORDER BY GenerationParamID"; cmd.CommandText = sqlQuery; cmd.CommandType = CommandType.Text; DbParameter dpID = provider.CreateParameter(); dpID.ParameterName = "AssemblyID"; dpID.Value = resultAssembly.ID; cmd.Parameters.Add(dpID); using (DbDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { resultAssembly.ModelType = GetModelType((int)dr["ModelID"]); resultAssembly.Name = (string)dr["Name"]; GenerationParam param = (GenerationParam)Enum.ToObject(typeof(GenerationParam), (int)dr["GenerationParamID"]); 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(dr["Value"], CultureInfo.InvariantCulture)); } else if (paramInfo.Type.Equals(typeof(Int16))) { resultAssembly.GenerationParams.Add(param, Convert.ToInt16(dr["Value"])); } else if (paramInfo.Type.Equals(typeof(Int32))) { resultAssembly.GenerationParams.Add(param, Convert.ToInt32(dr["Value"])); } else if (paramInfo.Type.Equals(typeof(bool))) { resultAssembly.GenerationParams.Add(param, Convert.ToBoolean(dr["Value"])); } else if (paramInfo.Type.Equals(typeof(String))) { resultAssembly.GenerationParams.Add(param, Convert.ToString(dr["Value"])); } } } sqlQuery = "SELECT Assemblies.[Name],AnalyzeOptionParamValues.* FROM Assemblies " + "LEFT JOIN AnalyzeOptionParamValues ON AnalyzeOptionParamValues.AssemblyID=Assemblies.AssemblyID " + "WHERE Assemblies.AssemblyID=@AssemblyID ORDER BY AnalyzeOptionParamID"; cmd.CommandText = sqlQuery; cmd.CommandType = CommandType.Text; using (DbDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { AnalyzeOptionParam param = (AnalyzeOptionParam)Enum.ToObject(typeof(AnalyzeOptionParam), (int)dr["AnalyzeOptionParamID"]); AnalyzeOptionParamInfo paramInfo = (AnalyzeOptionParamInfo)(param.GetType().GetField(param.ToString()).GetCustomAttributes(typeof(AnalyzeOptionParamInfo), false)[0]); if (paramInfo.Type.Equals(typeof(Double))) { resultAssembly.AnalyzeOptionParams[param] = Convert.ToDouble(dr["Value"], CultureInfo.InvariantCulture); } else if (paramInfo.Type.Equals(typeof(Int16))) { resultAssembly.AnalyzeOptionParams[param] = Convert.ToInt16(dr["Value"]); } else if (paramInfo.Type.Equals(typeof(BigInteger))) { resultAssembly.AnalyzeOptionParams[param] = Convert.ToString(dr["Value"]); } } } } }