/// <summary> /// 下载重置. /// </summary> public void DownloadReset() { // 打断当前线程并停止所有协同进程 isCanceled = true; this.StopAllCoroutines(); // 清空错误列表 if (this._errors != null) { this._errors.Clear(); } this._State = TRunState.OK; this._isCompleted = false; this.isStarted = false; // 清空上传列表 UploadList.GetInstance().Clear(); // 下载列表清空 DownloadList.GetInstance().Reset(); // 进度条重置 if (this._downloadBar != null) { this._downloadBar.Reset(); } }
public static string Upload(string filename, string path, out bool success) { success = false; if (!Authorised) { Logger.LogMessageToFile("Authorise dropbox in settings"); return(LocRm.GetString("CloudAddSettings")); } if (UploadList.SingleOrDefault(p => p.SourceFilename == filename) != null) { return(LocRm.GetString("FileInQueue")); } if (UploadList.Count >= CloudGateway.MaxUploadQueue) { return(LocRm.GetString("UploadQueueFull")); } UploadList.Add(new UploadEntry { DestinationPath = path, SourceFilename = filename }); if (!_uploading) { _uploading = true; ThreadPool.QueueUserWorkItem(Upload, null); } success = true; return(LocRm.GetString("AddedToQueue")); }
public static string Upload(string filename, string path, out bool success) { success = false; //if (!Statics.Subscribed) // return "NotSubscribed"; if (!Authorised) { return("CloudAddSettings"); } if (UploadList.SingleOrDefault(p => p.SourceFilename == filename) != null) { return("FileInQueue"); } if (UploadList.Count >= CloudGateway.MaxUploadQueue) { return("UploadQueueFull"); } UploadList.Add(new UploadEntry { DestinationPath = "iSpy" + "\\" + path.Replace("/", "\\").Trim(Path.DirectorySeparatorChar), SourceFilename = filename }); if (!_uploading) { _uploading = true; ThreadPool.QueueUserWorkItem(Upload, null); } success = true; return("AddedToQueue"); }
public static string Upload(int objectId, string filename) { if (UploadList.SingleOrDefault(p => p.Filename == filename) != null) { return(LocRm.GetString("FileInQueue")); } if (UploadList.Count >= CloudGateway.MaxUploadQueue) { return(LocRm.GetString("UploadQueueFull")); } if (Uploaded.FirstOrDefault(p => p == filename) != null) { return(LocRm.GetString("AlreadyUploaded")); } var us = new UserState(objectId, filename); UploadList.Add(us); if (!_uploading) { _uploading = true; ThreadPool.QueueUserWorkItem(Upload, null); } return(LocRm.GetString("AddedToQueue")); }
public void AddRange_WithDuplicate_DuplicatesAreNotAdded() { var uploadList = new UploadList(_helpers); const string duplicatePath = "a"; var duplicate = new UploadFile() { FullPath = duplicatePath }; var addFiles1 = new List <UploadFile> { new UploadFile() { FullPath = duplicatePath }, new UploadFile() { FullPath = "b" }, }; var addFiles2 = new List <UploadFile> { duplicate, new UploadFile() { FullPath = "c" }, }; uploadList.AddRange(addFiles1); uploadList.AddRange(addFiles2); Assert.That(uploadList.Count, Is.EqualTo(3)); Assert.That(uploadList, Does.Not.Contain(duplicate)); }
private static void Upload(object state) { try { if (UploadList.Count == 0) { _uploading = false; return; } UploadEntry entry; try { var l = UploadList.ToList(); entry = l[0];//could have been cleared by Authorise l.RemoveAt(0); UploadList = l.ToList(); } catch { _uploading = false; return; } var s = Service; if (s == null) { _uploading = false; return; } FileInfo fi; try { fi = new FileInfo(entry.SourceFilename); var r = s.UploadPicture(entry.SourceFilename, fi.Name, "iSpy video"); if (r != null) { Logger.LogMessage("Uploaded to flickr: " + fi.Name); } else { Logger.LogMessage("Upload to flickr failed (" + fi.Name + ")"); } } catch (Exception ex) { Logger.LogException(ex, "Flickr"); } Upload(null); } catch (Exception ex) { Logger.LogException(ex, "Dropbox"); } }
/// <summary> /// 取得上传列表文件Base URL. /// </summary> /// <returns>上传列表文件Base URL.</returns> /// <param name="iServerInfo">上传服务器信息.</param> public static string GetUploadListBaseUrl(UploadServerInfo iServerInfo) { string serverPostUrl = GetUploadBaseURL(iServerInfo); string uploadBaseUrl = string.Format("{0}/bundles/{1}/{2}", serverPostUrl, UploadList.GetInstance().BuildTarget, UploadList.GetInstance().AppVersion); return(uploadBaseUrl); }
public void AddNewRange_FilesAreAdded() { var uploadList = new UploadList(_helpers); var addFiles = new List <string> { "a", "b" }; uploadList.AddNewRange(addFiles); Assert.That(uploadList.Select(x => x.FullPath).ToList(), Is.EqualTo(addFiles)); }
public JsonSerializationContent(string serializationFolder, UploadList uploadList, TemplateList templateList, PlaylistList playlistList) { this.playlistListFilePath = Path.Combine(serializationFolder, "playlistlist.json"); this.uploadListFilePath = Path.Combine(serializationFolder, "uploadlist.json"); this.templateListFilePath = Path.Combine(serializationFolder, "templatelist.json"); this.allUploadsFilePath = Path.Combine(serializationFolder, "uploads.json"); this.uploadList = uploadList; this.templateList = templateList; this.playlistList = playlistList; }
/// <summary> /// 取得Bundle全名(包含后缀). /// </summary> /// <returns>Bundle全名.</returns> /// <param name="iBundleId">Bundle ID.</param> public string GetBundleFullName(string iBundleId) { string strRet = iBundleId; string fileSuffix = UploadList.GetInstance().FileSuffix; if (string.IsNullOrEmpty(fileSuffix) == false) { strRet = string.Format("{0}.{1}", strRet, fileSuffix); } return(strRet); }
/// <summary> /// 取得Bundle的上传地址. /// 上传地址:<上传资源用URL>/<BuildMode>/<UploadDateTime> /// </summary> /// <returns>Bundle的上传地址.</returns> /// <param name="iServerInfo">上传服务器信息.</param> /// <param name="iUploadInfo">上传信息.</param> public static string GetBundleUploadBaseURL( UploadServerInfo iServerInfo, UploadItem iUploadInfo) { string uploadBaseUrl = GetUploadBaseURL(iServerInfo); string bundleUploadUrl = string.Format("{0}/{1}", uploadBaseUrl, UploadList.GetBundleRelativePath((TBundleType.Scene == iUploadInfo.BundleType))); // UtilsLog.Info ("GetBundleUploadBaseURL", "BundleUploadUrl:{0}", bundleUploadUrl); return(bundleUploadUrl); }
public void AddAddIfNotDuplicate_AddsFile() { var uploadList = new UploadList(_helpers); var file = new UploadFile { FullPath = "foo.jpg" }; uploadList.AddIfNotDuplicate(file); Assert.That(uploadList.Count, Is.EqualTo(1)); Assert.That(uploadList[0], Is.EqualTo(file)); }
/// <summary> /// 取得Bundle全路径名. /// </summary> /// <returns>Bundle全路径名.</returns> /// <param name="iBundleId">BundleId.</param> /// <param name="iFileType">文件类型.</param> public string GetBundleFullPath( string iBundleId, TUploadFileType iFileType = TUploadFileType.Bundle) { DownloadTargetInfo targetInfo = null; if (isTargetExist(iBundleId, iFileType, out targetInfo) == false) { this.Error("GetBundleFullPath()::This bundles is not exist!!!({BundleId:{0} FileType:{1})", iBundleId, iFileType); return(null); } if (targetInfo == null) { return(null); } string fileName = UploadList.GetLocalBundleFileName(iBundleId, targetInfo.FileType); if (string.IsNullOrEmpty(fileName) == true) { return(null); } string fileFullPath = null; switch (targetInfo.BundleType) { case TBundleType.Normal: { fileFullPath = string.Format("{0}/{1}", ServersConf.BundlesDirOfNormal, fileName); } break; case TBundleType.Scene: { fileFullPath = string.Format("{0}/{1}", ServersConf.BundlesDirOfScenes, fileName); } break; default: { fileFullPath = string.Format("{0}/{1}", ServersConf.BundlesDir, fileName); } break; } return(fileFullPath); }
public void ReOrder(UploadList uploadList) { List <UploadViewModel> reOrderedViewModels = new List <UploadViewModel>(); foreach (Upload upload in uploadList) { reOrderedViewModels.Add(uploadViewModels.Find(vm => vm.Upload.Guid == upload.Guid)); } this.uploadViewModels = reOrderedViewModels; this.raiseNotifyCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); }
public async Task AddRangeAsync_FilesAreAdded() { var uploadList = new UploadList(_helpers); var addFiles = new List <UploadFile>(); for (var k = 0; k < 500; k++) { addFiles.Add(new UploadFile(k.ToString())); } await uploadList.AddRangeAsync(addFiles); Assert.That(uploadList.ToList(), Is.EqualTo(addFiles)); }
public async Task AddNewRangeAsync_FilesAreAdded() { var uploadList = new UploadList(_helpers); var addFiles = new List <string>(); for (var k = 0; k < 500; k++) { addFiles.Add(k.ToString()); } await uploadList.AddNewRangeAsync(addFiles); Assert.That(uploadList.Select(x => x.FullPath).ToList(), Is.EqualTo(addFiles)); }
void Awake() { ManifestUpload = UploadList.GetInstance().ManifestUpload; // 设定下载进度条委托 if (this._downloadBar != null) { this._downloadBar.SetDelegate( GetDownloadedProgress, GetDownloadedState, GetDownloadTotalCount, GetDownloadedCount); } }
private static void Upload(object state) { if (UploadList.Count == 0) { _uploading = false; return; } UploadEntry entry; try { var l = UploadList.ToList(); entry = l[0]; l.RemoveAt(0); UploadList = l.ToList(); } catch { _uploading = false; return; } if (AccessToken?.Length == 0) { _uploading = false; return; } try { var fi = new FileInfo(entry.SourceFilename); NameValueCollection values = new NameValueCollection(); NameValueCollection files = new NameValueCollection(); string fid = GetOrCreateFolder(entry.DestinationPath); values.Add("attributes", "{\"name\":\"" + fi.Name + "\", \"parent\":{\"id\":\"" + fid + "\"}}"); files.Add("file", fi.FullName); var responseString = SendHttpRequest("https://upload.box.com/api/2.0/files/content", values, files); dynamic d = JsonConvert.DeserializeObject(responseString); Logger.LogMessage("File uploaded to box: " + d.entries[0].id); } catch (Exception ex) { Logger.LogException(ex, "Box"); } Upload(null); }
public void Add_WithDuplicate_DoesNotAddFile() { var uploadList = new UploadList(_helpers); var file1 = new UploadFile { FullPath = "a" }; var file2 = new UploadFile { FullPath = "a" }; uploadList.AddIfNotDuplicate(file1); uploadList.AddIfNotDuplicate(file2); Assert.That(uploadList.Count, Is.EqualTo(1)); }
private async Task HandleIfExistsInCloud(B2Db b2Db, string filePath, B2File existingB2File, ulong xhash, string parentPath, string b2Path) { // try find local object in db FileObject existingFileObject = b2Db.GetFileObject(filePath); if (existingFileObject != null && existingFileObject.B2Files.ContainsKey(existingB2File.FileId)) { // local object xhash diff from cloud, then mark this for upload if (existingFileObject.Xhash != xhash) { existingFileObject.Xhash = xhash; UploadList.Add(new UploadObject(existingFileObject, parentPath, b2Path)); } } // if existing file object is available but b2file object is not available else if (existingFileObject != null && !existingFileObject.B2Files.ContainsKey(existingB2File.FileId)) { // update b2file object and does not need to reupload if (existingB2File.ContentSHA1.Equals("none") || Utils.FilepathToSha1Hash(filePath).Equals(existingB2File.ContentSHA1.Replace("unverified:", ""), StringComparison.InvariantCultureIgnoreCase)) { existingFileObject.B2Files.Add(existingB2File.FileId, existingB2File); existingFileObject.DateModified = DateTime.Now; await b2Db.UpdateFileObject(existingFileObject); } else // mark this object to upload if diff sha { existingFileObject.Xhash = xhash; UploadList.Add(new UploadObject(existingFileObject, parentPath, b2Path)); } } else { // local not available, so check it's sha1hash when same add to db or mark to upload FileObject tempFileObject = new FileObject(filePath, xhash); if (existingB2File.ContentSHA1.Equals("none") || Utils.FilepathToSha1Hash(filePath).Equals(existingB2File.ContentSHA1.Replace("unverified:", ""), StringComparison.InvariantCultureIgnoreCase)) { tempFileObject.B2Files.Add(existingB2File.FileId, existingB2File); await b2Db.Add(tempFileObject); } else { UploadList.Add(new UploadObject(tempFileObject, parentPath, b2Path)); } } }
/// <summary> /// 下载完毕拷贝文件. /// </summary> public void CopyTargetWhenDownloadCompleted() { string copyFrom = null; string copyTo = null; switch (this.BundleType) { case TBundleType.Scene: { copyFrom = ServersConf.DownloadDirOfScenes; copyTo = ServersConf.BundlesDirOfScenes; } break; case TBundleType.Normal: { copyFrom = ServersConf.DownloadDirOfNormal; copyTo = ServersConf.BundlesDirOfNormal; } break; default: { copyFrom = ServersConf.DownloadDir; copyTo = ServersConf.BundlesDir; } break; } string fileName = UploadList.GetLocalBundleFileName(this.ID, this.FileType); copyFrom = string.Format("{0}/{1}", copyFrom, fileName); copyTo = string.Format("{0}/{1}", copyTo, fileName); if (true == File.Exists(copyFrom)) { File.Copy(copyFrom, copyTo, true); this.Info("CopyTargetWhenDownloadCompleted()::Copy File:{0} -> {1}", copyFrom, copyTo); } if (false == File.Exists(copyTo)) { this.Error("CopyTargetWhenDownloadCompleted()::Failed!! FileName:{0} -> {1}", copyFrom, copyTo); } File.Delete(copyFrom); this.Info("CopyTargetWhenDownloadCompleted()::Delete File -> {0}", copyFrom); }
protected override void OnDisabled() { base.OnDisabled(); CraftAddQueue = new ConcurrentQueue <CraftChangeEntry>(); CraftDeleteQueue = new ConcurrentQueue <CraftChangeEntry>(); CraftResponseQueue = new ConcurrentQueue <CraftResponseEntry>(); PlayersWithCrafts.Clear(); PlayerList.Clear(); UploadList.Clear(); SelectedPlayer = ""; UploadCraftType = CraftType.Vab; UploadCraftName = ""; DownloadCraftType = CraftType.Vab; DownloadCraftName = ""; DeleteCraftType = CraftType.Vab; DeleteCraftName = ""; }
public override void OnDisabled() { base.OnDisabled(); CraftAddQueue.Clear(); CraftDeleteQueue.Clear(); CraftResponseQueue.Clear(); PlayersWithCrafts.Clear(); PlayerList.Clear(); UploadList.Clear(); SelectedPlayer = ""; UploadCraftType = CraftType.VAB; UploadCraftName = ""; DownloadCraftType = CraftType.VAB; DownloadCraftName = ""; DeleteCraftType = CraftType.VAB; DeleteCraftName = ""; }
public ObservableUploadViewModels(UploadList uploadList, ObservableTemplateViewModels observableTemplateViewModels, ObservablePlaylistViewModels observablePlaylistViewModels) { this.observableTemplateViewModels = observableTemplateViewModels; this.observablePlaylistViewModels = observablePlaylistViewModels; this.uploadViewModels = new List <UploadViewModel>(); if (uploadList != null) { foreach (Upload upload in uploadList) { this.uploadViewModels.Add(new UploadViewModel(upload, this.observableTemplateViewModels, this.observablePlaylistViewModels)); } uploadList.CollectionChanged += uploadListCollectionChanged; } }
public void BuildUploadList() { UploadList.Clear(); if (Directory.Exists(VabPath)) { UploadList.Add(CraftType.Vab, Directory.GetFiles(VabPath).Select(Path.GetFileNameWithoutExtension)); } if (Directory.Exists(SphPath)) { UploadList.Add(CraftType.Sph, Directory.GetFiles(SphPath).Select(Path.GetFileNameWithoutExtension)); } if (Directory.Exists(VabPath)) { UploadList.Add(CraftType.Subassembly, Directory.GetFiles(SubassemblyPath).Select(Path.GetFileNameWithoutExtension)); } }
public void AddRange_FilesAreAdded() { var uploadList = new UploadList(_helpers); var addFiles = new List <UploadFile> { new UploadFile() { FullPath = "a" }, new UploadFile() { FullPath = "b" }, }; uploadList.AddRange(addFiles); Assert.That(uploadList.ToList(), Is.EqualTo(addFiles)); }
/// <summary> /// 更新&生成上传列表信息. /// </summary> /// <param name="iBundleType">Bundle Type.</param> /// <param name="iHashCodes">HashCode列表(Unity3d打包生成).</param> public void UpdateUploadList(TBundleType iBundleType, Dictionary <string, string> iHashCodes = null) { UploadList list = UploadList.GetInstance(); if (list == null) { return; } list.AppVersion = BuildInfo.GetInstance().BuildVersion; list.CenterVersion = BuildInfo.GetInstance().CenterVersion; // MainManifest if (TBundleType.Normal == iBundleType) { list.AddMainManifestAssetsTarget(); } // 遍历Bundles foreach (BundleMap loop in this.Maps) { if (loop.Type != iBundleType) { continue; } string hashCode = null; if (iHashCodes != null) { hashCode = this.GetHashCodeOfBundle(iHashCodes, loop.ID); } // Bundle list.AddTarget(loop, TUploadFileType.Bundle, hashCode); if ((true == list.ManifestUpload) && (TBundleType.Scene != loop.Type)) { // Manifest(Normal) list.AddTarget(loop, TUploadFileType.NormalManifest); } } }
public async Task RetryAnyUploads() { if (RetryList.Count == 0) { return; } Log.Information("Retrying for {0} times", MaxRetries); for (int i = 0; i < MaxRetries; i++) { if (RetryList.Count == 0) { break; } Log.Information("Retry #{0}", i); UploadList.Clear(); UploadList = new ConcurrentBag <UploadObject>(RetryList); RetryList.Clear(); await UploadToB2(); } }
public static string Upload(string filename, string path) { if (UploadList.SingleOrDefault(p => p.SourceFilename == filename) != null) { return(LocRm.GetString("FileInQueue")); } if (UploadList.Count >= CloudGateway.MaxUploadQueue) { return(LocRm.GetString("UploadQueueFull")); } UploadList.Add(new UploadEntry { DestinationPath = "iSpy\\" + path.Replace("/", "\\").Trim('\\'), SourceFilename = filename }); if (!_uploading) { _uploading = true; ThreadPool.QueueUserWorkItem(Upload, null); } return(LocRm.GetString("AddedToQueue")); }
public async Task AddNewRangeAsync_WithDuplicates_DuplicatesAreNotAdded() { const string duplicatePath = "a"; var uploadList = new UploadList(_helpers) { new UploadFile { FullPath = duplicatePath }, new UploadFile { FullPath = "b" }, }; var addFiles = new List <string> { duplicatePath, "c" }; await uploadList.AddNewRangeAsync(addFiles); Assert.That(uploadList.Count, Is.EqualTo(3)); Assert.That(uploadList.Count(x => x.FullPath == duplicatePath), Is.EqualTo(1)); }