protected override CloudStorage CreateStorage() { var storage = new CloudStorage(); var config = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.SkyDrive); storage.Open(config, GetAccessToken()); return storage; }
protected override ICloudStorageAccessToken GetAccessToken() { //NOTE: first obtain and serialize valid token to file on desktop var token = new CloudStorage().DeserializeSecurityTokenEx( Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\Desktop\token_data")); return token; }
/// <summary> /// Constructor of Sandbox control /// </summary> public Sandbox() { InitializeComponent(); _syncContext = AsyncOperationManager.SynchronizationContext as WindowsFormsSynchronizationContext; _storage = null; listViewFilesSorter = new ListViewColumnSorter(); lstFiles.ListViewItemSorter = listViewFilesSorter; lstFiles.Sort(); }
public ActionResult Index() { var imageFiles = new List <ImageFile>(); var container = CloudStorage.GetContainer("uploadfotos"); foreach (IListBlobItem blobItem in container.ListBlobs(null, false)) { if (blobItem.GetType() == typeof(CloudBlockBlob)) { var blob = (CloudBlockBlob)blobItem; var imageFile = new ImageFile(blob.Name, blob.Uri.ToString()); imageFiles.Add(imageFile); } } return(View(imageFiles)); }
public void Open(string authToken) { if (IsOpened) { return; } if (_provider == null) { _provider = new GoogleDocsStorageProvider(); } var token = new CloudStorage().DeserializeSecurityTokenFromBase64(authToken); _provider.Open(new GoogleDocsConfiguration(), token); IsOpened = true; }
/// <summary> /// Do the actual upload to Dropbox /// For more details on the available parameters, see: http://sharpbox.codeplex.com/ /// </summary> /// <param name="imageData">byte[] with image data</param> /// <returns>DropboxResponse</returns> public static DropboxInfo UploadToDropbox(byte[] imageData, string title, string filename) { // get the config of dropbox Dropbox.DropBoxConfiguration dropBoxConfig = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox) as Dropbox.DropBoxConfiguration; // instanciate the cloudstorage manager CloudStorage storage = new CloudStorage(); // open the connection to the storage storage.Open(dropBoxConfig, config.DropboxAccessToken); // get the root entry of the cloud storage ICloudDirectoryEntry root = storage.GetRoot(); if (root == null) { Console.WriteLine("No root object found"); } else { // create the file ICloudFileSystemEntry file = storage.CreateFile(root, filename); // build the data stream Stream data = new MemoryStream(imageData); // reset stream data.Position = 0; // upload data file.GetDataTransferAccessor().Transfer(data, nTransferDirection.nUpload, null, null); } // close the cloud storage connection if (storage.IsOpened) { storage.Close(); } return(RetrieveDropboxInfo(filename)); }
protected override void Load(ContainerBuilder builder) { builder.Register(c => CloudStorage.ForInMemoryStorage().BuildStorageProviders()) .OnRelease(p => p.QueueStorage.AbandonAll()); builder.Register(c => new MemoryBlobStorageProvider()) .As <IBlobStorageProvider>(); builder.Register(c => new MemoryQueueStorageProvider()) .As <IQueueStorageProvider>() .OnRelease(p => p.AbandonAll()); builder.Register(c => new MemoryTableStorageProvider()) .As <ITableStorageProvider>(); builder.Register(c => new NeutralLogStorage { BlobStorage = new MemoryBlobStorageProvider() }); }
/// <summary> /// refresh the bucket list /// </summary> void RefreshBuckets() { //init buckets and files SelectedBucket = ""; SelectedFile = ""; Buckets.Clear(); Files.Clear(); //get the buckets IEnumerable <string> buckets; if (!CloudStorage.GetBuckets(out buckets)) { MessageBox.Show("There was an error getting buckets."); return; } //copy into our list buckets.ToList().ForEach(b => Buckets.Add(b)); }
internal static void LoadAccessToken() { string fileFullPath = Path.Combine(Environment.CurrentDirectory, Environment.UserName + "-Dropbox.tok"); if (File.Exists(fileFullPath)) { CloudStorage storage = new CloudStorage(); StreamReader tokenStream = new StreamReader(fileFullPath); config.DropboxAccessToken = storage.DeserializeSecurityToken(tokenStream.BaseStream); // close the cloud storage connection if (storage.IsOpened) { storage.Close(); } } }
///<summary>The first parameter, 'sourceFileName', must be a file that exists.</summary> public static void Copy(string sourceFileName, string destinationFileName, FileAtoZSourceDestination sourceDestination, string uploadMessage = "Copying file...", bool isFolder = false) { if (CloudStorage.IsCloudStorage) { sourceFileName = CloudStorage.PathTidy(sourceFileName); destinationFileName = CloudStorage.PathTidy(destinationFileName); FormProgress FormP = CreateFormProgress(uploadMessage, isFolder); OpenDentalCloud.TaskState state; if (sourceDestination == FileAtoZSourceDestination.AtoZToAtoZ) { state = CloudStorage.CopyAsync(sourceFileName, destinationFileName, new OpenDentalCloud.ProgressHandler(FormP.OnProgress)); } else if (sourceDestination == FileAtoZSourceDestination.LocalToAtoZ) { state = CloudStorage.UploadAsync(Path.GetDirectoryName(destinationFileName), Path.GetFileName(destinationFileName), File.ReadAllBytes(sourceFileName), new OpenDentalCloud.ProgressHandler(FormP.OnProgress)); } else if (sourceDestination == FileAtoZSourceDestination.AtoZToLocal) { state = CloudStorage.DownloadAsync(Path.GetDirectoryName(sourceFileName), Path.GetFileName(sourceFileName), new OpenDentalCloud.ProgressHandler(FormP.OnProgress)); } else { throw new Exception("Unsupported " + nameof(FileAtoZSourceDestination) + ": " + sourceDestination); } FormP.ShowDialog(); if (FormP.DialogResult == DialogResult.Cancel) { state.DoCancel = true; return; } if (sourceDestination == FileAtoZSourceDestination.AtoZToLocal) { File.WriteAllBytes(destinationFileName, ((OpenDentalCloud.Core.TaskStateDownload)state).FileContent); } } else //Not cloud { File.Copy(sourceFileName, destinationFileName); } }
///<summary>Writes or uploads the text to the specified file name.</summary> public static void WriteAllText(string fileName, string textForFile, string uploadMessage = "Uploading file") { if (CloudStorage.IsCloudStorage) { FormProgress FormP = CreateFormProgress(uploadMessage); OpenDentalCloud.Core.TaskStateUpload state = CloudStorage.UploadAsync(Path.GetDirectoryName(fileName), Path.GetFileName(fileName), Encoding.UTF8.GetBytes(textForFile), new OpenDentalCloud.ProgressHandler(FormP.OnProgress)); FormP.ShowDialog(); if (FormP.DialogResult == DialogResult.Cancel) { state.DoCancel = true; return; } } else //Not cloud { File.WriteAllText(fileName, textForFile); } }
public static DropboxInfo RetrieveDropboxInfo(string filename) { LOG.InfoFormat("Retrieving Dropbox info for {0}", filename); DropboxInfo dropBoxInfo = new DropboxInfo(); dropBoxInfo.ID = filename; dropBoxInfo.Title = filename; dropBoxInfo.Timestamp = DateTime.Now; dropBoxInfo.WebUrl = string.Empty; // get the config of dropbox Dropbox.DropBoxConfiguration dropBoxConfig = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox) as Dropbox.DropBoxConfiguration; // instanciate the cloudstorage manager CloudStorage storage = new CloudStorage(); // get the root entry of the cloud storage ICloudDirectoryEntry root = storage.GetRoot(); // open the connection to the storage storage.Open(dropBoxConfig, config.DropboxAccessToken); dropBoxInfo.WebUrl = storage.GetFileSystemObjectUrl(dropBoxInfo.ID, root).ToString(); ICloudFileSystemEntry fileSystemEntry = storage.GetFileSystemObject(dropBoxInfo.ID, root); if (fileSystemEntry != null) { dropBoxInfo.Title = fileSystemEntry.Name; dropBoxInfo.Timestamp = fileSystemEntry.Modified; } // close the cloud storage connection if (storage.IsOpened) { storage.Close(); } return(dropBoxInfo); }
private static SortedDictionary <string, ICloudFileSystemEntry> CreateRemoteFileList(ICloudDirectoryEntry start, bool bRescusive) { // result var result = new SortedDictionary <string, ICloudFileSystemEntry>(); // directoryStack var directoryStack = new Stack <ICloudDirectoryEntry>(); // add the start directory to the stack directoryStack.Push(start); // do enumeration until stack is empty while (directoryStack.Count > 0) { var current = directoryStack.Pop(); foreach (var fsinfo in current) { if (fsinfo is ICloudDirectoryEntry) { // check if recursion allowed if (bRescusive == false) { continue; } // push the directory to stack directoryStack.Push(fsinfo as ICloudDirectoryEntry); } // build the path var path = CloudStorage.GetFullCloudPath(fsinfo, Path.DirectorySeparatorChar); var startpath = CloudStorage.GetFullCloudPath(start, Path.DirectorySeparatorChar); path = path.Remove(0, startpath.Length); // add the entry to our output list result.Add(path, fsinfo); } } return(result); }
public async Task <IActionResult> UploadGeoJson([FromBody] List <JObject> postdata) { var errMsg = ""; var tasks = new List <Task>(); var cnt = -1; foreach (var oneData in postdata) { cnt += 1; var filename = JsonUtils.GetString("filename", oneData); var filePathArray = filename.Split("api/nfs/public/demo/", 2); string filePath; if (filePathArray.Length == 2) { filePath = filePathArray[1]; } else { filePath = Path.Combine("bingmap/pinggu/", filePathArray[0]); } var data = JsonUtils.GetJToken("data", oneData); if (Object.ReferenceEquals(data, null)) { var msg = $"Entry {cnt} is an empty JObject\n"; _logger.LogInformation($"UploadJson is not valid, name = {filename}"); errMsg += msg; continue; } var data64 = data.ToString().FromJSBase64(); var dataBytes = Convert.FromBase64String(data64); var container = CloudStorage.GetContainer("cdn", "public", null, null); var dataBlob = container.GetBlockBlobReference(Path.Combine("demo", filePath)); tasks.Add(dataBlob.UploadFromByteArrayAsync(dataBytes, 0, dataBytes.Length)); } await Task.WhenAll(tasks); if (errMsg.Length == 0) { return(Ok()); } return(Ok(new { error = errMsg })); }
protected void Page_Load(object sender, EventArgs e) { if (Session.IsReadOnly) { SubmitError("No session is availible.", Source); return; } var redirectUri = Request.GetUrlRewriter().GetLeftPart(UriPartial.Path); if (!string.IsNullOrEmpty(Request[AuthorizationCodeUrlKey])) { //we ready to obtain and store token var authCode = Request[AuthorizationCodeUrlKey]; var accessToken = SkyDriveAuthorizationHelper.GetAccessToken(ImportConfiguration.SkyDriveAppKey, ImportConfiguration.SkyDriveAppSecret, redirectUri, authCode); //serialize token var config = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.SkyDrive); var storage = new CloudStorage(); var base64AccessToken = storage.SerializeSecurityTokenToBase64Ex(accessToken, config.GetType(), new Dictionary <string, string>()); //check and submit storage.Open(config, accessToken); var root = storage.GetRoot(); if (root != null) { SubmitToken(base64AccessToken, Source); } else { SubmitError("Failed to open storage with token", Source); } } else { var authCodeUri = SkyDriveAuthorizationHelper.BuildAuthCodeUrl(ImportConfiguration.SkyDriveAppKey, null, redirectUri); Response.Redirect(authCodeUri); } }
public static CloudStorage OpenDropBoxStorage() { // Creating the cloudstorage object CloudStorage dropBoxStorage = new CloudStorage(); // get the configuration for dropbox var dropBoxConfig = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox); // declare an access token ICloudStorageAccessToken accessToken = null; // load a valid security token from file using (var tokenStream = new MemoryStream(SupportFiles.DropBoxToken)) { accessToken = dropBoxStorage.DeserializeSecurityToken(tokenStream); } // open the connection var storageToken = dropBoxStorage.Open(dropBoxConfig, accessToken); return(dropBoxStorage); }
private void CreateStorage() { _storage = new CloudStorage(); var config = CloudStorage.GetCloudConfigurationEasy(_providerName); if (!string.IsNullOrEmpty(_authData.Token)) { if (_providerName != nSupportedCloudConfigurations.BoxNet) { var token = _storage.DeserializeSecurityTokenFromBase64(_authData.Token); _storage.Open(config, token); } } else { _storage.Open(config, new GenericNetworkCredentials { Password = _authData.Password, UserName = _authData.Login }); } }
public void TableNameValidation() { var mockProvider = CloudStorage.ForInMemoryStorage().BuildTableStorage(); new CloudTable <int>(mockProvider, "abc"); // name is OK try { new CloudTable <int>(mockProvider, "ab"); // name too short Assert.Fail("#A00"); } catch (ArgumentException) { } try { new CloudTable <int>(mockProvider, "ab-sl"); // hyphen not permitted Assert.Fail("#A01"); } catch (ArgumentException) { } }
///<summary>Returns the string contents of the file.</summary> public static string ReadAllText(string fileName) { if (CloudStorage.IsCloudStorage) { FormProgress FormP = CreateFormProgress("Downloading..."); OpenDentalCloud.Core.TaskStateDownload state = CloudStorage.DownloadAsync(Path.GetDirectoryName(fileName), Path.GetFileName(fileName), new OpenDentalCloud.ProgressHandler(FormP.OnProgress)); FormP.ShowDialog(); if (FormP.DialogResult == DialogResult.Cancel) { state.DoCancel = true; return(""); } return(Encoding.UTF8.GetString(state.FileContent)); } else //Not cloud { return(File.ReadAllText(fileName)); } }
private void butOpen_Click(object sender, EventArgs e) { if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ) { System.Diagnostics.Process.Start("Explorer", Path.GetDirectoryName(textFileName.Text)); } else if (CloudStorage.IsCloudStorage) //First download, then open { FormProgress FormP = new FormProgress(); FormP.DisplayText = "Downloading..."; FormP.NumberFormat = "F"; FormP.NumberMultiplication = 1; FormP.MaxVal = 100; //Doesn't matter what this value is as long as it is greater than 0 FormP.TickMS = 1000; string patFolder; if (!TryGetPatientFolder(out patFolder, false)) { return; } OpenDentalCloud.Core.TaskStateDownload state = CloudStorage.DownloadAsync(patFolder , DocCur.FileName , new OpenDentalCloud.ProgressHandler(FormP.OnProgress)); FormP.ShowDialog(); if (FormP.DialogResult == DialogResult.Cancel) { state.DoCancel = true; return; } //Create temp file here or create the file with the actual name? Changes made when opening the file won't be saved, so I think temp file is best. string tempFile = PrefC.GetRandomTempFile(Path.GetExtension(DocCur.FileName)); File.WriteAllBytes(tempFile, state.FileContent); if (ODBuild.IsWeb()) { ThinfinityUtils.HandleFile(tempFile); } else { System.Diagnostics.Process.Start(tempFile); } } }
public NoteUpdater(string searchPattern = ".png") { SearchPattern = searchPattern; try { Storage = new CloudStorage(); var dropboxConfig = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox); ICloudStorageAccessToken accessToken; using (var fs = File.Open(Properties.Settings.Default.DropboxTokenFile, FileMode.Open, FileAccess.Read, FileShare.None)) { accessToken = Storage.DeserializeSecurityToken(fs); } storageToken = Storage.Open(dropboxConfig, accessToken); InitFolderIfNecessary(); } catch (Exception ex) { Utilities.UtilitiesLib.LogError(ex); } existingNotes = new Dictionary <int, ICloudFileSystemEntry>(); }
public DropBoxCloudStorageManager(string key, string secret) { _configuration = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox) as DropBoxConfiguration; _configuration.AuthorizationCallBack = new Uri("https://www.dropbox.com/home"); _requestToken = DropBoxStorageProviderTools.GetDropBoxRequestToken(_configuration, key, secret); try { _authorizationUrl = DropBoxStorageProviderTools.GetDropBoxAuthorizationUrl(_configuration, _requestToken); } catch (NullReferenceException) { throw new ArgumentException("Invalid application key and/or secret"); } _cloudStorage = new CloudStorage(); ApplicationFolderPath = "/"; }
private static AuthData GetEncodedAccesToken(AuthData authData, ProviderTypes provider) { switch (provider) { case ProviderTypes.Google: case ProviderTypes.GoogleDrive: var tokenSecret = ImportConfiguration.GoogleTokenManager.GetTokenSecret(authData.Token); var consumerKey = ImportConfiguration.GoogleTokenManager.ConsumerKey; var consumerSecret = ImportConfiguration.GoogleTokenManager.ConsumerSecret; var accessToken = GoogleDocsAuthorizationHelper.BuildToken(authData.Token, tokenSecret, consumerKey, consumerSecret); var storage = new CloudStorage(); authData.Token = storage.SerializeSecurityTokenToBase64Ex(accessToken, typeof(GoogleDocsConfiguration), null); break; } return(authData); }
public IEnumerator GetUpdatedSlot_Success() { CloudStorage cloudStorage = AccelBytePlugin.GetCloudStorage(); Result <Slot[]> getAllSlotsResults = null; cloudStorage.GetAllSlots(result => { getAllSlotsResults = result; }); while (getAllSlotsResults == null) { Thread.Sleep(100); yield return(null); } TestHelper.LogResult(getAllSlotsResults, "Get all slots 2, after updated"); TestHelper.Assert.That(!getAllSlotsResults.IsError); bool bSlotUpdated = false; foreach (Slot slot in getAllSlotsResults.Value) { if (slot.slotId == this.createdSlot.slotId) { if (slot.originalName == this.originalNames[1]) { bSlotUpdated = true; break; } else if (slot.originalName == this.originalNames[0]) { bSlotUpdated = false; break; } } } TestHelper.Assert.That(bSlotUpdated); }
public void ProcessRequest(HttpContext context) { var request = context.Request; var response = context.Response; var path = request.Url.AbsolutePath; var parts = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); // fetch record from db var attachment = Attachment.FetchByUrl(parts[parts.length - 1]); if (attachment == null) { throw new HttpException(404, "Blob not found."); } // helper method - get a blob instance, if it doesn't exist return null var blob = CloudStorage.GetBlob(Constants.StoragePrivateContainer, attachment.BlobPath); if (blob == null) { throw new HttpException(404, "Blob not found."); } // custom auth if (!context.Request.IsAuthenticated) { throw new HttpException(403, "Access denied."); } var p = context.User as CustomPrincipal; if (p == null) { throw new HttpException(403, "Access denied."); } if (!p.IsInRole(Enums.Role.Downloader)) { throw new HttpException(403, "Access denied."); } blob.DownloadToStream(context.Response.OutputStream); response.ContentType = blob.Properties.ContentType; response.Flush(); }
private CloudStorage CreateStorage() { var prms = string.IsNullOrEmpty(_authData.Url) ? new object[] { } : new object[] { new Uri(_authData.Url) }; var storage = new CloudStorage(); var config = CloudStorage.GetCloudConfigurationEasy(_providerKey, prms); if (!string.IsNullOrEmpty(_authData.Token)) { if (_providerKey != nSupportedCloudConfigurations.BoxNet) { var token = storage.DeserializeSecurityTokenFromBase64(_authData.Token); storage.Open(config, token); } } else { storage.Open(config, new GenericNetworkCredentials { Password = _authData.Password, UserName = _authData.Login }); } return(storage); }
///<summary>Copies or downloads the file and opens it. acutalFileName should be a full path, displayedFileName should be a file name only. ///</summary> public static void OpenFile(string actualFilePath, string displayedFileName = "") { try { string tempFile; if (displayedFileName == "") { tempFile = ODFileUtils.CombinePaths(PrefC.GetTempFolderPath(), Path.GetFileName(actualFilePath)); } else { tempFile = ODFileUtils.CombinePaths(PrefC.GetTempFolderPath(), displayedFileName); } if (CloudStorage.IsCloudStorage) { FormProgress FormP = CreateFormProgress("Downloading..."); OpenDentalCloud.Core.TaskStateDownload state = CloudStorage.DownloadAsync(Path.GetDirectoryName(actualFilePath), Path.GetFileName(actualFilePath), new OpenDentalCloud.ProgressHandler(FormP.OnProgress)); FormP.ShowDialog(); if (FormP.DialogResult == DialogResult.Cancel) { state.DoCancel = true; return; } File.WriteAllBytes(tempFile, state.FileContent); } else //Not Cloud //We have to create a copy of the file because the name is different. //There is also a high probability that the attachment no longer exists if //images are stored in the database, since the file will have originally been //placed in the temporary directory. { File.Copy(actualFilePath, tempFile, true); } Process.Start(tempFile); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public async Task <IActionResult> UploadSegmentation([FromBody] JObject postdata) { var prefix = JsonUtils.GetString(Constants.PrefixEntry, postdata); var metadata = await GetMetadata(prefix); var name = JsonUtils.GetString("name", postdata); var ret = ValidateName(postdata, metadata, name); if (!Object.ReferenceEquals(ret, null)) { return(ret); } var overlayBase64 = JsonUtils.GetString("overlay", postdata); var segBase64 = JsonUtils.GetString("seg", postdata); overlayBase64 = overlayBase64.FromJSBase64(); segBase64 = segBase64.FromJSBase64(); var container = CloudStorage.GetContainer(null); var dirPath = container.GetDirectoryReference(prefix); var segBytes = Convert.FromBase64String(segBase64); var basename = name.Split('.')[0]; var segBlob = dirPath.GetBlockBlobReference("seg_" + basename + ".png"); await segBlob.UploadFromByteArrayAsync(segBytes, 0, segBytes.Length); var overlayBlob = dirPath.GetBlockBlobReference("overlay_" + name); var overlayImage = ImageOps.FromBase64(overlayBase64, _logger); var overlayJpeg = overlayImage.ToJPEG(); await overlayBlob.UploadFromByteArrayAsync(overlayJpeg, 0, overlayJpeg.Length); _logger.LogInformation($"UploadSegmentation update segment {segBytes.Length} && overlay image {overlayJpeg.Length}"); return(Ok()); }
public IEnumerator GetCreatedSlot_Success() { CloudStorage cloudStorage = AccelBytePlugin.GetCloudStorage(); Result <Slot[]> getAllSlotsResults = null; bool bGetCreatedSlot = false; cloudStorage.GetAllSlots(result => { getAllSlotsResults = result; }); while (getAllSlotsResults == null) { Thread.Sleep(100); yield return(null); } TestHelper.LogResult(getAllSlotsResults, "Get all slots 1, after created"); TestHelper.Assert.That(!getAllSlotsResults.IsError); //this.createdSlot = null; foreach (Slot slot in getAllSlotsResults.Value) { /*if (slot.originalName == originalNames[0]) * { * this.createdSlot = slot; * break; * }*/ if (slot.slotId == this.createdSlot.slotId) { this.createdSlot = null; this.createdSlot = slot; bGetCreatedSlot = true; break; } } //Assert.That(this.createdSlot != null); TestHelper.Assert.That(bGetCreatedSlot); }
public IEnumerator CreateSlot_Success() { CloudStorage cloudStorage = AccelBytePlugin.GetCloudStorage(); Result <Slot> createSlotResult = null; cloudStorage.CreateSlot( Encoding.ASCII.GetBytes(this.payloads[0]), this.originalNames[0], result => { createSlotResult = result; }); while (createSlotResult == null) { Thread.Sleep(100); yield return(null); } TestHelper.LogResult(createSlotResult, "Create slot"); this.createdSlot = createSlotResult.Value; TestHelper.Assert.That(!createSlotResult.IsError); }
public IEnumerator UpdateSlot_Success() { CloudStorage cloudStorage = AccelBytePlugin.GetCloudStorage(); Result <Slot> updateSlotResult = null; cloudStorage.UpdateSlot( this.createdSlot.slotId, Encoding.ASCII.GetBytes(this.payloads[1]), this.originalNames[1], result => { updateSlotResult = result; }); while (updateSlotResult == null) { Thread.Sleep(100); yield return(null); } TestHelper.LogResult(updateSlotResult, "Update slot"); TestHelper.Assert.That(!updateSlotResult.IsError); }
static void Main(string[] args) { // insert your own connection string here, or use one of the other options: var tableStorage = CloudStorage .ForAzureConnectionString("DefaultEndpointsProtocol=https;AccountName=YOURACCOUNT;AccountKey=YOURKEY") .BuildTableStorage(); // 'books' is the name of the table var books = new CloudTable <Book>(tableStorage, "books"); var potterBook = new Book { Author = "J. K. Rowling", Title = "Harry Potter" }; var poemsBook = new Book { Author = "John Keats", Title = "Complete Poems" }; // inserting (or updating record in Table Storage) books.Upsert(new[] { new CloudEntity <Book> { PartitionKey = "UK", RowKey = "potter", Value = potterBook }, new CloudEntity <Book> { PartitionKey = "UK", RowKey = "poems", Value = poemsBook } }); // reading from table foreach (var entity in books.Get()) { Console.WriteLine("{0} by {1} in partition '{2}' and rowkey '{3}'", entity.Value.Title, entity.Value.Author, entity.PartitionKey, entity.RowKey); } Console.WriteLine("Press enter to exit."); Console.ReadLine(); }
protected override IEnumerable <CommandParameters> Execute(IEnumerable <CommandParameters> inParametersList) { foreach (var inParameters in inParametersList) { //inParameters = GetCurrentInParameters(); string url = inParameters.GetValue <string>("Url"); string user = inParameters.GetValue <string>("User"); string passWord = inParameters.GetValue <string>("Password"); string remoteDirectory = inParameters.GetValueOrDefault <string>("RemoteDirectory", "/"); string localDirectory = inParameters.GetValue <string>("LocalDirectory"); var cloudConfig = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.WebDav, new Uri(url)); var cloudCredentials = new GenericNetworkCredentials() { UserName = user, Password = passWord }; this.cloudStorage.Open(cloudConfig, cloudCredentials); this.LogDebugFormat("Start reading files from Url='{0}', RemoteDirectory='{1}'", url, remoteDirectory); int fileIdx = 0; foreach (var localFileName in this.ReadData(remoteDirectory, localDirectory)) { fileIdx++; var outParameters = this.GetCurrentOutParameters(); outParameters.SetOrAddValue("File", localFileName); yield return(outParameters); } this.LogDebugFormat("End reading files from Url='{0}', RemoteDirectory='{1}': FilesCount={2}", url, remoteDirectory, fileIdx); this.cloudStorage.Close(); } }
/// <summary> /// Assign cloud storage /// </summary> /// <param name="storage">Cloud storage object</param> public void SetCloudStorage(CloudStorage storage) { _storage = storage; }
protected override ICloudStorageAccessToken GetAccessToken() { var token = new CloudStorage().DeserializeSecurityTokenFromBase64("PEFycmF5T2ZLZXlWYWx1ZU9mc3RyaW5nc3RyaW5nIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tLzIwMDMvMTAvU2VyaWFsaXphdGlvbi9BcnJheXMiIHhtbG5zOmk9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hLWluc3RhbmNlIj48S2V5VmFsdWVPZnN0cmluZ3N0cmluZz48S2V5PlRva2VuUHJvdkNvbmZpZ1R5cGU8L0tleT48VmFsdWU+QXBwTGltaXQuQ2xvdWRDb21wdXRpbmcuU2hhcnBCb3guU3RvcmFnZVByb3ZpZGVyLkRyb3BCb3guRHJvcEJveENvbmZpZ3VyYXRpb248L1ZhbHVlPjwvS2V5VmFsdWVPZnN0cmluZ3N0cmluZz48S2V5VmFsdWVPZnN0cmluZ3N0cmluZz48S2V5PlRva2VuQ3JlZFR5cGU8L0tleT48VmFsdWU+QXBwTGltaXQuQ2xvdWRDb21wdXRpbmcuU2hhcnBCb3guU3RvcmFnZVByb3ZpZGVyLkRyb3BCb3guRHJvcEJveFRva2VuPC9WYWx1ZT48L0tleVZhbHVlT2ZzdHJpbmdzdHJpbmc+PEtleVZhbHVlT2ZzdHJpbmdzdHJpbmc+PEtleT5Ub2tlbkRyb3BCb3hQYXNzd29yZDwvS2V5PjxWYWx1ZT43endvOXJhMm5uZXh0Z2E8L1ZhbHVlPjwvS2V5VmFsdWVPZnN0cmluZ3N0cmluZz48S2V5VmFsdWVPZnN0cmluZ3N0cmluZz48S2V5PlRva2VuRHJvcEJveFVzZXJuYW1lPC9LZXk+PFZhbHVlPmJ0emhuN3Q3d3c5b3RjMjwvVmFsdWU+PC9LZXlWYWx1ZU9mc3RyaW5nc3RyaW5nPjxLZXlWYWx1ZU9mc3RyaW5nc3RyaW5nPjxLZXk+VG9rZW5Ecm9wQm94QXBwS2V5PC9LZXk+PFZhbHVlPmIzcGRvYjFwcDMyeWpyajwvVmFsdWU+PC9LZXlWYWx1ZU9mc3RyaW5nc3RyaW5nPjxLZXlWYWx1ZU9mc3RyaW5nc3RyaW5nPjxLZXk+VG9rZW5Ecm9wQm94QXBwU2VjcmV0PC9LZXk+PFZhbHVlPm5yeXp6NXR3dWRvcWxwczwvVmFsdWU+PC9LZXlWYWx1ZU9mc3RyaW5nc3RyaW5nPjwvQXJyYXlPZktleVZhbHVlT2ZzdHJpbmdzdHJpbmc+"); return token; }
protected CloudStorage GetStorage() { return _storage ?? (_storage = CreateStorage()); }