|
@@ -44,8 +44,9 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
int selectedPublish = -1;
|
|
|
public MainWindow()
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
InitializeComponent();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void UxSubmitBtn_Click(object sender, RoutedEventArgs e)
|
|
@@ -202,7 +203,7 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
connectorId = Convert.ToInt32(uxConnectorIdTb.Text),
|
|
|
csChargingProfiles = new csChargingProfiles()
|
|
|
{
|
|
|
- chargingProfileId = Convert.ToInt32(DateTime.Now.ToString("yyMMddHHmm")),
|
|
|
+ chargingProfileId = Convert.ToInt32(DateTime.Now.ToUniversalTime().ToString("yyMMddHHmm")),
|
|
|
chargingProfileKind = ChargingProfileKindType.Absolute,
|
|
|
chargingProfilePurpose = isDefault ? ChargingProfilePurposeType.TxDefaultProfile : ChargingProfilePurposeType.TxProfile,
|
|
|
recurrencyKind = RecurrencyKindType.Daily,
|
|
@@ -212,7 +213,7 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
chargingRateUnit = ChargingRateUnitType.A,
|
|
|
duration = 300,
|
|
|
minChargingRate = 0,
|
|
|
- startSchedule = DateTime.Now.Date,
|
|
|
+ startSchedule = DateTime.Now.ToUniversalTime().Date,
|
|
|
chargingSchedulePeriod = new List<ChargingSchedulePeriod>()
|
|
|
{
|
|
|
new ChargingSchedulePeriod()
|
|
@@ -300,23 +301,45 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
|
|
|
private void ReserveNow()
|
|
|
{
|
|
|
-
|
|
|
+ bool isError = false;
|
|
|
+ DateTime expiryTime = DateTime.Now;
|
|
|
try
|
|
|
{
|
|
|
-
|
|
|
- var uuid = Guid.NewGuid().ToString();
|
|
|
- var request = new ReserveNowRequest()
|
|
|
+ try
|
|
|
{
|
|
|
- connectorId = Convert.ToInt32(uxConnectorIdTb.Text),
|
|
|
- expiryDate = DateTime.Now.AddDays(5),
|
|
|
- idTag = uxIdTagTb.Text,
|
|
|
- parentIdTag = "PTAG",
|
|
|
- reservationId = Convert.ToInt32(DateTime.Now.ToString("yyMMddHHmm")),
|
|
|
+ expiryTime = Convert.ToDateTime(uxExpiryTimeTb.Text);
|
|
|
+ if(expiryTime <DateTime.Now.AddSeconds(60))
|
|
|
+ {
|
|
|
+ isError = true;
|
|
|
+ uxMsgTb.Text = string.Format("ExpiryTime is too close or too early to the current time (60 seconds).");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ if (ex is FormatException)
|
|
|
+ {
|
|
|
+ isError = true;
|
|
|
+ uxMsgTb.Text = string.Format("ExpiryTime's Format is wrong Example:{0}",DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isError)
|
|
|
+ {
|
|
|
+ var uuid = Guid.NewGuid().ToString();
|
|
|
+ var request = new ReserveNowRequest()
|
|
|
+ {
|
|
|
+ connectorId = Convert.ToInt32(uxConnectorIdTb.Text),
|
|
|
+ expiryDate = expiryTime.ToUniversalTime(),
|
|
|
+ idTag = uxIdTagTb.Text,
|
|
|
+ parentIdTag = "PTAG",
|
|
|
+ reservationId = Convert.ToInt32(expiryTime.ToUniversalTime().ToString("yyMMddHHmm")),
|
|
|
|
|
|
- };
|
|
|
+ };
|
|
|
+
|
|
|
+ WritetoDB(uuid, request);
|
|
|
+ uxMsgTb.Text = string.Format("UUID:{0}", uuid);
|
|
|
+ }
|
|
|
|
|
|
- WritetoDB(uuid, request);
|
|
|
- uxMsgTb.Text = string.Format("UUID:{0}", uuid);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
@@ -332,12 +355,12 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
var uuid = Guid.NewGuid().ToString();
|
|
|
var request = new GetDiagnosticsRequest()
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
location = new Uri("ftp://phihong:y42j%2f4cj84@test.evsocket.phihong.com.cn/"),
|
|
|
retries = 1,
|
|
|
retryInterval = 30,
|
|
|
- startTime = DateTime.Now.AddHours(-1),
|
|
|
- stopTime = DateTime.Now
|
|
|
+ startTime = DateTime.Now.AddHours(-1).ToUniversalTime(),
|
|
|
+ stopTime = DateTime.Now.ToUniversalTime()
|
|
|
|
|
|
|
|
|
};
|
|
@@ -381,18 +404,18 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
var uuid = Guid.NewGuid().ToString();
|
|
|
var request = new SendLocalListRequest()
|
|
|
{
|
|
|
- listVersion = Convert.ToInt32(DateTime.Now.ToString("yyMMddHHmm")),
|
|
|
+ listVersion = Convert.ToInt32(DateTime.Now.ToUniversalTime().ToString("yyMMddHHmm")),
|
|
|
updateType = isFull ? UpdateType.Full : UpdateType.Differential,
|
|
|
localAuthorizationList = new List<AuthorizationData>()
|
|
|
{
|
|
|
new AuthorizationData()
|
|
|
{
|
|
|
|
|
|
- idTagInfo=new IdTagInfo(){ expiryDate=DateTime.Now.AddDays(3), status= AuthorizationStatus.Accepted},
|
|
|
+ idTagInfo=new IdTagInfo(){ expiryDate=DateTime.Now.ToUniversalTime().AddDays(3), status= AuthorizationStatus.Accepted},
|
|
|
idTag="123"
|
|
|
}, new AuthorizationData()
|
|
|
{
|
|
|
- idTagInfo=new IdTagInfo(){ expiryDate=DateTime.Now.AddDays(3), status= AuthorizationStatus.Expired},
|
|
|
+ idTagInfo=new IdTagInfo(){ expiryDate=DateTime.Now.ToUniversalTime().AddDays(3), status= AuthorizationStatus.Expired},
|
|
|
idTag="456"
|
|
|
}
|
|
|
}
|
|
@@ -473,7 +496,7 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
{
|
|
|
request.chargingProfile = new csChargingProfiles()
|
|
|
{
|
|
|
- chargingProfileId = Convert.ToInt32(DateTime.Now.ToString("yyMMddHHmm")),
|
|
|
+ chargingProfileId = Convert.ToInt32(DateTime.Now.ToUniversalTime().ToString("yyMMddHHmm")),
|
|
|
chargingProfileKind = ChargingProfileKindType.Absolute,
|
|
|
chargingProfilePurpose = ChargingProfilePurposeType.TxProfile,
|
|
|
recurrencyKind = RecurrencyKindType.Daily,
|
|
@@ -483,7 +506,7 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
chargingRateUnit = ChargingRateUnitType.A,
|
|
|
duration = 300,
|
|
|
minChargingRate = 0,
|
|
|
- startSchedule = DateTime.Now.Date,
|
|
|
+ startSchedule = DateTime.Now.ToUniversalTime().Date,
|
|
|
chargingSchedulePeriod = new List<ChargingSchedulePeriod>()
|
|
|
{
|
|
|
new ChargingSchedulePeriod()
|
|
@@ -698,7 +721,7 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
{
|
|
|
db.MachineOperateRecord.Add(new MachineOperateRecord()
|
|
|
{
|
|
|
- CreatedOn = DateTime.Now,
|
|
|
+ CreatedOn = DateTime.Now.ToUniversalTime(),
|
|
|
ChargeBoxId = uxChargeBoxIdTb.Text,
|
|
|
SerialNo = uuid,
|
|
|
RequestContent = JsonConvert.SerializeObject(request, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.None }),
|
|
@@ -712,7 +735,7 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
{
|
|
|
ChargeBoxId = uxChargeBoxIdTb.Text,
|
|
|
CreatedBy = "TestTool",
|
|
|
- CreatedOn = DateTime.Now,
|
|
|
+ CreatedOn = DateTime.Now.ToUniversalTime(),
|
|
|
OutAction = request.Action.ToString(),
|
|
|
OutRequest = JsonConvert.SerializeObject(request, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.None }),
|
|
|
SerialNo = uuid,
|
|
@@ -744,6 +767,7 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
}
|
|
|
|
|
|
FileInfo f = new FileInfo(uxUploadFileTb.Text);
|
|
|
+
|
|
|
int size = (int)f.Length;
|
|
|
string md5 = "";
|
|
|
string filePreUrl = ConfigurationManager.AppSettings["FilePreUrl"];
|
|
@@ -756,16 +780,12 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
var _md5 = MD5.Create();
|
|
|
var hash = _md5.ComputeHash(fileStream);
|
|
|
md5 = BitConverter.ToString(hash).Replace("-", String.Empty).ToLowerInvariant();
|
|
|
- //using (Stream requestStream = client.OpenWrite(new Uri(@filePreUrl + "UploadFiles/Fw/" + ufObj.FileName), "POST"))
|
|
|
- //{
|
|
|
|
|
|
- // fileStream.CopyTo(requestStream);
|
|
|
- //}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
UploadFile ufObj = new UploadFile();
|
|
|
- ufObj.CreatedOn = DateTime.Now;
|
|
|
+ ufObj.CreatedOn = DateTime.Now.ToUniversalTime();
|
|
|
ufObj.FileExtensionName = System.IO.Path.GetExtension(uxUploadFileTb.Text);
|
|
|
ufObj.Id = Guid.NewGuid();
|
|
|
ufObj.FileName = md5 + ufObj.FileExtensionName;
|
|
@@ -774,15 +794,16 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
ufObj.FileMD5 = md5;
|
|
|
ufObj.CustomerId = new Guid("8456AED9-6DD9-4BF3-A94C-9F5DCB9506F7");
|
|
|
ufObj.OriginName = System.IO.Path.GetFileName(uxUploadFileTb.Text);
|
|
|
- ufObj.FileUrl = new Uri(Properties.Settings.Default.FilePreUrl + ufObj.FilePath.Replace("~/","")).ToString();
|
|
|
+ ufObj.FileUrl = new Uri(Properties.Settings.Default.FilePreUrl + ufObj.FilePath.Replace("~/", "")).ToString();
|
|
|
ufObj.IsOnline = true;
|
|
|
|
|
|
+
|
|
|
using (var db = new MainDBContext())
|
|
|
{
|
|
|
db.UploadFile.Add(ufObj);
|
|
|
db.SaveChanges();
|
|
|
var pvQry = db.PublishVersion.Where(x => x.CustomerMachineComponentId == 1).OrderByDescending(c => c.Version).FirstOrDefault();
|
|
|
- PublishVersion pv = new PublishVersion { CustomerMachineComponentId = 1, CreatedOn = DateTime.Now, Version = 1 };
|
|
|
+ PublishVersion pv = new PublishVersion { CustomerMachineComponentId = 1, CreatedOn = DateTime.Now.ToUniversalTime(), Version = 1 };
|
|
|
if (pvQry != null)
|
|
|
{
|
|
|
pv.Version = pvQry.Version + 1;
|
|
@@ -792,11 +813,80 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
db.SaveChanges();
|
|
|
}
|
|
|
|
|
|
+ FTPClient UploadClient = new FTPClient(@"ftp://test.evsocket.phihong.com.cn", "testocpp", "testocpp");
|
|
|
+ bool uploadResult = UploadClient.FtpUploadBroken(uxUploadFileTb.Text, @"ftp://test.evsocket.phihong.com.cn/" + ufObj.FileName);
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- uxMsgTb.Text = "write to DB ,but you must manaul upload file to server and filename replace with " + ufObj.FileName;
|
|
|
+ uxMsgTb.Text = "Upload File Result :" + (uploadResult ? "Success" : "Fail");
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private void uxFTPUploadBtn_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(uxUploadFileTb.Text))
|
|
|
+ {
|
|
|
+ uxMsgTb.Text = "Please select upload file!";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ FileInfo f = new FileInfo(uxUploadFileTb.Text);
|
|
|
+
|
|
|
+ int size = (int)f.Length;
|
|
|
+ string md5 = "";
|
|
|
+
|
|
|
+ using (WebClient client = new WebClient())
|
|
|
+ {
|
|
|
+ client.UseDefaultCredentials = false;
|
|
|
+ client.Headers.Add("Content-Type", "application/octet-stream");
|
|
|
+ using (Stream fileStream = File.OpenRead(uxUploadFileTb.Text))
|
|
|
+ {
|
|
|
+ var _md5 = MD5.Create();
|
|
|
+ var hash = _md5.ComputeHash(fileStream);
|
|
|
+ md5 = BitConverter.ToString(hash).Replace("-", String.Empty).ToLowerInvariant();
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ UploadFile ufObj = new UploadFile();
|
|
|
+ ufObj.CreatedOn = DateTime.Now.ToUniversalTime();
|
|
|
+ ufObj.FileExtensionName = System.IO.Path.GetExtension(uxUploadFileTb.Text);
|
|
|
+ ufObj.Id = Guid.NewGuid();
|
|
|
+ ufObj.FileName = md5 + ufObj.FileExtensionName;
|
|
|
+ ufObj.FilePath = "~/UploadFiles/Fw/" + ufObj.FileName;
|
|
|
+ ufObj.FileSize = size;
|
|
|
+ ufObj.FileMD5 = md5;
|
|
|
+ ufObj.CustomerId = new Guid("8456AED9-6DD9-4BF3-A94C-9F5DCB9506F7");
|
|
|
+ ufObj.OriginName = System.IO.Path.GetFileName(uxUploadFileTb.Text);
|
|
|
+ ufObj.FileUrl = new Uri(Properties.Settings.Default.FTPFilePreUrl + ufObj.FileName).ToString();
|
|
|
+ ufObj.IsOnline = true;
|
|
|
+
|
|
|
+
|
|
|
+ using (var db = new MainDBContext())
|
|
|
+ {
|
|
|
+ db.UploadFile.Add(ufObj);
|
|
|
+ db.SaveChanges();
|
|
|
+ var pvQry = db.PublishVersion.Where(x => x.CustomerMachineComponentId == 1).OrderByDescending(c => c.Version).FirstOrDefault();
|
|
|
+ PublishVersion pv = new PublishVersion { CustomerMachineComponentId = 1, CreatedOn = DateTime.Now.ToUniversalTime(), Version = 1 };
|
|
|
+ if (pvQry != null)
|
|
|
+ {
|
|
|
+ pv.Version = pvQry.Version + 1;
|
|
|
+ }
|
|
|
+ pv.PublishVersionFiles.Add(new PublishVersionFile() { UploadFileId = ufObj.Id });
|
|
|
+ db.PublishVersion.Add(pv);
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+
|
|
|
+ FTPClient UploadClient = new FTPClient(@"ftp://test.evsocket.phihong.com.cn", "testocpp", "testocpp");
|
|
|
+ bool uploadResult = UploadClient.FtpUploadBroken(uxUploadFileTb.Text, @"ftp://test.evsocket.phihong.com.cn/" + ufObj.FileName);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ uxMsgTb.Text = "Upload File Result :" + (uploadResult ? "Success" : "Fail");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private void uxRefreshBtn_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
using (var db = new MainDBContext())
|
|
@@ -814,7 +904,9 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
uxPublishCb.Items.Clear();
|
|
|
foreach (var i in publishes)
|
|
|
{
|
|
|
+ string prefix = i.PublishVersionFiles.FirstOrDefault().UploadFile.FileUrl.StartsWith("ftp") ? "FTP" : "HTTP";
|
|
|
sb.Clear();
|
|
|
+ sb.Append(string.Format("[{0}]", prefix));
|
|
|
sb.Append("_版本號:");
|
|
|
sb.Append(i.Version);
|
|
|
sb.Append("_上傳日期:");
|
|
@@ -843,9 +935,18 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
{
|
|
|
|
|
|
var machine = db.Machine.Where(x => x.ChargeBoxId == uxChargeBoxIdTb.Text).FirstOrDefault();
|
|
|
- MachineVersion obj = new MachineVersion() { MachineId = machine.Id, PublishVersionId = publishes[selectedPublish].Id, CreatedOn = DateTime.Now };
|
|
|
+ MachineVersion obj = new MachineVersion()
|
|
|
+ {
|
|
|
+ MachineId = machine.Id,
|
|
|
+ PublishVersionId = publishes[selectedPublish].Id,
|
|
|
+ CreatedOn = DateTime.Now.ToUniversalTime()
|
|
|
+ };
|
|
|
|
|
|
- obj.MachineVersionFiles.Add(new MachineVersionFile() { UploadFileId = publishes[selectedPublish].PublishVersionFiles.First().UploadFileId, CreatedOn = DateTime.Now });
|
|
|
+ obj.MachineVersionFiles.Add(new MachineVersionFile()
|
|
|
+ {
|
|
|
+ UploadFileId = publishes[selectedPublish].PublishVersionFiles.First().UploadFileId,
|
|
|
+ CreatedOn = DateTime.Now.ToUniversalTime()
|
|
|
+ });
|
|
|
db.MachineVersion.Add(obj);
|
|
|
|
|
|
//將machine的軟體更新更新到這個值
|
|
@@ -865,5 +966,22 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
selectedPublish = uxPublishCb.SelectedIndex;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ private void uxClearPublishBtn_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ using (var db = new MainDBContext())
|
|
|
+ {
|
|
|
+
|
|
|
+ var machine = db.Machine.Where(x => x.ChargeBoxId == uxChargeBoxIdTb.Text).FirstOrDefault();
|
|
|
+ machine.FW_AssignedVersion = null;
|
|
|
+ machine.FW_AssignedMachineVersionId = null;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+
|
|
|
+ uxMsgTb.Text = "Clear Publish";
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|