/// <summary> /// 增加download下载任务(可等待) /// </summary> public CFTask <DownloadAwaitEventArgs> AwaitAddDownload(string downloadPath, string downloadUri, int priority, object userData) { if (string.IsNullOrEmpty(downloadPath)) { throw new Exception("Download path is invalid."); } if (string.IsNullOrEmpty(downloadUri)) { throw new Exception("Download uri is invalid."); } if (TotalAgentCount <= 0) { throw new Exception("You must add download agent first."); } var tcs = new CFTaskCompletionSource <DownloadAwaitEventArgs>(); DownloadTask downloadTask = DownloadTask.AwaitCreate(downloadPath, downloadUri, priority, m_FlushSize, m_Timeout, userData, (DownloadPath) => { try { tcs.TrySetResult(DownloadPath); } catch (Exception e) { tcs.TrySetException(new Exception($"Rpc Error: {DownloadPath.GetType().FullName}", e)); } }); m_TaskPool.AddTask(downloadTask); return(tcs.Task); }
public override int GetHashCode() { unchecked { var hashCode = (DownloadPath != null ? DownloadPath.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (WebSiteUrl != null ? WebSiteUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (KeePassEntryUuid != null ? KeePassEntryUuid.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (AdditionalKeePassFields != null ? AdditionalKeePassFields.GetHashCode() : 0); return(hashCode); } }
private void ClientEditWindow_DownloadFolderOpen(object sender, RoutedEventArgs e) { System.Windows.Forms.FolderBrowserDialog dlg = new System.Windows.Forms.FolderBrowserDialog() { Description = "Select the directory that you want to use as the download location.", SelectedPath = DownloadPath.Text }; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { DownloadPath.Text = dlg.SelectedPath; DownloadPath.Focus(); } }
public override int GetHashCode() { return(DownloadPath.GetHashCode()); }
private void ClientEditWindow_DownloadFolderClear(object sender, RoutedEventArgs e) { DownloadPath.Text = ""; DownloadPath.Focus(); }
private void SckSAcceptProc() { Form.CheckForIllegalCrossThreadCalls = false; int Scki = SckCIndex; SckSs[Scki] = new VESocket(); vec[Scki - 1] = new VEClient(); sckAccept[Scki] = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { //Socket s = SckSs[Scki].getSck(); //s = sckAccept.Accept(); //SckSs[Scki].SckAccept(sckAccept); sckAccept[Scki] = sckAccept[0].Accept(); accumulate++; lblAcc.Text = Convert.ToString(accumulate); //SckSs[Scki].setSck(s); SckSsWaitAccept(); byte[] clientData = new byte[1024]; while (true) { // if (SckSs[Scki].getSck().Connected == true) if (sckAccept[Scki].Connected == true) { //SckSs[Scki].getSck().Receive(clientData); sckAccept[Scki].Receive(clientData); BinaryFormatter bf = new BinaryFormatter(); MemoryStream stream = new MemoryStream(clientData); SQLiteDataReader sqlite_datareader; object obj = bf.Deserialize(stream); if (obj.GetType() == vec[Scki - 1].GetType()) { vec[Scki - 1] = (VEClient)obj; //lblclientComputerName.Text = vec.getComputerName(); lblClientIpAddress.Text = vec[Scki - 1].getIpAddress(); listBox1.Items.Add(vec[Scki - 1].getComputerName()); //讀取SQLite /*SQLiteConnection sqlite_conn = new SQLiteConnection(); * SQLiteCommand sqlite_cmd = new SQLiteCommand(); * * bool isRepeated = true; #region 檢查重複 * * if (vec[Scki - 1].getCommand() == "檢查重複") * { * sqlite_conn = new SQLiteConnection("Data source=" + SQLitePath.path); * sqlite_conn.Open(); * sqlite_cmd = sqlite_conn.CreateCommand(); * sqlite_cmd.CommandText = "SELECT * FROM UsersData"; * sqlite_datareader = sqlite_cmd.ExecuteReader(); * while (sqlite_datareader.Read()) * { * if (sqlite_datareader["User"].ToString() == vec[Scki - 1].getUserName()) * { * vec[Scki - 1].setCommand("重複"); * Serialize(vec[Scki - 1], Scki); * isRepeated = true; * break; * } * isRepeated = false; * } * if (!isRepeated) * { * vec[Scki - 1].setCommand("可用"); * Serialize(vec[Scki - 1], Scki); * } * sqlite_datareader.Close(); * } #endregion #region 註冊 * else if(vec[Scki - 1].getCommand()=="註冊") * { * sqlite_conn = new SQLiteConnection("Data source=" + SQLitePath.path); * sqlite_conn.Open(); * sqlite_cmd = sqlite_conn.CreateCommand(); * sqlite_cmd.CommandText = "SELECT * FROM UsersData"; * sqlite_cmd.ExecuteNonQuery(); * sqlite_datareader = sqlite_cmd.ExecuteReader(); * sqlite_cmd.CommandText = "INSERT INTO UsersData (User,Password,Name) VALUES('" + vec[Scki - 1].getUserName() + "','" + vec[Scki - 1].getPassword() + "','" + vec[Scki - 1].getName() + "')"; * sqlite_cmd.ExecuteNonQuery(); * sqlite_datareader.Close(); * } #endregion #region 登入 * else * { * sqlite_conn = new SQLiteConnection("Data source=" + SQLitePath.path); * sqlite_conn.Open(); * sqlite_cmd = sqlite_conn.CreateCommand(); * sqlite_cmd.CommandText = "SELECT * FROM UsersData"; * sqlite_datareader = sqlite_cmd.ExecuteReader(); * bool isCorrceted = true; * while (sqlite_datareader.Read()) * { * if (sqlite_datareader["User"].ToString() == vec[Scki - 1].getUserName()) * { * if (sqlite_datareader["Password"].ToString() == vec[Scki - 1].getPassword()) * { * vec[Scki - 1].setCommand("正確"); * Serialize(vec[Scki - 1], Scki); * isCorrceted = true; * break; * } * } * isCorrceted = false; * * } * if (!isCorrceted) * { * sckAccept[Scki].Close(); * } * sqlite_datareader.Close(); * * } #endregion*/ } else if (obj.GetType() == dlPath.GetType()) { dlPath = (DownloadPath)obj; sendMyExcelCollection(dlPath.getPath(), Scki); } } } } catch (Exception e) { //MessageBox.Show(e.Message); } }
public string VaultFileName(string vaultRoot) { return(DownloadPath.Replace(vaultRoot, "$").Replace("\\", "/") + "/" + File.Name); }
public async Task <IHttpActionResult> Add(string message, int problemId) { var problem = this.data.Problems.Find(problemId); if (problem == null) { return(NotFound()); } if (Request.Content.IsMimeMultipartContent()) { var path = Path.GetTempPath(); var streamProvider = new MultipartFormDataStreamProvider(path); await Request.Content.ReadAsMultipartAsync(streamProvider); foreach (MultipartFileData fileData in streamProvider.FileData) { if (string.IsNullOrEmpty(fileData.Headers.ContentDisposition.FileName)) { return(BadRequest()); } string fileName = fileData.Headers.ContentDisposition.FileName; if (fileName.StartsWith("\"") && fileName.EndsWith("\"")) { fileName = fileName.Trim('"'); } if (fileName.Contains(@"/") || fileName.Contains(@"\")) { fileName = Path.GetFileName(fileName); } var finalPath = Path.Combine(StoragePath, fileName); File.Move(fileData.LocalFileName, finalPath); var file = new FileResource(finalPath); var uploadedfFile = this.dropbox.UploadFileToCloud(file); var fileUrl = dropbox.GetFileLink(uploadedfFile.Path).Url; var downloadPath = new DownloadPath() { AddDate = DateTime.Now, Link = fileUrl, Message = message, }; problem.DownloadPaths.Add(downloadPath); try { this.data.SaveChanges(); } catch (Exception) { return(BadRequest()); } return(Ok(downloadPath.Link)); } return(Ok()); } else { return(BadRequest()); } }