public MainWindow() { try { this.dropNetClient = new DropNetClient(API_KEY, APP_SECRET); this.dropNetClient.UseSandbox = true; this.employees = HierarchyGenerator.GenerateEmployees(); InitializeComponent(); this.importDataBtn.Click += (sender, eventArgs) => { var reportsPage = new ReportsPage(employees); this.pagesFrame.Navigate(reportsPage); this.currentPage = reportsPage; }; this.exportToDropBoxBtn.Click += ExportToDropBoxAccount; this.exportToWordBtn.Click += (sender, e) => { try { ExportToWordFile(sender, e); } catch (Exception ex) { ShowError(ex); } }; this.aboutBtn.Click += ShowAboutBox; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private static DropNetClient CreateClient(string apiKey, string apiSecret, string userToken, string userSecret, bool sandbox) { var _client = new DropNetClient(apiKey, apiSecret, userToken, userSecret); _client.UseSandbox = sandbox; return(_client); }
/// <summary> /// Constructor for the Application object. /// </summary> public App() { // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; // Standard Silverlight initialization InitializeComponent(); // Phone-specific initialization InitializePhoneApplication(); // Show graphics profiling information while debugging. if (System.Diagnostics.Debugger.IsAttached) { // Display the current frame rate counters. Application.Current.Host.Settings.EnableFrameRateCounter = true; PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; } //////////////////////////////////////////////////// // NOTE: This key is a Development only key setup for this sample and will only work with my login. // MAKE SURE YOU CHANGE IT OR IT WONT WORK! //////////////////////////////////////////////////// DropNetClient = new DropNetClient("9m6v782a7aeop0w", "dbd11uqce6hr8zg"); //NOTE: If user Token and Secret are stored from previous login session: //DropNetClient.UserLogin = new Models.UserLogin { Token = "TokenFromStorage", Secret = "SecretFromStorage" }; }
public void UploadFolderCreate(string folder, string path, DropNetClient client) { //client = new DropNetClient(apiKey, appSecret, GetUserLoginDB(tokendb), GetUserLoginDB(secretdb)); try { //Create a Folder if (path == null) { var metaData = client.GetMetaData("/", null, false); if (!(metaData.Contents.Any(c => c.Is_Dir && c.Path == "/" + folder))) { client.CreateFolder("/" + folder); } } else { var metaData = client.GetMetaData(path, null, false); if (!(metaData.Contents.Any(c => c.Is_Dir && c.Path == folder))) { client.CreateFolder(path + "/" + folder); } } } catch (DirectoryNotFoundException ex) { MessageBox.Show(ex.Message.ToString()); } }
public FileAsyncTests() { _client = new DropNetClient(TestVariables.ApiKey, TestVariables.ApiSecret); _client.Login(TestVariables.Email, TestVariables.Password); fixture = new Fixture(); }
public UserTests() { // // TODO: Add constructor logic here // _client = new DropNetClient(TestVariables.ApiKey, TestVariables.ApiSecret); }
// Shouldn't be constructing client here in static constructor. // needs to be 1) not static (need multiple of these)... 2) generated maybe in the GetClient() method. static DropboxHelper() { if (client == null) { // dummy names, avoiding obvious names. var key = ConfigHelper.DropBoxAPIKey; var secret = ConfigHelper.DropBoxAPISecret; var userSecret = ConfigHelper.DropBoxUserSecret; var userToken = ConfigHelper.DropBoxUserToken; // Obviously don't share DropBoxAPIKey or DropBoxAPISecret in source. This is to be kept private. if (string.IsNullOrEmpty(key)) { key = APIKeys.DropBoxAPIKey; } if (string.IsNullOrEmpty(secret)) { secret = APIKeys.DropBoxAPISecret; } if (string.IsNullOrEmpty(userSecret) || string.IsNullOrEmpty(userToken)) { client = new DropNetClient(key, secret); } else { client = new DropNetClient(key, secret, userToken, userSecret, null); } } }
public DropNetClient Connect(TokenAndSecretModel model) { _client = new DropNetClient("token", "secret", model.Token, model.Secret); var info = _client.AccountInfo(); return(_client); }
public static void BackUp() { var _client = new DropNetClient(WebConfigurationManager.AppSettings["Dropbox.AppKey"], WebConfigurationManager.AppSettings["Dropbox.AppSecret"], WebConfigurationManager.AppSettings["Dropbox.AccessToken"]); //Get metadata from Backup folder var metaData = _client.GetMetaData("/Backup", null, false, false); var backup = metaData.Contents.FirstOrDefault(c => c.Extension == ".bak" && c.Name.Contains("prohaihung")); //Delete existing file. if (backup != null) { _client.Delete(backup.Path); } //Backup file. string directory = HttpContext.Current.Server.MapPath("~/") + "/backups/"; var directoryInfo = new DirectoryInfo(directory); var files = directoryInfo.GetFiles(); var file = files.OrderByDescending(c => c.Name).FirstOrDefault(); Logger.Log(file.FullName); byte[] bytes = File.ReadAllBytes(file.FullName); Logger.Log("Length file: " + bytes.LongLength); _client.UploadFile("/Backup", file.Name, bytes); }
public async Task <bool> AutoLogin() { try { if (File.Exists(tokendb) && File.Exists(secretdb)) { client = new DropNetClient(apiKey, appSecret, GetUserLoginDB(tokendb), GetUserLoginDB(secretdb)); if (client != null) { SignedIn = true; return(true); } else { SignedIn = false; return(false); } } else { SignedIn = false; return(false); } } catch (Exception) { SignedIn = false; return(false); } }
public string GetConnectUrl(DropNetClient client, string callbackurl) { _client = client; var url = _client.BuildAuthorizeUrl(callbackurl); return(url); }
public void uploadOnCloud() { Cursor.Current = Cursors.WaitCursor; _client = new DropNetClient("biiqqvfg85c7xej", "4sessrgrtccoxnc", "mteIhoZWcVAAAAAAAAAACGYLFlxTAk-tW2wsJp2fKfg7obSJGPehHLqYkLmLOxKm"); _client.UserLogin = new UserLogin { Token = "mteIhoZWcVAAAAAAAAAACGYLFlxTAk-tW2wsJp2fKfg7obSJGPehHLqYkLmLOxKm", Secret = "4sessrgrtccoxnc" }; int idx2 = fname.LastIndexOf("\\") + 1; string fnamepart1 = fname.Substring(idx2) + "_part1"; string fnamepart2 = fname.Substring(idx2) + "_part2"; for (int i = 0; i < 2; i++) { string filename = ""; if (i == 0) { filename = Application.StartupPath + "\\block\\" + fnamepart1; } else { filename = Application.StartupPath + "\\block\\" + fnamepart2; } var x = @"/" + Path.GetFileName(filename); MetaData mm = _client.UploadFile("/", Path.GetFileName(filename), File.ReadAllBytes(@"" + filename)); } Cursor.Current = Cursors.Default; MessageBox.Show("file uploaded successfully"); }
public override SyncInfo Initialize(DatabaseInfo info) { if (info == null) { throw new ArgumentNullException("info"); } var details = info.Details; var url = new Uri(details.Url); _client = CreateClient(url.UserInfo); _info = new SyncInfo { Path = url.LocalPath, Modified = details.Modified, HasLocalChanges = details.HasLocalChanges, }; info.OpenDatabaseFile(x => { using (var buffer = new MemoryStream()) { BufferEx.CopyStream(x, buffer); _info.Database = buffer.ToArray(); } }); return(_info); }
public ChunkedUploadHelper(DropNetClient client, Func<long, byte[]> chunkNeeded, string path, Action<MetaData> success, Action<DropboxException> failure, Action<ChunkedUploadProgress> progress, bool overwrite, string parentRevision, long? fileSize, long? maxRetries) { if (client == null) { throw new ArgumentNullException("client"); } if (chunkNeeded == null) { throw new ArgumentNullException("chunkNeeded"); } if (success == null) { throw new ArgumentNullException("success"); } if (failure == null) { throw new ArgumentNullException("failure"); } _client = client; _chunkNeeded = chunkNeeded; _path = path; _success = success; _failure = failure; _progress = progress; _overwrite = overwrite; _parentRevision = parentRevision; _fileSize = fileSize; _maxRetries = maxRetries; }
public async Task <long[]> DetermineAvailableCloudSpace(object DriveServiceClient) { long[] space = new long[2]; DropNetClient client = DriveServiceClient as DropNetClient; try { //Das ganze ist aber erst möglich nach der fix fertigen anmeldung!!! var info = client.AccountInfo(); long totalSpace = info.quota_info.quota; //Gesamtverfügbare Speicher in byte long neededSpace = info.quota_info.normal; //belegter Speichermomentan in byte //string str2 = info.quota_info.shared.ToString(); //freigegebener SPeicher(geteilt mit anderen usern) in byte long availableSpace = totalSpace - neededSpace; space[0] = totalSpace; //totalspace space[1] = availableSpace; //availablespace } catch (Exception ex) { MessageBox.Show(ex.Message); } return(space); }
public DropboxCachedFile(DokanFileInfo dokanInfo, Logger log = null) { var appContext = dokanInfo.TryGetApplicationContext(); _dokanInfo = dokanInfo; _client = appContext.DropNetClient; _metaData = appContext.MetaData; if (log != null) { _log = log; } else { _log = LogManager.CreateNullLogger(); LogManager.DisableLogging(); } _file = appContext.FileNameComponents; var path = string.Format(@"temp\{0}", _dokanInfo.DokanContext); Directory.CreateDirectory(Path.GetDirectoryName(path)); _innerStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite, 512, FileOptions.DeleteOnClose | FileOptions.RandomAccess); _innerStream.SetLength(_metaData.Bytes); _log.Trace("File length is {0}", _metaData.Bytes); _cacheMap = new CacheMap(); }
public DropBoxAuth() { InitializeComponent(); _indicator = AddIndicator(); _client = DropBoxUtils.Create(); }
public ChunkedUploadHelper(DropNetClient client, Func <long, byte[]> chunkNeeded, string path, Action <MetaData> success, Action <DropboxException> failure, Action <ChunkedUploadProgress> progress, bool overwrite, string parentRevision, long?fileSize, long?maxRetries) { if (client == null) { throw new ArgumentNullException("client"); } if (chunkNeeded == null) { throw new ArgumentNullException("chunkNeeded"); } if (success == null) { throw new ArgumentNullException("success"); } if (failure == null) { throw new ArgumentNullException("failure"); } _client = client; _chunkNeeded = chunkNeeded; _path = path; _success = success; _failure = failure; _progress = progress; _overwrite = overwrite; _parentRevision = parentRevision; _fileSize = fileSize; _maxRetries = maxRetries; }
/// <summary> /// Upload a file /// </summary> /// <param name="client"></param> /// <param name="localPath">Local filename</param> /// <param name="remotePath">Filename on Dropbox</param> public static void UploadFile(this DropNetClient client, string localPath, string remotePath) { var path = remotePath.ParentDirectory(); var fileName = remotePath.GetFileNameUniversal(); client.UploadFile(path, fileName, File.ReadAllBytes(localPath)); }
public string SaveAttachment(AttachmentRequest request) { try { DropNetClient _client = new DropNetClient(AppConstants.DropboxClientId, AppConstants.DropboxClientSecret); _client.UserLogin = Storage.Dropbox.Token; DropNet.Models.UserLogin login = _client.GetAccessToken(); Attachment attachment = AppUtility.GetAttachment(request.AttachmentId, request.AuthToken, request.EwsUrl); _client.UploadFile("/", attachment.AttachmentName, attachment.AttachmentBytes); return("Uploaded Sucessfully."); } catch (Exception s) { return(s.Message); } //return ""; }
public static void uploadFile(string fileName) { /// You'll need to go on this following site "https://www.dropbox.com/developers/apps/create" and select Dropbox API app var _appKey = "i1lao88ewl6jjqf"; //You'll get these once you've created you app in dropbox var _appSecret = "s3538tkq57rfzrz"; //You'll get these once you've created you app in dropbox var _accessToken = "f3fhn9gjsxh1zugl"; var _accesTokenSecret = "lw0hfw3zvk13qr1"; System.Net.IWebProxy proxy = null; //If there's a proxy put it here var _client = new DropNetClient(_appKey, _appSecret, _accessToken, _accesTokenSecret, proxy); //_client.GetToken(); //_client.UserLogin = token; //var url = _client.BuildAuthorizeUrl(); //need to login to get the _accessToken and _accessTokenSecret //var log = _client.GetAccessToken(); //var f = log.Token; //var y = log.Secret; _client.UseSandbox = true; //allow access to root folder var content = File.ReadAllBytes(@"" + fileName + ""); //read the bytes for the file that you wish to upload var uploaded = _client.UploadFile("/", fileName, content); //upload var sharefile = _client.GetShare("/" + fileName + ""); //Share the file SendEmail.SendEmail.sendEmail(sharefile.Url); }
private DropNetClient GetClient(StorageCredentials credentials) { var client = new DropNetClient(credentials.Key, credentials.Secret); client.GetAccessToken(); return(client); }
private static DropNetClient CreateAuthenticatedClient(bool showsuccessfulinfo) { RequireUserInfo(); var c = new DropNetClient(settings.ApiKey, settings.Secret); try { var ul = c.Login(settings.Email, settings.Password); if (!string.IsNullOrEmpty(ul.Token)) { if (showsuccessfulinfo) { Console.WriteLine("Authentication successful."); Console.WriteLine("\tToken: " + ul.Token); Console.WriteLine("\tSecret: " + ul.Secret); } else { Console.WriteLine("Authenticated."); } } else { Console.WriteLine("Authentication failed."); } } catch (Exceptions.DropboxException e) { Console.WriteLine("Authentication failed."); Console.WriteLine(e); } return(c); }
public Task <bool> Init(string key, string secret, bool useSandbox) { if (_finalLogin == null) { _client = new DropNetClient(key, secret) { UseSandbox = useSandbox } } ; else { _client = new DropNetClient(key, secret, _finalLogin.Token, _finalLogin.Secret) { UseSandbox = useSandbox }; return(Task.Factory.StartNew(() => true)); } var tcs = new TaskCompletionSource <bool>(); _client.GetTokenAsync(login => { SingInUrl = _client.BuildAuthorizeUrl(); tcs.SetResult(true); }, tcs.SetException); return(tcs.Task); }
private bool Dropbox(User user, byte[] data) { try { OnAccountStart(new BackupEventArgs(AccountEnum.Dropbox.ToString())); var dropClient = new DropNetClient(DropboxConfigurationSection.DropboxApiKey, DropboxConfigurationSection.DropboxAppSecret); dropClient.UserLogin = new UserLogin { Secret = user.DropboxAccount.UserSecret, Token = user.DropboxAccount.UserToken }; dropClient.AccountInfo(); try { dropClient.UploadFile("/List Defender", "ListDefender " + DateTime.Now + ".zip", data); } catch (Exception) { dropClient.CreateFolder("List Defender"); dropClient.UploadFile("/List Defender", "ListDefender " + DateTime.Now + ".zip", data); } OnAccountComplete(new BackupEventArgs(AccountEnum.Dropbox.ToString())); return(true); } catch (Exception ex) { OnShowError(new BackupEventArgs(AccountEnum.Dropbox.ToString())); logger.Error("Problems with Dropbox"); _unitOfWork.DropboxRepository.Delete(user.Id); _unitOfWork.Commit(); return(false); } }
public string AskForRegistrationUrl(UserProfileInfo user, string redirectUrl, out int tempCredentialId) { var _client = new DropNetClient(MogConstants.DROPBOX_KEY, MogConstants.DROPBOX_SECRET); UserLogin login = _client.GetToken(); // UserLogin login = _client.GetAccessToken(); var url = _client.BuildAuthorizeUrl(login, redirectUrl); var query = repoAuthCredential.GetByUserId(user.Id); List <AuthCredential> existingCredentials = null; if (query != null) {//TODO : gerer le cas des accounts multiples existingCredentials = query.Where(a => a.CloudService == CloudStorageServices.Dropbox).ToList(); foreach (var credential in existingCredentials) { repoAuthCredential.Delete(credential); } } AuthCredential newCredential = new AuthCredential(); newCredential.Token = login.Token; newCredential.Secret = login.Secret; newCredential.UserId = user.Id; newCredential.CloudService = CloudStorageServices.Dropbox; this.repoAuthCredential.Create(newCredential); tempCredentialId = newCredential.Id; return(url); }
public MetaDataTests() { // // TODO: Add constructor logic here // _client = new DropNetClient(TestVarables.ApiKey, TestVarables.ApiSecret); }
public FileSyncTests() { _client = new DropNetClient(TestVariables.ApiKey, TestVariables.ApiSecret); _client.UserLogin = new Models.UserLogin { Token = TestVariables.Token, Secret = TestVariables.Secret }; _fixture = new Fixture(); }
public async Task When_Token_Requested_Then_User_Token_Is_Returned() { var client = new DropNetClient(AppKey, AppSecret); var userToken = await client.GetRequestTokenAsync(); Assert.NotNull(userToken); }
public static void Main() { var client = new DropNetClient(DropboxAppKey, DropboxAppSecret); var token = client.GetToken(); var url = client.BuildAuthorizeUrl(); Console.WriteLine("COPY?PASTE Link: {0}", url); Console.WriteLine("Press enter when clicked allow"); Process.Start(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", url); Console.ReadLine(); var accessToken = client.GetAccessToken(); client.UseSandbox = true; var metaData = client.CreateFolder("NewUpload" + DateTime.Now.ToString()); string[] dir = Directory.GetFiles("../../images/", "*.JPG"); foreach (var item in dir) { Console.WriteLine("Reading file....."); FileStream stream = File.Open(item, FileMode.Open); var bytes = new byte[stream.Length]; stream.Read(bytes, 0, (int)stream.Length); Console.WriteLine(bytes.Length + " bytes uploading..."); client.UploadFile("/" + metaData.Name.ToString(), item.Substring(6), bytes); Console.WriteLine("{0} uploaded!", item); stream.Close(); } Console.WriteLine("Job Done!"); var picUrl = client.GetShare(metaData.Path); Process.Start(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", picUrl.Url); }
static void Main(string[] args) { Console.WriteLine("You must first login in your dropbox account."); string currentDir = Directory.GetCurrentDirectory(); DirectoryInfo info = new DirectoryInfo(currentDir).Parent.Parent; FileInfo[] pictures = info.GetFiles("*.jpg"); List <int> indexesOfChosen = new List <int>(); PrintAndChoosePictures(pictures, indexesOfChosen); DropNetClient client = new DropNetClient("8lc93q5ybq85syv", "nt6wrs7m0maixnl"); var token = client.GetToken(); var url = client.BuildAuthorizeUrl(); Clipboard.SetText(url); Console.WriteLine("\n\nUrl copied to clipboard. Paste in browser and allow.\nPress any key to continue", url); Console.ReadKey(true); var accessToken = client.GetAccessToken(); client.UserLogin.Secret = accessToken.Secret; client.UserLogin.Token = accessToken.Token; client.UseSandbox = true; Console.Write("Enter album name: "); var albumName = Console.ReadLine(); var folder = client.CreateFolder(albumName); Console.WriteLine("\nUploading...\n"); foreach (var i in indexesOfChosen) { MemoryStream sr = new MemoryStream((int)pictures[i].Length); FileStream fs = File.Open(pictures[i].FullName, FileMode.Open); var bytes = new byte[fs.Length]; fs.Read(bytes, 0, Convert.ToInt32(fs.Length)); client.UploadFile(folder.Path, pictures[i].Name, bytes); fs.Close(); } var shareUrl = client.GetShare(folder.Path); Clipboard.SetText(shareUrl.Url); Console.WriteLine(shareUrl.Url); Console.WriteLine("Share Url is also in clipboard"); }
public FileTests_Sandbox() { _client = new DropNetClient(TestVariables.ApiKey_Sandbox, TestVariables.ApiSecret_Sandbox); _client.UserLogin = new Models.UserLogin { Token = TestVariables.Token_Sandbox, Secret = TestVariables.Secret_Sandbox }; _client.UseSandbox = true; fixture = new Fixture(); }
public FileTests() { // // TODO: Add constructor logic here // _client = new DropNetClient(TestVariables.ApiKey, TestVariables.ApiSecret); fixture = new Fixture(); }
public async Task Given_A_Clent_Get_User_Account_Infromation() { var client = new DropNetClient(AppKey, AppSecret, UserToken, UserSecret); var accountInfromation = await client.AccountInfoAsync(); Assert.NotNull(accountInfromation); Assert.NotNull(accountInfromation.QuotaInfo); }
public void Connect() { client = new DropNetClient("e68hlm6xcdpgema", "0iu2v5ccm4qm2a8"); client.UseSandbox = true; client.UserLogin = new DropNet.Models.UserLogin { Token = "jdukos6bnbdo8b9v", Secret = "zg2t3o1qcjjy4ul" }; }
public void TestMethod1() { var client = new DropNetClient(TestVariables.ApiKey, TestVariables.ApiSecret); var url = client.WebAuthUrl("http://example.com"); }
public frmDropbox() { InitializeComponent(); _client = new DropNetClient(APP_KEY, APP_SECRET); AuthoriseDropbox(); }
public FileAsyncTests() { _client = new DropNetClient(TestVariables.ApiKey, TestVariables.ApiSecret) { UserLogin = new UserLogin { Token = TestVariables.Token, Secret = TestVariables.Secret } }; _fixture = new Fixture(); }
public Form1() { InitializeComponent(); //////////////////////////////////////////////////// // NOTE: This key is a Development only key setup for this sample and will only work with my login. // MAKE SURE YOU CHANGE IT OR IT WONT WORK! //////////////////////////////////////////////////// _client = new DropNetClient("9m6v782a7aeop0w", "dbd11uqce6hr8zg"); //NOTE: If user Token and Secret are stored from previous login session: //DropNetClient.UserLogin = new Models.UserLogin { Token = "TokenFromStorage", Secret = "SecretFromStorage" }; }
public ChunkedUploadHelper(DropNetClient client, Func<long, byte[]> chunkNeeded, string path, Action<ChunkedUploadProgress> progress, bool overwrite, string parentRevision, long? fileSize, long? maxRetries) { if (client == null) { throw new ArgumentNullException("client"); } if (chunkNeeded == null) { throw new ArgumentNullException("chunkNeeded"); } _client = client; _chunkNeeded = chunkNeeded; _path = path; _progress = progress; _overwrite = overwrite; _parentRevision = parentRevision; _fileSize = fileSize; _maxRetries = maxRetries; _lastChunkUploaded = new ChunkedUpload(); // initial chunk }
public void Timeout_Exception_Raised_On_Super_Short_Timeout() { var client = new DropNetClient("", ""); client.TimeoutMS = 100; client.GetToken(); }
public void TestMethod1() { var client = new DropNetClient(TestVariables.ApiKey, TestVariables.ApiSecret); client.WebAuthUrl("test"); }
public UserTests1() { _client = new DropNetClient(TestVariables.ApiKey, TestVariables.ApiSecret); }
public GetFileTests() { _client = TestSettings.CreateClient(); _fixture = new Fixture(); }
private static DropNetClient CreateAuthenticatedClient(bool showsuccessfulinfo) { RequireUserInfo(); var c = new DropNetClient(settings.ApiKey, settings.Secret); try { var ul = c.Login(settings.Email, settings.Password); if (!string.IsNullOrEmpty(ul.Token)) { if (showsuccessfulinfo) { Console.WriteLine("Authentication successful."); Console.WriteLine("\tToken: " + ul.Token); Console.WriteLine("\tSecret: " + ul.Secret); } else { Console.WriteLine("Authenticated."); } } else { Console.WriteLine("Authentication failed."); } } catch (Exceptions.DropboxException e) { Console.WriteLine("Authentication failed."); Console.WriteLine(e); } return c; }