private void BackSiteThread(int threadid) { string name = this.SiteObj.SiteBaseInfo.NAME; foreach (TaskFileInfo filePair in this.file[threadid]) { if (filePair != null && !this.hasError) { if (UploadTrace.IsTaskCancel(this.block)) { this.hasError = true; break; } else { try { string fileName = filePair.FileName; byte[] backFileBytes = this.GetBackFileBytes(this.SiteObj.SiteBaseInfo.SERVLIST[0], filePair, this.SiteObj.SiteBaseInfo.LOCALBAKTRANSFOLDER, this.SiteObj.SiteBaseInfo.NAME); if (backFileBytes != null) { foreach (WebSiteServer ServObj in this.SiteObj.SiteBaseInfo.SERVLIST) { if (UploadTrace.IsTaskCancel(this.block)) { this.hasError = true; return; } else if (this.BackupServ(ServObj, backFileBytes, name, filePair, this._BackupBlock, new FtpAtomOperation(this.dbLog))) { this.LogRollBack(ServObj, filePair, name, this._BackupBlock, "COVER"); this.dbLog.Trace("[备份]单个服务器", name, "[成功]___服务器名:" + ServObj.NAME + ",文件名:" + fileName); } else { UploadTrace.FileBackupFail(filePair, this.block, ServObj.NAME); UploadTrace.AddLog(filePair, this.block, "文件备份:" + filePair.FileName + "到:" + ServObj.NAME + "出错."); this.dbLog.Trace("[备份]单个服务器", name, "[失败]___服务器名:" + ServObj.NAME + ",文件名:" + fileName); this.hasError = true; } } } } catch (Exception ex) { UploadTrace.AddLog(filePair, this.block, "文件备份:" + filePair.FileName + "出错.出错原因:" + ex.Message + ex.StackTrace); UploadTrace.FileUploadFail(filePair, this.block, ""); this.hasError = true; break; } UploadTrace.FileBackupSuccess(filePair, this.block); ++this.successnum; } } } }
/// <summary> /// 任务控制:线程上传 /// </summary> /// <param name="threadid"></param> private void UploadSiteThread(int threadid) { foreach (TaskFileInfo filePair in this.file[threadid]) { if (filePair != null && !this.hasError) { if (UploadTrace.IsTaskCancel(this.block)) { this.hasError = true; break; } else { try { FileStream fileStream = File.Open(filePair.SrcFile, FileMode.Open, FileAccess.Read, FileShare.Read); byte[] numArray = new byte[fileStream.Length]; fileStream.Read(numArray, 0, numArray.Length); fileStream.Close(); fileStream.Dispose(); string name = this.SiteObj.SiteBaseInfo.NAME; foreach (WebSiteServer ServObj in this.SiteObj.SiteBaseInfo.SERVLIST) { if (UploadTrace.IsTaskCancel(this.block)) { this.hasError = true; return; } else if (!this.UploadServ(ServObj, numArray, name, filePair, new FtpAtomOperation(this.dbLog))) { this.hasError = true; return; } } } catch (Exception ex) { UploadTrace.AddLog(filePair, this.block, "文件上传:" + filePair.FileName + "出错.出错原因:" + ex.Message); UploadTrace.FileUploadFail(filePair, this.block, ""); this.hasError = true; break; } UploadTrace.FileUploadSuccess(filePair, this.block); ++this.successnum; } } } }