private void CoverSiteThread(WebSiteServer ServObj) { string name = this.SiteObj.SiteBaseInfo.NAME; int count = this.SiteObj.SiteBaseInfo.SERVLIST.Count; foreach (TaskFileInfo filePair in this.SiteObj.FilePairList) { if (!this.hasError) { if (this.CoverServ(ServObj, filePair, name, new FtpAtomOperation(this.dbLog))) { this.dbLog.Trace("[覆盖]单个服务器", name, "[成功]___服务器名:" + ServObj.NAME + "文件路径:" + filePair.AimFile); UploadTrace.AddLog(filePair, this.block, "覆盖文件:" + filePair.FileName + "到:" + ServObj.NAME + "成功."); ++this.successnum; UploadTrace.FileCoverSuccess(filePair, this.block, ""); } else { UploadTrace.FileCoverFail(filePair, this.block, ServObj.NAME, ""); this._coverErrorFile = filePair; this._coverErrorServer = ServObj; UploadTrace.AddLog(filePair, this.block, "覆盖文件:" + filePair.FileName + "到:" + ServObj.NAME + "出错.准备回滚"); this.dbLog.Trace("[覆盖]单个服务器", name, "[失败]___服务器名:" + ServObj.NAME + "文件路径:" + filePair.AimFile); this.hasError = true; break; } } } }
private void AutoRollBackSuccess(WebSiteServer ServObj, TaskFileInfo FileObj, string SiteName, string MarkBlock, string RollOp, string block) { string str1 = FileObj.RelAimFolder + "/" + FileObj.FileName; string str2 = "/" + ServObj.BAKFOLDER + "/" + MarkBlock + str1; this.dbLog.RollBakAutoSuccess(MarkBlock, ServObj.IP.ToString(), ServObj.PORT, str2, str1, SiteName, RollOp, this.block); }
private bool CoverServ(WebSiteServer ServObj, TaskFileInfo FileObj, string SiteName, FtpAtomOperation ftpCmdV3) { string SrcUriStr = this.PreCoverSrcFile(ServObj, FileObj); string AimUriStr = this.PreCoverAimFile(ServObj, FileObj); if (ftpCmdV3.CreateFtpListDirectory(ServObj.BaseUri, "/" + ServObj.DIRPATH + FileObj.RelAimFolder, ServObj.USER, ServObj.PASS)) { this.dbLog.Trace("[级联检查/创建]覆盖目标目录", SiteName, "[成功]___服务器名:" + ServObj.NAME + ",路径:" + FileObj.RelAimFolder); if (ftpCmdV3.RenameFtpFile(ServObj.BaseUri, SrcUriStr, AimUriStr, ServObj.USER, ServObj.PASS)) { this.dbLog.Trace("[文件移动]单个服务器", SiteName, "[成功]___服务器名:" + ServObj.NAME + ",文件源位置:" + SrcUriStr + ",文件目标位置:" + AimUriStr); return(true); } else { this.dbLog.Trace("[文件移动]单个服务器", SiteName, "[失败]___服务器名:" + ServObj.NAME + ",文件源位置:" + SrcUriStr + ",文件目标位置:" + AimUriStr); return(false); } } else { this.dbLog.Trace("[级联检查/创建]覆盖目标目录", SiteName, "[失败]___服务器名:" + ServObj.NAME + ",路径:" + FileObj.RelAimFolder); return(false); } }
/// <summary> /// 任务控制:覆盖 /// </summary> /// <returns></returns> private bool CoverSite() { if (!this.multiCover) { string name = this.SiteObj.SiteBaseInfo.NAME; int count = this.SiteObj.SiteBaseInfo.SERVLIST.Count; int num = 0; foreach (WebSiteServer ServObj in this.SiteObj.SiteBaseInfo.SERVLIST) { string coverStatus = num.ToString() + (object)"/" + (string)(object)count; foreach (TaskFileInfo filePair in this.SiteObj.FilePairList) { if (this.CoverServ(ServObj, filePair, name, new FtpAtomOperation(this.dbLog))) { this.dbLog.Trace("[覆盖]单个服务器", name, "[成功]___服务器名:" + ServObj.NAME + "文件路径:" + filePair.AimFile); UploadTrace.FileCoverSuccess(filePair, this.block, coverStatus); } else { UploadTrace.FileCoverFail(filePair, this.block, ServObj.NAME, coverStatus); this._coverErrorFile = filePair; this._coverErrorServer = ServObj; UploadTrace.AddLog(filePair, this.block, "覆盖文件:" + filePair.FileName + "到:" + ServObj.NAME + "出错.准备回滚"); this.dbLog.Trace("[覆盖]单个服务器", name, "[失败]___服务器名:" + ServObj.NAME + "文件路径:" + filePair.AimFile); return(false); } } ++num; } return(true); } else { this.successnum = 0; if (UploadTrace.IsTaskCancel(this.block)) { return(false); } try { foreach (WebSiteServer serv in this.SiteObj.SiteBaseInfo.SERVLIST) { TaskWorker.doCover doCover = new TaskWorker.doCover(this.CoverSiteThread); doCover.BeginInvoke(serv, new AsyncCallback(this.doCoverCallBack), (object)doCover); } } catch { return(false); } while (!this.hasError && this.successnum != this.SiteObj.FilePairList.Count * this.SiteObj.SiteBaseInfo.SERVLIST.Count) { Thread.Sleep(100); } return(!this.hasError); } }
/// <summary> /// 生成上传文件路径 /// </summary> /// <param name="ServObj"></param> /// <param name="FileObj"></param> /// <returns></returns> private string PreUpAimFile(WebSiteServer ServObj, TaskFileInfo FileObj) { if (!string.IsNullOrEmpty(ServObj.DIRPATH)) { return(ServObj.DIRPATH + "/" + ServObj.TRANSFOLDER + "/" + this.block + FileObj.AimFile.Replace("../", "/")); } else { return(ServObj.TRANSFOLDER + "/" + this.block + FileObj.AimFile.Replace("../", "/")); } }
/// <summary> /// 生成备份文件目录 /// </summary> /// <param name="ServObj"></param> /// <param name="FileObj"></param> /// <param name="BackBlock"></param> /// <returns></returns> private string PreBakAimFolder(WebSiteServer ServObj, TaskFileInfo FileObj, string BackBlock) { if (!string.IsNullOrEmpty(ServObj.DIRPATH)) { return(ServObj.DIRPATH + "/" + ServObj.BAKFOLDER + "/" + BackBlock + FileObj.RelAimFolder); } else { return(ServObj.BAKFOLDER + "/" + BackBlock + FileObj.RelAimFolder); } }
/// <summary> /// 生成备份文件路径 /// </summary> /// <param name="ServObj"></param> /// <param name="FileObj"></param> /// <param name="BackBlock"></param> /// <returns></returns> private string PreBakAimFile(WebSiteServer ServObj, TaskFileInfo FileObj, string BackBlock) { if (!string.IsNullOrEmpty(ServObj.DIRPATH)) { return(ServObj.DIRPATH + "/" + ServObj.BAKFOLDER + "/" + BackBlock + FileObj.AimFile.Replace("../", "/")); } else { return(ServObj.BAKFOLDER + "/" + BackBlock + FileObj.AimFile.Replace("../", "/")); } }
/// <summary> /// 生成覆盖操作目标文件路径 /// </summary> /// <param name="ServObj"></param> /// <param name="FileObj"></param> /// <returns></returns> private string PreCoverAimFile(WebSiteServer ServObj, TaskFileInfo FileObj) { if (!string.IsNullOrEmpty(ServObj.DIRPATH)) { return("/" + ServObj.DIRPATH + (string.IsNullOrEmpty(FileObj.RelAimFolder) ? "" : FileObj.RelAimFolder) + "/" + FileObj.FileName); } else { return((string.IsNullOrEmpty(FileObj.RelAimFolder) ? "" : FileObj.RelAimFolder) + "/" + FileObj.FileName); } }
/// <summary> /// 生成上传目录 /// </summary> /// <param name="ServObj"></param> /// <param name="FileObj"></param> /// <returns></returns> private string PreUpAimFolder(WebSiteServer ServObj, TaskFileInfo FileObj) { if (!string.IsNullOrEmpty(ServObj.DIRPATH)) { return(ServObj.DIRPATH + "/" + ServObj.TRANSFOLDER + "/" + this.block + FileObj.RelAimFolder); } else { return(ServObj.TRANSFOLDER + "/" + this.block + FileObj.RelAimFolder); } }
private TaskFileInfo[] GetTaskFiles(FileBasedProject createdProject, Language targetLanguage) { List <TaskFileInfo> files = new List <TaskFileInfo>(); foreach (var item in createdProject.GetTargetLanguageFiles(targetLanguage)) { TaskFileInfo fileInfo = new TaskFileInfo(); fileInfo.ProjectFileId = item.Id; fileInfo.ReadOnly = false; files.Add(fileInfo); } return(files.ToArray()); }
/// <summary> /// 记录任务单文件备份成功 /// </summary> /// <param name="file"></param> /// <param name="block"></param> public static void FileBackupSuccess(TaskFileInfo file, string block) { // string cmdText = "update BlockTaskList set Status=2 where Block=@block and FilePath=@filepath "; // using (SqlConnection connection = new SqlConnection(UploadTrace.ConnString)) // { // connection.Open(); // new SqlCommand(cmdText, connection) // { // Parameters = { // new SqlParameter("@block", (object) block), // new SqlParameter("@filepath", (object) file.AimFile) //} // }.ExecuteNonQuery(); // connection.Close(); // } Trans.Db.Data.NBlock_Task.Update("BlockCode=@block and FilePath=@filepath", "Status=@Status", new object[] { block, file.AimFile, 2 }); }
/// <summary> /// 更新任务文件日志 /// </summary> /// <param name="file"></param> /// <param name="block"></param> /// <param name="log"></param> public static void AddLog(TaskFileInfo file, string block, string log) { // string cmdText = "update BlockTaskList set UploadLog=UploadLog+'\r\n" + log.Replace("'", "''") + "' where Block=@block and FilePath=@filepath"; // using (SqlConnection connection = new SqlConnection(UploadTrace.ConnString)) // { // connection.Open(); // new SqlCommand(cmdText, connection) // { // Parameters = { // new SqlParameter("@block", (object) block), // new SqlParameter("@filepath", (object) file.AimFile) //} // }.ExecuteNonQuery(); // connection.Close(); // } Trans.Db.Data.NBlock_Task.Update("BlockCode=@BlockCode and FilePath=@filepath", "UploadLog=UploadLog+@UploadLog", new object[] { block, file.AimFile, "\r\n" + log.Replace("'", "''") }); }
private byte[] GetBackFileBytes(WebSiteServer ServObj, TaskFileInfo FileObj, string LocalTransFolder, string SiteName) { bool flag = false; string ServRelFilePath = "/" + ServObj.DIRPATH + FileObj.AimFile.Replace("../", "/"); if (this.ftpcmd.GetFtpFileSize(ServObj.BaseUri, ServRelFilePath, ServObj.USER, ServObj.PASS) != -1) { flag = true; } if (!flag) { return((byte[])null); } if (!Directory.Exists(LocalTransFolder)) { this.CreateLocalListDir(LocalTransFolder); } if (!Directory.Exists(LocalTransFolder + "/" + this.block)) { this.CreateLocalListDir(LocalTransFolder + "/" + this.block); } if (!Directory.Exists(LocalTransFolder + "/" + this.block + FileObj.RelAimFolder)) { this.CreateLocalListDir(LocalTransFolder + "/" + this.block + FileObj.RelAimFolder); } //备份转存本地临时文件路径 string str = LocalTransFolder + "/" + this.block + FileObj.RelAimFolder + "/" + FileObj.FileName; if (this.ftpcmd.DownLoadFtpFile(ServObj.BaseUri, ServRelFilePath, str, ServObj.USER, ServObj.PASS)) { FileStream fileStream = File.Open(str, FileMode.Open, FileAccess.Read, FileShare.Read); byte[] buffer = new byte[fileStream.Length]; fileStream.Read(buffer, 0, buffer.Length); fileStream.Close(); fileStream.Dispose(); this.dbLog.Trace("[备份下载]下载文件", SiteName, "[成功]___服务器名:" + ServObj.NAME + ",文件名:" + ServRelFilePath); return(buffer); } else { this.dbLog.Trace("[备份下载]下载文件", SiteName, "[失败]___服务器名:" + ServObj.NAME + ",文件名:" + ServRelFilePath); return((byte[])null); } }
/// <summary> /// 记录任务单文件回滚失败 /// </summary> /// <param name="file"></param> /// <param name="block"></param> /// <param name="errorServer"></param> /// <param name="coverStatus"></param> public static void FileRollBackFail(TaskFileInfo file, string block, string errorServer, string coverStatus) { // string cmdText = "update BlockTaskList set Status=-4 ,coverStatus=@coverStatus,ErrorServer=@ErrorServer where Block=@block and FilePath=@filepath"; // using (SqlConnection connection = new SqlConnection(UploadTrace.ConnString)) // { // connection.Open(); // new SqlCommand(cmdText, connection) // { // Parameters = { // new SqlParameter("@coverStatus", (object) coverStatus), // new SqlParameter("@ErrorServer", (object) errorServer), // new SqlParameter("@block", (object) block), // new SqlParameter("@filepath", (object) file.AimFile) //} // }.ExecuteNonQuery(); // connection.Close(); // } Trans.Db.Data.NBlock_Info.Update("BlockCode=@block and FilePath=@filepath", "Status=@Status,coverStatus=@coverStatus,ErrorServer=@ErrorServer", new object[] { block, file.AimFile, -1, coverStatus, errorServer }); }
private bool RollbackServ(WebSiteServer ServObj, TaskFileInfo FileObj, string SiteName, string block, string serverstatus) { string SrcUriStr = ""; //如果_BackupBlock不为空,则为同步任务失败的回滚,否则为延后回滚 if (!string.IsNullOrEmpty(this._BackupBlock)) { SrcUriStr = this.PreBakAimFile(ServObj, FileObj, this._BackupBlock).Replace("//", "/"); } else { SrcUriStr = this.PreBakAimFile(ServObj, FileObj, this.block).Replace("//", "/"); } string AimUriStr = this.PreCoverAimFile(ServObj, FileObj); try { this.dbLog.Trace("[级联检查/回滚]覆盖目标目录", SiteName, "[成功]___服务器名:" + ServObj.NAME + ",路径:" + FileObj.RelAimFolder); if (this.ftpcmd.RenameFtpFile(ServObj.BaseUri, SrcUriStr, AimUriStr, ServObj.USER, ServObj.PASS)) { UploadTrace.FileRollBackSuccess(FileObj, block, serverstatus); this.AutoRollBackSuccess(ServObj, FileObj, SiteName, this._BackupBlock, "COVER", block); this.dbLog.Trace("[文件回滚]单个服务器", SiteName, "[成功]___服务器名:" + ServObj.NAME + ",文件源位置:" + SrcUriStr + ",文件目标位置:" + AimUriStr); return(true); } else { UploadTrace.FileRollBackFail(FileObj, block, ServObj.NAME, serverstatus); UploadTrace.AddLog(FileObj, block, "文件回滚:" + FileObj.FileName + "到:" + ServObj.NAME + "出错."); this.dbLog.Trace("[文件回滚]单个服务器", SiteName, "[失败]___服务器名:" + ServObj.NAME + ",文件源位置:" + SrcUriStr + ",文件目标位置:" + AimUriStr); this._coverErrorServer = ServObj; this._coverErrorFile = FileObj; return(false); } } catch { UploadTrace.FileRollBackFail(FileObj, block, ServObj.NAME, serverstatus); UploadTrace.AddLog(FileObj, block, "文件回滚:" + FileObj.FileName + "到:" + ServObj.NAME + "出错."); this.dbLog.Trace("[文件回滚]单个服务器", SiteName, "[失败]___服务器名:" + ServObj.NAME + ",文件源位置:" + SrcUriStr + ",文件目标位置:" + AimUriStr); return(false); } }
public static List <TaskFileInfo> GetFileTasks(LearningActivity act) { List <TaskFileInfo> toRet = new List <TaskFileInfo>(); if (act.LearningTasks == null) { return(toRet); } foreach (LearningTask t in act.LearningTasks) { try { TaskFileInfo parentInfo = GetInfoForTask(t); if (parentInfo != null) { toRet.Add(parentInfo); } foreach (LearningTask child in t.ChildTasks) { TaskFileInfo childInfo = GetInfoForTask(child); if (childInfo != null) { toRet.Add(childInfo); } } } catch (Exception e) { Console.WriteLine(e.Message); } } return(toRet); }
public void ImportTaskObjects(ImportSettings importSettings) { DateTime lastProgressNotice = DateTime.Now; int incomplete = 0; var agentSyncFolderHolder = Exporting.FolderCalled("TaskInvHolder"); int created = 0; var tos = LocalScene.TaskObjects; foreach (var file in Directory.GetFiles(ExportCommand.dumpDir, "*.taskobj")) { string[] c = File.ReadAllText(file).Split(','); TaskFileInfo to = new TaskFileInfo() { OldLid = uint.Parse(c[0]), RezzedID = UUID.Parse(c[2]), OldTaskHolder = UUID.Parse(c[3]), AssetUUID = UUID.Parse(c[4]), TaskItemID = UUID.Parse(c[5]) }; tos.Add(to); created++; } foreach (TaskFileInfo o in tos) { var r = o.Rezzed; if (r != null) r.SetIsAsset(); } foreach (TaskFileInfo o in tos) { PrimToCreate oInsideOf = o.InsideOf; if (oInsideOf == null) continue; List<InventoryBase> taskInv = oInsideOf.SourceTaskInventory(true); if (taskInv == null) continue; foreach (var b in taskInv) { InventoryItem i = b as InventoryItem; if (i == null) continue; if (CogbotHelpers.IsNullOrZero(i.AssetUUID)) { if (i.UUID == o.TaskItemID) { i.RezzID = o.RezzedID; o.IsPlaced = true; break; } } } } foreach (TaskFileInfo o in tos) { if (!o.IsPlaced) { Failure("UNPLACED: " + o); } } // this makes sure we know that late found childs are assets foreach (PrimToCreate parent in LockInfo.CopyOf(parents)) { if (parent.IsAsset) parent.SetIsAsset(); } }
/// <summary> /// 同步 /// </summary> public void Execute() { try { //记录开始日志 this.dbLog.Trace("站点同步", this.SiteObj.SiteBaseInfo.NAME, "开始同步"); #region 务器检查 Msg msg = this.CheckServs(this.SiteObj); if (!msg.MsgResult) { this.dbLog.Trace("检查服务器状态", this.SiteObj.SiteBaseInfo.NAME, "服务器网络连接出现问题:" + msg.MsgContent + "有服务器出现网络连接错误,请立即通知技术人员维护"); UploadTrace.TaskFailed(this.block); return; } else { this.dbLog.Trace("检查服务器状态", this.SiteObj.SiteBaseInfo.NAME, "一切正常"); } #endregion #region 判定是否用户取消任务 if (UploadTrace.IsTaskCancel(this.block)) { this.dbLog.Trace("上传站点", this.SiteObj.SiteBaseInfo.NAME, "失败,用户取消"); return; } #endregion #region 照线程分割文件列表到线程任务中 this.file = new TaskFileInfo[this.threadNumber][]; for (int index = 0; index < this.threadNumber; ++index) { this.file[index] = new TaskFileInfo[this.SiteObj.FilePairList.Count / this.threadNumber + 1]; } for (int index = 0; index < this.SiteObj.FilePairList.Count; ++index) { TaskFileInfo filePair = this.SiteObj.FilePairList[index]; this.file[index / (this.SiteObj.FilePairList.Count / this.threadNumber + 1)][index % (this.SiteObj.FilePairList.Count / this.threadNumber + 1)] = filePair; } #endregion #region 步骤一:上传文件到所有任务服务器 if (!this.UploadSite()) { this.dbLog.Trace("上传站点", this.SiteObj.SiteBaseInfo.NAME, "失败,任务终止"); UploadTrace.TaskFailed(this.block); return; } else { this.dbLog.Trace("上传站点", this.SiteObj.SiteBaseInfo.NAME, "成功"); } #endregion #region 判定是否用户取消任务 if (UploadTrace.IsTaskCancel(this.block)) { this.dbLog.Trace("上传站点", this.SiteObj.SiteBaseInfo.NAME, "失败,用户取消"); return; } #endregion #region 步骤二:备份文件到所有任务服务器 if (!this.BackupSite()) { this.dbLog.Trace("备份站点", this.SiteObj.SiteBaseInfo.NAME, "失败,任务终止"); UploadTrace.TaskFailed(this.block); return; } else { this.dbLog.Trace("备份站点", this.SiteObj.SiteBaseInfo.NAME, "成功"); } UploadTrace.TaskBackuping(this.block); #endregion #region 判定用户是否取消任务 if (UploadTrace.IsTaskCancel(this.block)) { this.dbLog.Trace("上传站点", this.SiteObj.SiteBaseInfo.NAME, "失败,用户取消"); return; } #endregion #region 步骤三:覆盖文件到所有任务服务器 if (this.CoverSite()) { this.dbLog.Trace("覆盖站点", this.SiteObj.SiteBaseInfo.NAME, "成功"); this.dbLog.Trace("同步站点", this.SiteObj.SiteBaseInfo.NAME, "结束同步"); UploadTrace.TaskSuccess(this.block); return; } else { this.dbLog.Trace("覆盖站点", this.SiteObj.SiteBaseInfo.NAME, "失败,任务终止"); } UploadTrace.TaskCovering(this.block); #endregion #region 步骤四:回滚文件到所有任务服务器 if (this.RollBackSite()) { this.dbLog.Trace("覆盖回滚", this.SiteObj.SiteBaseInfo.NAME, "成功"); } else { this.dbLog.Trace("覆盖回滚", this.SiteObj.SiteBaseInfo.NAME, "失败,任务终止"); } UploadTrace.TaskFailed(this.block); #endregion } catch (Exception ex) { this.dbLog.Trace("上传站点", this.SiteObj.SiteBaseInfo.NAME, "失败,任务终止。错误信息:" + ex.Message + ex.StackTrace); UploadTrace.TaskFailed(this.block); } }
public override bool Equals(object obj) { TaskFileInfo tob = obj as TaskFileInfo; return(tob != null && tob.TaskItemID == TaskItemID); }
private void CheckTasks(ImportSettings settings) { foreach (PrimToCreate parent in LockInfo.CopyOf(parents)) { var ls = new Linkset() { Parent = parent }; parent.Link = ls; LocalScene.Links.Add(ls); } foreach (PrimToCreate ch in childs) { var pp = ch.ParentPrim; if (pp == null) { continue; } pp.Link.ChildAdd(ch); } foreach (var ls in LockInfo.CopyOf(LocalScene.Links)) { ls.Children.Sort(compareLocalIDs); if (ls.Parent.IsAsset) { LocalScene.AssetLinks.Add(ls); LocalScene.Links.Remove(ls); } } int found = 0; Dictionary <UUID, TaskFileInfo> item2TO = new Dictionary <UUID, TaskFileInfo>(); List <TaskFileInfo> mssingTO = new List <TaskFileInfo>(); List <TaskFileInfo> duped = new List <TaskFileInfo>(); foreach (var file in Directory.GetFiles(ExportCommand.dumpDir, "*.objectAsset")) { break; found++; string fileString = File.ReadAllText(file); string[] c = fileString.Split(','); try { TaskFileInfo to = new TaskFileInfo() { OldLid = uint.Parse(c[0]), RezzedID = UUID.Parse(c[2]), OldTaskHolder = UUID.Parse(c[3]), AssetUUID = UUID.Parse(c[4]), TaskItemID = UUID.Parse(c[5]) }; bool missing = false; if (MissingLLSD(to.RezzedID)) { Failure("Need LLSD: " + fileString); to.missingLLSD = true; mssingTO.Add(to); } TaskFileInfo old; if (item2TO.TryGetValue(to.TaskItemID, out old)) { if (old.missingLLSD) { item2TO[to.TaskItemID] = to; duped.Add(old); } else { duped.Add(to); } } else { if (to.missingLLSD) { continue; } item2TO[to.TaskItemID] = to; } } catch (Exception ee) { Failure("fileIssue: " + file + " = " + fileString); } } Success("t=" + found + " m=" + mssingTO.Count + " td=" + item2TO.Count + " duped=" + duped.Count); }
/// <summary> /// 记录任务单文件备份成功 /// </summary> /// <param name="file"></param> /// <param name="block"></param> public static void FileBackupSuccess(TaskFileInfo file, string block) { Trans.Db.Data.NBlock_Task.Update("BlockCode=@block and FilePath=@filepath", "Status=@Status", new object[] { block, file.AimFile, 2 }); }
public void ImportTaskObjects(ImportSettings importSettings) { DateTime lastProgressNotice = DateTime.Now; int incomplete = 0; var agentSyncFolderHolder = Exporting.FolderCalled("TaskInvHolder"); int created = 0; var tos = LocalScene.TaskObjects; foreach (var file in Directory.GetFiles(ExportCommand.dumpDir, "*.taskobj")) { string[] c = File.ReadAllText(file).Split(','); TaskFileInfo to = new TaskFileInfo() { OldLid = uint.Parse(c[0]), RezzedID = UUID.Parse(c[2]), OldTaskHolder = UUID.Parse(c[3]), AssetUUID = UUID.Parse(c[4]), TaskItemID = UUID.Parse(c[5]) }; tos.Add(to); created++; } foreach (TaskFileInfo o in tos) { var r = o.Rezzed; if (r != null) { r.SetIsAsset(); } } foreach (TaskFileInfo o in tos) { PrimToCreate oInsideOf = o.InsideOf; if (oInsideOf == null) { continue; } List <InventoryBase> taskInv = oInsideOf.SourceTaskInventory(true); if (taskInv == null) { continue; } foreach (var b in taskInv) { InventoryItem i = b as InventoryItem; if (i == null) { continue; } if (CogbotHelpers.IsNullOrZero(i.AssetUUID)) { if (i.UUID == o.TaskItemID) { i.RezzID = o.RezzedID; o.IsPlaced = true; break; } } } } foreach (TaskFileInfo o in tos) { if (!o.IsPlaced) { Failure("UNPLACED: " + o); } } // this makes sure we know that late found childs are assets foreach (PrimToCreate parent in LockInfo.CopyOf(parents)) { if (parent.IsAsset) { parent.SetIsAsset(); } } }
/// <summary> /// 记录任务单文件回滚成功 /// </summary> /// <param name="file"></param> /// <param name="block"></param> /// <param name="coverStatus"></param> public static void FileRollBackSuccess(TaskFileInfo file, string block, string coverStatus) { Trans.Db.Data.NBlock_Info.Update("BlockCode=@block and FilePath=@filepath", "Status=@Status,coverStatus=@coverStatus", new object[] { block, file.AimFile, 4, coverStatus }); }
/// <summary> /// 记录任务单文件回滚失败 /// </summary> /// <param name="file"></param> /// <param name="block"></param> /// <param name="errorServer"></param> /// <param name="coverStatus"></param> public static void FileRollBackFail(TaskFileInfo file, string block, string errorServer, string coverStatus) { Trans.Db.Data.NBlock_Info.Update("BlockCode=@block and FilePath=@filepath", "Status=@Status,coverStatus=@coverStatus,ErrorServer=@ErrorServer", new object[] { block, file.AimFile, -1, coverStatus, errorServer }); }
/// <summary> /// 更新任务文件日志 /// </summary> /// <param name="file"></param> /// <param name="block"></param> /// <param name="log"></param> public static void AddLog(TaskFileInfo file, string block, string log) { Trans.Db.Data.NBlock_Task.Update("BlockCode=@BlockCode and FilePath=@filepath", "UploadLog=UploadLog+@UploadLog", new object[] { block, file.AimFile, "\r\n" + log.Replace("'", "''") }); }
/// <summary> /// 记录任务单文件上传失败 /// </summary> /// <param name="file"></param> /// <param name="block"></param> /// <param name="errorServer"></param> public static void FileUploadFail(TaskFileInfo file, string block, string errorServer) { Trans.Db.Data.NBlock_Task.Update("BlockCode=@BlockCode and FilePath=@filepath", "Status=@Status,ErrorServer=@ErrorServer", new object[] { block, file.AimFile, -1, errorServer }); }
private bool BackupServ(WebSiteServer ServObj, byte[] FileBytes, string SiteName, TaskFileInfo FileObj, string BackupBlock, FtpAtomOperation ftpCmdV3) { string AimUriStr1 = this.PreBakAimFolder(ServObj, FileObj, BackupBlock); if (ftpCmdV3.CreateFtpListDirectory(ServObj.BaseUri, AimUriStr1, ServObj.USER, ServObj.PASS)) { this.dbLog.Trace("[创建备份目录]", SiteName, "[成功]___服务器名:" + ServObj.NAME + ",路径:" + AimUriStr1); string AimUriStr2 = this.PreBakAimFile(ServObj, FileObj, BackupBlock); if (ftpCmdV3.UploadFtpFile(ServObj.BaseUri, AimUriStr2, ServObj.USER, ServObj.PASS, FileBytes)) { this.dbLog.Trace("[上传备份文件]单个服务器", SiteName, "[成功]___服务器名:" + ServObj.NAME + ",备份路径:" + AimUriStr2); return(true); } else { this.dbLog.Trace("[上传备份文件]单个服务器", SiteName, "[失败]___服务器名:" + ServObj.NAME + ",备份路径:" + AimUriStr2); return(false); } } else { this.dbLog.Trace("[创建备份目录]", SiteName, "[失败]___服务器名:" + ServObj.NAME + ",路径:" + AimUriStr1); return(false); } }
private void CheckTasks(ImportSettings settings) { foreach (PrimToCreate parent in LockInfo.CopyOf(parents)) { var ls = new Linkset() { Parent = parent }; parent.Link = ls; LocalScene.Links.Add(ls); } foreach (PrimToCreate ch in childs) { var pp = ch.ParentPrim; if (pp == null) { continue; } pp.Link.ChildAdd(ch); } foreach (var ls in LockInfo.CopyOf(LocalScene.Links)) { ls.Children.Sort(compareLocalIDs); if (ls.Parent.IsAsset) { LocalScene.AssetLinks.Add(ls); LocalScene.Links.Remove(ls); } } int found = 0; Dictionary<UUID, TaskFileInfo> item2TO = new Dictionary<UUID, TaskFileInfo>(); List<TaskFileInfo> mssingTO = new List<TaskFileInfo>(); List<TaskFileInfo> duped = new List<TaskFileInfo>(); foreach (var file in Directory.GetFiles(ExportCommand.dumpDir, "*.objectAsset")) { break; found++; string fileString = File.ReadAllText(file); string[] c = fileString.Split(','); try { TaskFileInfo to = new TaskFileInfo() { OldLid = uint.Parse(c[0]), RezzedID = UUID.Parse(c[2]), OldTaskHolder = UUID.Parse(c[3]), AssetUUID = UUID.Parse(c[4]), TaskItemID = UUID.Parse(c[5]) }; bool missing = false; if (MissingLLSD(to.RezzedID)) { Failure("Need LLSD: " + fileString); to.missingLLSD = true; mssingTO.Add(to); } TaskFileInfo old; if (item2TO.TryGetValue(to.TaskItemID, out old)) { if (old.missingLLSD) { item2TO[to.TaskItemID] = to; duped.Add(old); } else { duped.Add(to); } } else { if (to.missingLLSD) { continue; } item2TO[to.TaskItemID] = to; } } catch (Exception ee) { Failure("fileIssue: " + file + " = " + fileString); } } Success("t=" + found + " m=" + mssingTO.Count + " td=" + item2TO.Count + " duped=" + duped.Count); }
/// <summary> /// 上传文件到单个服务器 /// </summary> /// <param name="ServObj"></param> /// <param name="FileBytes"></param> /// <param name="SiteName"></param> /// <param name="FileObj"></param> /// <param name="ftpcmdv3"></param> /// <returns></returns> private bool UploadServ(WebSiteServer ServObj, byte[] FileBytes, string SiteName, TaskFileInfo FileObj, FtpAtomOperation ftpcmdv3) { string AimUriStr1 = this.PreUpAimFolder(ServObj, FileObj); string AimUriStr2 = this.PreUpAimFile(ServObj, FileObj); if (!ftpcmdv3.CreateFtpListDirectory(ServObj.BaseUri, AimUriStr1, ServObj.USER, ServObj.PASS)) { this.dbLog.Trace("[级联创建]单个服务器", SiteName, "[失败]___服务器名:" + ServObj.NAME + ",路径:" + AimUriStr1); return(false); } else { try { this.dbLog.Trace("[级联创建]单个服务器", SiteName, "[成功]___服务器名:" + ServObj.NAME + ",路径:" + AimUriStr1); if (!ftpcmdv3.UploadFtpFile(ServObj.BaseUri, AimUriStr2, ServObj.USER, ServObj.PASS, FileBytes)) { this.dbLog.Trace("[上传文件]单个服务器", SiteName, "[失败]___服务器名:" + ServObj.NAME + ",路径:" + AimUriStr2); return(false); } else { this.dbLog.Trace("[上传文件]单个服务器", SiteName, "[成功]___服务器名:" + ServObj.NAME + ",路径:" + AimUriStr2); return(true); } } catch (Exception ex) { this.dbLog.Trace("[上传文件]单个服务器", SiteName, "[失败]___服务器名:" + ServObj.NAME + ",路径:" + AimUriStr2 + ",错误信息:" + ex.Message); return(false); } } }