Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public ActionResult projectFileContent(string repositoryId, string version, string path)
        {
            if (repositoryId != null || !repositoryId.Equals("") ||
                version != null || !version.Equals(""))
            {
                string projectPath           = Server.MapPath("/");                             //取得项目决对路径
                string repositorySavePath    = ConfigConstant.repositoryPath;                   //获取仓库存放位置
                string currentRepositoryPath = projectPath + repositorySavePath + repositoryId; //当前仓库路径

                Repository      repository = repositoryDao.findRepositoryById(repositoryId);    //获取仓库的id
                Src.Dao.UserDao userDao    = new Src.Dao.UserDao();
                User            user       = userDao.findUserByEmail(repository.email);         //根据仓库id查找用户的信息

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

                DirectoryInfo[] versions = SingletonSyncFileManager.getInstance(currentRepositoryPath).listDir(); //版本列表
                ViewData["versions"] = versions;                                                                  //版本列表
                SingletonSyncFileManager.removeOneOperator(currentRepositoryPath);
                ViewData["repositoryId"] = repositoryId;
                ViewData["version"]      = version;
                ViewData["path"]         = path;
                string       showPath = projectPath + repositorySavePath + repositoryId + "/" + version + "/" + path;
                SyncFileUtil fileUtil = SingletonSyncFileManager.getInstance(showPath);
                string       content  = fileUtil.readFile();
                ViewData["fileContent"] = content;
                SingletonSyncFileManager.removeOneOperator(showPath);
                return(View("projectFileContent"));
            }
            return(RedirectToAction("frame", "User"));
        }
Beispiel #2
0
        public ActionResult projectFileModify(string repositoryId, string version, string path)
        {
            ViewData["repositoryId"] = repositoryId;
            ViewData["version"]      = version;
            ViewData["path"]         = path;

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



            Repository repository = repositoryDao.findRepositoryById(repositoryId);//获取仓库的id

            Src.Dao.UserDao userDao = new Src.Dao.UserDao();
            User            user    = userDao.findUserByEmail(repository.email);                              //根据仓库id查找用户的信息

            ViewData["user"]       = user;                                                                    //设置仓库所属用户信息
            ViewData["repository"] = repository;                                                              //设置仓库信息

            DirectoryInfo[] versions = SingletonSyncFileManager.getInstance(currentRepositoryPath).listDir(); //版本列表
            ViewData["versions"] = versions;                                                                  //版本列表
            SingletonSyncFileManager.removeOneOperator(currentRepositoryPath);
            return(View());
        }
Beispiel #3
0
        public ActionResult doRegeist(User user)
        {
            User user1 = (User)Session["loginUser"];

            if (user1 != null)
            {
                return(RedirectToAction("frame", "User"));
            }
            Src.Dao.UserDao dao = new Src.Dao.UserDao();
            if (dao.findUserByEmail(user.email) != null)
            {
                ViewData["msg"]    = "注册失败";
                ViewData["result"] = "对不起,这个邮箱账号已经被注册";
            }
            else
            {
                if (dao.save(user) > 0)
                {
                    ViewData["msg"]    = "注册成功";
                    ViewData["result"] = "欢迎你,您已成功注册<strong> CGit</strong > 账号";
                }
                else
                {
                    ViewData["msg"]    = "注册失败";
                    ViewData["result"] = "对不起,由于服务器的原因可能注册失败";
                }
            }
            return(View("registerResult"));
        }
Beispiel #4
0
        /// <summary>
        /// 转到用户主页
        /// </summary>
        /// <returns></returns>
        public ActionResult userHome(string email)
        {
            //获取显示的用户email的主页
            User user = null;

            if (email == null || email.Equals(""))//如果email为空是查看自己的信息
            {
                user  = (User)Session["loginUser"];
                email = user.email;
            }
            else//如果email不为空就查找这个用户
            {
                user = userDao.findUserByEmail(email);
            }
            if (user == null)//防止不存在该email的用户
            {
                user = (User)Session["loginUser"];
                if (user == null)
                {
                    return(RedirectToAction("login", "Home"));//如果用户不存在就跳转到首页
                }
                email = user.email;
            }
            User currentUser = (User)Session["loginUser"];

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


            List <Repository> repositoryList = repositoryDao.findAllRepositoryByEmail(email); //查找所有仓库

            ViewData["repositoryList"] = repositoryList;                                      //将仓库数据放入viewData
            ViewData["user"]           = user;                                                //将用户信息放入viewData
            return(View("userHome"));
        }
Beispiel #5
0
        public ActionResult doFindPwd()
        {
            Src.Dao.UserDao dao   = new Src.Dao.UserDao();
            string          email = Request["eamil"];
            User            user  = dao.findUserByEmail(email);

            if (user == null)//邮箱没有被注册
            {
                ViewData["msg"] = "该邮箱未注册,请重新输入";
            }
            else
            {
                ViewData["msg"] = "找回密码成功,请到邮箱查看";
                Src.Util.EmailUtil.SentMail(email, "您的密码找回成功,密码为" + user.pwd, "CGit找回密码", "CGit");
            }
            return(View("findPwd"));
        }
Beispiel #6
0
        // GET: Comment
        public ActionResult projectComment(string repositoryId)
        {
            if (repositoryId != null && repositoryId != "")
            {
                ViewData["repositoryId"] = repositoryId;
                RepositoryDao   repositoryDao = new RepositoryDao();
                Repository      repository    = repositoryDao.findRepositoryById(repositoryId); //获取仓库的id
                Src.Dao.UserDao userDao       = new Src.Dao.UserDao();
                User            user          = userDao.findUserByEmail(repository.email);      //根据仓库id查找用户的信息

                ViewData["user"]       = user;                                                  //设置仓库所属用户信息
                ViewData["repository"] = repository;                                            //设置仓库信息

                List <Comment> comments = bll.findAllcommentByRepositoryId(repositoryId);
                ViewData["commnets"] = comments;
            }

            return(View("projectComment"));
        }
Beispiel #7
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"));
        }