示例#1
0
        public Task <StreamDownloadResponse> DownloadStream(StreamDownloadRequest request)
        {
            MemoryStream stream = NetHelper.SerializeToStream <Workers>(ViewModel.Instance.Workers);

            return(Task.FromResult(new StreamDownloadResponse {
                Stream = stream
            }));
        }
示例#2
0
        public async Task <StreamDownloadResponse> GetPriceHistoryAsync(StreamDownloadRequest request)
        {
            try
            {
                var task = Task.Run(async() =>
                {
                    var vm = ViewModel.Instance;
                    await vm.UpdatePriceHistory();
                    return(ViewModel.ReadHistoricalData(request.Period));
                });
                var history = await task;

                MemoryStream stream = NetHelper.SerializeToStream <List <HistoricalData> >(history);
                return(new StreamDownloadResponse {
                    Stream = stream
                });
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }