Ejemplo n.º 1
0
        private FolderModel uploadfolderInit(string bucket, string parentKey, string dir)
        {
            DirectoryInfo dirInfo = new DirectoryInfo(dir);

            FolderModel folderModel = new FolderModel();

            folderModel.objListAll = new List <FileModel>();
            folderModel.Size       = 0;
            folderModel.bucketName = bucket;
            folderModel.key        = parentKey + dirInfo.Name + "/";
            folderModel.initial();

            FileInfo[] fileInfos = dirInfo.GetFiles();
            foreach (FileInfo fileInfo in fileInfos)
            {
                folderModel.objListAll.Add(new FileModel()
                {
                    bucketName = folderModel.bucketName, key = folderModel.key + fileInfo.Name, localPath = fileInfo.FullName
                });
                folderModel.Size += fileInfo.Length;
            }

            DirectoryInfo[] sonDirInfos = dirInfo.GetDirectories();
            foreach (DirectoryInfo sonDirInfo in sonDirInfos)
            {
                FolderModel model = uploadfolderInit(bucket, folderModel.key, sonDirInfo.FullName);
                folderModel.objListAll.AddRange(model.objListAll);
                folderModel.Size += model.Size;
            }

            return(folderModel);
        }
Ejemplo n.º 2
0
        public async void searchOperate(string text)
        {
            ProgressVisible = true;
            if (text != "")
            {
                FolderModel searchFolder;
                if (currentFolder != null)
                {
                    searchFolder        = currentFolder;
                    backUpCurrentFolder = currentFolder;
                }
                else
                {
                    searchFolder = backUpCurrentFolder;
                }

                FolderModel folderModel = new FolderModel();
                folderModel.folderList = new List <FolderModel>();
                folderModel.objList    = new List <FileModel>();

                List <ObjectListing> listObjectListing = await folderListModel.getObjectListing(searchFolder.bucketName, searchFolder.key);

                foreach (ObjectListing objectlisting in listObjectListing)
                {
                    foreach (OssObjectSummary ossObj in objectlisting.ObjectSummaries)
                    {
                        if (ossObj.Key.EndsWith("/"))
                        {
                            if (FolderModel.lastName(ossObj.Key).Contains(text))
                            {
                                FolderModel folder = new FolderModel()
                                {
                                    bucketName = ossObj.BucketName, key = ossObj.Key
                                };
                                folder.initial();
                                folderModel.folderList.Add(folder);
                            }
                        }
                        else
                        {
                            if (FileModel.lastName(ossObj.Key).Contains(text))
                            {
                                FileModel fileModel = new FileModel()
                                {
                                    bucketName = ossObj.BucketName, key = ossObj.Key, Size = ossObj.Size
                                };
                                fileModel.modifyTime = ossObj.LastModified;
                                fileModel.initial();
                                folderModel.objList.Add(fileModel);
                            }
                        }
                    }
                }
                currentFolder = null;

                refreshObjectList(folderModel);
                ProgressVisible = false;
            }
        }
Ejemplo n.º 3
0
 public DownloadViewModel(IEventAggregator _events, IClientService _clientService,
                          IWindowManager _windowManager)
 {
     this.events   = _events;
     clientService = _clientService;
     windowManager = _windowManager;
     events.Subscribe(this);
     downloadingListModel     = new BindableCollection <ObjectModel>();
     uploadingListModel       = new BindableCollection <ObjectModel>();
     compeletedListModel      = new BindableCollection <ObjectModel>();
     objectModelForSerialList = CompleteTaskListFile.readFromFile();
     if (objectModelForSerialList != null)
     {
         foreach (ObjectModelForSerial obj in objectModelForSerialList)
         {
             if (obj.key.EndsWith("/"))
             {
                 FolderModel folder = new FolderModel()
                 {
                     bucketName = obj.bucketName, key = obj.key
                 };
                 folder.initial();
                 folder.localPath       = obj.localPath;
                 folder.Size            = obj.size;
                 folder.completeTime    = obj.completeTime;
                 folder.compeleteStatus = obj.compeleteStatus;
                 compeletedListModel.Add(folder);
             }
             else
             {
                 FileModel fileModel = new FileModel()
                 {
                     bucketName = obj.bucketName, key = obj.key, Size = obj.size
                 };
                 fileModel.initial();
                 fileModel.localPath       = obj.localPath;
                 fileModel.completeTime    = obj.completeTime;
                 fileModel.compeleteStatus = obj.compeleteStatus;
                 compeletedListModel.Add(fileModel);
             }
         }
         events.Publish(new TaskCountEvent(compeletedListModel.Count, TaskCountEventType.COMPELETED));
     }
     else
     {
         objectModelForSerialList = new List <ObjectModelForSerial>();
     }
 }