Exemplo n.º 1
0
        public ActionResult search(string keyWord)
        {
            UserBll     userBll  = new UserBll();
            List <User> userList = userBll.searchUser(keyWord);

            ViewData["userList"] = userList;
            RepositoryBll     repositoryBll  = new RepositoryBll();
            List <Repository> repositoryList = repositoryBll.searchRepository(keyWord);

            ViewData["repositoryList"] = repositoryList;

            RepositoryDao       repositoryDao       = new RepositoryDao();
            FollowRepositoryBll followRepositoryBll = new FollowRepositoryBll();
            List <string>       repositoryCountList = followRepositoryBll.findRepositoryAndCount();

            if (repositoryCountList != null)
            {
                List <Repository> repositorylist = new List <Repository>();
                foreach (string userEmail in repositoryCountList)
                {
                    repositorylist.Add(repositoryDao.findRepositoryById(userEmail));
                }
                ViewData["repositoryCountList"] = repositorylist;
            }
            return(View("searchResult"));
        }
Exemplo n.º 2
0
        public ActionResult unfollow(string repositoryId)
        {
            User user = (User)Session["loginUser"];
            FollowRepositoryBll bll = new FollowRepositoryBll();

            bll.delete(user.email, repositoryId);
            return(projectFiles(repositoryId, null, null));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 热门项目视图
        /// </summary>
        /// <returns></returns>
        public ActionResult hotProject()
        {
            FollowRepositoryBll repositoryBll  = new FollowRepositoryBll();
            List <string>       repositoryList = repositoryBll.findRepositoryAndCount();

            if (repositoryList != null)
            {
                List <Repository> repositorylist = new List <Repository>();
                foreach (string userEmail in repositoryList)
                {
                    repositorylist.Add(repositoryDao.findRepositoryById(userEmail));
                }
                ViewData["repositoryList"] = repositorylist;
            }
            return(View());
        }
Exemplo n.º 4
0
        /// <summary>
        /// 我的关注
        /// </summary>
        /// <returns></returns>
        public ActionResult myFollow()
        {
            if ((User)Session["loginUser"] == null)
            {
                return(RedirectToAction("login", "Home"));//如果用户不存在就跳转到首页
            }
            string email = ((CGit.Models.User)Session["loginUser"]).email;

            FollowUserBll userBll  = new FollowUserBll();
            List <string> userList = userBll.findAllFollowUserByUserEmail(email);

            if (userList != null)
            {
                List <User> userlist = new List <User>();
                foreach (string userEmail in userList)
                {
                    userlist.Add(userDao.findUserByEmail(userEmail));
                }
                ViewData["userList"] = userlist;
            }


            FollowRepositoryBll repositoryBll  = new FollowRepositoryBll();
            List <string>       repositoryList = repositoryBll.findAllFollowRepositoryByRepositoryEmail(email);

            if (repositoryList != null)
            {
                List <Repository> repositorylist = new List <Repository>();
                foreach (string userEmail in userList)
                {
                    repositorylist.Add(repositoryDao.findRepositoryById(userEmail));
                }
                ViewData["repositoryList"] = repositoryList;
            }

            return(View());
        }
Exemplo n.º 5
0
        /// <summary>
        /// 列出所有文件和文件夹
        /// </summary>
        /// <param name="repositoryId">要列出文件的仓库id</param>
        /// <param name="version">要列出的版本</param>
        /// <param name="path">版本内的路径</param>
        /// <returns></returns>
        public ActionResult projectFiles(string repositoryId, string version, string path)
        {
            if (repositoryId != null)                                                        //传来的仓库id不为空
            {
                Repository      repository = repositoryDao.findRepositoryById(repositoryId); //获取仓库的id
                Src.Dao.UserDao userDao    = new Src.Dao.UserDao();
                User            user       = userDao.findUserByEmail(repository.email);      //根据仓库id查找用户的信息

                User currentUser = (User)Session["loginUser"];
                if (currentUser != null)
                {
                    FollowRepositoryBll bll = new FollowRepositoryBll();
                    ViewData["isFollow"] = bll.isFollow(currentUser.email, repositoryId);//判断是否关注
                }
                else
                {
                    ViewData["isFollow"] = false;
                }


                string projectPath           = Server.MapPath("/");                             //取得项目决对路径
                string repositorySavePath    = ConfigConstant.repositoryPath;                   //获取仓库存放位置
                string currentRepositoryPath = projectPath + repositorySavePath + repositoryId; //当前仓库路径

                user.pwd               = "";
                ViewData["user"]       = user;                                                                    //设置仓库所属用户信息
                ViewData["repository"] = repository;                                                              //设置仓库信息
                                                                                                                  //List<MVersion> versions = versionDao.findVersionByRepositoryId(id);//根据仓库查找所有版本

                DirectoryInfo[] versions = SingletonSyncFileManager.getInstance(currentRepositoryPath).listDir(); //版本列表
                ViewData["versions"] = versions;                                                                  //版本列表
                SingletonSyncFileManager.removeOneOperator(currentRepositoryPath);


                if (versions == null || versions.Length == 0)
                {
                    return(View("projectFiles"));
                }


                if (path == null)
                {
                    path = "";
                }
                //VersionService service = new VersionService();
                string showPath;//要显示的文件列表路径
                if (version == null || version.Equals(""))
                {
                    showPath            = projectPath + repositorySavePath + repositoryId + "/" + versions[0] + "/" + path;
                    ViewData["version"] = versions[0];//文件夹列表
                }
                else
                {
                    showPath            = projectPath + repositorySavePath + repositoryId + "/" + version + "/" + path;
                    ViewData["version"] = version;//文件夹列表
                }
                SyncFileUtil fileUtil = SingletonSyncFileManager.getInstance(showPath);
                ViewData["dirList"]  = fileUtil.listDir();  //文件夹列表
                ViewData["fileList"] = fileUtil.listFile(); //文件列表
                SingletonSyncFileManager.removeOneOperator(showPath);
                ViewData["path"] = path;
            }
            else
            {
                return(RedirectToAction("frame", "User"));
            }
            return(View("projectFiles"));
        }