Ejemplo n.º 1
0
        /// <summary>
        /// Illustrate of work...
        /// </summary>
        public void OtherWork()
        {
            // Login to Ge.tt
            var user = new Gett.Sharing.GettUser();
            user.Login("myapikey", "mymail@local", "mypassword");

            // Find specefic share
            Gett.Sharing.GettShare share1 = user.Shares.GetShare("9XwUVrB");

            // Create new file on share.
            Gett.Sharing.GettFile file1 = share1.CreateFile("mybackup.sql");

            // Start upload new file
            file1.UploadFile(@"d:\mysqlbackupdump\today.sql");

            // Get all shares with most files count in it ordered
            var shareWithMostfiles = from share in user.Shares.GetShares()
                                     where share.FilesInfo.Length > 0
                                     orderby share.FilesInfo.Length descending
                                     select share;

            // Get all shares with the largeste files
            var shareWithTheLargestFileSize = from share in user.Shares.GetShares()
                                              where share.FilesInfo.Length > 0
                                              orderby share.FilesInfo.Max(f => f.Size) descending
                                              select share;

            // Begin async upload of file
            Gett.Sharing.GettFile file2 = share1.CreateFile("contacts.sql");
            file2.BeginUploadFile(@"d:\mysqlbackupdump\contacts.sql", UploadFileCompleted, file2);

            // Begin async download of file
            file1.BeginDownloadFile(@"d:\download\today.sql", file1.EndDownloadFile, null);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Illustrate of work...
        /// </summary>
        public void OtherWork()
        {
            // Login to Ge.tt
            var user = new Gett.Sharing.GettUser();

            user.Login("myapikey", "mymail@local", "mypassword");

            // Find specefic share
            Gett.Sharing.GettShare share1 = user.Shares.GetShare("9XwUVrB");

            // Create new file on share.
            Gett.Sharing.GettFile file1 = share1.CreateFile("mybackup.sql");

            // Start upload new file
            file1.UploadFile(@"d:\mysqlbackupdump\today.sql");

            // Get all shares with most files count in it ordered
            var shareWithMostfiles = from share in user.Shares.GetShares()
                                     where share.FilesInfo.Length > 0
                                     orderby share.FilesInfo.Length descending
                                     select share;

            // Get all shares with the largeste files
            var shareWithTheLargestFileSize = from share in user.Shares.GetShares()
                                              where share.FilesInfo.Length > 0
                                              orderby share.FilesInfo.Max(f => f.Size) descending
                                              select share;

            // Begin async upload of file
            Gett.Sharing.GettFile file2 = share1.CreateFile("contacts.sql");
            file2.BeginUploadFile(@"d:\mysqlbackupdump\contacts.sql", UploadFileCompleted, file2);

            // Begin async download of file
            file1.BeginDownloadFile(@"d:\download\today.sql", file1.EndDownloadFile, null);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Illustrate of more work...
        /// </summary>
        public void OtherWork2()
        {
            // Login to Ge.tt
            var user = new Gett.Sharing.GettUser();

            user.Login("myapikey", "mymail@local", "mypassword");

            // Create new share
            Gett.Sharing.GettShare share1 = user.Shares.CreateShare(DateTime.Now.ToString("s"));
            Gett.Sharing.GettFile  file1  = share1.CreateFile("MyDataFile." + DateTime.Now.ToString("s") + ".txt");

            // Upload own string as a file to Ge.tt
            const string myDataString = "Hello from Gett.NET library";

            file1.UploadData(System.Text.Encoding.UTF8.GetBytes(myDataString));

            // Download file as a string or ...
            byte[] content       = file1.DownloadData();
            string contentString = System.Text.Encoding.UTF8.GetString(content);

            if (myDataString == contentString)
            {
                MessageBox.Show(@"It is a match!");
            }

            // Download content to a local file
            file1.DownloadFile(@"C:\TEMP\MyFileFromGett.txt");

            // Delete file or ...
            file1.Destroy();

            // Delete share and all files
            share1.Destroy();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Illustrate of work with the async/await i .NET 4.5
        /// </summary>
        public async void OtherWorkAsync()
        {
            try
            {
                // Login to Ge.tt
                var user = new Gett.Sharing.GettUser();
                await user.LoginAsync("myapikey", "mymail@local", "mypassword");

                // Create new share
                Gett.Sharing.GettShare share1 = await user.Shares.CreateShareAsync(DateTime.Now.ToString("s"));

                Gett.Sharing.GettFile file1 = await share1.CreateFileAsync("MyDataFile." + DateTime.Now.ToString("s") + ".txt");

                // Upload own string as a file to Ge.tt
                const string myDataString = "Hello from Gett.NET library with async/await";
                await file1.UploadDataAsync(System.Text.Encoding.UTF8.GetBytes(myDataString));

                // Download file as a string or ...
                byte[] content = await file1.DownloadDataAsync();

                string contentString = System.Text.Encoding.UTF8.GetString(content);

                if (myDataString == contentString)
                {
                    MessageBox.Show(@"It is a match!");
                }

                // Download content to a local file
                await file1.DownloadFileAsync(@"C:\Workspace\MyFileFromGett.txt");

                // Delete file or ...
                await file1.DestroyAsync();

                // Delete share and all files
                await share1.DestroyAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show(@"Exception" + ex);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Illustrate of work with the async/await i .NET 4.5
        /// </summary>
        public async void OtherWorkAsync()
        {
            try
            {
                // Login to Ge.tt
                var user = new Gett.Sharing.GettUser();
                await user.LoginAsync("myapikey", "mymail@local", "mypassword");

                // Create new share
                Gett.Sharing.GettShare share1 = await user.Shares.CreateShareAsync(DateTime.Now.ToString("s"));
                Gett.Sharing.GettFile file1 = await share1.CreateFileAsync("MyDataFile." + DateTime.Now.ToString("s") + ".txt");

                // Upload own string as a file to Ge.tt
                const string myDataString = "Hello from Gett.NET library with async/await";
                await file1.UploadDataAsync(System.Text.Encoding.UTF8.GetBytes(myDataString));

                // Download file as a string or ...
                byte[] content = await file1.DownloadDataAsync();
                string contentString = System.Text.Encoding.UTF8.GetString(content);

                if (myDataString == contentString)
                {
                    MessageBox.Show(@"It is a match!");
                }

                // Download content to a local file
                await file1.DownloadFileAsync(@"C:\Workspace\MyFileFromGett.txt");

                // Delete file or ...
                await file1.DestroyAsync();

                // Delete share and all files
                await share1.DestroyAsync();

            }
            catch (Exception ex)
            {
                MessageBox.Show(@"Exception" + ex);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Illustrate of more work...
        /// </summary>
        public void OtherWork2()
        {
            // Login to Ge.tt
            var user = new Gett.Sharing.GettUser();
            user.Login("myapikey", "mymail@local", "mypassword");

            // Create new share
            Gett.Sharing.GettShare share1 = user.Shares.CreateShare(DateTime.Now.ToString("s"));
            Gett.Sharing.GettFile file1 = share1.CreateFile("MyDataFile." + DateTime.Now.ToString("s") + ".txt");

            // Upload own string as a file to Ge.tt
            const string myDataString = "Hello from Gett.NET library";
            file1.UploadData(System.Text.Encoding.UTF8.GetBytes(myDataString));

            // Download file as a string or ...
            byte[] content = file1.DownloadData();
            string contentString = System.Text.Encoding.UTF8.GetString(content);

            if (myDataString == contentString)
            {
                MessageBox.Show(@"It is a match!");
            }

            // Download content to a local file
            file1.DownloadFile(@"C:\TEMP\MyFileFromGett.txt");

            // Delete file or ...
            file1.Destroy();

            // Delete share and all files
            share1.Destroy();
        }