Beispiel #1
0
        // 后续记录需要过滤掉未变化的重复项
        private void SaveBeanForOtherRecord(RecordBean bean, RecordBean[] childDirBeans)
        {
            RecordBean targetBean = Extend.GetLastBean(bean.Path);

            if (targetBean == null)
            {
                bean.IsChange = true;
            }
            else
            {
                bean.IsChange = bean.IsChange || !bean.Equals(targetBean);
            }
            //如果该bean没有变化,则不再记录
            if (bean.IsChange)
            {
                bean.Id = RecordMapper.AddOne(bean, incidentId, false);
                beanCount++;
                //刷新索引
                DirIndexMapper.RefreshIndex(new DirIndexBean()
                {
                    Path       = bean.Path,
                    IncidentId = incidentId,
                    TargectId  = bean.Id,
                });
                foreach (RecordBean dirBean in childDirBeans)
                {
                    if (dirBean.IsChange)
                    {
                        RecordMapper.SetParentId(dirBean.Id, bean.Id, incidentId);
                    }
                    else
                    {
                        //将未改变的bena也记录下来
                        dirBean.ParentId = bean.Id;
                        RecordMapper.AddOne(dirBean, incidentId, false);
                        beanCount++;
                    }
                }
            }
            else
            {
                //为未改变节点添加索引
                bean.IncidentId = targetBean.IncidentId;
                bean.TargetId   = targetBean.Id;
            }
        }
Beispiel #2
0
 // 第一次记录
 private void SaveBeanForFirstRecord(RecordBean bean, RecordBean[] childDirBeans)
 {
     //记录并获取当前id
     bean.Id = RecordMapper.AddOne(bean, incidentId, true);
     //记录索引
     DirIndexMapper.AddOne(new DirIndexBean()
     {
         Path       = bean.Path,
         IncidentId = incidentId,
         TargectId  = bean.Id,
     });
     beanCount++;
     //设置子一级的父id
     foreach (RecordBean dirBean in childDirBeans)
     {
         RecordMapper.SetParentId(dirBean.Id, bean.Id, incidentId);
     }
 }