コード例 #1
0
ファイル: CopyOps.cs プロジェクト: warlord256/Medusa
        private static async Task breakHeader(string header)
        {
            WorkItemMessage message = JsonConvert.DeserializeObject <WorkItemMessage>(header);

            foreach (var itr in message.content)
            {
                Clipboard.SetText(itr);
            }
            //Clipboard.SetText(message.content);
        }
コード例 #2
0
ファイル: CopyOps.cs プロジェクト: warlord256/Medusa
        private async Task makeHeader(WorkItemMessage message)
        {
            await cloudContainer.CreateIfNotExistsAsync();

            SharedAccessBlobPermissions permissions = SharedAccessBlobPermissions.Read;

            TimeSpan clockSkew      = TimeSpan.FromMinutes(15d);
            TimeSpan accessDuration = TimeSpan.FromMinutes(15d);

            string serializedMessage = JsonConvert.SerializeObject(message);

            Console.WriteLine(serializedMessage);

            foreach (string filePath in message.content)
            {
                string key = Path.GetFileName(filePath);
                CopyOps.uploadBlob(cloudContainer, key, filePath, true);
            }

            var blobSAS = new SharedAccessBlobPolicy
            {
                SharedAccessStartTime  = DateTime.UtcNow.Subtract(clockSkew),
                SharedAccessExpiryTime = DateTime.UtcNow.Add(accessDuration) + clockSkew,
                Permissions            = permissions
            };

            foreach (string filePath in message.content)
            {
                string key = Path.GetFileName(filePath);

                var blobRef      = cloudContainer.GetBlockBlobReference(key);
                var sasBlobToken = blobRef.GetSharedAccessSignature(blobSAS);

                var blobUri  = blobRef.Uri.AbsoluteUri;
                var queueUrl = blobUri + sasBlobToken;
            }

            var blobRef2  = cloudContainer.GetBlockBlobReference("Shanthi Insurance Policy.pdf");
            var blockBlob = cloudContainer.GetBlockBlobReference("Shanthi Insurance Policy.pdf");

            var downloadsPathOnServer = Path.Combine("C:\\SEM 2", "Shanthi Insurance Policy.pdf");

            using (var fileStream = File.OpenWrite(downloadsPathOnServer))
            {
                await blockBlob.DownloadToStreamAsync(fileStream);
            }

            var test = cloudContainer.ListBlobs("Shanthi Insurance Policy.pdf");

            foreach (var item in test)
            {
                Console.WriteLine(item);
            }
        }
コード例 #3
0
ファイル: FormLogin.cs プロジェクト: warlord256/Medusa
        /// <summary>
        /// Delegate function to handle the global keyboard keyUp
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">e</param>
        public async void gHook_KeyUp(object sender, KeyEventArgs e)
        {
            string[] files;

            if (string.IsNullOrEmpty(this.textUserId.Text))
            {
                MessageBox.Show("Empty userId");
                return;
            }
            // more username validation if needed.

            WorkItemMessage message = new WorkItemMessage(this.textUserId.Text, WorkItemMessage.FileType.Text, null);

            if (Control.ModifierKeys == Keys.Control && e.KeyCode == Keys.C)
            {
                IDataObject data_object = Clipboard.GetDataObject();

                // File drop
                if (data_object.GetDataPresent(DataFormats.FileDrop))
                {
                    message.fileType = WorkItemMessage.FileType.File;
                    files            = (string[])data_object.GetData(DataFormats.FileDrop);
                    foreach (string fileName in files)
                    {
                        string name = fileName;
                        if (System.IO.Directory.Exists(fileName))
                        {
                            name = "[" + name + "]";
                        }

                        this.lstFiles.Items.Add(name);
                    }

                    message.content = files;
                }
                else
                // Text drop
                {
                    string currentClipboardText = Clipboard.GetText(System.Windows.Forms.TextDataFormat.Text);
                    //message.content.Add(currentClipboardText);
                }
            }

            await this.copyOps.copyWorkItem(message).ConfigureAwait(false);
        }
コード例 #4
0
ファイル: CopyOps.cs プロジェクト: warlord256/Medusa
 public async Task copyWorkItem(WorkItemMessage message)
 {
     await makeHeader(message);
 }