예제 #1
0
 public NodeMoveBetweenDBManager(String SourceDBFileWithPath, String TargetDBFileWithPath)
 {
     //_SourceDBFileWithPath = SourceDBFileWithPath;
     SourceDbContext = new InfocenterEntities(DALConfig.getEFConnectionString(SourceDBFileWithPath));
     //_TargetDBFileWithPath = TargetDBFileWithPath;
     TargetDbContext = new InfocenterEntities(DALConfig.getEFConnectionString(TargetDBFileWithPath));
 }
 public void DeleteAll()
 {
     using (InfocenterEntities context = new InfocenterEntities(DALConfig.ConnectString))
     {
         context.Database.ExecuteSqlCommand("delete from DetailTextDB ");
     }
 }
 /// <summary>
 /// 删除一个节点及其所有的子节点
 /// </summary>
 /// <param name="dbobj"></param>
 /// <returns></returns>
 public int DeleteNodeAndItsChild(String nodePath)
 {
     using (InfocenterEntities context = new InfocenterEntities(DALConfig.ConnectString))
     {
         return context.Database.ExecuteSqlCommand("Delete from DetailTextDB where Path like {0}", nodePath + "%");
     }
 }
 public NodeMoveBetweenDBManager(String SourceDBFileWithPath, String TargetDBFileWithPath)
 {
     //_SourceDBFileWithPath = SourceDBFileWithPath;
     SourceDbContext = new InfocenterEntities(DALConfig.getEFConnectionString(SourceDBFileWithPath));
     //_TargetDBFileWithPath = TargetDBFileWithPath;
     TargetDbContext = new InfocenterEntities(DALConfig.getEFConnectionString(TargetDBFileWithPath));
 }
 public int Delete(int id)
 {
     using (InfocenterEntities context = new InfocenterEntities(DALConfig.ConnectString))
     {
         return context.Database.ExecuteSqlCommand("delete from DetailTextDB where ID={0}", id);
     }
 }
 /// <summary>
 /// 向数据库中加入一条新记录
 /// </summary>
 /// <param name="dataInfoObject"></param>
 /// <returns></returns>
 public int Create(DetailTextDB dbObj)
 {
     if (dbObj == null)
     {
         return -1;
     }
     using (InfocenterEntities context = new InfocenterEntities(DALConfig.ConnectString))
     {
         context.DetailTextDBs.Add(dbObj);
         return context.SaveChanges();
     }
 }
 /// <summary>
 /// 向数据库中加入一条新记录
 /// </summary>
 /// <param name="dataInfoObject"></param>
 /// <returns></returns>
 public int Create(DetailTextDB dbObj)
 {
     if (dbObj == null)
     {
         return -1;
     }
     using (InfocenterEntities context = new InfocenterEntities(EFConnectionString))
     {
         context.DetailTextDBs.Add(dbObj);
         Console.WriteLine("详细节点的Create()方法:Text:{0},Path:{1},EFConnectionString:{2}", dbObj.Text, dbObj.Path, EFConnectionString);
         return context.SaveChanges();
     }
 }
        /// <summary>
        /// 按照路径提取DetailTextDB对象
        /// </summary>
        /// <param name="nodePath"></param>
        /// <returns></returns>
        public DetailTextDB GetDataInfoObjectByPath(string nodePath)
        {
            if (String.IsNullOrEmpty(nodePath))
            {
                return null;
            }
            using (InfocenterEntities context = new InfocenterEntities(DALConfig.ConnectString))
            {
                DetailTextDB dbobj = context.DetailTextDBs.FirstOrDefault(o => o.Path == nodePath);
                if (dbobj != null)
                {
                    return dbobj;
                }

            }
            return null;
        }
        /// <summary>
        /// 在数据库中查找包容指定字串的记录,返回其路径集合
        /// </summary>
        /// <param name="FindWhat"></param>
        /// <returns></returns>
        public List<String> SearchDataNodeText(String FindWhat,String EFConnectionString)
        {
            using (InfocenterEntities context = new InfocenterEntities(EFConnectionString))
            {
                List<String> result = new List<string>();
                //搜索详细信息表
                var query = from node in context.DetailTextDBs
                            where node.Text.IndexOf(FindWhat) != -1
                            select node.Path;
                result.AddRange(query.ToList());

                //搜索文件夹节点表
                query = from node in context.FolderDBs
                            where node.Text.IndexOf(FindWhat) != -1
                            select node.Path;
                result.AddRange(query.ToList());
                return result;
            }
        }
예제 #10
0
        /// <summary>
        /// 在数据库中查找包容指定字串的记录,返回其路径集合
        /// </summary>
        /// <param name="FindWhat"></param>
        /// <returns></returns>
        public List <String> SearchDataNodeText(String FindWhat, String EFConnectionString)
        {
            using (InfocenterEntities context = new InfocenterEntities(EFConnectionString))
            {
                List <String> result = new List <string>();
                //搜索详细信息表
                var query = from node in context.DetailTextDBs
                            where node.Text.IndexOf(FindWhat) != -1
                            select node.Path;
                result.AddRange(query.ToList());

                //搜索文件夹节点表
                query = from node in context.FolderDBs
                        where node.Text.IndexOf(FindWhat) != -1
                        select node.Path;
                result.AddRange(query.ToList());
                return(result);
            }
        }
 public int Update(DetailTextDB dbObj)
 {
     if (dbObj == null)
     {
         return 0;
     }
     using (InfocenterEntities context = new InfocenterEntities(DALConfig.ConnectString))
     {
         DetailTextDB oldObj = context.DetailTextDBs.FirstOrDefault(o => o.ID == dbObj.ID);
         if (oldObj != null)
         {
             //最大的字段长度为3000
             if (dbObj.Text.Length >DALConfig.MaxTextFieldSize)
             {
                 dbObj.Text.Substring(0, DALConfig.MaxTextFieldSize);
             }
             //更新数据库
             oldObj.ModifyTime = dbObj.ModifyTime;
             oldObj.Path = dbObj.Path;
             oldObj.RTFText = dbObj.RTFText;
             oldObj.Text = dbObj.Text;
             return context.SaveChanges();
         }
         return 0;
     }
 }
 /// <summary>
 /// 更新节点的路径:查找所有路径以oldPath打头的记录,将其路径替换为以newPath打头
 /// 有效路径前后应该以“/”包围
 /// </summary>
 /// <param name="oldPath"></param>
 /// <param name="newPath"></param>
 public void UpdateNodePaths(String oldPath, String newPath)
 {
     using (InfocenterEntities context = new InfocenterEntities(DALConfig.ConnectString))
     {
         var query = from item in context.DetailTextDBs
                     where item.Path.StartsWith(oldPath)
                     select item;
         foreach (var item in query)
         {
             item.Path = item.Path.Replace(oldPath, newPath);
         }
         context.SaveChanges();
     }
 }