示例#1
0
        private void GetDownloadingInfoResult(String response)
        {
            try
            {
                JsonResultMultiCalls info = JsonRequest.GetResultMultiCalls(response);

                List <JsonResultMultiCalls.ResultItemA> results = new List <JsonResultMultiCalls.ResultItemA>();
                results.AddRange(JsonRequest.GetResultMultiCallsResultItemAReform(info.result[0][0]));
                results.AddRange(JsonRequest.GetResultMultiCallsResultItemAReform(info.result[1][0]));

                String globelResult = JsonRequest.GetResultMultiCallsResultItemBReform(info.result[2][0]).ToString();

                results.ForEach(result =>
                {
                    _downloadItems.First(downloadItem => downloadItem.GetGid.Equals(result.gid)).SetDownloadInfo(result.files[0].uris[0].uri, result.files[0].path, result.status, Int64.Parse(result.totalLength), Int64.Parse(result.completedLength), Int64.Parse(result.downloadSpeed));
                });

                GetDownloadingInfoResultHandler?.Invoke(globelResult);
            }
            catch (Exception e)
            {
                GetDownloadingInfoResultHandler?.Invoke(String.Empty);
                ExceptionHelper.ShowErrorMsg("GetDownloadHistoryInfo", e);
            }
        }
示例#2
0
        private async Task GetDownloadingInfo()
        {
            try
            {
                String request = new JsonRequest("GetDownloadingInfo", new JsonRequest.MultiCalls[] {
                    new JsonRequest.MultiCalls("aria2.tellActive", $"[\"gid\",\"files\",\"status\",\"downloadSpeed\",\"totalLength\",\"completedLength\"]"),
                    new JsonRequest.MultiCalls("aria2.tellWaiting", $"0,{Int32.MaxValue},[\"gid\",\"files\",\"status\",\"downloadSpeed\",\"totalLength\",\"completedLength\"]"),
                    new JsonRequest.MultiCalls("aria2.getGlobalStat", String.Empty)
                }).ToJson();

                await SocketSend(request);
            }
            catch (Exception e)
            {
                GetDownloadingInfoResultHandler?.Invoke(String.Empty);
                ExceptionHelper.ShowErrorMsg("GetDownloadingInfo", e);
            }
        }