123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869 |
- using EVCB_OCPP.Domain;
- using EVCB_OCPP.Domain.Models.Database;
- using EVCB_OCPP.Packet.Features;
- using EVCB_OCPP.Packet.Messages;
- using EVCB_OCPP.Packet.Messages.Core;
- using Microsoft.Win32;
- using Newtonsoft.Json;
- using OCPPPackage.Profiles;
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Security.Cryptography;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using System.Data.Entity;
- using EVCB_OCPP.Packet.Messages.RemoteTrigger;
- using EVCB_OCPP.Packet.Messages.SubTypes;
- using EVCB_OCPP.Packet.Messages.LocalAuthListManagement;
- using EVCB_OCPP.Packet.Messages.FirmwareManagement;
- using EVCB_OCPP.Packet.Messages.Reservation;
- using EVCB_OCPP.Packet.Messages.SmartCharging;
- namespace TestTool.RemoteTriggerAPP
- {
- /// <summary>
- /// MainWindow.xaml 的互動邏輯
- /// </summary>
- public partial class MainWindow : Window
- {
- string action = "";
- List<PublishVersion> publishes = new List<PublishVersion>();
- int selectedPublish = -1;
- public MainWindow()
- {
-
- InitializeComponent();
- }
- private void UxSubmitBtn_Click(object sender, RoutedEventArgs e)
- {
- switch (action)
- {
- #region Core Profile
- case "ChangeAvailability_Inoperative":
- {
- SetChangeAvailability_Inoperative();
- }
- break;
- case "ChangeAvailability_Operative":
- {
- SetChangeAvailability_Operative();
- }
- break;
- case "GetConfiguration":
- {
- if (uxConfigKeyTb.Text == "")
- {
- SetGetConfiguration_ALL();
- }
- else
- {
- SetGetConfiguration();
- }
- }
- break;
- case "ChangeConfiguration":
- {
- SetChangeConfiguration();
- }
- break;
- case "ClearCache":
- {
- SetClearCache();
- }
- break;
- case "RemoteStartTransaction":
- {
- SetRemoteStartTransaction();
- }
- break;
- case "RemoteStartTransaction_ChargingProfile":
- {
- SetRemoteStartTransaction(true);
- }
- break;
- case "RemoteStopTransaction":
- {
- SetRemoteStopTransaction();
- }
- break;
- case "HardReset":
- {
- SetHardReset();
- }
- break;
- case "SoftReset":
- {
- SetSoftReset();
- }
- break;
- case "UnlockConnector":
- {
- SetUnlockConnector();
- }
- break;
- #endregion
- #region Local Authorization
- case "GetLocalListVersion":
- {
- GetLocalListVersion();
- }
- break;
- case "SendLocalAuthorizationList_Full":
- {
- SendLocalAuthorizationList(true);
- }
- break;
- case "SendLocalAuthorizationList_Diff":
- {
- SendLocalAuthorizationList(false);
- }
- break;
- #endregion
- case "GetDiagnostics":
- {
- GetDiagnostics();
- }
- break;
- case "ReserveNow":
- {
- ReserveNow();
- }
- break;
- case "CancelReservation":
- {
- CancelReservation();
- }
- break;
- case "ClearChargingProfile":
- {
- ClearChargingProfile();
- }
- break;
- case "GetCompositeSchedule":
- {
- GetCompositeSchedule();
- }
- break;
- case "SetChargingProfile_TxDefault":
- {
- SetChargingProfile(true);
- }
- break;
- case "SetChargingProfile_Tx":
- {
- SetChargingProfile(false);
- }
- break;
- #region Trigger Profile
- case "TriggerMessage_BootNotification":
- case "TriggerMessage_DiagnosticsStatusNotification":
- case "TriggerMessage_FirmwareStatusNotification":
- case "TriggerMessage_Heartbeat":
- case "TriggerMessage_MeterValues":
- case "TriggerMessage_StatusNotification":
- {
- SetRemoteTrigger(action);
- }
- break;
- #endregion
- default:
- break;
- }
- }
- private void SetChargingProfile(bool isDefault)
- {
- try
- {
- var uuid = Guid.NewGuid().ToString();
- var request = new SetChargingProfileRequest()
- {
- connectorId = Convert.ToInt32(uxConnectorIdTb.Text),
- csChargingProfiles = new csChargingProfiles()
- {
- chargingProfileId = Convert.ToInt32(DateTime.Now.ToString("yyMMddHHmm")),
- chargingProfileKind = ChargingProfileKindType.Absolute,
- chargingProfilePurpose = isDefault ? ChargingProfilePurposeType.TxDefaultProfile : ChargingProfilePurposeType.TxProfile,
- recurrencyKind = RecurrencyKindType.Daily,
- stackLevel = 1,
- chargingSchedule = new ChargingSchedule()
- {
- chargingRateUnit = ChargingRateUnitType.A,
- duration = 300,
- minChargingRate = 0,
- startSchedule = DateTime.Now.Date,
- chargingSchedulePeriod = new List<ChargingSchedulePeriod>()
- {
- new ChargingSchedulePeriod()
- { limit=10, startPeriod=0, numberPhases=3 },
- new ChargingSchedulePeriod()
- { limit=2, startPeriod=60, numberPhases=3 },
- new ChargingSchedulePeriod()
- { limit=8, startPeriod=120, numberPhases=3 }
- }
- }
- }
- };
- WritetoDB(uuid, request);
- uxMsgTb.Text = string.Format("UUID:{0}", uuid);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- private void GetCompositeSchedule()
- {
- try
- {
- var uuid = Guid.NewGuid().ToString();
- var request = new GetCompositeScheduleRequest()
- {
- connectorId = Convert.ToInt32(uxConnectorIdTb.Text),
- duration = 300
- };
- WritetoDB(uuid, request);
- uxMsgTb.Text = string.Format("UUID:{0}", uuid);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- private void ClearChargingProfile()
- {
- try
- {
- var uuid = Guid.NewGuid().ToString();
- var request = new ClearChargingProfileRequest()
- {
- connectorId = Convert.ToInt32(uxConnectorIdTb.Text),
- };
- WritetoDB(uuid, request);
- uxMsgTb.Text = string.Format("UUID:{0}", uuid);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- private void CancelReservation()
- {
- try
- {
- var uuid = Guid.NewGuid().ToString();
- var request = new CancelReservationRequest()
- {
- reservationId = Convert.ToInt32(uxReservationTb.Text),
- };
- WritetoDB(uuid, request);
- uxMsgTb.Text = string.Format("UUID:{0}", uuid);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- private void ReserveNow()
- {
- try
- {
- var uuid = Guid.NewGuid().ToString();
- var request = new ReserveNowRequest()
- {
- connectorId = Convert.ToInt32(uxConnectorIdTb.Text),
- expiryDate = DateTime.Now.AddMinutes(1),
- idTag = uxIdTagTb.Text,
- parentIdTag = "PTAG",
- reservationId = Convert.ToInt32(DateTime.Now.ToString("yyMMddHHmm")),
- };
- WritetoDB(uuid, request);
- uxMsgTb.Text = string.Format("UUID:{0}", uuid);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- private void GetDiagnostics()
- {
- try
- {
- 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
- };
- WritetoDB(uuid, request);
- uxMsgTb.Text = string.Format("UUID:{0}", uuid);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- #region Local Authorization
- private void GetLocalListVersion()
- {
- try
- {
- var uuid = Guid.NewGuid().ToString();
- var request = new GetLocalListVersionRequest()
- {
- };
- WritetoDB(uuid, request);
- uxMsgTb.Text = string.Format("UUID:{0}", uuid);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- private void SendLocalAuthorizationList(bool isFull)
- {
- try
- {
- var uuid = Guid.NewGuid().ToString();
- var request = new SendLocalListRequest()
- {
- listVersion = Convert.ToInt32(DateTime.Now.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},
- idTag="123"
- }, new AuthorizationData()
- {
- idTagInfo=new IdTagInfo(){ expiryDate=DateTime.Now.AddDays(3), status= AuthorizationStatus.Expired},
- idTag="456"
- }
- }
- };
- WritetoDB(uuid, request);
- uxMsgTb.Text = string.Format("UUID:{0}", uuid);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- #endregion
- private void SetRemoteTrigger(string action)
- {
- try
- {
- string type = action.Split('_').Last();
- var uuid = Guid.NewGuid().ToString();
- var request = new TriggerMessageRequest()
- {
- requestedMessage = (MessageTrigger)Enum.Parse(typeof(MessageTrigger), type, false)
- };
- WritetoDB(uuid, request);
- uxMsgTb.Text = string.Format("UUID:{0}", uuid);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- private void SetGetConfiguration()
- {
- try
- {
- var uuid = Guid.NewGuid().ToString();
- var request = new GetConfigurationRequest()
- {
- key = new List<string>() { uxConfigKeyTb.Text }
- };
- WritetoDB(uuid, request);
- uxMsgTb.Text = string.Format("UUID:{0}", uuid);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- private void UxCmdCb_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- var item = uxCmdCb.SelectedValue as ComboBoxItem;
- action = item.Content as string;
- }
- private void SetRemoteStartTransaction(bool hasProfile = false)
- {
- try
- {
- var uuid = Guid.NewGuid().ToString();
- var request = new RemoteStartTransactionRequest()
- {
- connectorId = byte.Parse(uxConnectorIdTb.Text),
- idTag = uxIdTagTb.Text
- };
- if (hasProfile)
- {
- request.chargingProfile = new csChargingProfiles()
- {
- chargingProfileId = Convert.ToInt32(DateTime.Now.ToString("yyMMddHHmm")),
- chargingProfileKind = ChargingProfileKindType.Absolute,
- chargingProfilePurpose = ChargingProfilePurposeType.TxProfile,
- recurrencyKind = RecurrencyKindType.Daily,
- stackLevel = 1,
- chargingSchedule = new ChargingSchedule()
- {
- chargingRateUnit = ChargingRateUnitType.A,
- duration = 300,
- minChargingRate = 0,
- startSchedule = DateTime.Now.Date,
- chargingSchedulePeriod = new List<ChargingSchedulePeriod>()
- {
- new ChargingSchedulePeriod()
- { limit=10, startPeriod=0, numberPhases=3 },
- new ChargingSchedulePeriod()
- { limit=2, startPeriod=60, numberPhases=3 },
- new ChargingSchedulePeriod()
- { limit=8, startPeriod=120, numberPhases=3 }
- }
- }
- };
- }
- WritetoDB(uuid, request);
- uxMsgTb.Text = string.Format("UUID:{0}", uuid);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- private void SetUnlockConnector()
- {
- try
- {
- var uuid = Guid.NewGuid().ToString();
- var request = new UnlockConnectorRequest()
- {
- connectorId = byte.Parse(uxConnectorIdTb.Text),
- };
- WritetoDB(uuid, request);
- uxMsgTb.Text = string.Format("UUID:{0}", uuid);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- private void SetChangeAvailability_Inoperative()
- {
- try
- {
- var uuid = Guid.NewGuid().ToString();
- var request = new ChangeAvailabilityRequest()
- {
- connectorId = byte.Parse(uxConnectorIdTb.Text),
- type = EVCB_OCPP.Packet.Messages.SubTypes.AvailabilityType.Inoperative
- };
- WritetoDB(uuid, request);
- uxMsgTb.Text = string.Format("UUID:{0}", uuid);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- private void SetChangeAvailability_Operative()
- {
- try
- {
- var uuid = Guid.NewGuid().ToString();
- var request = new ChangeAvailabilityRequest()
- {
- connectorId = byte.Parse(uxConnectorIdTb.Text),
- type = EVCB_OCPP.Packet.Messages.SubTypes.AvailabilityType.Operative
- };
- WritetoDB(uuid, request);
- uxMsgTb.Text = string.Format("UUID:{0}", uuid);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- private void SetChangeConfiguration()
- {
- try
- {
- var uuid = Guid.NewGuid().ToString();
- var request = new ChangeConfigurationRequest()
- {
- key = uxConfigKeyTb.Text,
- value = uxConfigValueTb.Text,
- };
- WritetoDB(uuid, request);
- uxMsgTb.Text = string.Format("UUID:{0}", uuid);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- private void SetClearCache()
- {
- try
- {
- var uuid = Guid.NewGuid().ToString();
- var request = new ClearCacheRequest()
- {
- };
- WritetoDB(uuid, request);
- uxMsgTb.Text = string.Format("UUID:{0}", uuid);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- private void SetGetConfiguration_ALL()
- {
- try
- {
- var uuid = Guid.NewGuid().ToString();
- var request = new GetConfigurationRequest()
- {
- key = new List<string>() { }
- };
- WritetoDB(uuid, request);
- uxMsgTb.Text = string.Format("UUID:{0}", uuid);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- private void SetHardReset()
- {
- try
- {
- var uuid = Guid.NewGuid().ToString();
- var request = new ResetRequest()
- {
- type = EVCB_OCPP.Packet.Messages.SubTypes.ResetType.Hard
- };
- WritetoDB(uuid, request);
- uxMsgTb.Text = string.Format("UUID:{0}", uuid);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- private void SetSoftReset()
- {
- try
- {
- var uuid = Guid.NewGuid().ToString();
- var request = new ResetRequest()
- {
- type = EVCB_OCPP.Packet.Messages.SubTypes.ResetType.Soft
- };
- WritetoDB(uuid, request);
- uxMsgTb.Text = string.Format("UUID:{0}", uuid);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- private void SetRemoteStopTransaction()
- {
- try
- {
- var uuid = Guid.NewGuid().ToString();
- var request = new RemoteStopTransactionRequest()
- {
- transactionId = int.Parse(uxTransactionIdTb.Text)
- };
- WritetoDB(uuid, request);
- uxMsgTb.Text = string.Format("UUID:{0}", uuid);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- private void WritetoDB(string uuid, IRequest request)
- {
- using (var db = new MainDBContext())
- {
- db.MachineOperateRecord.Add(new MachineOperateRecord()
- {
- CreatedOn = DateTime.Now,
- ChargeBoxId = uxChargeBoxIdTb.Text,
- SerialNo = uuid,
- RequestContent = JsonConvert.SerializeObject(request, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.None }),
- EVSE_Status = 0,
- Status = 0,
- RequestType = 1,
- });
- db.ServerMessage.Add(new ServerMessage()
- {
- ChargeBoxId = uxChargeBoxIdTb.Text,
- CreatedBy = "TestTool",
- CreatedOn = DateTime.Now,
- OutAction = request.Action.ToString(),
- OutRequest = JsonConvert.SerializeObject(request, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.None }),
- SerialNo = uuid,
- InMessage = string.Empty
- });
- db.SaveChanges();
- }
- }
- private void uxFileSubmitBtn_Click(object sender, RoutedEventArgs e)
- {
- OpenFileDialog openFileDialog = new OpenFileDialog();
- openFileDialog.Title = "Select file";
- var result = openFileDialog.ShowDialog();
- if (result == true)
- {
- uxUploadFileTb.Text = openFileDialog.FileName;
- }
- }
- private void uxUploadBtn_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 = "";
- string filePreUrl = ConfigurationManager.AppSettings["FilePreUrl"];
- 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();
- //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.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.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 };
- if (pvQry != null)
- {
- pv.Version = pvQry.Version + 1;
- }
- pv.PublishVersionFiles.Add(new PublishVersionFile() { UploadFileId = ufObj.Id });
- db.PublishVersion.Add(pv);
- db.SaveChanges();
- }
- uxMsgTb.Text = "write to DB ,but you must manaul upload file to server and filename replace with " + ufObj.FileName;
- }
- private void uxRefreshBtn_Click(object sender, RoutedEventArgs e)
- {
- using (var db = new MainDBContext())
- {
- publishes = db.PublishVersion
- .Include(c => c.PublishVersionFiles)
- .Include(c => c.PublishVersionFiles.Select(z => z.UploadFile))
- .Include(c => c.CustomerMachineComponent)
- .Include(c => c.CustomerMachineComponent.MachineComponent)
- .Include(c => c.CustomerMachineComponent.MachineComponent.MachineModel)
- .Include(c => c.CustomerMachineComponent.MachineComponent.MachinePart)
- .Where(c => c.CustomerMachineComponent.CustomerId == new Guid("8456AED9-6DD9-4BF3-A94C-9F5DCB9506F7") && c.CustomerMachineComponent.Id == 1 && c.CustomerMachineComponent.Id == 1).OrderByDescending(c => c.Id).Take(20).ToList();
- StringBuilder sb = new StringBuilder();
- uxPublishCb.Items.Clear();
- foreach (var i in publishes)
- {
- sb.Clear();
- sb.Append("_版本號:");
- sb.Append(i.Version);
- sb.Append("_上傳日期:");
- sb.Append(i.PublishVersionFiles.First().UploadFile.CreatedOn.ToString());
- sb.Append("_檔名:");
- foreach (var f in i.PublishVersionFiles)
- {
- sb.Append(f.UploadFile.OriginName);
- sb.Append("、");
- }
- uxPublishCb.Items.Add(sb.ToString());
- uxPublishCb.SelectedIndex = 0;
- }
- }
- }
- private void uxPublishBtn_Click(object sender, RoutedEventArgs e)
- {
- if (selectedPublish < 0)
- {
- uxMsgTb.Text = "Please choose publish version!";
- return;
- }
- using (var db = new MainDBContext())
- {
- 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 };
- obj.MachineVersionFiles.Add(new MachineVersionFile() { UploadFileId = publishes[selectedPublish].PublishVersionFiles.First().UploadFileId, CreatedOn = DateTime.Now });
- db.MachineVersion.Add(obj);
- //將machine的軟體更新更新到這個值
- machine.FW_AssignedVersion = publishes[selectedPublish].Version;
- machine.FW_MachineVersion = obj;
- db.SaveChanges();
- }
- uxMsgTb.Text = "Publish Complete";
- }
- private void uxPublishCb_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- selectedPublish = uxPublishCb.SelectedIndex;
- }
- }
- }
|