Example #1
0
        private void LogBroker_OnLog(object sender, LoggerEventArgs e)
        {
            try
            {
                if (Application.Current != null) // Null when window is closing
                {
                    Application.Current.Dispatcher.Invoke(
                        (Action) delegate()
                    {
                        lock (StatusItems)
                            StatusItems.Add(e.Event);

                        if (e.Event.Contains("Join Complete"))
                        {
                            Icon = Image = "/TPC_GUI;component/Images/Light_On.png";
                        }
                        else if (e.Event.Contains("Leave Complete"))
                        {
                            Icon = Image = "/TPC_GUI;component/Images/Light_Off.png";
                        }
                    },
                        DispatcherPriority.Render);
                }
            }
            catch
            {
                // Just ignore, this may happen if the task
                // created by the dispatcher is cancelled before
                // it's executed like when the program is closed
            }
        }
Example #2
0
 public MicroViewModel()
 {
     search = new MicroQueries()
     {
         Page   = 0,
         Status = 1
     };
     Items = new IncrementalLoadingCollection <MicroItem>(count =>
     {
         return(Task.Run(async() =>
         {
             search.Page++;
             var data = await App.Repository.Micro.GetPageAsync(search);
             if (data == null)
             {
                 return Tuple.Create <IList <MicroItem>, bool>(null, false);
             }
             return Tuple.Create(data.Data, data.Paging.More);
         }));
     });
     StatusItems.Add(new TabItem(1, "推荐"));
     StatusItems.Add(new TabItem(2, "关注"));
     StatusItems.Add(new TabItem(3, "热门"));
     StatusItems.Add(new TabItem(4, "话题"));
 }
Example #3
0
 private void ListView_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Add)
     {
         StatusItems.ScrollIntoView(e.NewItems[0]);
     }
 }
        /// <summary>
        /// Loads the repository status (modified, added, removed).
        /// </summary>
        private void LoadRepositoryStatus(LibGit2Sharp.Repository repo = null)
        {
            var dispose = false;

            if (repo == null)
            {
                repo    = new LibGit2Sharp.Repository(RepositoryFullPath);
                dispose = true;
            }

            // A small performance boost.
            StatusItems.DisableNotifications();

            StatusItems.Clear();

            // Load status items.
            var itemList = new List <StatusItem>();

            var status = repo.Index.RetrieveStatus();

            foreach (var fileStatus in status)
            {
                foreach (LibGit2Sharp.FileStatus value in Enum.GetValues(typeof(LibGit2Sharp.FileStatus)))
                {
                    var isSet = fileStatus.State.HasFlag(value);

                    if (isSet == false || value.ToString() == "Unaltered" || value.ToString() == "Ignored")
                    {
                        continue;
                    }

                    var fileFullPath = RepositoryFullPath + "/" + fileStatus.FilePath;

                    // Only those enum statuses that were set will generate a row in the status grid (and those that are not ignored/unaltered).
                    var item = new StatusItem
                    {
                        Filename = fileStatus.FilePath,
                        Status   = value,
                        Size     = FileUtil.GetFormattedFileSize(fileFullPath),
                        IsBinary = FileUtil.IsBinaryFile(fileFullPath) ? "Yes" : "-"
                    };

                    itemList.Add(item);
                }
            }

            StatusItems.AddRange(itemList);

            if (dispose)
            {
                repo.Dispose();
            }

            // Fire notifications for the collection on the UI thread.
            Application.Current.Dispatcher.Invoke(
                DispatcherPriority.Normal,
                (Action)(() => StatusItems.EnableNotifications(true))
                );
        }
Example #5
0
 public (DateTime LastUpate, IEnumerable <ContinuumStatus> ContinuumStatus, IEnumerable <ZabbixStatus> ZabbixStatus) GetStatus(int count)
 {
     if (DateTime.Now - _lastRetrieval > _retrievalInterval)
     {
         _continuum.PollStatus(MAX_COUNT);
         _zabbix.PollStatus(MAX_COUNT);
         _lastRetrieval = DateTime.Now;
     }
     return(_lastRetrieval, _continuum.StatusItems.Take(count), _zabbix.StatusItems.Take(count));
 }
Example #6
0
 private void ClearStatusItems()
 {
     if (StatusItems.Count > 0)
     {
         lock (StatusItems)
         {
             var idItem = StatusItems[0];
             StatusItems.Clear();
             StatusItems.Add(idItem);
         }
     }
 }
        /// <summary>
        /// Checks if there is anything to commit
        /// </summary>
        /// <param name="action"></param>
        private bool CommitChanges_CanExecute(object action)
        {
            var commitMessage = (string)action;

            // Only allow commit if there's something to commit and there's a commit message.
            if (commitMessage != null && StatusItems.Any(s => s.IsStaged))
            {
                return(commitMessage.Length > 0);
            }

            return(false);
        }
Example #8
0
        /// <summary>
        /// Loads the repository status (modified, added, removed).
        /// </summary>
        private void LoadRepositoryStatus()
        {
            var repo = new LibGit2Sharp.Repository(RepositoryFullPath);

            StatusItems.Clear();

            // Load status items.
            List <StatusItem> itemList = new List <StatusItem>();

            LibGit2Sharp.RepositoryStatus status = repo.Index.RetrieveStatus();
            foreach (LibGit2Sharp.StatusEntry fileStatus in status)
            {
                foreach (LibGit2Sharp.FileStatus value in Enum.GetValues(typeof(LibGit2Sharp.FileStatus)))
                {
                    bool isSet = fileStatus.State.HasFlag(value);

                    if (isSet == false || value.ToString() == "Unaltered" || value.ToString() == "Ignored")
                    {
                        continue;
                    }

                    string fileFullPath = RepositoryFullPath + "/" + fileStatus.FilePath;

                    // Only those enum statuses that were set will generate a row in the status grid (and those that are not ignored/unaltered).
                    StatusItem item = new StatusItem
                    {
                        Filename = fileStatus.FilePath,
                        Status   = value,
                        Size     = FileUtil.GetFormattedFileSize(fileFullPath),
                        IsBinary = FileUtil.IsBinaryFile(fileFullPath) ? "Yes" : "-"
                    };

                    itemList.Add(item);
                }
            }

            StatusItems.AddRange(itemList);

            repo.Dispose();
        }
Example #9
0
        public StudentViewModel()
        {
            StatusItems.Add(new SelectListItem
            {
                Text  = "Confirmed",
                Value = "Confirmed"
            });
            StatusItems.Add(new SelectListItem
            {
                Text  = "Waiting",
                Value = "Waiting"
            });

            //get Courses list
            CoursesRepository coursesRepository = new CoursesRepository();

            CoursesList = coursesRepository.GetAllCourses();

            RulesRepository rulesRepository = new RulesRepository();

            RulesList = rulesRepository.GetAllRules();
        }
Example #10
0
 public TaskViewModel()
 {
     search = new SearchForm()
     {
         Page   = 0,
         Status = 1
     };
     Items = new IncrementalLoadingCollection <TaskItem>(count =>
     {
         return(Task.Run(async() =>
         {
             search.Page++;
             var data = await App.Repository.Task.GetTaskAsync(search);
             if (data == null)
             {
                 return Tuple.Create <IList <TaskItem>, bool>(null, false);
             }
             return Tuple.Create(data.Data, data.Paging.More);
         }));
     });
     StatusItems.Add(new TabItem(1, Constants.GetString("task_tab_1")));
     StatusItems.Add(new TabItem(2, Constants.GetString("task_tab_2")));
 }
Example #11
0
 private void Save(string fileName)
 {
     PropertyInfo[] pil = GetType().GetProperties();
     using StreamWriter sw = new StreamWriter(fileName);
     foreach (PropertyInfo pi in pil)
     {
         if (pi.PropertyType.IsEnum)
         {
             sw.WriteLine($"{pi.Name}\t{(int)pi.GetValue(this, null)}");
         }
         else if (Type.GetTypeCode(pi.PropertyType) != TypeCode.Object)
         {
             sw.WriteLine($"{pi.Name}\t{pi.GetValue(this, null)}");
         }
         else
         {
             if (pi.PropertyType == StatusItems.GetType())
             {
                 foreach (var si in (List <StatusItem>)pi.GetValue(this, null))
                 {
                     sw.WriteLine($"{pi.Name}\t{si}");
                 }
             }
             else if (pi.PropertyType == ExtensionRules.GetType())
             {
                 foreach (var si in (List <ExtensionRule>)pi.GetValue(this, null))
                 {
                     sw.WriteLine($"{pi.Name}\t{si.Extension}\t{si.PlayMethod}");
                 }
             }
             else
             {
                 sw.WriteLine($"{pi.Name}\t{pi.GetValue(this, null)}");
             }
         }
     }
 }
Example #12
0
		/// <summary>
		/// Get all of the folders within the specified namespace.
		/// </summary>
		/// <remarks>
		/// Gets all of the folders within the specified namespace.
		/// </remarks>
		/// <returns>The folders.</returns>
		/// <param name="namespace">The namespace.</param>
		/// <param name="items">The status items to pre-populate.</param>
		/// <param name="subscribedOnly">If set to <c>true</c>, only subscribed folders will be listed.</param>
		/// <param name="cancellationToken">The cancellation token.</param>
		/// <exception cref="System.ArgumentNullException">
		/// <paramref name="namespace"/> is <c>null</c>.
		/// </exception>
		/// <exception cref="System.ObjectDisposedException">
		/// The <see cref="ImapClient"/> has been disposed.
		/// </exception>
		/// <exception cref="ServiceNotConnectedException">
		/// The <see cref="ImapClient"/> is not connected.
		/// </exception>
		/// <exception cref="ServiceNotAuthenticatedException">
		/// The <see cref="ImapClient"/> is not authenticated.
		/// </exception>
		/// <exception cref="System.OperationCanceledException">
		/// The operation was canceled via the cancellation token.
		/// </exception>
		/// <exception cref="FolderNotFoundException">
		/// The namespace folder could not be found.
		/// </exception>
		/// <exception cref="System.IO.IOException">
		/// An I/O error occurred.
		/// </exception>
		/// <exception cref="ImapCommandException">
		/// The server replied to the LIST or LSUB command with a NO or BAD response.
		/// </exception>
		/// <exception cref="ImapProtocolException">
		/// The server responded with an unexpected token.
		/// </exception>
		public override IEnumerable<IMailFolder> GetFolders (FolderNamespace @namespace, StatusItems items = StatusItems.None, bool subscribedOnly = false, CancellationToken cancellationToken = default (CancellationToken))
		{
			if (@namespace == null)
				throw new ArgumentNullException ("namespace");

			CheckDisposed ();
			CheckConnected ();
			CheckAuthenticated ();

			foreach (var folder in engine.GetFolders (@namespace, items, subscribedOnly, cancellationToken))
				yield return folder;

			yield break;
		}
Example #13
0
		string GetStatusQuery (StatusItems items)
		{
			var flags = string.Empty;

			if ((items & StatusItems.Count) != 0)
				flags += "MESSAGES ";
			if ((items & StatusItems.Recent) != 0)
				flags += "RECENT ";
			if ((items & StatusItems.UidNext) != 0)
				flags += "UIDNEXT ";
			if ((items & StatusItems.UidValidity) != 0)
				flags += "UIDVALIDITY ";
			if ((items & StatusItems.Unread) != 0)
				flags += "UNSEEN ";

			if ((Engine.Capabilities & ImapCapabilities.CondStore) != 0) {
				if ((items & StatusItems.HighestModSeq) != 0)
					flags += "HIGHESTMODSEQ ";
			}

			return flags.TrimEnd ();
		}
Example #14
0
        /// <summary>
        /// Asynchronously get all of the folders within the specified namespace.
        /// </summary>
        /// <remarks>
        /// Asynchronously gets all of the folders within the specified namespace.
        /// </remarks>
        /// <returns>The folders.</returns>
        /// <param name="namespace">The namespace.</param>
        /// <param name="items">The status items to pre-populate.</param>
        /// <param name="subscribedOnly">If set to <c>true</c>, only subscribed folders will be listed.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="namespace"/> is <c>null</c>.
        /// </exception>
        /// <exception cref="System.ObjectDisposedException">
        /// The <see cref="MailStore"/> has been disposed.
        /// </exception>
        /// <exception cref="ServiceNotConnectedException">
        /// The <see cref="MailStore"/> is not connected.
        /// </exception>
        /// <exception cref="ServiceNotAuthenticatedException">
        /// The <see cref="MailStore"/> is not authenticated.
        /// </exception>
        /// <exception cref="System.OperationCanceledException">
        /// The operation was canceled via the cancellation token.
        /// </exception>
        /// <exception cref="System.IO.IOException">
        /// An I/O error occurred.
        /// </exception>
        /// <exception cref="ProtocolException">
        /// A protocol error occurred.
        /// </exception>
        /// <exception cref="CommandException">
        /// The command failed.
        /// </exception>
        public virtual Task <IEnumerable <IMailFolder> > GetFoldersAsync(FolderNamespace @namespace, StatusItems items = StatusItems.None, bool subscribedOnly = false, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (@namespace == null)
            {
                throw new ArgumentNullException("namespace");
            }

            return(Task.Factory.StartNew(() => {
                lock (SyncRoot) {
                    return GetFolders(@namespace, items, subscribedOnly, cancellationToken);
                }
            }, cancellationToken, TaskCreationOptions.None, TaskScheduler.Default));
        }
Example #15
0
 public (DateTime LastUpate, IEnumerable <ContinuumStatus> ContinuumStatus, IEnumerable <ZabbixStatus> ZabbixStatus) GetStatus(int maxItems)
 {
     return(_lastRetrieval, _continuum.StatusItems.Take(maxItems), _zabbix.StatusItems.Take(maxItems));
 }
 public LoadStatus(long totalResults, long totalResultsLoaded, StatusItems status)
 {
     Status             = status;
     TotalResults       = TotalResults;
     TotalResultsLoaded = totalResultsLoaded;
 }
Example #17
0
 /// <summary>
 /// Get all of the folders within the specified namespace.
 /// </summary>
 /// <remarks>
 /// Gets all of the folders within the specified namespace.
 /// </remarks>
 /// <returns>The folders.</returns>
 /// <param name="namespace">The namespace.</param>
 /// <param name="items">The status items to pre-populate.</param>
 /// <param name="subscribedOnly">If set to <c>true</c>, only subscribed folders will be listed.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <exception cref="System.ArgumentNullException">
 /// <paramref name="namespace"/> is <c>null</c>.
 /// </exception>
 /// <exception cref="System.ObjectDisposedException">
 /// The <see cref="MailStore"/> has been disposed.
 /// </exception>
 /// <exception cref="ServiceNotConnectedException">
 /// The <see cref="MailStore"/> is not connected.
 /// </exception>
 /// <exception cref="ServiceNotAuthenticatedException">
 /// The <see cref="MailStore"/> is not authenticated.
 /// </exception>
 /// <exception cref="System.OperationCanceledException">
 /// The operation was canceled via the cancellation token.
 /// </exception>
 /// <exception cref="System.IO.IOException">
 /// An I/O error occurred.
 /// </exception>
 /// <exception cref="ProtocolException">
 /// A protocol error occurred.
 /// </exception>
 /// <exception cref="CommandException">
 /// The command failed.
 /// </exception>
 public abstract IEnumerable <IMailFolder> GetFolders(FolderNamespace @namespace, StatusItems items = StatusItems.None, bool subscribedOnly = false, CancellationToken cancellationToken = default(CancellationToken));
Example #18
0
		/// <summary>
		/// Updates the values of the specified items.
		/// </summary>
		/// <remarks>
		/// <para>Updates the values of the specified items.</para>
		/// <para>The <see cref="Status(StatusItems, System.Threading.CancellationToken)"/> method
		/// MUST NOT be used on a folder that is already in the opened state. Instead, other ways
		/// of getting the desired information should be used.</para>
		/// <para>For example, a common use for the <see cref="Status(StatusItems,System.Threading.CancellationToken)"/>
		/// method is to get the number of unread messages in the folder. When the folder is open, however, it is
		/// possible to use the <see cref="ImapFolder.Search(MailKit.Search.SearchQuery, System.Threading.CancellationToken)"/>
		/// method to query for the list of unread messages.</para>
		/// <para>For more information about the <c>STATUS</c> command, see
		/// <a href="https://tools.ietf.org/html/rfc3501#section-6.3.10">rfc3501</a>.</para>
		/// </remarks>
		/// <param name="items">The items to update.</param>
		/// <param name="cancellationToken">The cancellation token.</param>
		/// <exception cref="System.ObjectDisposedException">
		/// The <see cref="ImapClient"/> has been disposed.
		/// </exception>
		/// <exception cref="ServiceNotConnectedException">
		/// The <see cref="ImapClient"/> is not connected.
		/// </exception>
		/// <exception cref="ServiceNotAuthenticatedException">
		/// The <see cref="ImapClient"/> is not authenticated.
		/// </exception>
		/// <exception cref="FolderNotFoundException">
		/// The <see cref="ImapFolder"/> does not exist.
		/// </exception>
		/// <exception cref="System.NotSupportedException">
		/// The IMAP server does not support the STATUS command.
		/// </exception>
		/// <exception cref="System.OperationCanceledException">
		/// The operation was canceled via the cancellation token.
		/// </exception>
		/// <exception cref="System.IO.IOException">
		/// An I/O error occurred.
		/// </exception>
		/// <exception cref="ImapProtocolException">
		/// The server's response contained unexpected tokens.
		/// </exception>
		/// <exception cref="ImapCommandException">
		/// The server replied with a NO or BAD response.
		/// </exception>
		public override void Status (StatusItems items, CancellationToken cancellationToken = default (CancellationToken))
		{
			if ((Engine.Capabilities & ImapCapabilities.Status) == 0)
				throw new NotSupportedException ("The IMAP server does not support the STATUS command.");

			CheckState (false, false);

			if (items == StatusItems.None)
				return;

			var command = string.Format ("STATUS %F ({0})\r\n", Engine.GetStatusQuery (items));
			var ic = Engine.QueueCommand (cancellationToken, null, command, this);

			Engine.Wait (ic);

			ProcessResponseCodes (ic, this);

			if (ic.Response != ImapCommandResponse.Ok)
				throw ImapCommandException.Create ("STATUS", ic);
		}
Example #19
0
 /// <summary>
 /// Updates the values of the specified items.
 /// </summary>
 /// <param name="items">The items to update.</param>
 /// <exception cref="System.ObjectDisposedException">
 /// The <see cref="ImapClient"/> has been disposed.
 /// </exception>
 /// <exception cref="System.InvalidOperationException">
 /// <para>The <see cref="ImapClient"/> is not connected.</para>
 /// <para>-or-</para>
 /// <para>The <see cref="ImapClient"/> is not authenticated.</para>
 /// <para>-or-</para>
 /// <para>The folder is not currently open.</para>
 /// </exception>
 /// <exception cref="System.NotSupportedException">
 /// The IMAP server does not support the STATUS command.
 /// </exception>
 /// <exception cref="System.IO.IOException">
 /// An I/O error occurred.
 /// </exception>
 /// <exception cref="ImapProtocolException">
 /// The server's response contained unexpected tokens.
 /// </exception>
 /// <exception cref="ImapCommandException">
 /// The server replied with a NO or BAD response.
 /// </exception>
 public void Status(StatusItems items)
 {
     Status (items, CancellationToken.None);
 }
 /// <summary>
 /// Asynchronously get all of the folders within the specified namespace.
 /// </summary>
 /// <remarks>
 /// Gets all of the folders within the specified namespace.
 /// </remarks>
 /// <returns>The folders.</returns>
 /// <param name="namespace">The namespace.</param>
 /// <param name="items">The status items to pre-populate.</param>
 /// <param name="subscribedOnly">If set to <c>true</c>, only subscribed folders will be listed.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <exception cref="System.ArgumentNullException">
 /// <paramref name="namespace"/> is <c>null</c>.
 /// </exception>
 /// <exception cref="System.ObjectDisposedException">
 /// The <see cref="ImapClient"/> has been disposed.
 /// </exception>
 /// <exception cref="ServiceNotConnectedException">
 /// The <see cref="ImapClient"/> is not connected.
 /// </exception>
 /// <exception cref="ServiceNotAuthenticatedException">
 /// The <see cref="ImapClient"/> is not authenticated.
 /// </exception>
 /// <exception cref="System.OperationCanceledException">
 /// The operation was canceled via the cancellation token.
 /// </exception>
 /// <exception cref="FolderNotFoundException">
 /// The namespace folder could not be found.
 /// </exception>
 /// <exception cref="System.IO.IOException">
 /// An I/O error occurred.
 /// </exception>
 /// <exception cref="ImapCommandException">
 /// The server replied to the LIST or LSUB command with a NO or BAD response.
 /// </exception>
 /// <exception cref="ImapProtocolException">
 /// The server responded with an unexpected token.
 /// </exception>
 public override Task <IList <IMailFolder> > GetFoldersAsync(FolderNamespace @namespace, StatusItems items = StatusItems.None, bool subscribedOnly = false, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(GetFoldersAsync(@namespace, items, subscribedOnly, true, cancellationToken));
 }
Example #21
0
		/// <summary>
		/// Asynchronously get all of the folders within the specified namespace.
		/// </summary>
		/// <remarks>
		/// Asynchronously gets all of the folders within the specified namespace.
		/// </remarks>
		/// <returns>The folders.</returns>
		/// <param name="namespace">The namespace.</param>
		/// <param name="items">The status items to pre-populate.</param>
		/// <param name="subscribedOnly">If set to <c>true</c>, only subscribed folders will be listed.</param>
		/// <param name="cancellationToken">The cancellation token.</param>
		/// <exception cref="System.ArgumentNullException">
		/// <paramref name="namespace"/> is <c>null</c>.
		/// </exception>
		/// <exception cref="System.ObjectDisposedException">
		/// The <see cref="MailStore"/> has been disposed.
		/// </exception>
		/// <exception cref="ServiceNotConnectedException">
		/// The <see cref="MailStore"/> is not connected.
		/// </exception>
		/// <exception cref="ServiceNotAuthenticatedException">
		/// The <see cref="MailStore"/> is not authenticated.
		/// </exception>
		/// <exception cref="System.OperationCanceledException">
		/// The operation was canceled via the cancellation token.
		/// </exception>
		/// <exception cref="System.IO.IOException">
		/// An I/O error occurred.
		/// </exception>
		/// <exception cref="ProtocolException">
		/// A protocol error occurred.
		/// </exception>
		/// <exception cref="CommandException">
		/// The command failed.
		/// </exception>
		public virtual Task<IEnumerable<IMailFolder>> GetFoldersAsync (FolderNamespace @namespace, StatusItems items = StatusItems.None, bool subscribedOnly = false, CancellationToken cancellationToken = default (CancellationToken))
		{
			if (@namespace == null)
				throw new ArgumentNullException ("namespace");

			return Task.Factory.StartNew (() => {
				lock (SyncRoot) {
					return GetFolders (@namespace, items, subscribedOnly, cancellationToken);
				}
			}, cancellationToken, TaskCreationOptions.None, TaskScheduler.Default);
		}
Example #22
0
		/// <summary>
		/// Asynchronously update the values of the specified items.
		/// </summary>
		/// <remarks>
		/// <para>Updates the values of the specified items.</para>
		/// <para>The <see cref="Status(StatusItems, System.Threading.CancellationToken)"/> method
		/// MUST NOT be used on a folder that is already in the opened state. Instead, other ways
		/// of getting the desired information should be used.</para>
		/// <para>For example, a common use for the <see cref="Status(StatusItems,System.Threading.CancellationToken)"/>
		/// method is to get the number of unread messages in the folder. When the folder is open, however, it is
		/// possible to use the <see cref="MailFolder.Search(MailKit.Search.SearchQuery, System.Threading.CancellationToken)"/>
		/// method to query for the list of unread messages.</para>
		/// </remarks>
		/// <returns>An asynchronous task context.</returns>
		/// <param name="items">The items to update.</param>
		/// <param name="cancellationToken">The cancellation token.</param>
		/// <exception cref="System.ObjectDisposedException">
		/// The <see cref="IMailStore"/> has been disposed.
		/// </exception>
		/// <exception cref="ServiceNotConnectedException">
		/// The <see cref="IMailStore"/> is not connected.
		/// </exception>
		/// <exception cref="ServiceNotAuthenticatedException">
		/// The <see cref="IMailStore"/> is not authenticated.
		/// </exception>
		/// <exception cref="System.NotSupportedException">
		/// The mail store does not support the STATUS command.
		/// </exception>
		/// <exception cref="System.OperationCanceledException">
		/// The operation was canceled via the cancellation token.
		/// </exception>
		/// <exception cref="System.IO.IOException">
		/// An I/O error occurred.
		/// </exception>
		/// <exception cref="ProtocolException">
		/// The server's response contained unexpected tokens.
		/// </exception>
		/// <exception cref="CommandException">
		/// The command failed.
		/// </exception>
		public virtual Task StatusAsync (StatusItems items, CancellationToken cancellationToken = default (CancellationToken))
		{
			return Task.Factory.StartNew (() => {
				lock (SyncRoot) {
					Status (items, cancellationToken);
				}
			}, cancellationToken, TaskCreationOptions.None, TaskScheduler.Default);
		}
Example #23
0
        private void Load(string fileName)
        {
            if (File.Exists(fileName))
            {
                string err = "";
                try
                {
                    using StreamReader sr = new StreamReader(fileName);
                    string   line;
                    string[] elem;
                    while ((line = sr.ReadLine()) != null)
                    {
                        elem = line.Split('\t');
                        if (elem.Length != 2)
                        {
                            if (elem.Length == 3)
                            {
                                PropertyInfo pi3 = GetType().GetProperty(elem[0]);
                                if (pi3.PropertyType == typeof(List <ExtensionRule>))
                                {
                                    ((List <ExtensionRule>)pi3.GetValue(this, null)).Add(ExtensionRule.Parse(elem[1], elem[2]));
                                }
                            }
                            continue;
                        }
                        if (elem[0] == "StatusItem")
                        {
                            elem[0] = "StatusItems";
                        }
                        if (elem[0] == "Logging")
                        {
                            elem[0] = "PlayLog";
                        }
                        PropertyInfo pi = GetType().GetProperty(elem[0]);
                        if (pi == null)
                        {
                            err += $"存在しない設定項目「{elem[0]}」を読み込もうとしました。\n";
                            continue;
                        }
                        object?value = null;
                        try
                        {
                            switch (Type.GetTypeCode(pi.PropertyType))
                            {
                            case TypeCode.Boolean:
                                value = bool.Parse(elem[1]);
                                break;

                            case TypeCode.Byte:
                                value = byte.Parse(elem[1]);
                                break;

                            case TypeCode.Char:
                                value = char.Parse(elem[1]);
                                break;

                            case TypeCode.DBNull:
                                err += $"読み込みに対応していない設定「{elem[0]}」を読み込もうとしました。\n";
                                continue;

                            case TypeCode.DateTime:
                                value = DateTime.Parse(elem[1]);
                                break;

                            case TypeCode.Decimal:
                                value = decimal.Parse(elem[1]);
                                break;

                            case TypeCode.Double:
                                value = double.Parse(elem[1]);
                                break;

                            case TypeCode.Empty:
                                err += $"読み込みに対応していない設定「{elem[0]}」を読み込もうとしました。\n";
                                continue;

                            case TypeCode.Int16:
                                value = short.Parse(elem[1]);
                                break;

                            case TypeCode.Int32:
                                value = int.Parse(elem[1]);
                                break;

                            case TypeCode.Int64:
                                value = long.Parse(elem[1]);
                                break;

                            case TypeCode.Object:
                                if (pi.PropertyType == typeof(List <StatusItem>))
                                {
                                    ((List <StatusItem>)pi.GetValue(this, null)).Add(StatusItem.Parse(elem[1]));
                                }
                                else
                                {
                                    err += $"読み込みに対応していない設定「{elem[0]}」を読み込もうとしました。\n";
                                }
                                continue;

                            case TypeCode.SByte:
                                value = sbyte.Parse(elem[1]);
                                break;

                            case TypeCode.Single:
                                value = float.Parse(elem[1]);
                                break;

                            case TypeCode.String:
                                value = elem[1];
                                break;

                            case TypeCode.UInt16:
                                value = ushort.Parse(elem[1]);
                                break;

                            case TypeCode.UInt32:
                                value = uint.Parse(elem[1]);
                                break;

                            case TypeCode.UInt64:
                                value = ulong.Parse(elem[1]);
                                break;

                            default:
                                err += $"読み込みに対応していない設定「{elem[0]}」を読み込もうとしました。\n";
                                continue;
                            }
                            pi.SetValue(this, value, null);
                        }
                        catch (Exception e)
                        {
                            err += $"設定「{elem[0]}」の値「{elem[1]}」が以下のエラーのため認識できませんでした。\n メッセージ:{e.Message}\n";
                        }
                    }
                }
                catch (Exception e)
                {
                    err += $"設定読み込み中に以下のエラーが発生しました。\n メッセージ:{e.Message}\n";
                }
                if (err.Length > 0)
                {
                    MessageBox.Show(err);
                }
            }
            if (StatusItems.Count == 0)
            {
                StatusItems.Add(new StatusItemFullPathName());
                StatusItems.Add(new StatusItemPlayGauge());
            }
        }
 public LoadStatus()
 {
     Status             = StatusItems.STOPPED;
     TotalResults       = 0;
     TotalResultsLoaded = 0;
 }
Example #25
0
		/// <summary>
		/// Update the values of the specified items.
		/// </summary>
		/// <remarks>
		/// <para>Updates the values of the specified items.</para>
		/// <para>The <see cref="Status(StatusItems, System.Threading.CancellationToken)"/> method
		/// MUST NOT be used on a folder that is already in the opened state. Instead, other ways
		/// of getting the desired information should be used.</para>
		/// <para>For example, a common use for the <see cref="Status(StatusItems,System.Threading.CancellationToken)"/>
		/// method is to get the number of unread messages in the folder. When the folder is open, however, it is
		/// possible to use the <see cref="MailFolder.Search(MailKit.Search.SearchQuery, System.Threading.CancellationToken)"/>
		/// method to query for the list of unread messages.</para>
		/// </remarks>
		/// <param name="items">The items to update.</param>
		/// <param name="cancellationToken">The cancellation token.</param>
		/// <exception cref="System.ObjectDisposedException">
		/// The <see cref="IMailStore"/> has been disposed.
		/// </exception>
		/// <exception cref="ServiceNotConnectedException">
		/// The <see cref="IMailStore"/> is not connected.
		/// </exception>
		/// <exception cref="ServiceNotAuthenticatedException">
		/// The <see cref="IMailStore"/> is not authenticated.
		/// </exception>
		/// <exception cref="FolderNotFoundException">
		/// The <see cref="MailFolder"/> does not exist.
		/// </exception>
		/// <exception cref="System.NotSupportedException">
		/// The mail store does not support the STATUS command.
		/// </exception>
		/// <exception cref="System.OperationCanceledException">
		/// The operation was canceled via the cancellation token.
		/// </exception>
		/// <exception cref="System.IO.IOException">
		/// An I/O error occurred.
		/// </exception>
		/// <exception cref="ProtocolException">
		/// The server's response contained unexpected tokens.
		/// </exception>
		/// <exception cref="CommandException">
		/// The command failed.
		/// </exception>
		public abstract void Status (StatusItems items, CancellationToken cancellationToken = default (CancellationToken));
Example #26
0
        public async void LoadData()
        {
            IsBusy = true;
            if (_isDataLoading)
            {
                return;
            }
            _isDataLoading = true;
            LoadOptions();

            EndDate   = EndDateOption;
            StartDate = StartDateOption;

            var rates = await _reportsDataUnit.ProductVatRatesRepository.GetAllAsync();

            ProductVATRates = rates.OrderBy(x => x.Rate);
            ProductGroups   = await _reportsDataUnit.ProductGroupsRepository.GetAllAsync(x => x.GroupName != "Blank");

            ProductDepartments = await _reportsDataUnit.ProductDepartmentsRepository.GetAllAsync(x => x.Department != "Blank");

            var bookedProducts = await _reportsDataUnit.EventBookedProductsRepository.GetAllAsyncWithIncludeForwardBook(x => !x.Event.IsDeleted && x.Event.ShowInForwardBook && x.Event.Date > StartDate && x.Event.Date < EndDate);

            _allEventBookedProducts = new List <EventBookedProductModel>(bookedProducts.Select(x => new EventBookedProductModel(x)));
            EventBookedProducts     = new ObservableCollection <EventBookedProductModel>(_allEventBookedProducts);

            ForwardBook      = new ObservableCollection <ForwardBookModel>();
            ColumnCollection = new ObservableCollection <GridViewDataColumn>();

            EventBookedProducts = new ObservableCollection <EventBookedProductModel>(_allEventBookedProducts.Where(x => StatusItems.Contains(x.EventStatus)));
            EventBookedProducts.ForEach(p => p.GroupByProductGroup = GroupOption);
            EventBookedProducts.ForEach(p => p.IncVat = IncVATOption);

            _isDataLoading = false;

            IsBusy = false;
        }
Example #27
0
		/// <summary>
		/// Get all of the folders within the specified namespace.
		/// </summary>
		/// <remarks>
		/// Gets all of the folders within the specified namespace.
		/// </remarks>
		/// <returns>The folders.</returns>
		/// <param name="namespace">The namespace.</param>
		/// <param name="items">The status items to pre-populate.</param>
		/// <param name="subscribedOnly">If set to <c>true</c>, only subscribed folders will be listed.</param>
		/// <param name="cancellationToken">The cancellation token.</param>
		/// <exception cref="System.ArgumentNullException">
		/// <paramref name="namespace"/> is <c>null</c>.
		/// </exception>
		/// <exception cref="System.ObjectDisposedException">
		/// The <see cref="MailStore"/> has been disposed.
		/// </exception>
		/// <exception cref="ServiceNotConnectedException">
		/// The <see cref="MailStore"/> is not connected.
		/// </exception>
		/// <exception cref="ServiceNotAuthenticatedException">
		/// The <see cref="MailStore"/> is not authenticated.
		/// </exception>
		/// <exception cref="System.OperationCanceledException">
		/// The operation was canceled via the cancellation token.
		/// </exception>
		/// <exception cref="System.IO.IOException">
		/// An I/O error occurred.
		/// </exception>
		/// <exception cref="ProtocolException">
		/// A protocol error occurred.
		/// </exception>
		/// <exception cref="CommandException">
		/// The command failed.
		/// </exception>
		public abstract IEnumerable<IMailFolder> GetFolders (FolderNamespace @namespace, StatusItems items = StatusItems.None, bool subscribedOnly = false, CancellationToken cancellationToken = default (CancellationToken));
Example #28
0
        private async void RefreshForwardBookings()
        {
            if (!_isDescriptionActivated)
            {
                return;
            }

            if (_isDataLoading || _isRefreshing)
            {
                return;
            }

            _isRefreshing = true;

            ForwardBook      = new ObservableCollection <ForwardBookModel>();
            ColumnCollection = new ObservableCollection <GridViewDataColumn>();

            IsBusy = true;

            _reportsDataUnit.EventsRepository.Refresh();
            _reportsDataUnit.EventBookedProductsRepository.Refresh();
            var bookedProducts = await _reportsDataUnit.EventBookedProductsRepository.GetAllAsyncWithIncludeForwardBook(x => !x.Event.IsDeleted && x.Event.ShowInForwardBook && x.Event.Date > StartDate && x.Event.Date < EndDate);

            _allEventBookedProducts = new List <EventBookedProductModel>(bookedProducts.Select(x => new EventBookedProductModel(x)));

            EventBookedProducts = new ObservableCollection <EventBookedProductModel>(_allEventBookedProducts.Where(x => StatusItems.Contains(x.EventStatus)));
            EventBookedProducts.ForEach(p => p.GroupByProductGroup = GroupOption);
            EventBookedProducts.ForEach(p => p.IncVat = IncVATOption);

            _isRefreshing = false;

            IsBusy = false;
        }
Example #29
0
		/// <summary>
		/// Updates the values of the specified items.
		/// </summary>
		/// <remarks>
		/// <para>Updates the values of the specified items.</para>
		/// <para>The <see cref="Status(StatusItems, System.Threading.CancellationToken)"/> method
		/// MUST NOT be used on a folder that is already in the opened state. Instead, other ways
		/// of getting the desired information should be used.</para>
		/// <para>For example, a common use for the <see cref="Status(StatusItems,System.Threading.CancellationToken)"/>
		/// method is to get the number of unread messages in the folder. When the folder is open, however, it is
		/// possible to use the <see cref="ImapFolder.Search(MailKit.Search.SearchQuery, System.Threading.CancellationToken)"/>
		/// method to query for the list of unread messages.</para>
		/// <para>For more information about the <c>STATUS</c> command, see
		/// <a href="https://tools.ietf.org/html/rfc3501#section-6.3.10">rfc3501</a>.</para>
		/// </remarks>
		/// <param name="items">The items to update.</param>
		/// <param name="cancellationToken">The cancellation token.</param>
		/// <exception cref="System.ObjectDisposedException">
		/// The <see cref="ImapClient"/> has been disposed.
		/// </exception>
		/// <exception cref="ServiceNotConnectedException">
		/// The <see cref="ImapClient"/> is not connected.
		/// </exception>
		/// <exception cref="ServiceNotAuthenticatedException">
		/// The <see cref="ImapClient"/> is not authenticated.
		/// </exception>
		/// <exception cref="FolderNotFoundException">
		/// The <see cref="ImapFolder"/> does not exist.
		/// </exception>
		/// <exception cref="System.NotSupportedException">
		/// The IMAP server does not support the STATUS command.
		/// </exception>
		/// <exception cref="System.OperationCanceledException">
		/// The operation was canceled via the cancellation token.
		/// </exception>
		/// <exception cref="System.IO.IOException">
		/// An I/O error occurred.
		/// </exception>
		/// <exception cref="ImapProtocolException">
		/// The server's response contained unexpected tokens.
		/// </exception>
		/// <exception cref="ImapCommandException">
		/// The server replied with a NO or BAD response.
		/// </exception>
		public override void Status (StatusItems items, CancellationToken cancellationToken = default (CancellationToken))
		{
			if ((Engine.Capabilities & ImapCapabilities.Status) == 0)
				throw new NotSupportedException ("The IMAP server does not support the STATUS command.");

			CheckState (false, false);

			string flags = string.Empty;
			if ((items & StatusItems.Count) != 0)
				flags += "MESSAGES ";
			if ((items & StatusItems.Recent) != 0)
				flags += "RECENT ";
			if ((items & StatusItems.UidNext) != 0)
				flags += "UIDNEXT ";
			if ((items & StatusItems.UidValidity) != 0)
				flags += "UIDVALIDITY ";
			if ((items & StatusItems.Unread) != 0)
				flags += "UNSEEN ";

			if ((Engine.Capabilities & ImapCapabilities.CondStore) != 0) {
				if ((items & StatusItems.HighestModSeq) != 0)
					flags += "HIGHESTMODSEQ ";
			}

			flags = flags.TrimEnd ();

			var command = string.Format ("STATUS %F ({0})\r\n", flags);
			var ic = Engine.QueueCommand (cancellationToken, null, command, this);

			Engine.Wait (ic);

			ProcessResponseCodes (ic, this);

			if (ic.Response != ImapCommandResponse.Ok)
				throw ImapCommandException.Create ("STATUS", ic);
		}
Example #30
0
		/// <summary>
		/// Get the subfolders.
		/// </summary>
		/// <remarks>
		/// <para>Gets the subfolders as well as queries the server for the status of the requested items.</para>
		/// <para>When the <paramref name="items"/> argument is non-empty, this has the equivalent functionality
		/// of calling <see cref="GetSubfolders(bool,System.Threading.CancellationToken)"/> and then calling
		/// <see cref="Status(StatusItems,System.Threading.CancellationToken)"/> on each of the returned folders.</para>
		/// </remarks>
		/// <returns>The subfolders.</returns>
		/// <param name="items">The status items to pre-populate.</param>
		/// <param name="subscribedOnly">If set to <c>true</c>, only subscribed folders will be listed.</param>
		/// <param name="cancellationToken">The cancellation token.</param>
		/// <exception cref="System.ObjectDisposedException">
		/// The <see cref="IMailStore"/> has been disposed.
		/// </exception>
		/// <exception cref="ServiceNotConnectedException">
		/// The <see cref="IMailStore"/> is not connected.
		/// </exception>
		/// <exception cref="ServiceNotAuthenticatedException">
		/// The <see cref="IMailStore"/> is not authenticated.
		/// </exception>
		/// <exception cref="System.OperationCanceledException">
		/// The operation was canceled via the cancellation token.
		/// </exception>
		/// <exception cref="System.IO.IOException">
		/// An I/O error occurred.
		/// </exception>
		/// <exception cref="ProtocolException">
		/// The server's response contained unexpected tokens.
		/// </exception>
		/// <exception cref="CommandException">
		/// The command failed.
		/// </exception>
		public abstract IEnumerable<IMailFolder> GetSubfolders (StatusItems items, bool subscribedOnly = false, CancellationToken cancellationToken = default (CancellationToken));
Example #31
0
 /// <summary>
 /// Asynchronously get all of the folders within the specified namespace.
 /// </summary>
 /// <remarks>
 /// Asynchronously gets all of the folders within the specified namespace.
 /// </remarks>
 /// <returns>The folders.</returns>
 /// <param name="namespace">The namespace.</param>
 /// <param name="items">The status items to pre-populate.</param>
 /// <param name="subscribedOnly">If set to <c>true</c>, only subscribed folders will be listed.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <exception cref="System.ArgumentNullException">
 /// <paramref name="namespace"/> is <c>null</c>.
 /// </exception>
 /// <exception cref="System.ObjectDisposedException">
 /// The <see cref="MailStore"/> has been disposed.
 /// </exception>
 /// <exception cref="ServiceNotConnectedException">
 /// The <see cref="MailStore"/> is not connected.
 /// </exception>
 /// <exception cref="ServiceNotAuthenticatedException">
 /// The <see cref="MailStore"/> is not authenticated.
 /// </exception>
 /// <exception cref="System.OperationCanceledException">
 /// The operation was canceled via the cancellation token.
 /// </exception>
 /// <exception cref="System.IO.IOException">
 /// An I/O error occurred.
 /// </exception>
 /// <exception cref="ProtocolException">
 /// A protocol error occurred.
 /// </exception>
 /// <exception cref="CommandException">
 /// The command failed.
 /// </exception>
 public abstract Task <IList <IMailFolder> > GetFoldersAsync(FolderNamespace @namespace, StatusItems items = StatusItems.None, bool subscribedOnly = false, CancellationToken cancellationToken = default(CancellationToken));
Example #32
0
		/// <summary>
		/// Asynchronously get the subfolders.
		/// </summary>
		/// <remarks>
		/// <para>Asynchronously gets the subfolders as well as queries the server for the status of the requested items.</para>
		/// <para>When the <paramref name="items"/> argument is non-empty, this has the equivalent functionality
		/// of calling <see cref="GetSubfoldersAsync(bool,System.Threading.CancellationToken)"/> and then calling
		/// <see cref="StatusAsync(StatusItems,System.Threading.CancellationToken)"/> on each of the returned folders.</para>
		/// </remarks>
		/// <returns>The subfolders.</returns>
		/// <param name="items">The status items to pre-populate.</param>
		/// <param name="subscribedOnly">If set to <c>true</c>, only subscribed folders will be listed.</param>
		/// <param name="cancellationToken">The cancellation token.</param>
		/// <exception cref="System.ObjectDisposedException">
		/// The <see cref="IMailStore"/> has been disposed.
		/// </exception>
		/// <exception cref="ServiceNotConnectedException">
		/// The <see cref="IMailStore"/> is not connected.
		/// </exception>
		/// <exception cref="ServiceNotAuthenticatedException">
		/// The <see cref="IMailStore"/> is not authenticated.
		/// </exception>
		/// <exception cref="System.OperationCanceledException">
		/// The operation was canceled via the cancellation token.
		/// </exception>
		/// <exception cref="System.IO.IOException">
		/// An I/O error occurred.
		/// </exception>
		/// <exception cref="ProtocolException">
		/// The server's response contained unexpected tokens.
		/// </exception>
		/// <exception cref="CommandException">
		/// The command failed.
		/// </exception>
		public virtual Task<IEnumerable<IMailFolder>> GetSubfoldersAsync (StatusItems items, bool subscribedOnly = false, CancellationToken cancellationToken = default (CancellationToken))
		{
			return Task.Factory.StartNew (() => {
				lock (SyncRoot) {
					return GetSubfolders (items, subscribedOnly, cancellationToken);
				}
			}, cancellationToken, TaskCreationOptions.None, TaskScheduler.Default);
		}
Example #33
0
		/// <summary>
		/// Gets the subfolders.
		/// </summary>
		/// <remarks>
		/// Gets the subfolders.
		/// </remarks>
		/// <returns>The subfolders.</returns>
		/// <param name="items">The status items to pre-populate.</param>
		/// <param name="subscribedOnly">If set to <c>true</c>, only subscribed folders will be listed.</param>
		/// <param name="cancellationToken">The cancellation token.</param>
		/// <exception cref="System.ObjectDisposedException">
		/// The <see cref="ImapClient"/> has been disposed.
		/// </exception>
		/// <exception cref="ServiceNotConnectedException">
		/// The <see cref="ImapClient"/> is not connected.
		/// </exception>
		/// <exception cref="ServiceNotAuthenticatedException">
		/// The <see cref="ImapClient"/> is not authenticated.
		/// </exception>
		/// <exception cref="System.OperationCanceledException">
		/// The operation was canceled via the cancellation token.
		/// </exception>
		/// <exception cref="System.IO.IOException">
		/// An I/O error occurred.
		/// </exception>
		/// <exception cref="ImapProtocolException">
		/// The server's response contained unexpected tokens.
		/// </exception>
		/// <exception cref="ImapCommandException">
		/// The server replied with a NO or BAD response.
		/// </exception>
		public override IEnumerable<IMailFolder> GetSubfolders (StatusItems items, bool subscribedOnly = false, CancellationToken cancellationToken = default (CancellationToken))
		{
			CheckState (false, false);

			var pattern = EncodedName.Length > 0 ? EncodedName + DirectorySeparator : string.Empty;
			var children = new List<IMailFolder> ();
			var status = items != StatusItems.None;
			var list = new List<ImapFolder> ();
			var command = new StringBuilder ();
			var lsub = subscribedOnly;

			if (subscribedOnly) {
				if ((Engine.Capabilities & ImapCapabilities.ListExtended) != 0) {
					command.Append ("LIST (SUBSCRIBED)");
					lsub = false;
				} else {
					command.Append ("LSUB");
				}
			} else {
				command.Append ("LIST");
			}

			command.Append (" \"\" %S");

			if (!lsub) {
				if (items != StatusItems.None && (Engine.Capabilities & ImapCapabilities.ListStatus) != 0) {
					command.Append (" RETURN (");

					if ((Engine.Capabilities & ImapCapabilities.ListExtended) != 0) {
						if (!subscribedOnly)
							command.Append ("SUBSCRIBED ");
						command.Append ("CHILDREN ");
					}

					command.AppendFormat ("STATUS ({0})", Engine.GetStatusQuery (items));
					command.Append (')');
					status = false;
				} else if ((Engine.Capabilities & ImapCapabilities.ListExtended) != 0) {
					command.Append (" RETURN (");
					if (!subscribedOnly)
						command.Append ("SUBSCRIBED ");
					command.Append ("CHILDREN");
					command.Append (')');
				}
			}

			command.Append ("\r\n");

			var ic = new ImapCommand (Engine, cancellationToken, null, command.ToString (), pattern + "%");
			ic.RegisterUntaggedHandler (lsub ? "LSUB" : "LIST", ImapUtils.ParseFolderList);
			ic.UserData = list;

			Engine.QueueCommand (ic);
			Engine.Wait (ic);

			// Note: Some broken IMAP servers (*cough* SmarterMail 13.0 *cough*) return folders
			// that are not children of the folder we requested, so we need to filter those
			// folders out of the list that we'll be returning to our caller.
			//
			// See https://github.com/jstedfast/MailKit/issues/149 for more details.
			var prefix = FullName.Length > 0 ? FullName + DirectorySeparator : string.Empty;
			prefix = ImapUtils.CanonicalizeMailboxName (prefix, DirectorySeparator);
			foreach (var folder in list) {
				var canonicalFullName = ImapUtils.CanonicalizeMailboxName (folder.FullName, folder.DirectorySeparator);
				var canonicalName = ImapUtils.IsInbox (folder.FullName) ? "INBOX" : folder.Name;

				if (canonicalFullName != prefix + canonicalName)
					continue;

				if (lsub) {
					// the LSUB command does not send \Subscribed flags so we need to add them ourselves
					folder.Attributes |= FolderAttributes.Subscribed;
				}

				folder.ParentFolder = this;
				children.Add (folder);
			}

			ProcessResponseCodes (ic, null);

			if (ic.Response != ImapCommandResponse.Ok)
				throw ImapCommandException.Create (lsub ? "LSUB" : "LIST", ic);

			if (status) {
				for (int i = 0; i < children.Count; i++)
					children[i].Status (items, cancellationToken);
			}

			return children;
		}
Example #34
0
		/// <summary>
		/// Get all of the folders within the specified namespace.
		/// </summary>
		/// <remarks>
		/// Gets all of the folders within the specified namespace.
		/// </remarks>
		/// <returns>The folders.</returns>
		/// <param name="namespace">The namespace.</param>
		/// <param name="items">The status items to pre-populate.</param>
		/// <param name="subscribedOnly">If set to <c>true</c>, only subscribed folders will be listed.</param>
		/// <param name="cancellationToken">The cancellation token.</param>
		/// <exception cref="System.ArgumentNullException">
		/// <paramref name="namespace"/> is <c>null</c>.
		/// </exception>
		/// <exception cref="System.ObjectDisposedException">
		/// The <see cref="ImapClient"/> has been disposed.
		/// </exception>
		/// <exception cref="ServiceNotConnectedException">
		/// The <see cref="ImapClient"/> is not connected.
		/// </exception>
		/// <exception cref="ServiceNotAuthenticatedException">
		/// The <see cref="ImapClient"/> is not authenticated.
		/// </exception>
		/// <exception cref="System.OperationCanceledException">
		/// The operation was canceled via the cancellation token.
		/// </exception>
		/// <exception cref="FolderNotFoundException">
		/// The namespace folder could not be found.
		/// </exception>
		/// <exception cref="System.IO.IOException">
		/// An I/O error occurred.
		/// </exception>
		/// <exception cref="ImapCommandException">
		/// The server replied to the LIST or LSUB command with a NO or BAD response.
		/// </exception>
		/// <exception cref="ImapProtocolException">
		/// The server responded with an unexpected token.
		/// </exception>
		public override IList<IMailFolder> GetFolders (FolderNamespace @namespace, StatusItems items = StatusItems.None, bool subscribedOnly = false, CancellationToken cancellationToken = default (CancellationToken))
		{
			if (@namespace == null)
				throw new ArgumentNullException (nameof (@namespace));

			CheckDisposed ();
			CheckConnected ();
			CheckAuthenticated ();

			var folders = engine.GetFolders (@namespace, items, subscribedOnly, cancellationToken);
			var list = new IMailFolder[folders.Count];

			for (int i = 0; i < list.Length; i++)
				list[i] = (IMailFolder) folders[i];

			return list;
		}