/**************************
        *   ===== Processing =====
        **************************/

        private void ProcessThread(int id, string html)
        {
            if (String.IsNullOrEmpty(html))
            {
                DatabaseQueue.Enqueue(new DbModels.Thread()
                {
                    Id = id
                });
                TelemetryManager.IncrimentEmptyThreads();
                return;
            }

            RobloxThread thread = new RobloxThread(id);

            thread.AddPage(html);
            if (thread.IsEmpty)
            {
                DatabaseQueue.Enqueue(new DbModels.Thread()
                {
                    Id = id
                });
                TelemetryManager.IncrimentEmptyThreads();
                return;
            }
            if (thread.PagesCount > 1 && thread.CurrentPage < thread.PagesCount)
            {
                PageDownloadingQueue.Enqueue(thread);
                return;
            }

            DbModels.Thread dbThread = thread.ToDbThread();
            DatabaseQueue.Enqueue(dbThread);
            thread = null; //TODO: Evaluate necessity
            return;
        }
        /// <summary>
        /// Modifies the mailbox permissions for the user and updates the database that it was completed
        /// </summary>
        /// <param name="getQueue"></param>
        /// <param name="database"></param>
        private void SetCalendarPermissions(DatabaseQueue getQueue)
        {
            ExchPowershell powershell = null;

            try
            {
                // DEBUG // 
                logger.Debug("Found queue to modify mailbox calendar permissions for " + getQueue.UserPrincipalName);

                // Start up powershell
                powershell = new ExchPowershell();

                // Run powershell command
                powershell.Set_MailboxCalendarPermission(getQueue.UserPrincipalName, getQueue.CompanyCode);

                // Update database
                getQueue.TaskOutput = "Completed Successfully";
                getQueue.TaskCompleted = DateTime.Now;
                getQueue.TaskSuccess = (int)Enumerations.TaskSuccess.Completed;

                DbSql.Update_DatabaseQueue(getQueue);
            }
            catch (Exception ex)
            {
                // Update database
                getQueue.TaskOutput = ex.Message;
                getQueue.TaskCompleted = DateTime.Now;
                getQueue.TaskSuccess = Enumerations.TaskSuccess.Failed;

                DbSql.Update_DatabaseQueue(getQueue);

                // Compile message
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Failed to set the correct calendar permissions on user: "******"");
                sb.AppendLine("Recommended Action:");
                sb.AppendLine("Not having the correct permissions on the mailbox calendar can cause leakage of information between tenants. Please contact support or try the recommended action below.");
                sb.AppendLine("");
                sb.AppendLine("Open Exchange Shell and run the following commands:");
                sb.AppendLine(string.Format(@"Set-MailboxFolderPermission -Identity '{0}:\Calendar' -User Default -AccessRights None", getQueue.UserPrincipalName));
                sb.AppendLine("");
                sb.AppendLine(string.Format(@"Add-MailboxFolderPermission -Identity '{0}:\Calendar' -User 'ExchangeSecurity@{1}' -AccessRights AvailabilityOnly", getQueue.UserPrincipalName, getQueue.CompanyCode));
                sb.AppendLine("");
                sb.AppendLine("");
                sb.AppendLine("Please remember that the word 'Calendar' may be in a differnet language depending on the language the mailbox is set for.");
                sb.AppendLine("If you have any issues after attempting to repair please contact support.");
                sb.AppendLine("");
                sb.AppendLine("");
                sb.AppendLine("Error:");
                sb.AppendLine(ex.ToString());

                // Send message
                Support.SendEmailMessage("Failed to set calendar permissions on user: "+  getQueue.UserPrincipalName, sb.ToString());
            }
            finally
            {
                if (powershell != null)
                    powershell.Dispose();
            }
        }