try to serve d3.js directly
This commit is contained in:
parent
6ff8631121
commit
484396086b
|
@ -0,0 +1 @@
|
|||
<%@ WebService Language="C#" CodeBehind="ClusterService.asmx.cs" Class="EHEC_Server.ClusterService" %>
|
|
@ -0,0 +1,34 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -83,6 +83,7 @@
|
|||
<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" />
|
||||
|
@ -164,9 +165,14 @@
|
|||
<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\ClusterOrigin.cs" />
|
||||
<Compile Include="cluster_dependencies\Models\ClusterPatient.cs" />
|
||||
<Compile Include="cluster_dependencies\Models\ClusterResult.cs" />
|
||||
<Compile Include="DatabaseAccess\Doctor.cs" />
|
||||
|
@ -223,7 +229,9 @@
|
|||
<ItemGroup>
|
||||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Connected Services\" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
<link rel="stylesheet" type="text/css" href="cluster_dependencies/alchemy/styles/vendor.css" />
|
||||
<link rel="stylesheet" type="text/css" href="cluster_dependencies/bootstrap/css/bootstrap.css" />
|
||||
<script type="text/javascript" src="cluster_dependencies/jquery/jquery-3.3.1.min.js"></script>
|
||||
<script type="text/javascript" src="~/Scripts/jquery-1.10.2.intellisense.js"></script>
|
||||
<script type="text/javascript" src="cluster_dependencies/lodash/lodash.js"></script>
|
||||
<script type="text/javascript" src="cluster_dependencies/bootstrap/js/bootstrap.bundle.js"></script>
|
||||
<%--<script type="text/javascript" src="cluster_dependencies/d3/d3.min.js"></script>--%>
|
||||
|
@ -18,19 +19,75 @@
|
|||
<script type="text/javascript" src="cluster_dependencies/alchemy/alchemy.js"></script>
|
||||
<%--<script type="text/javascript" src="cluster_dependencies/alchemy/alchemy.min.js"></script>--%>
|
||||
<script type="text/javascript" src="cluster_dependencies/alchemy/scripts/vendor.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<%--diese habe ich versucht nachzustellen:--%>
|
||||
<%--https://codereview.stackexchange.com/questions/3208/making-a-simple-call-to-a-server--%>
|
||||
<%--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">
|
||||
$(function () {
|
||||
$("#myButton").on("click", function (e) {
|
||||
console.log("inside_myButton_onClick");
|
||||
e.preventDefault();
|
||||
var aData= [];
|
||||
aData[0] = $("#ddlSelectYear").val();
|
||||
$("#contentHolder").empty();
|
||||
var jsonData = JSON.stringify({ aData:aData});
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
//getListOfCars is my webmethod
|
||||
url: "ClusterService.asmx.cs",
|
||||
data: jsonData,
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json", // dataType is json format
|
||||
success: OnSuccess,
|
||||
error: OnErrorCall
|
||||
});
|
||||
function OnSuccess(response) {
|
||||
console.log("inside_myButton_onSuccess");
|
||||
console.log(response.d);
|
||||
}
|
||||
function OnErrorCall(response) {
|
||||
console.log("inside_myButton_onErrorCall");
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<form id="form1" runat="server">
|
||||
<div>
|
||||
<h1>EHEC Clusteranalysis</h1>
|
||||
</div>
|
||||
<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
|
||||
ID="Button1"
|
||||
runat="server"
|
||||
Text="First Button"
|
||||
OnClick="Button1_Click"
|
||||
Font-Bold="true"
|
||||
ForeColor="DodgerBlue"
|
||||
Height="45"
|
||||
Width="150"
|
||||
/>--%>
|
||||
</form>
|
||||
<div class="alchemy" id="alchemy"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
//$url = "@C:\Users\Public\Documents\cluster.json"";
|
||||
//$json = file_get_contents($url);
|
||||
//$data = json_decode($json);
|
||||
var config = {
|
||||
dataSource: 'cluster_dependencies/alchemy/testdata/contrib.json',
|
||||
dataSource: "C:\Users\Public\Documents\cluster.json",
|
||||
forceLocked: true,
|
||||
graphHeight: function(){ return 800; },
|
||||
graphWidth: function(){ return 800; },
|
||||
|
|
|
@ -13,5 +13,11 @@ namespace EHEC_Server
|
|||
{
|
||||
|
||||
}
|
||||
//protected void Button1_Click(object sender, EventArgs e)
|
||||
//{
|
||||
// ClusterConverter cc = new ClusterConverter();
|
||||
// cc.WriteJson();
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
|
@ -3,20 +3,29 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Web;
|
||||
using EHEC_Server;
|
||||
using System.Web.Script.Serialization;
|
||||
|
||||
namespace EHEC_Server
|
||||
{
|
||||
public class ClusterConverter
|
||||
{
|
||||
public void WriteJson()
|
||||
public string WriteJson()
|
||||
{
|
||||
ClusterPatient p = new ClusterPatient();
|
||||
List<ClusterPatient> clusterPatientsList = new List<ClusterPatient>();
|
||||
clusterPatientsList = p.GetClusterPatients();
|
||||
//clusterPatient =
|
||||
|
||||
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\novski\Desktop\cluster.json", json);
|
||||
System.IO.File.WriteAllText(@"C:\Users\Public\Documents\cluster.json", json);
|
||||
return json;
|
||||
}
|
||||
private List<ClusterPatient> GetCluster()
|
||||
{
|
||||
|
|
|
@ -32,13 +32,14 @@ namespace EHEC_Server
|
|||
//// For parsing user defined class object
|
||||
//// To get all properties of object
|
||||
//// and then store object properties and their value in dictionary container
|
||||
var objectDataContainer = obj.GetType();
|
||||
var objectDataContainer1 = objectDataContainer.GetProperties();
|
||||
var objectDataContainer2 = objectDataContainer1.ToDictionary(i => i.Name, i => i.GetValue(obj));
|
||||
var objectDataContainer = obj.GetType().GetProperties().ToDictionary(
|
||||
i => i.Name,
|
||||
i => i.GetValue(obj)
|
||||
);
|
||||
|
||||
StringBuilder jsonfile = new StringBuilder();
|
||||
jsonfile.Append("{");
|
||||
foreach (var data in objectDataContainer2)
|
||||
foreach (var data in objectDataContainer)
|
||||
{
|
||||
jsonfile.Append($"\"{data.Key}\":{Serialize(data.Value)},");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace EHEC_Server
|
||||
{
|
||||
/// <summary>
|
||||
/// This clas converts the object from db model to the needs of Json
|
||||
/// conversion for Clusteranalysis.
|
||||
/// </summary>
|
||||
public class ClusterOrigin
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,22 +5,23 @@ using System.Web;
|
|||
|
||||
namespace EHEC_Server
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// This clas converts the object from db model to the needs of Json
|
||||
/// conversion for Clusteranalysis.
|
||||
/// </summary>
|
||||
public class ClusterPatient
|
||||
{
|
||||
private int Id { get; set; }
|
||||
private string Name { get; set; }
|
||||
private 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>();
|
||||
|
||||
List<ClusterPatient> clusterPatients = new List<ClusterPatient>();
|
||||
foreach (Patient element in patients)
|
||||
{
|
||||
ClusterPatient clusterPatient = new ClusterPatient
|
||||
|
@ -29,12 +30,9 @@ namespace EHEC_Server
|
|||
Nodetype = "patient",
|
||||
Name = element.FirstName + " " + element.LastName
|
||||
};
|
||||
ClusterPatients.Add(clusterPatient);
|
||||
clusterPatients.Add(clusterPatient);
|
||||
}
|
||||
return ClusterPatients;
|
||||
return clusterPatients;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -5,18 +5,34 @@ using System.Web;
|
|||
|
||||
namespace EHEC_Server
|
||||
{
|
||||
/// <summary>
|
||||
/// This clas converts the object from db model to the needs of Json
|
||||
/// conversion for Clusteranalysis.
|
||||
/// </summary>
|
||||
public class ClusterResult
|
||||
{
|
||||
public List<Result> result = new List<Result>();
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Nodetype { get; set; }
|
||||
|
||||
public ClusterResult() { }
|
||||
public ClusterResult(int id, string name)
|
||||
public List<ClusterResult> GetClusterResults()
|
||||
{
|
||||
Id = id;
|
||||
Name = name;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue