public static bool ClientDownLoadFile(string path, string fileName, string guId, out string msg, out long FileSize) { if (WCFClientProxy.TestPCClientProxy()) { if (GlobalStaticObj.Instance.proxyFile.DownLoadFile(path, fileName, guId, UserId, PCClientCookieStr, out msg, out FileSize)) { DownLoadFileOoj_Client fileObj = new DownLoadFileOoj_Client(); fileObj.FileName = fileName; fileObj.guId = guId; fileObj.FileSize = FileSize; fileObj.path = path; fileObj.NextDataBlockNum = 1; fileObj.DownLoadStatus = GetFileDownLoadStatus.waiting; DownLoadFilesQueue.Instance.Add(guId, fileObj); DownLoadFileMsg(new DownLoadFileEventArgs(guId, fileObj)); lock (mylock3) { ParameterizedThreadStart ParStart = new ParameterizedThreadStart(ThreadDownLoadMethod); Thread myThread = new Thread(ParStart); myThread.IsBackground = true; FileThreadPramObj o = new FileThreadPramObj(); o.guId = guId; o.myThread = myThread; myThread.Start(o); } return true; } return false; } else { msg = "无法连接服务端"; FileSize = 0; return false; } }
public void Add(DownLoadFileDataObj item) { PCClientDownLoadFileBlocksBag.Add(item); Interlocked.Increment(ref queueLength); lock (mylock3) { if (item.Order_Num == 1) { ParameterizedThreadStart ParStart = new ParameterizedThreadStart(ThreadWriteFileMethod); Thread myThread = new Thread(ParStart); myThread.IsBackground = true; FileThreadPramObj o = new FileThreadPramObj(); o.guId = item.guId; o.myThread = myThread; myThread.Start(o); } } }
public void Add(TransferFileDataObj item) { //ServerFilesBlocksQueue.Enqueue(item); ServerFilesBlocksBag.Add(item); Interlocked.Increment(ref queueLength); //if (RunFlag) //{ // ThreadPool.QueueUserWorkItem(new WaitCallback(NewThreadFunc)); //} lock (lockerRunFlag) { if (item.Order_Num == 1) { ParameterizedThreadStart ParStart = new ParameterizedThreadStart(ThreadMethod); Thread myThread = new Thread(ParStart); myThread.IsBackground = true; FileThreadPramObj o = new FileThreadPramObj(); o.guId=item.guId; o.myThread = myThread; myThread.Start(o); } } //if (RunFlag) //{ // writeFileThread = new Thread(new ThreadStart(NewThreadFunc)); // writeFileThread.IsBackground = true; // writeFileThread.Start(); //} }
public bool DownLoadFile(string path, string fileName, string guId, string UserID, string PCClientCookieStr, out string msg, out long FileSize) { if (!SessionCookie.CheckPCClientCookieStr(UserID, PCClientCookieStr)) { msg = "Session Error"; FileSize = 0; return false; } bool result = false; try { string fileFullPath = Path.Combine(FilesBlocksQueue.Instance.SavePath + path, fileName);//合并路径生成文件存放路径 if (!File.Exists(fileFullPath)) { msg = "File not find"; FileSize = 0; return result; } FileInfo fileInfo = new FileInfo(fileFullPath); FileSize = fileInfo.Length; DownLoadFileOoj_Server fileObj = new DownLoadFileOoj_Server(); fileObj.FileName = fileName; fileObj.serverDir = path; fileObj.FileSize = fileInfo.Length; fileObj.ReadSize = 0; fileObj.SendSize = 0; fileObj.ReadStatus = GetFileReadStatus.StartRead; fileObj.SendStatus = GetFileSendStatus.waiting; fileObj.guId = guId; DownLoadFilesQueue.Instance.Add(guId, fileObj); msg = "File have find, reading..."; lock (mylock0) { ParameterizedThreadStart ParStart = new ParameterizedThreadStart(ThreadMethod); Thread myThread = new Thread(ParStart); myThread.IsBackground = true; FileThreadPramObj o = new FileThreadPramObj(); o.guId = guId; o.myThread = myThread; myThread.Start(o); result = true; } //Action<Stream, string, string, string> readFile = SafeReadFile; //readFile.BeginInvoke(fs, guId, fileName, path, null, null); //result = true; } catch (Exception ex) { msg = "error"; result = false; throw ex; } return result; }