Exemplo n.º 1
0
 internal static void SetQuota(QuotaLimiter quota)
 {
     if (QuotaTextBlock != null)
     {
         string message = $"Использовано {DirectoryItem.SetFormat(quota.QuotaUsedBytes)} "
                          + (quota.IsLimited ? $"из {DirectoryItem.SetFormat(quota.QuotaBytes)}" : "");
         QuotaTextBlock.Text = message;
     }
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 private void Show_Quota(QuotaLimiter quota)
 {
     StatusBar.SetQuota(quota);
 }