예제 #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"));
        }
예제 #2
0
 public ActionResult fileDownload(string repositoryId)
 {
     if (repositoryId != null && !repositoryId.Equals(""))
     {
         string       projectPath           = Server.MapPath("/");                             //取得项目决对路径
         string       repositorySavePath    = ConfigConstant.repositoryPath;                   //获取仓库存放位置
         string       currentRepositoryPath = projectPath + repositorySavePath + repositoryId; //当前仓库路径
         string       temp     = projectPath + "temp/" + repositoryId + ".zip";                //当前仓库路径
         SyncFileUtil fileUtil = SingletonSyncFileManager.getInstance(temp);
         fileUtil.delete();
         SingletonSyncFileManager.removeOneOperator(temp);
         ZipFile.CreateFromDirectory(currentRepositoryPath, temp);
         return(File(temp, "1", Url.Encode(repositoryId + ".zip")));
     }
     return(null);
 }
예제 #3
0
        public ActionResult saveFile(string repositoryId, string version, string path, string fileContent)
        {
            if (repositoryId != null || !repositoryId.Equals("") ||
                version != null || !version.Equals(""))
            {
                string projectPath           = Server.MapPath("/");                             //取得项目决对路径
                string repositorySavePath    = ConfigConstant.repositoryPath;                   //获取仓库存放位置
                string currentRepositoryPath = projectPath + repositorySavePath + repositoryId; //当前仓库路径

                string       showPath = projectPath + repositorySavePath + repositoryId + "/" + version + "/" + path;
                SyncFileUtil fileUtil = SingletonSyncFileManager.getInstance(showPath);
                fileUtil.createFileAndWrite(fileContent);
                SingletonSyncFileManager.removeOneOperator(showPath);
                return(projectFileContent(repositoryId, version, path));
            }
            return(RedirectToAction("frame", "User"));
        }
예제 #4
0
        public string getFileConetent(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; //当前仓库路径

                string       showPath = projectPath + repositorySavePath + repositoryId + "/" + version + "/" + path;
                SyncFileUtil fileUtil = SingletonSyncFileManager.getInstance(showPath);
                string       content  = fileUtil.readFile();
                ViewData["fileContent"] = content;
                SingletonSyncFileManager.removeOneOperator(showPath);
                return(content);
            }
            return("");
        }
예제 #5
0
        public ActionResult newDir(string repositoryId, string version, string path, string fileName)
        {
            if (repositoryId != null && !repositoryId.Equals("") &&
                version != null && !version.Equals("") &&
                fileName != null && !fileName.Equals(""))
            {
                string projectPath           = Server.MapPath("/");                             //取得项目决对路径
                string repositorySavePath    = ConfigConstant.repositoryPath;                   //获取仓库存放位置
                string currentRepositoryPath = projectPath + repositorySavePath + repositoryId; //当前仓库路径

                string       showPath = projectPath + repositorySavePath + repositoryId + "/" + version + "/" + path + "/" + fileName;
                SyncFileUtil fileUtil = SingletonSyncFileManager.getInstance(showPath);
                fileUtil.createDictionary();
                SingletonSyncFileManager.removeOneOperator(showPath);
                return(projectFiles(repositoryId, version, path));
            }
            return(RedirectToAction("frame", "User"));
        }
예제 #6
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"));
        }