internal static void SetQuota(QuotaLimiter quota) { if (QuotaTextBlock != null) { string message = $"Использовано {DirectoryItem.SetFormat(quota.QuotaUsedBytes)} " + (quota.IsLimited ? $"из {DirectoryItem.SetFormat(quota.QuotaBytes)}" : ""); QuotaTextBlock.Text = message; } }
public async Task <bool> LoadQuotaAsync() { quota = new QuotaLimiter(); Progress_Start(); try { // ||=========||====\\ // ||*костыль*|| ||========{| // ||=========||====// using (WebDavClient client = new WebDavClient( new HttpClientHandler() { PreAuthenticate = true, // Учетные данные пользователя. Credentials = new NetworkCredential(User, Pass) }, version)) { var response = await client.PropFindAsync(Server); var multistatus = await WebDavResponseContentParser.ParseMultistatusResponseContentAsync(response.Content); foreach (var responseItem in multistatus.Response) { if (responseItem.Href == "/remote.php/webdav/") { foreach (var item in responseItem.Items) { var propStat = item as Propstat; var prop = propStat.Prop; quota.QuotaAvailableBytes = prop.QuotaAvailableBytes; quota.QuotaUsedBytes = prop.QuotaUsedBytes; } } } //LogController.Info(logger, $"Получена квота"); Show_Quota(quota); } } catch (Exception e) { LogController.Error(logger, e, $"Ошибка, не удалось получить квоту"); return(false); } Progress_Stop(); return(true); }
private void Show_Quota(QuotaLimiter quota) { StatusBar.SetQuota(quota); }