void addToCompleteList(ObjectModel obj) { compeletedListModel.Insert(0, obj); objectModelForSerialList.Insert(0, new ObjectModelForSerial() { bucketName = obj.bucketName, key = obj.key, displayName = obj.displayName, localPath = obj.localPath, size = obj.Size, completeTime = obj.completeTime, compeleteStatus = obj.compeleteStatus }); //List<ObjectModelForSerial> temp = new List<ObjectModelForSerial>(); //foreach (ObjectModel objM in compeletedListModel) //{ // temp.Add(new ObjectModelForSerial() // { // bucketName = objM.bucketName, // key = objM.key, // displayName = objM.displayName, // localPath = objM.localPath, // size = objM.Size // }); //} CompleteTaskListFile.writeToFile(objectModelForSerialList); }
void deleteInCompleteList(ObjectModel obj) { compeletedListModel.Remove(obj); objectModelForSerialList.RemoveAll(x => (x.bucketName == obj.bucketName && x.key == obj.key && x.displayName == obj.displayName && x.localPath == obj.localPath)); CompleteTaskListFile.writeToFile(objectModelForSerialList); }
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>(); } }