public FolderVaultMapping(FolderVaultMapping mapping)
 {
     this.LocalFolder = mapping.LocalFolder;
     this.VaultName = mapping.VaultName;
     this.Region = mapping.Region;
     this.NotificationTopicARN = mapping.NotificationTopicARN;
     this.NotificationQueueURL = mapping.NotificationQueueURL;
     this.AccessKey = mapping.AccessKey;
     this.SecretKey = mapping.SecretKey;
 }
Пример #2
0
        public static DescribeJobResult describeJob(FolderVaultMapping mapping, string jobId)
        {
            using (AmazonGlacierClient client = new AmazonGlacierClient(mapping.AccessKey, mapping.SecretKey, mapping.Endpoint))
            {
                DescribeJobRequest req = new DescribeJobRequest();
                req.AccountId = "-";
                req.JobId = jobId;
                req.VaultName = mapping.VaultName;

                return client.DescribeJob(req).DescribeJobResult;
            }
        }
Пример #3
0
        public static List<GlacierJobDescription> listJobs(FolderVaultMapping mapping)
        {
            using (AmazonGlacierClient client = new AmazonGlacierClient(mapping.AccessKey, mapping.SecretKey, mapping.Endpoint))
            {
                ListJobsRequest req = new ListJobsRequest();
                req.AccountId = "-";
                req.Completed = false;
                req.VaultName = mapping.VaultName;

                return client.ListJobs(req).ListJobsResult.JobList;
            }
        }
Пример #4
0
        public void publish(FolderVaultMapping mapping, bool publishToEmailTopic)
        {
            StringBuilder message = new StringBuilder("{\"Action\":");
            message.Append(safeString(Action));
            foreach (KeyValuePair<string, string> pair in Properties)
            {
                message.Append(',');
                message.Append(safeString(pair.Key));
                message.Append(':');
                message.Append(safeString(pair.Value));
            }
            message.Append("}");

            using (AmazonSimpleNotificationServiceClient client = new AmazonSimpleNotificationServiceClient(mapping.AccessKey, mapping.SecretKey, mapping.Endpoint))
            {
                PublishRequest req = new PublishRequest();
                req.TopicArn = publishToEmailTopic ? mapping.EmailTopicARN : mapping.NotificationTopicARN;
                req.Message = message.ToString();
                MessageId = client.Publish(req).PublishResult.MessageId;
            }
        }
Пример #5
0
 public VaultContext(FolderVaultMapping mapping, Vault inventory)
 {
     Mapping = mapping;
     Vault = inventory == null ? new Vault(mapping.VaultName) : inventory;
 }
Пример #6
0
 public VaultContext(FolderVaultMapping mapping)
     : this(mapping, null)
 {
 }
Пример #7
0
        public void save(XmlWriter writer, FolderVaultMapping mapping)
        {
            DateTime start = DateTime.Now;

            writer.WriteStartElement("Vault");

            if (mapping != null)
            {
                writer.WriteElementString("LocalFolder", mapping.LocalFolder);
                writer.WriteElementString("AccessKey", mapping.AccessKey);
                writer.WriteElementString("SecretKey", mapping.SecretKey);
                writer.WriteElementString("NotificationQueueURL", mapping.NotificationQueueURL);
                writer.WriteElementString("NotificationTopicARN", mapping.NotificationTopicARN);
                writer.WriteElementString("Region", mapping.Region.ToString());
            }

            writer.WriteElementString("VaultARN", VaultARN);
            writer.WriteElementString("VaultName", VaultName);
            writer.WriteElementString("InventoryDate", DateFormat.formatDateTime(InventoryDate, true));
            writer.WriteElementString("SaveDate", DateFormat.formatDateTime(DateTime.Now, true));
            writer.WriteElementString("UploadCount", UploadCount.ToString());
            writer.WriteElementString("UploadBytes", UploadBytes.ToString());
            writer.WriteElementString("UploadTime", UploadTime.ToString());
            writer.WriteElementString("DownloadCount", DownloadCount.ToString());
            writer.WriteElementString("DownloadBytes", DownloadBytes.ToString());
            writer.WriteElementString("DownloadTime", DownloadTime.ToString());
            writer.WriteElementString("DeleteCount", DeleteCount.ToString());
            writer.WriteElementString("DeleteTime", DeleteTime.ToString());
            writer.WriteElementString("LoadedFromFile", loadedFromFile.ToString());
            writer.WriteElementString("LoadedFromServer", loadedFromServer.ToString());
            save(writer, "ArchiveList", Uploaded);
            save(writer, "ToDelete", ToDelete);
            save(writer, "ToUpload", ToUpload);
            save(writer, "DeleteErrors", DeleteErrors);
            save(writer, "UploadErrors", UploadErrors);
            writer.WriteEndElement();

            SaveTime += DateTime.Now.Subtract(start);
            isDirty = false;
        }
Пример #8
0
 public void downloadArchive(string archiveId, FolderVaultMapping mapping, Func<bool> keepRunning)
 {
     Archive arch = inventoryById.ContainsKey(archiveId) ? inventoryById[archiveId] : null;
     if (arch != null)
     {
         arch.beginDownload(mapping, keepRunning);
         toDownload.Add(arch);
         isDirty = true;
     }
 }
Пример #9
0
        public void completeDownload(FolderVaultMapping mapping, string archiveId, string jobId, long totalBytes, Stream body)
        {
            Archive arch = inventoryById.ContainsKey(archiveId) ? inventoryById[archiveId] : null;

            if (arch != null)
            {
                DateTime start = DateTime.Now;

                try
                {
                    arch.endDownload(mapping, jobId, totalBytes, body);
                }
                finally
                {
                    DownloadBytes += arch.DownloadDetails != null ? arch.DownloadDetails.TransferredBytes : arch.FileLength;
                    DownloadTime += DateTime.Now.Subtract(start);
                    toDownload.Remove(arch);
                    isDirty = true;
                }
            }
        }
 public InventoryRetrievalJob(FolderVaultMapping mapping, Func<bool> keepRunning, bool sendJobScheduledNotification)
     : base(mapping, keepRunning, sendJobScheduledNotification)
 {
 }
 public InventoryRetrievalJob(FolderVaultMapping mapping, Func<bool> keepRunning)
     : this(mapping, keepRunning, false)
 {
 }
Пример #12
0
 protected JobExecutor(FolderVaultMapping mapping, Func<bool> keepRunning, bool sendJobScheduledNotification)
 {
     Mapping = mapping;
     KeepRunning = keepRunning;
     SendJobScheduledNotification = sendJobScheduledNotification;
 }
 public ArchiveRetrievalJob(FolderVaultMapping mapping, Func<bool> keepRunning, string archiveId, bool sendJobScheduledNotification)
     : base(mapping, keepRunning, sendJobScheduledNotification)
 {
     ArchiveId = archiveId;
 }
 public ArchiveRetrievalJob(FolderVaultMapping mapping, Func<bool> keepRunning, string archiveId)
     : this(mapping, keepRunning, archiveId, false)
 {
 }
Пример #15
0
        public void endDownload(FolderVaultMapping mapping, string jobId, long totalBytes, Stream body)
        {
            byte[] buffer = new byte[65536];
            int len;

            DownloadDetails = DownloadDetails == null ? new DownloadInfo(jobId, DateTime.Now) : DownloadDetails;
            DownloadDetails.StartedAt = DateTime.Now;
            DownloadDetails.TotalBytes = totalBytes;

            try
            {
                using (FileStream file = File.OpenWrite(mapping.LocalFolder + "\\" + RelativePath))
                {
                    while ((len = body.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        DownloadDetails.TransferredBytes += len;
                        file.Write(buffer, 0, len);
                    }

                    file.Flush();
                }
            }
            finally
            {
                DownloadDetails.CompletedAt = DateTime.Now;
                IsDirty = true;
            }
        }
Пример #16
0
 public void beginDownload(FolderVaultMapping mapping, Func<bool> keepRunning)
 {
     if (ArchiveId != null)
     {
         string jobId = new ArchiveRetrievalJob(mapping, keepRunning, ArchiveId).run();
         DownloadDetails = new DownloadInfo(jobId, DateTime.Now);
         IsDirty = true;
     }
 }