public void uploadAmazon()
        {
            System.IO.FileInfo ft = new System.IO.FileInfo(@"C:\Logs\ImportManager\ErrorLog.xml");
            IcloudFileInfo fi = new cloudFileInfo ()
            { 
                localfolderName = ft.DirectoryName,
                localfileLastModifiedDate = ft.LastWriteTime.ToString(),
                localfileName = ft.Name,
                DateofBackup = DateTime.Now,
                deviceName = tr.customerName,
                 OperatingSystem = Environment.OSVersion.ToString().Split(' ').FirstOrDefault()
            };

            Task dt = st.uploadFileAsyc(fi);
            dt.Wait();
            Assert.IsTrue(dt.IsCompleted);
           
        }
        public async Task uploadFilesAsync()
        {
            string systemO = null; 
            try
            {

                systemO = Environment.OSVersion.ToString().Split(' ').FirstOrDefault();
            }
            catch (Exception)
            {

                throw;
            }
            
            var defaultCloud = this._settings.icloudSettings.FirstOrDefault(p => p.isactive == true);
            iCloud _iCloud = null;
            try
            {

                
                switch (defaultCloud.storageType)
                {

                    case cloudTypes.Amazon:
                        _iCloud = new sAmazonS3(this._settings);
                        break;
                    case cloudTypes.Azure:
                        throw (new NotImplementedException());
                    default:
                        throw (new NotImplementedException());

                }

                foreach (string item in this._settings.foldersToBackUp)
                {
                    try
                    {
                        DirectoryInfo di = new DirectoryInfo(item);

                        foreach (FileInfo fi in di.GetFiles("*", SearchOption.AllDirectories))
                        {
                            IcloudFileInfo cloudFi = new cloudFileInfo()
                            {
                                DateofBackup = DateTime.Now,
                                deviceName = this._settings.customerName,
                                localfileName = fi.Name,
                                localfileLastModifiedDate = fi.LastWriteTime.ToString(),
                                localfolderName = fi.DirectoryName,
                                OperatingSystem = systemO
                            };

                            await _iCloud.uploadFileAsyc(cloudFi);

                        }
                    }
                    catch (Exception ex)
                    {
                        throw;
                        //Write ErrorLogging
                    }


                }

                
            }

            catch (Exception ex)
            {

                throw;
            }
            finally
            {
                if (_iCloud != null) _iCloud.Dispose();                           
            }

        }
        public List<IcloudFileInfo> getAllfiles(int container = 0)
        {
            List<IcloudFileInfo> listOFFiles = new List<IcloudFileInfo>();

            using (client)
            {

                
                ListObjectsRequest request = new ListObjectsRequest
                {
                    BucketName = this.bucketname,
                    MaxKeys = 30

                };

                if (container > 0)
                {
                    request.Prefix = container.ToString() + "/";                    
                }

                do
                {

                    ListObjectsResponse response = client.ListObjects(request);
                    
                    foreach (S3Object entry in response.S3Objects)
                    {
                            if (entry.Key == container.ToString() + "/")
                            {
                                continue ;
                            }

                            IcloudFileInfo rd = new cloudFileInfo();
                            rd.DateofBackup = entry.LastModified;
                            rd.CloudFileName = entry.Key.Split('/')[1];
                            rd.fileSize = entry.Size;
                            
                            GetObjectMetadataRequest metaRequest = new GetObjectMetadataRequest
                            {
                                BucketName = this.bucketname,
                                Key = entry.Key
                            };
                            try
                            {
                             // A try catch is needed to skip all keys that don't have valid metadata;

                            GetObjectMetadataResponse responseMeta = client.GetObjectMetadata(metaRequest);                            
                            rd.fileSize = entry.Size;
                            rd.deviceName = responseMeta.Metadata["x-amz-meta-devicename"];
                            rd.localfileName = responseMeta.Metadata["x-amz-meta-filename"];
                            rd.localfileLastModifiedDate = responseMeta.Metadata["x-amz-meta-modifieddate"].ToString();                                                        
                            rd.localfolderName = responseMeta.Metadata["x-amz-meta-foldername"].ToString();
                            rd.OperatingSystem = responseMeta.Metadata["x-amz-meta-operatingsystem"].ToString();
                             
                            listOFFiles.Add(rd);
                            }
                            catch (Exception)
                            {
                                continue;
                            }
                            
                        
                    }
                    // If response is truncated, set the marker to get the next 
                    // set of keys.
                    if (response.IsTruncated)
                    {
                        request.Marker = response.NextMarker;
                    }
                    else
                    {
                        request = null;
                    }
                } while (request != null);
             }
            return listOFFiles;
            

        }