100 lines
2.8 KiB
Plaintext
100 lines
2.8 KiB
Plaintext
|
|
|||
|
@{
|
|||
|
Layout = null;
|
|||
|
}
|
|||
|
|
|||
|
<!DOCTYPE html>
|
|||
|
<html>
|
|||
|
<head>
|
|||
|
<meta http-equiv="cache-control" content="max-age=0" />
|
|||
|
<meta http-equiv="cache-control" content="no-cache, no-store, must-revalidate" />
|
|||
|
|
|||
|
<title>This is test page</title>
|
|||
|
</head>
|
|||
|
|
|||
|
<body>
|
|||
|
<h1>Test</h1>
|
|||
|
</body>
|
|||
|
</html>
|
|||
|
|
|||
|
|
|||
|
@*<!DOCTYPE html>
|
|||
|
|
|||
|
<html>
|
|||
|
<head>
|
|||
|
<meta name="viewport" content="width=device-width" />
|
|||
|
<title>This is test page</title>
|
|||
|
</head>
|
|||
|
<body>
|
|||
|
<div>
|
|||
|
<form>
|
|||
|
<label>File</label>
|
|||
|
<br />
|
|||
|
<input id="file-input" name="fileInput" type="file" />
|
|||
|
<button type="button" id="submit">submit</button>
|
|||
|
</form>
|
|||
|
</div>
|
|||
|
</body>
|
|||
|
</html>
|
|||
|
|
|||
|
@Scripts.Render("~/jQuery")
|
|||
|
@Scripts.Render("~/papaParse")
|
|||
|
|
|||
|
<script>
|
|||
|
(function () {
|
|||
|
var Transport = function (lcaId) {
|
|||
|
this.ID = 0;
|
|||
|
this.TransportDate = null,
|
|||
|
this.JourneyNO = null,
|
|||
|
this.StartLocation = null,
|
|||
|
this.EndLocation = null,
|
|||
|
this.TransportDistance = null,
|
|||
|
this.TransportQuantity = null,
|
|||
|
this.TransportWeight = null,
|
|||
|
this.Scalar = null,
|
|||
|
this.KgCO2e = null,
|
|||
|
this.DQI = null,
|
|||
|
this.ParameterID = null,
|
|||
|
this.LCAID = lcaId
|
|||
|
}
|
|||
|
|
|||
|
$('#submit').click(function () {
|
|||
|
var input = $('#file-input')[0];
|
|||
|
file = input.files[0];
|
|||
|
|
|||
|
Papa.parse(file, {
|
|||
|
complete: function (results) {
|
|||
|
var testLcaId = 3;
|
|||
|
var transportList = [];
|
|||
|
var data = results.data;
|
|||
|
for (var key = 1; key < data.length; key++) {
|
|||
|
|
|||
|
if (data[key].length != 10) continue; // data is not intact
|
|||
|
|
|||
|
var transport = new Transport(testLcaId);
|
|||
|
transport.TransportDate = data[key][0];
|
|||
|
transport.JourneyNO = data[key][1];
|
|||
|
transport.StartLocation = data[key][2];
|
|||
|
transport.EndLocation = data[key][3];
|
|||
|
transport.TransportDistance = data[key][4];
|
|||
|
transport.TransportQuantity = data[key][5];
|
|||
|
transport.TransportWeight = data[key][6];
|
|||
|
transport.Scalar = data[key][7];
|
|||
|
transport.KgCO2e = data[key][8];
|
|||
|
transport.DQI = data[key][9];
|
|||
|
|
|||
|
transportList.push(transport);
|
|||
|
}
|
|||
|
|
|||
|
var jsonData = JSON.stringify({ toBeSave: transportList });
|
|||
|
|
|||
|
$.post("../api/Transport/SaveAll", jsonData, function (data) {
|
|||
|
|
|||
|
});
|
|||
|
|
|||
|
console.log(transportList);
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
})();
|
|||
|
</script>*@
|