//通过路径获取最新的记录节点 internal static RecordBean GetLastBean(string path) { DirIndexBean dirIndex = DirIndexMapper.GetOneByPath(path); if (dirIndex == null) { return(null); } RecordBean bean = RecordMapper.GetOneById(dirIndex.TargectId, dirIndex.IncidentId); if (bean == null) { return(null); } //告知该bean是属于哪一个事件的 bean.IncidentId = dirIndex.IncidentId; return(bean); }
/// <summary> /// 通过节点获取文件夹的比较信息 /// </summary> public static ComparisonInfo GetInfoByNode(DirNode node) { //获取bean RecordBean oldBean = null; if (node.OldId != 0) { oldBean = RecordMapper.GetOneById(node.OldId, node.OldIncidentId); } RecordBean newBean = null; if (node.NewId != 0) { newBean = RecordMapper.GetOneById(node.NewId, node.NewIncidentId); } //设置标签 ComparisonInfo info = new ComparisonInfo() { TagName = string.Concat("标签:", node.Tag.Name ?? "没有标签") }; //设置主要比较的数据 BigInteger oldSize, newSize, oldUsage, newUsage; if (oldBean != null) { info.Title = oldBean.Name; info.Location = oldBean.Location; info.CreateTime = "创建时间:" + oldBean.CerateTime.ToString("yy-MM-dd HH:mm:ss"); info.OldFileCount = Convert.ToInt32(oldBean.FileCount); info.OldDirCount = Convert.ToInt32(oldBean.DirCount); oldSize = oldBean.Size; oldUsage = oldBean.SpaceUsage; } else { oldSize = BigInteger.Zero; oldUsage = BigInteger.Zero; } if (newBean != null) { info.Title = newBean.Name; info.Location = newBean.Location; info.CreateTime = "创建时间:" + newBean.CerateTime.ToString("yy-MM-dd HH:mm:ss"); info.NewFileCount = Convert.ToInt32(newBean.FileCount); info.NewDirCount = Convert.ToInt32(newBean.DirCount); newSize = newBean.Size; newUsage = newBean.SpaceUsage; } else { newSize = BigInteger.Zero; newUsage = BigInteger.Zero; } //单位换算 info.OldSize = ConversionUtil.StorageFormate(oldSize, false); info.NewSize = ConversionUtil.StorageFormate(newSize, false); info.SizeChanged = ConversionUtil.StorageFormate(newSize - oldSize, true); info.OldUsage = ConversionUtil.StorageFormate(oldUsage, false); info.NewUsage = ConversionUtil.StorageFormate(newUsage, false); info.UsageChanged = ConversionUtil.StorageFormate(newUsage - oldUsage, true); //设置状态 switch (node.Type) { case DirNodeType.Unchanged: info.Action = "文件夹未发生变化"; break; case DirNodeType.Added: info.Action = "该文件夹是新增的文件夹"; break; case DirNodeType.Changed: info.Action = "该文件夹发生了变化"; break; case DirNodeType.Deleted: info.Action = "该文件夹已经被删除"; break; } return(info); }