Commit e159d2b8 by Jorem Magcawas

remove php codes

parent 2ab0e629
var Dirfiles = <?php $arrFiles = array();
$path = './input';
$iterator = new FilesystemIterator($path);
foreach($iterator as $entry) {
$arrFiles[] = './input/' . $entry-> getFilename();
}
echo json_encode($arrFiles);
?>
"record_no","filename","speed","eoe_timestamp","avg_speed"
"1","worker1_Metrics_20230104.csv","6211.6564417177915","1/4/2023 9:25:39 AM","6211.6564417177915"
<?php
/* Get the name of the uploaded file */
$filename = $_FILES['file']['name'];
/* Choose where to save the uploaded file */
$location = "../../output/".$filename;
/* Save the uploaded file to the local filesystem */
if ( move_uploaded_file($_FILES['file']['tmp_name'], $location) ) {
echo 'Success';
} else {
echo 'Failure';
}
?>
\ No newline at end of file
<?php
/* Get the name of the uploaded file */
$filename = $_FILES['file']['name'];
/* Choose where to save the uploaded file */
$location = "./uploadimg/".$filename;
/* Save the uploaded file to the local filesystem */
if ( move_uploaded_file($_FILES['file']['tmp_name'], $location) ) {
echo 'Success';
} else {
echo 'Failure';
}
?>
\ No newline at end of file
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
<hr>
<address>Apache/2.4.53 (Win64) OpenSSL/1.1.1n PHP/8.1.6 Server at localhost Port 80</address>
</body></html>
<?php
$dir = json_decode($_POST['data'], true)['metrics_dir'];
/* Get the name of the uploaded file */
$filename = $_FILES['file']['name'];
/* Choose where to save the uploaded file */
$location = $dir.$filename;
/* Save the uploaded file to the local filesystem */
if ( move_uploaded_file($_FILES['file']['tmp_name'], $location) ) {
echo 'Success';
} else {
echo 'Failure';
}
?>
\ No newline at end of file
......@@ -118,11 +118,9 @@ public class GDEWebServices {
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/write-mertrics")
public Response writeCSVMetrics(JsonObject jsonObject) {
public Response writeCSVMetrics(JsonObject jsonObject) {
String tempDir = "C:\\Users\\jmagcawas\\git\\web-ui\\WebGde\\WebContent\\metrics\\" + jsonObject.getString("file_name").trim();
File file = new File(tempDir);
//File file = new File(jsonObject.getString("metrics_dir").trim() + jsonObject.getString("filename").trim());
int record_count = 1;
if (!file.exists()) {
try {
......@@ -156,8 +154,7 @@ public class GDEWebServices {
int lastRecordIndex = Integer.parseInt(lastLine[0]);
BigDecimal metric = new BigDecimal(lastLine[2]);//speed
BigDecimal average = new BigDecimal(lastLine[4]);//average speed
float newAvg = ((average.floatValue() * size) + metric.floatValue()) / (size + 1);
System.out.println("newAvg " + newAvg);
float newAvg = ((average.floatValue() * size) + metric.floatValue()) / (size + 1);
FileWriter outputfile = new FileWriter(file,true);
CSVWriter writer = new CSVWriter(outputfile);
String[] data = { Integer.toString(lastRecordIndex + 1), jsonObject.getString("file_name"), jsonObject.get("metrics_rate").toString(), jsonObject.getString("eoe_ts"), String.valueOf(newAvg)};
......
......@@ -7,32 +7,32 @@ import java.io.IOException;
import com.opencsv.CSVWriter;
public class CSVUtil {
public static void writeData(File file) {
try {
// create FileWriter object with file as parameter
FileWriter outputfile = new FileWriter(file);
// create CSVWriter object filewriter object as parameter
CSVWriter writer = new CSVWriter(outputfile);
// adding header to csv
String[] header = { "Name", "Class", "Marks" };
writer.writeNext(header);
// add data to csv
String[] data1 = { "Aman", "10", "620" };
writer.writeNext(data1);
String[] data2 = { "Suraj", "10", "630" };
writer.writeNext(data2);
// closing writer connection
writer.close();
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
// create FileWriter object with file as parameter
FileWriter outputfile = new FileWriter(file);
// create CSVWriter object filewriter object as parameter
CSVWriter writer = new CSVWriter(outputfile);
// adding header to csv
String[] header = { "Name", "Class", "Marks" };
writer.writeNext(header);
// add data to csv
String[] data1 = { "Aman", "10", "620" };
writer.writeNext(data1);
String[] data2 = { "Suraj", "10", "630" };
writer.writeNext(data2);
// closing writer connection
writer.close();
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment