private void showResults(QueueMessage message, Dictionary<string, string>[] results)
 {
     showResults(message.Properties["PublishToEmail"].Equals("true", StringComparison.InvariantCultureIgnoreCase) , results);
 }
        private bool handleMessage(QueueMessage message)
        {
            if(!KeepRunning())
            {
                return false;
            }

            if (active)
            {
                if ((message.Action == "InventoryRetrieval" || message.Action == "ArchiveRetrieval") && message.JobId != null)
                {
                    completeJob(message.Properties, message.Action);
                    return true;
                }
                else if (message.Action == "ReuploadArchive" && message.ArchiveId != null)
                {
                    using (ArchiveTransferManager manager = new ArchiveTransferManager(Context.Mapping.AccessKey, Context.Mapping.SecretKey, Context.Mapping.Endpoint))
                    {
                        Context.Vault.reuploadArchive(manager, message.ArchiveId, Context.Mapping.LocalFolder);
                    }
                    return true;
                }
                else if (message.Action == "DeleteArchive" && message.ArchiveId != null)
                {
                    using (ArchiveTransferManager manager = new ArchiveTransferManager(Context.Mapping.AccessKey, Context.Mapping.SecretKey, Context.Mapping.Endpoint))
                    {
                        Context.Vault.deleteArchive(manager, message.ArchiveId);
                    }
                    return true;
                }
                else if (message.Action == "ArchiveRetrievalStarted" && message.ArchiveId != null)
                {
                    DateTime scheduledAt = message.ScheduledAt != null && message.ScheduledAt.HasValue ? message.ScheduledAt.Value : DateTime.Now;
                    Context.Vault.recordDownloadScheduled(message.ArchiveId, message.JobId, scheduledAt);
                    return true;
                }
                else if (message.Action == "StartSynchronizing")
                {
                    Sync.SynchronizingWithServer = true;
                    return true;
                }
                else if (message.Action == "Stop")
                {
                    Sync.stop();
                    return true;
                }
                else if (message.Action == "ListJobs")
                {
                    showResults(message, listJobs());
                    return true;
                }
                else if (message.Action == "DescribeJob" && message.JobId != null)
                {
                    showResults(message, describeJob(message.JobId));
                    return true;
                }
            }

            if (message.Action == "StatusCheck")
            {
                showResults(message, showStatus());
                return true;
            }
            else if (message.Action == "Inactivate")
            {
                active = false;
                return true;
            }
            else if (message.Action == "Activate")
            {
                active = true;
                return true;
            }

            return false;
        }