public bool BeginUpload(TaskInfo task) { if (!Path.IsPathRooted(task.File)) { task.File = Path.Combine(_Root, task.File); } if (!File.Exists(task.File)) { return false; } task.FileStream = File.OpenRead(task.File); task.FileSize = task.FileStream.Length; task.FileName = Path.GetFileName(task.File); if (task.File.StartsWith(_Root)) { task.File = task.File.Substring(_Root.Length); } else { task.File = task.FileName; } return true; }
public bool BeginDownload(TaskInfo task) { if (task == null) { return false; } var file = GetPhysicalPath(task.File); string folder = Path.GetDirectoryName(file); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } if (task.IsAppend) { task.FileSize = new FileInfo(file).Length; if (task.FileSize >= task.MetaSize) { return false; } task.FileStream = new FileStream(file, FileMode.Append); } else { task.FileStream = new FileStream(file, FileMode.Create); } return true; }
public string BeginUpload(TaskInfo info) { lock (_Params) { ResetParams(); string url = KuaipanServer.UPLOAD; PrepareParams(); AddParam(OAuthConstants.OAUTH_TOKEN, Token.oauth_token); SortParam(); AddParam(OAuthConstants.OAUTH_SIGNATURE, Signature(GenerateBaseString(url))); string t = GenBaseParams(); byte[] r = _Server.Get(url, t); if (r == null || r.Length < 1) { return null; } t = GetString(r); KuaipanMetaUrl uri = JsonConvert.DeserializeObject<KuaipanMetaUrl>(t); if (uri.stat != "OK") { info.Message = uri.stat; return null; } return uri.url; } }
public void RemoveTask(TaskInfo thread, int index) { GvTask.Rows.RemoveAt(index); }
public void AppendTask(TaskInfo thread) { GvTask.Rows.Add(thread.FileName, "", thread.Message); }
/// <summary> /// /// </summary> /// <param name="thread"></param> public void UpdateTask(TaskInfo thread, int index) { DataGridViewRow row = GvTask.Rows[index]; var cell = row.Cells[2]; if (cell != null) { cell.Value = thread.Message; } cell = row.Cells[3]; if (cell != null) { cell.Value = thread.Percent; } }