Exemplo n.º 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            TableView.TableFooterView = new UIView();

            this.NavigationItem.SetLeftBarButtonItem(new UIBarButtonItem(
                                                         UIImage.FromBundle("BackArrow"), UIBarButtonItemStyle.Plain, (sender, args) =>
            {
                NavigationController.PopViewController(true);
            }), true);

            this.Title = metaData.Name;

            cloudStorageLogic = new CloudStorageLogic();


            activityIndicator        = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.White);
            activityIndicator.Frame  = new CGRect(150, 120, 30, 30);
            activityIndicator.Center = View.Center;
            View.AddSubview(activityIndicator);
            activityIndicator.BringSubviewToFront(View);
            activityIndicator.Color = UIColor.LightGray;
            activityIndicator.StartAnimating();

            //Peform delay 1
            PerformSelector(new Selector("GetFilesFolders"), null, 1.0f);
        }
Exemplo n.º 2
0
 public CloudStorageSource(CRCloudMetaData[] metaData, ICRCloudStorageProtocol cloudStorage, CloudStorageViewController controller)
 {
     this._metaData     = metaData;
     this._cloudStorage = cloudStorage;
     this._controller   = controller;
     helper             = new Helper();
     logic = new CloudStorageLogic();
 }
Exemplo n.º 3
0
        //Download File

        public void DownloadFile(CRCloudMetaData metaData)
        {
            new System.Threading.Thread(new System.Threading.ThreadStart(() =>
            {
                InvokeOnMainThread(() =>
                {
                    CloudStorageLogic cloudStorageLogic = new CloudStorageLogic();
                    NSInputStream inputStream           = cloudStorageLogic.DownloadFileWithPath(_cloudStorage, metaData.Path);
                    NSMutableData data = new NSMutableData();
                    inputStream.Open();

                    var int32Value = metaData.Size.Int32Value;
                    var intValue   = metaData.Size.NIntValue;

                    var buffer = new byte[1024];

                    while (inputStream.HasBytesAvailable())
                    {
                        var len = inputStream.Read(buffer, 1024);
                        data.AppendBytes(buffer);
                    }

                    if (inputStream.HasBytesAvailable() == false)
                    {
                        inputStream.Close();

                        var documents        = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                        var bytes            = data.Bytes;
                        string localFilename = metaData.Name;
                        string localPath     = Path.Combine(documents, localFilename);

                        byte[] managedArray = new byte[intValue];
                        Marshal.Copy(bytes, managedArray, 0, int32Value);

                        File.WriteAllBytes(localPath, managedArray);

                        helper.Alert("Download Completed", "File downloaded and saved to file sharing", _controller);
                    }
                });
            })).Start();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.NavigationItem.SetLeftBarButtonItem(new UIBarButtonItem(
                                                         UIImage.FromBundle("BackArrow"), UIBarButtonItemStyle.Plain, (sender, args) =>
            {
                NavigationController.PopViewController(true);
            }), true);

            this.Title = selectedService;

            TableView.TableFooterView = new UIView();

            this.NavigationItem.SetRightBarButtonItem(new UIBarButtonItem(
                                                          UIBarButtonSystemItem.Add, (sender, args) =>
            {
                var alert = UIAlertController.Create("Upload File", "Uploads photos to Cloud Ctorage", UIAlertControllerStyle.ActionSheet);

                alert.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, null));
                alert.AddAction(UIAlertAction.Create("Take a Photo", UIAlertActionStyle.Default, action => CameraPhoto()));
                alert.AddAction(UIAlertAction.Create("Choose a Photo", UIAlertActionStyle.Default, action => UploadImage()));
                PresentViewController(alert, animated: true, completionHandler: null);
            }), true);


            activityIndicator        = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.White);
            activityIndicator.Frame  = new CGRect(150, 120, 30, 30);
            activityIndicator.Center = View.Center;
            View.AddSubview(activityIndicator);
            activityIndicator.BringSubviewToFront(View);
            activityIndicator.Color = UIColor.LightGray;
            activityIndicator.StartAnimating();

            cloudStorageLogic = new CloudStorageLogic();

            if (selectedService == "Box")
            {
                cloudStorage = new CRBox("qnskodzvd2naq16xowc40t43fug2848n", "cQE7Sf9DzZqChjvCTxIMTp3ye6hynhTd");
            }
            else if (selectedService == "Dropbox")
            {
                cloudStorage = new CRDropbox("38nu3lwdvyaqs78", "c95g0wfkdv6ua2d");
            }
            else if (selectedService == "Google Drive")
            {
                CRGoogleDrive drive = new CRGoogleDrive("1007170750392-r3p483hu2q02nsp45679dbqsbt9po8h0.apps.googleusercontent.com", "", "com.cloudrail.unifiedcloudstorage:/oauth2redirect", "State");
                drive.UseAdvancedAuthentication();
                cloudStorage = drive;
            }
            else if (selectedService == "One Drive")
            {
                cloudStorage = new CROneDrive("000000004018F12F", "lGQPubehDO6eklir1GQmIuCPFfzwihMo");
            }
            else if (selectedService == "One Drive for Business")
            {
                cloudStorage = new CROneDriveBusiness("", "");
            }
            else if (selectedService == "Egnynte")
            {
                cloudStorage = new CREgnyte("cloudrailcloudtest", "k9y879bha2kmsyyqx4urtnaz", "TsgByd2YZqsJPyYMDhEB6ctAYQ6kP35qYTnEG9urPKq2eNNXRF", "https://www.cloudrailauth.com/auth", "State");
            }

            //First Service Called (delay it by 500 millseconds for Advanced Authentication)
            PerformSelector(new Selector("GetRootFilesFolders"), null, 1.0f);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.NavigationItem.SetLeftBarButtonItem(new UIBarButtonItem(
                                                         UIImage.FromBundle("BackArrow"), UIBarButtonItemStyle.Plain, (sender, args) =>
            {
                NavigationController.PopViewController(true);
            }), true);

            this.Title = selectedService;

            TableView.TableFooterView = new UIView();

            this.NavigationItem.SetRightBarButtonItem(new UIBarButtonItem(
                                                          UIBarButtonSystemItem.Add, (sender, args) =>
            {
                var alert = UIAlertController.Create("Upload File", "Uploads photos to Cloud Ctorage", UIAlertControllerStyle.ActionSheet);

                alert.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, null));
                alert.AddAction(UIAlertAction.Create("Take a Photo", UIAlertActionStyle.Default, action => CameraPhoto()));
                alert.AddAction(UIAlertAction.Create("Choose a Photo", UIAlertActionStyle.Default, action => UploadImage()));
                PresentViewController(alert, animated: true, completionHandler: null);
            }), true);


            activityIndicator        = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.White);
            activityIndicator.Frame  = new CGRect(150, 120, 30, 30);
            activityIndicator.Center = View.Center;
            View.AddSubview(activityIndicator);
            activityIndicator.BringSubviewToFront(View);
            activityIndicator.Color = UIColor.LightGray;
            activityIndicator.StartAnimating();

            cloudStorageLogic = new CloudStorageLogic();

            //Setup:
            //https://cloudrail.com/integrations/interfaces/CloudStorage;serviceIds=Box,Dropbox,Egnyte,GoogleDrive,OneDrive,OneDriveBusiness,PCloud;platformId=XamarinIOS;tab=setup

            if (selectedService == "Box")
            {
                cloudStorage = new CRBox("Box Client Identifier", "Box Client Secret");
            }
            else if (selectedService == "Dropbox")
            {
                CRDropbox dropbox = new CRDropbox("Dropbox Client Identifier", "Dropbox Client Secret", "https://auth.cloudrail.com/com.cloudrail.unifiedcloudstorage", "State");
                dropbox.UseAdvancedAuthentication();
                cloudStorage = dropbox;
            }
            else if (selectedService == "Google Drive")
            {
                //NOTE: Only Need Client Identifier
                CRGoogleDrive drive = new CRGoogleDrive("Google Drive Client Identifier", "", "com.cloudrail.unifiedcloudstorage:/oauth2redirect", "State");
                drive.UseAdvancedAuthentication();
                cloudStorage = drive;
            }
            else if (selectedService == "One Drive")
            {
                cloudStorage = new CROneDrive("OneDrive Client Identifier", "OneDrive Client Secret");
            }
            else if (selectedService == "One Drive for Business")
            {
                cloudStorage = new CROneDriveBusiness("OneDrive Business Client Identifier", "OneDrive Business Client Secret");
            }
            else if (selectedService == "Egnynte")
            {
                cloudStorage = new CREgnyte("Your Egnyte Domain", "Your Egnyte API Key", "Your Egnyte Shared Secret", "https://www.cloudrailauth.com/auth", "State");
            }
            else if (selectedService == "PCloud")
            {
                cloudStorage = new CRPCloud("PCloud Client Identifier", "PCloud Client Secret");
            }

            //First Service Called (delay it by 500 millseconds for Advanced Authentication)
            PerformSelector(new Selector("GetRootFilesFolders"), null, 1.0f);
        }