Example #1
0
 /// <summary>
 /// 获得子文件夹
 /// </summary>
 /// <param name="name">文件名</param>
 /// <returns>子文件夹集合</returns>
 public static List <Floder> GetChildfolder(string name)
 {
     using (mainEntities db = new mainEntities())
     {
         Floder flode = db.Floder.Where(u => u.Name == name).FirstOrDefault();
         return(db.Floder.Where(u => u.FatherDirectory == flode.ID).ToList());
     }
 }
Example #2
0
 /// <summary>
 /// 获得子文件
 /// </summary>
 /// <param name="name">文件名</param>
 /// <returns>子文件集合</returns>
 public static List <Filedate> GetChildfiledate(string name)
 {
     using (mainEntities db = new mainEntities())
     {
         Floder flode = db.Floder.Where(u => u.Name == name).FirstOrDefault();
         return(db.Filedate.Where(u => u.FatherFolder == flode.ID).ToList());
     }
 }
Example #3
0
 /// <summary>
 /// 移动文件夹EF
 /// </summary>
 /// <param name="name">文件夹名称</param>
 /// <param name="relativePath">相对路径</param>
 /// <returns>成功OR失败</returns>
 public static bool MoveFloder(string name, string relativePath)
 {
     using (mainEntities db = new mainEntities())
     {
         Floder floder = db.Floder.Where(u => u.Name == name).FirstOrDefault();
         floder.RelativePath = relativePath;
         // floder.FullPath = path + relativePath;
         return(db.SaveChanges() > 0 ? true : false);
     }
 }
Example #4
0
 /// <summary>
 /// 移动文件EF
 /// </summary>
 /// <param name="name">文件名</param>
 /// <param name="relativePath">相对路径</param>
 /// <returns>成功OR失败</returns>
 public static bool MoveFile(string name, string fullPath)
 {
     using (mainEntities db = new mainEntities())
     {
         Floder   floder   = db.Floder.Where(u => u.FullPath == fullPath).FirstOrDefault();
         Filedate filedate = db.Filedate.Where(u => u.Name == name).FirstOrDefault();
         filedate.FatherFolder = floder.ID;
         filedate.FullPath     = floder.FullPath + @"\" + filedate.MD5Name;
         filedate.RelativePath = floder.RelativePath + @"\" + filedate.MD5Name;
         return(db.SaveChanges() > 0 ? true : false);
     }
 }
Example #5
0
 /// <summary>
 /// 获取完整路径EF
 /// </summary>
 /// <param name="name">文件夹名称</param>
 /// <returns>文件夹路径</returns>
 public static string GetFullPath(string name)
 {
     using (mainEntities db = new mainEntities())
     {
         Floder   floder   = db.Floder.Where(u => u.Name == name).FirstOrDefault();
         Filedate filedate = db.Filedate.Where(u => u.Name == name).FirstOrDefault();
         if (filedate != null)
         {
             return(filedate.FullPath);
         }
         return(floder.FullPath);
     }
 }
Example #6
0
 /// <summary>
 /// 重命名文件夹EF
 /// </summary>
 /// <param name="name">旧文件名</param>
 /// <param name="newname">新文件名</param>
 /// <returns>成功OR失败</returns>
 public static bool NewNameFloderOrFile(string name, string newname)
 {
     using (mainEntities db = new mainEntities())
     {
         Floder floder = db.Floder.Where(u => u.FullPath == name).FirstOrDefault();
         if (floder != null)
         {
             floder.Name = newname;
         }
         Filedate filedate = db.Filedate.Where(u => u.FullPath == name).FirstOrDefault();
         if (filedate != null)
         {
             filedate.Name = newname;
         }
         return(db.SaveChanges() > 0 ? true : false);
     }
 }
Example #7
0
 /// <summary>
 /// 得到相对路径
 /// </summary>
 /// <param name="name">名称</param>
 /// <returns>路径</returns>
 public static string GetRelativePath(string name)
 {
     using (mainEntities db = new mainEntities())
     {
         Filedate filedate = db.Filedate.Where(u => u.Name == name).FirstOrDefault();
         if (filedate != null)
         {
             return(filedate.RelativePath);
         }
         Floder flode = db.Floder.Where(u => u.Name == name).FirstOrDefault();
         if (flode != null)
         {
             Floder flod = db.Floder.Where(u => u.ID == flode.ID).FirstOrDefault();
             return(flod.RelativePath);
         }
         return(null);
     }
 }
Example #8
0
 /// <summary>
 /// 获得ID
 /// </summary>
 /// <returns>ID</returns>
 public static long GetID(string name)
 {
     using (mainEntities db = new mainEntities())
     {
         Filedate filedate = db.Filedate.Where(u => u.Name == name).FirstOrDefault();
         if (filedate != null)
         {
             Floder floder = db.Floder.Where(u => u.ID == filedate.FatherFolder).FirstOrDefault();
             return(floder.ID);
         }
         Floder flode = db.Floder.Where(u => u.Name == name).FirstOrDefault();
         if (flode != null)
         {
             Floder flod = db.Floder.Where(u => u.ID == flode.ID).FirstOrDefault();
             return(flod.ID);
         }
         return(0);
     }
 }
Example #9
0
 /// <summary>
 /// 新建文件夹EF
 /// </summary>
 /// <param name="name">文件夹名称</param>
 /// <param name="directoryNum">文件夹层级</param>
 /// <param name="fatherDirectory">父文件夹ID</param>
 /// <param name="relativePath">相对路径</param>
 /// <returns>成功OR失败</returns>
 public static bool NewFloder(string name, long fatherDirectory, string relativePath)
 {
     using (mainEntities db = new mainEntities())
     {
         if (db.Floder.Where(u => u.RelativePath == relativePath).FirstOrDefault() == null)
         {
             Floder floder = new Floder()
             {
                 Name            = name,
                 FatherDirectory = fatherDirectory,
                 FullPath        = AppDomain.CurrentDomain.BaseDirectory + relativePath,
                 RelativePath    = relativePath,
                 Date            = DateTime.Now.ToString()
             };
             db.Floder.Add(floder);
             return(db.SaveChanges() > 0 ? true : false);
         }
         else
         {
             return(false);
         }
     }
 }
        /// <summary>
        /// 新增分类
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsm_AddFloder_Click(object sender, EventArgs e)
        {
            if (this._bindDataNode == null)
            {
                MessageBox.Show("请选择你要添加分类的父节点"); return;
            }
            if (this._bindDataNode.NodeType == NodeType.BEProj
                || this._bindDataNode.NodeType == NodeType.BPProj
                || this._bindDataNode.NodeType == NodeType.Floder)
            {
                if (this._currentProj != null)
                {
                    ComponentTreeNode tn = new ComponentTreeNode(NodeType.Floder, Guid.NewGuid().ToString());
                    tn.Text = "新增分类";
                    tn.ImageIndex = tn.SelectedImageIndex = 3;
                    this._bindDataNode.Nodes.Add(tn);

                    Floder floder = new Floder(this._currentProj, tn.Guid);
                    floder.Name = tn.Text;
                    if (this._bindDataNode.NodeType == NodeType.Floder)
                    {
                        floder.PGuid = this._bindDataNode.Guid;
                    }
                    this._currentProj.FloderList.Add(floder);

                    this.tvProject.SelectedNode = tn;
                }
            }
        }
Example #11
0
        public List<Floder> LoadFloderList(XmlNode node)
        {
            XmlNodeList nodeList = node.SelectNodes("Floder");
            List<Floder> sourceList = new List<Floder>();
            List<Floder> resultList = new List<Floder>();
            //查找当前工程下所有的文件夹
            if (nodeList != null)
            {
                foreach (XmlNode n in nodeList)
                {
                    Floder floder = new Floder(this, string.Empty);
                    floder.FromXML(n);
                    sourceList.Add(floder);
                }
            }
            //先加载根节点的
            for (var i = sourceList.Count - 1; i >= 0; i--)
            {
                Floder floder = sourceList[i];
                if (string.IsNullOrEmpty(floder.PGuid))
                {
                    resultList.Add(floder);
                    sourceList.RemoveAt(i);
                }
            }
            while (sourceList.Count > 0)
            {

                for (int j = 0; j < resultList.Count; j++)
                {
                    for (int i = sourceList.Count - 1; i >= 0; i--)
                    {
                        if (sourceList[i].PGuid == resultList[j].Guid)
                        {
                            resultList.Add(sourceList[i]);
                            sourceList.RemoveAt(i);
                        }
                    }
                }
            }
            return resultList;
        }