refactoring clusterjson

This commit is contained in:
Ivan Hörler 2018-07-23 14:46:41 +02:00
parent 484396086b
commit cff5a09e01
13 changed files with 289 additions and 146 deletions

View File

@ -1 +0,0 @@
<%@ WebService Language="C#" CodeBehind="ClusterService.asmx.cs" Class="EHEC_Server.ClusterService" %>

View File

@ -1,34 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using System.Web.Script.Serialization;
namespace EHEC_Server
{
/// <summary>
/// Summary description for ClusterService
/// </summary>
[WebService(Namespace = "http://localhost:50200/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class ClusterService : System.Web.Services.WebService
{
[WebMethod]
//[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public void GetJson(HttpContext context)
{
context.Response.ContentType = "application/json";
ClusterConverter cc = new ClusterConverter();
var json = cc.WriteJson();
JavaScriptSerializer js = new JavaScriptSerializer();
context.Response.Write(js.Serialize(json));
//return new JavaScriptSerializer().Serialize(json);
}
}
}

View File

@ -83,7 +83,6 @@
<Generator>EntityModelCodeGenerator</Generator>
<LastGenOutput>Model.Designer.cs</LastGenOutput>
</EntityDeploy>
<Content Include="ClusterService.asmx" />
<Content Include="cluster_dependencies\alchemy\alchemy-white.css" />
<Content Include="cluster_dependencies\alchemy\alchemy.css" />
<Content Include="cluster_dependencies\alchemy\alchemy.js" />
@ -165,16 +164,15 @@
<Compile Include="cluster.aspx.designer.cs">
<DependentUpon>cluster.aspx</DependentUpon>
</Compile>
<Compile Include="ClusterService.asmx.cs">
<DependentUpon>ClusterService.asmx</DependentUpon>
<SubType>Component</SubType>
</Compile>
<Compile Include="cluster_dependencies\ClusterConverter.cs" />
<Compile Include="cluster_dependencies\JsonConverter.cs" />
<Compile Include="cluster_dependencies\JsonModel.cs" />
<Compile Include="cluster_dependencies\Models\Cluster.cs" />
<Compile Include="cluster_dependencies\Models\ClusterOrigin.cs" />
<Compile Include="cluster_dependencies\Models\ClusterPatient.cs" />
<Compile Include="cluster_dependencies\Models\ClusterResult.cs" />
<Compile Include="cluster_dependencies\Models\Edges.cs" />
<Compile Include="cluster_dependencies\Models\Nodes.cs" />
<Compile Include="DatabaseAccess\Doctor.cs" />
<Compile Include="DatabaseAccess\Origin.cs" />
<Compile Include="DatabaseAccess\Origin_Exam.cs" />

View File

@ -27,7 +27,7 @@
<%--https://stackoverflow.com/questions/8703317/troubleshooting-jquery-ajax-call-using-generic-handler-in-asp-net--%>
<%--https://codepedia.info/jquery-ajax-json-example-asp-net-sql-database/--%>
<script type="text/javascript">
<%-- <script type="text/javascript">
$(function () {
$("#myButton").on("click", function (e) {
console.log("inside_myButton_onClick");
@ -56,20 +56,20 @@
}
});
});
</script>
</script>--%>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>EHEC Clusteranalysis</h1>
</div>
<select id="ddlSelectYear">
<%--<select id="ddlSelectYear">
<option>2014</option>
<option>2015</option>
</select>
<button id="myButton" style="color:DodgerBlue;font-weight:bold;height:45px;width:150px;">Get Cluster Data</button>
<div id="contentHolder"></div>
<%-- <asp:Button
<div id="contentHolder"></div>--%>
<asp:Button
ID="Button1"
runat="server"
Text="First Button"
@ -78,7 +78,7 @@
ForeColor="DodgerBlue"
Height="45"
Width="150"
/>--%>
/>
</form>
<div class="alchemy" id="alchemy"></div>
@ -87,16 +87,16 @@
//$json = file_get_contents($url);
//$data = json_decode($json);
var config = {
dataSource: "C:\Users\Public\Documents\cluster.json",
dataSource: "<%=Clusterdata%>",
forceLocked: true,
graphHeight: function(){ return 800; },
graphWidth: function(){ return 800; },
linkDistance: function(){ return 50; },
nodeTypes: {
"node_type": [
"Maintainer",
"Contributor",
"none"
"Nodetype": [
"Patient",
"Result",
"Origin"
]
},
nodeMouseOver: 'fun_fact',

View File

@ -9,15 +9,16 @@ namespace EHEC_Server
{
public partial class cluster : System.Web.UI.Page
{
protected string Clusterdata { get; set; }
ClusterConverter cc = new ClusterConverter();
protected void Page_Load(object sender, EventArgs e)
{
Clusterdata = cc.WriteJson();
}
//protected void Button1_Click(object sender, EventArgs e)
//{
// ClusterConverter cc = new ClusterConverter();
// cc.WriteJson();
//}
protected void Button1_Click(object sender, EventArgs e)
{
Clusterdata = cc.WriteJson();
}
}
}

View File

@ -20,5 +20,14 @@ namespace EHEC_Server {
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
/// <summary>
/// Button1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Button Button1;
}
}

View File

@ -9,32 +9,38 @@ namespace EHEC_Server
{
public class ClusterConverter
{
protected string Json { get; set; }
public string WriteJson()
{
ClusterPatient p = new ClusterPatient();
List<ClusterPatient> clusterPatientsList = new List<ClusterPatient>();
clusterPatientsList = p.GetClusterPatients();
ClusterResult r = new ClusterResult();
List<ClusterResult> clusterResultsList = new List<ClusterResult>();
clusterResultsList = r.GetClusterResults();
//var json = JsonConverter.Serialize(clusterPatientsList);
//string path = System.Reflection.Assembly.GetExecutingAssembly().Location;
//string fileName = Path.Combine(path, "ClusterData.json");
//System.IO.File.WriteAllText(fileName, json);
var json = JsonConverter.Serialize(clusterPatientsList);
System.IO.File.WriteAllText(@"C:\Users\Public\Documents\cluster.json", json);
return json;
var Json = JsonConverter.Serialize(GetCluster());
//ClusterPatient p = new ClusterPatient();
//List<ClusterPatient> clusterPatientsList = new List<ClusterPatient>();
//clusterPatientsList = p.GetClusterPatients();
//ClusterResult r = new ClusterResult();
//List<ClusterResult> clusterResultsList = new List<ClusterResult>();
//clusterResultsList = r.GetClusterResults();
System.IO.File.WriteAllText(@"C: \Users\novski\Desktop\cluster.json", Json);
return Json; //= JsonConverter.Serialize(clusterPatientsList);
}
private List<ClusterPatient> GetCluster()
private Cluster GetCluster()
{
return new List<ClusterPatient>();
return new Cluster
{
Comment = "some comment",
Nodes = new List<Node>
{
new Node
{
Node get = new Node();
List <Node> xs = new List<Node>();
}
Nodes.add(getClusterPatients()) // irrgend sowas...
}
};
}
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace EHEC_Server
{
public class Cluster
{
public string Comment { get; set; }
public List<Node> Nodes { get; set; }
public List<Edges> Edges { get; set; }
}
}

View File

@ -11,28 +11,28 @@ namespace EHEC_Server
/// </summary>
public class ClusterOrigin
{
public int Id { get; set; }
public string Name { get; set; }
public string Nodetype { get; set; }
//public int Id { get; set; }
//public string Name { get; set; }
//public string Nodetype { get; set; }
public ClusterOrigin() { }
public List<ClusterOrigin> GetClusterOrigins()
{
Origin origin = new Origin();
List<Origin> origins = new List<Origin>();
origins = origin.GetAllOrigins();
List<ClusterOrigin> clusterOrigins = new List<ClusterOrigin>();
foreach (Origin element in origins)
{
ClusterOrigin clusterOrigin = new ClusterOrigin
{
Id = element.OriginId,
Nodetype = "origin",
Name = element.City
};
clusterOrigins.Add(clusterOrigin);
};
return clusterOrigins;
}
//public ClusterOrigin() { }
//public List<ClusterOrigin> GetClusterOrigins()
//{
// Origin origin = new Origin();
// List<Origin> origins = new List<Origin>();
// origins = origin.GetAllOrigins();
// List<ClusterOrigin> clusterOrigins = new List<ClusterOrigin>();
// foreach (Origin element in origins)
// {
// ClusterOrigin clusterOrigin = new ClusterOrigin
// {
// Id = element.OriginId,
// Nodetype = "origin",
// Name = element.City
// };
// clusterOrigins.Add(clusterOrigin);
// };
// return clusterOrigins;
//}
}
}

View File

@ -11,28 +11,28 @@ namespace EHEC_Server
/// </summary>
public class ClusterPatient
{
public int Id { get; set; }
public string Name { get; set; }
public string Nodetype { get; set; }
//public int Id { get; set; }
//public string Name { get; set; }
//public string Nodetype { get; set; }
public ClusterPatient() { }
public List<ClusterPatient> GetClusterPatients()
{
Patient patient = new Patient();
List<Patient> patients = new List<Patient>();
patients = patient.GetAllPatients();
List<ClusterPatient> clusterPatients = new List<ClusterPatient>();
foreach (Patient element in patients)
{
ClusterPatient clusterPatient = new ClusterPatient
{
Id = element.PatientId,
Nodetype = "patient",
Name = element.FirstName + " " + element.LastName
};
clusterPatients.Add(clusterPatient);
}
return clusterPatients;
}
//public ClusterPatient() { }
//public List<ClusterPatient> GetClusterPatients()
//{
// Patient patient = new Patient();
// List<Patient> patients = new List<Patient>();
// patients = patient.GetAllPatients();
// List<ClusterPatient> clusterPatients = new List<ClusterPatient>();
// foreach (Patient element in patients)
// {
// ClusterPatient clusterPatient = new ClusterPatient
// {
// Id = element.PatientId,
// Nodetype = "patient",
// Name = element.FirstName + " " + element.LastName
// };
// clusterPatients.Add(clusterPatient);
// }
// return clusterPatients;
//}
}
}

View File

@ -11,28 +11,28 @@ namespace EHEC_Server
/// </summary>
public class ClusterResult
{
public int Id { get; set; }
public string Name { get; set; }
public string Nodetype { get; set; }
//public int Id { get; set; }
//public string Name { get; set; }
//public string Nodetype { get; set; }
public ClusterResult() { }
public List<ClusterResult> GetClusterResults()
{
Result result = new Result();
List<Result> results = new List<Result>();
results = result.GetAllResults();
List<ClusterResult> clusterResults = new List<ClusterResult>();
foreach (Result element in results)
{
ClusterResult clusterResult = new ClusterResult
{
Id = element.ResultId,
Nodetype = "result",
Name = element.Name
};
clusterResults.Add(clusterResult);
};
return clusterResults;
}
//public ClusterResult() { }
//public List<ClusterResult> GetClusterResults()
//{
// Result result = new Result();
// List<Result> results = new List<Result>();
// results = result.GetAllResults();
// List<ClusterResult> clusterResults = new List<ClusterResult>();
// foreach (Result element in results)
// {
// ClusterResult clusterResult = new ClusterResult
// {
// Id = element.ResultId,
// Nodetype = "result",
// Name = element.Name
// };
// clusterResults.Add(clusterResult);
// };
// return clusterResults;
//}
}
}

View File

@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace EHEC_Server
{
public class Edges
{
public int Source { get; set; }
public int Target { get; set; }
public string Edgetype { get; set; }
public Edges() { }
public List<Edges> GetClusterRelationsPatientsOrigins()
{
Exam exam = new Exam();
List<Exam> exams = new List<Exam>();
exams = exam.GetAllExams();
List<Edges> clusterEdges = new List<Edges>();
foreach (Exam element in exams)
{
Edges clusterEdge = new Edges
{
Edgetype = "Angesteckt in ",
Source = element.PatientId,
Target = element.DoctorId ///for tests !!!!!!!!!!!!!!!! correct it to Origin id somehow!!!!!!!!
};
clusterEdges.Add(clusterEdge);
}
return clusterEdges;
}
public List<Edges> GetClusterRelationsPatientsResults()
{
Exam exam = new Exam();
List<Exam> exams = new List<Exam>();
exams = exam.GetAllExams();
List<Edges> clusterEdges = new List<Edges>();
foreach (Exam element in exams)
{
Edges clusterEdge = new Edges
{
Edgetype = "Wurde Angesteckt mit ",
Source = element.PatientId,
Target = element.ResultId
};
clusterEdges.Add(clusterEdge);
};
return clusterEdges;
}
//public List<Edges> GetClusterRelationOrigin()
//{
// Origin origin = new Origin();
// List<Origin> origins = new List<Origin>();
// origins = origin.GetAllOrigins();
// List<Edges> clusterOrigins = new List<Edges>();
// foreach (Origin element in origins)
// {
// Nodes clusterOrigin = new Nodes
// {
// Nodetype = "Angesteckt in ",
// Source = element.OriginId,
// Target = element.City
// };
// clusterOrigins.Add(clusterOrigin);
// };
// return clusterOrigins;
//}
}
}

View File

@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace EHEC_Server
{
public class Node
{
public int Id { get; set; }
public string Name { get; set; }
public string Nodetype { get; set; }
public Node() { }
public List<Node> GetNodes()
{
List<Node> X = new List<Node>();
X.AddRange(GetClusterOrigins());
X.AddRange(GetClusterPatients());
X.AddRange(GetClusterResults());
return X;
}
public List<Node> GetClusterOrigins()
{
Origin origin = new Origin();
List<Origin> origins = new List<Origin>();
origins = origin.GetAllOrigins();
List<Node> clusterOrigins = new List<Node>();
foreach (Origin element in origins)
{
Node clusterOrigin = new Node
{
Id = element.OriginId,
Nodetype = "origin",
Name = element.City
};
clusterOrigins.Add(clusterOrigin);
};
return clusterOrigins;
}
public List<Node> GetClusterPatients()
{
Patient patient = new Patient();
List<Patient> patients = new List<Patient>();
patients = patient.GetAllPatients();
List<Node> clusterPatients = new List<Node>();
foreach (Patient element in patients)
{
Node clusterPatient = new Node
{
Id = element.PatientId,
Nodetype = "patient",
Name = element.FirstName + " " + element.LastName
};
clusterPatients.Add(clusterPatient);
}
return clusterPatients;
}
public List<Node> GetClusterResults()
{
Result result = new Result();
List<Result> results = new List<Result>();
results = result.GetAllResults();
List<Node> clusterResults = new List<Node>();
foreach (Result element in results)
{
Node clusterResult = new Node
{
Id = element.ResultId,
Nodetype = "result",
Name = element.Name
};
clusterResults.Add(clusterResult);
};
return clusterResults;
}
}
}