Exemplo n.º 1
0
        public async Task <bool> AddDownloadLog(string DownloadDate, string LoginID, string Status, string DBPath, string TotalTime, string AppVersion, string OSType, string OSVersion, string MacAddr)
        {
            var param    = new AddDownloadLogRM(DownloadDate, LoginID, Status, DBPath, TotalTime, AppVersion, OSType, OSVersion, MacAddr);
            var response = await _sgService
                           .AddDownloadLog(Priority.UserInitiated, param)
                           .ConfigureAwait(false);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        public async Task <HttpResponseMessage> AddDownloadLog(Priority priority, AddDownloadLogRM param)
        {
            HttpResponseMessage        response = null;
            Task <HttpResponseMessage> task;

            switch (priority)
            {
            case Priority.Background:
                task = _apiService.Background.AddDownloadLog(param);
                break;

            case Priority.UserInitiated:
                task = _apiService.UserInitiated.AddDownloadLog(param);
                break;

            case Priority.Speculative:
                task = _apiService.Speculative.AddDownloadLog(param);
                break;

            default:
                task = _apiService.UserInitiated.AddDownloadLog(param);
                break;
            }

            if (CrossConnectivity.Current.IsConnected)
            {
                response = await Policy
                           .Handle <Exception>()
                           .WaitAndRetryAsync
                           (
                    retryCount: 3,
                    sleepDurationProvider: retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))
                           )
                           .ExecuteAsync(async() => await task);
            }

            return(response);
        }