Ejemplo n.º 1
0
 public async void CreateFolder(FileTreeNode folderIn, string name)
 {
     CheckAutorization();
     await _client.CreateFolderTask(String.Format("{0}/{1}",
         folderIn.IsDirectory ? folderIn.Path : Path.GetDirectoryName(folderIn.Path).Replace('\\', '/'), name).TrimEnd('/'), null,
         null);
 }
Ejemplo n.º 2
0
        private async Task AddNewUserToGroup(List <User> usersList, User newUser)
        {
            try
            {
                if (!DoesUserExist(usersList, newUser))
                {
                    usersList.Add(newUser);

                    var settings = new XmlWriterSettings();
                    settings.Indent = true;
                    settings.Async  = true;
                    var tempFile = Path.GetTempFileName();
                    using (XmlWriter writer = XmlWriter.Create(tempFile, settings))
                    {
                        await writer.WriteStartElementAsync(null, _configuration.UsersNodeName, null);

                        foreach (User user in usersList)
                        {
                            await writer.WriteStartElementAsync(null, _configuration.UserNodeName, null);

                            await writer.WriteAttributeStringAsync(null, _configuration.UserIdAttributeName, null, user.ID);

                            await writer.WriteAttributeStringAsync(null, _configuration.UserCommonNameAttributeName, null, user.CommonName);

                            await writer.WriteAttributeStringAsync(null, _configuration.UserEmailAttributeName, null, user.Email);

                            await writer.WriteEndElementAsync();
                        }
                        await writer.WriteEndElementAsync();

                        await writer.FlushAsync();
                    }
                    await _client.CreateFolderTask(_path + "/" + newUser.ID, (succes) => { }, (failure) => { });
                    await UploadFileAsync(tempFile, _configuration.UsersListFileName);

                    File.Delete(tempFile);
                }
            }
            catch (DropboxException)
            {
                throw new CloudException("Couldn't add user to group.");
            }
        }