/// <summary>
        /// Initializes a new instance of the <see cref="CmisSync.Lib.Events.PermissionDeniedEvent"/> class.
        /// </summary>
        /// <param name="e">thrown permission denied exception</param>
        public PermissionDeniedEvent(DotCMIS.Exceptions.CmisPermissionDeniedException e) : base(e)
        {
            if (e.Data != null && e.Data.Contains(HttpHeaderRetryAfter))
            {
                string[] values = e.Data[HttpHeaderRetryAfter] as string[];
                if (values == null)
                {
                    return;
                }

                List <DateTime> dates = new List <DateTime>();
                foreach (var value in values)
                {
                    try {
                        long seconds = Convert.ToInt64(value);
                        dates.Add(DateTime.UtcNow + TimeSpan.FromSeconds(seconds));
                    } catch (FormatException) {
                        DateTime parsed;
                        if (DateTime.TryParse(value, out parsed))
                        {
                            dates.Add(parsed);
                        }
                    }
                }

                dates.Sort();
                this.IsBlockedUntil = dates.Count > 0 ? dates[0] : (DateTime?)null;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CmisSync.Lib.Events.PermissionDeniedEvent"/> class.
        /// </summary>
        /// <param name="e">thrown permission denied exception</param>
        public PermissionDeniedEvent(CmisPermissionDeniedException e) : base(e) {
            if (e.Data != null && e.Data.Contains(HttpHeaderRetryAfter)) {
                string[] values = e.Data[HttpHeaderRetryAfter] as string[];
                if (values == null) {
                    return;
                }

                List<DateTime> dates = new List<DateTime>();
                foreach (var value in values) {
                    try {
                        long seconds = Convert.ToInt64(value);
                        dates.Add(DateTime.UtcNow + TimeSpan.FromSeconds(seconds));
                    } catch(FormatException) {
                        DateTime parsed;
                        if (DateTime.TryParse(value, out parsed)) {
                            dates.Add(parsed);
                        }
                    }
                }

                dates.Sort();
                this.IsBlockedUntil = dates.Count > 0 ? dates[0] : (DateTime?)null;
            }
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CmisSync.Lib.Events.PermissionDeniedEvent"/> class.
 /// </summary>
 /// <param name="e">thrown permission denied exception</param>
 public PermissionDeniedEvent(DotCMIS.Exceptions.CmisPermissionDeniedException e) : base(e)
 {
 }