public static Task <Stream> GetFileAsync(MessageFileModel response) { using (WebClient client = new WebClient()) { return(client.OpenReadTaskAsync(response.DowloadUrl)); } }
public void Load(MessageUploadFileModel model) { if (model != null) { Model = model.ConvertToMessageFileModel(); Load(); } }
public static void DowloadFileAsync(MessageFileModel response, string savepath = @"D:\Test\") { using (WebClient client = new WebClient()) { //client.DownloadProgressChanged += new DownloadProgressChangedEventHandler((sender, e) => Console.WriteLine(e.ProgressPercentage)); client.DownloadFileTaskAsync(response.DowloadUrl, savepath + response.FileName); } }
public ActionResult GetMediaFile(int fileID) { try { MessageFileModel file = new MessageFileModel(fileID, SessionHandler.UserDetails.UserID); return(File(file.Data, file.FileType)); } catch (Exception e) { return(RedirectToAction("HandledCodeError", "ErrorHandler", new { exception = e.ToString() })); } }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { MessageFileModel model = new MessageFileModel(); await _messageService.StartReceiveMessagesFromSubscriptionAsync( message => { _logger.LogInformation("DEVICE: {0}, TEMP: {1}", message.FileName, message.Message); model.FileName = message.FileName; model.Message = message.Message; model.WriteFile(model.FileName, model.Message); }); while (!stoppingToken.IsCancellationRequested) { _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); await Task.Delay(10000, stoppingToken); } }
public MessageFileControl(MessageFileModel model) { InitializeComponent(); Model = model; Load(); }