public async Task <IResult> FetchItem(TextID id) { _bodyConstants.TryGetValue(id, out var bodykey); if (string.IsNullOrWhiteSpace(bodykey)) { return(NotFound); } _subjectConstants.TryGetValue(id, out var subjkey); return(Json(await DB.RunInTransactionAsync(db => { var body = Services.TextHelper.GetTextEntryFromDb(db, bodykey, "en"); var res = new DataTransport() { ID = id, Body = body?.Text, LastChanged = body == null ? new DateTime(0) : body.Updated }; if (!string.IsNullOrWhiteSpace(subjkey)) { res.Subject = Services.TextHelper.GetTextFromDb(db, subjkey, "en"); } return res; }))); }
public void DownloadPartialData(Client player, ResourceInfo info) { var transferObj = new DataTransport(); transferObj.Datatype = "partial"; transferObj.Data = API.toJson(info); string data = API.toJson(transferObj); API.downloadData(player, data); }
public void DownloadClientData(Client player) { var transferObj = new DataTransport(); transferObj.Datatype = "complete"; transferObj.Data = API.toJson(Information); string data = API.toJson(transferObj); API.downloadData(player, data); }
protected TransportViewModel(DataTransport <T> dataTransport) { _dataTransport = dataTransport; _dataTransport.CanOpenChanged += delegate { OpenCommand.RaiseCanExecuteChanged(); }; _dataTransport.CanCloseChanged += delegate { CloseCommand.RaiseCanExecuteChanged(); }; _dataTransport.IsOpenChanged += (sender, args) => { RaisePropertyChanged(nameof(IsOpen)); }; }
/// <summary> /// Initializes a new instance of the <see cref="SettingViewModel" /> class /// </summary> public LiveDataLogViewModel(ServoDriveService servoDriveService, DataTransport <Packet> dataTransport) { _servoDriveService = servoDriveService; this.dataTransport = dataTransport; _servoDriveService.PropertyChanged += (sender, e) => RaisePropertyChanged(e.PropertyName); channel = dataTransport.Channels.FirstOrDefault(); if (channel != null) { channel.DataReceived += ServoViewModel_DataReceived; } ((INotifyCollectionChanged)dataTransport.Channels).CollectionChanged += ServoViewModel_CollectionChanged; }
public Form2(DataTransport dataTransport) { _dataTransport = dataTransport; InitializeComponent(); }
public async Task <IResult> UpdateItem(TextID id, DataTransport data) { if (data == null || data.Body == null) { return(BadRequest); } _bodyConstants.TryGetValue(id, out var bodykey); if (string.IsNullOrWhiteSpace(bodykey)) { return(NotFound); } _subjectConstants.TryGetValue(id, out var subjkey); var res = await DB.RunInTransactionAsync(db => { var e = db.SelectItemById <Database.TextEntry>(bodykey); if (e == null) { db.InsertItem(new Database.TextEntry() { ID = bodykey, Text = data.Body, IsDraft = false, Language = "en" }); } else { if (e.Updated > data.LastChanged) { throw new HttpException(HttpStatusCode.Conflict, "The server data changed"); } e.Text = data.Body; e.Language = "en"; e.IsDraft = false; db.UpdateItem(e); } // Re-read the values for reporting e = db.SelectItemById <Database.TextEntry>(bodykey); var dt = new DataTransport() { Body = e.Text, LastChanged = e.Updated, ID = id }; if (!string.IsNullOrWhiteSpace(subjkey) && data.Subject != null) { e = db.SelectItemById <Database.TextEntry>(subjkey); if (e == null) { e = db.InsertItem(new Database.TextEntry() { ID = subjkey, Text = data.Subject, IsDraft = false, Language = "en" }); } else { e.Text = data.Subject; e.Language = "en"; e.IsDraft = false; db.UpdateItem(e); } dt.Subject = e.Text; } return(dt); }); return(Json(res)); }
public void RegisterDataTransport(DataTransport <Packet> dataTransport) { DataTransports.Add(dataTransport); }
public void RegisterDataTransport(DataTransport <Device> dataTransport) { _dataTransports.Add(dataTransport); }
protected DeviceService(DataTransport <T> dataTransport, Codec <T> codec) { DataTransport = dataTransport; Codec = codec; dataTransport.IsOpenChanged += IsOpenChanged; }
public void Close() => DataTransport.Close();
public void Open() => DataTransport.Open();