⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 project.cs

📁 BugNET is an issue tracking and project issue management solution built using the ASP.NET web applic
💻 CS
📖 第 1 页 / 共 2 页
字号:
					    
					int TempId = DataProviderManager.Provider.CreateNewProject(this);
					if (TempId>Globals.NewId) 
					{
						_Id = TempId;
						try
						{	
                            //create default roles for new project.
                            Role.CreateDefaultProjectRoles(_Id);
							//create attachment directory

                            //ONLY DO THIS IF STORAGE TYPE IS FILE SYSETM -- CATCH ERRORS!!
							System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~\\Uploads\\" + _UploadPath));
						}
						catch(Exception ex)
                        {
                            return false;
                        }   
						
						return true;
					}  
					else
						return false;
				}
				else
					return (UpdateProject());
			}		
		#endregion

		#region Private Methods
			

			private bool UpdateProject()
			{
				
				return DataProviderManager.Provider.UpdateProject(this);
			
			}
		#endregion

		#region Static Methods
            /// <summary>
            /// Gets the project by id.
            /// </summary>
            /// <param name="projectId">The project id.</param>
            /// <returns></returns>
			public static Project GetProjectById(int  projectId) 
			{
				// validate input
				if (projectId <= 0)
					throw (new ArgumentOutOfRangeException("projectId"));

				
				
				return DataProviderManager.Provider.GetProjectById(projectId);
			}

            /// <summary>
            /// Gets the project by code.
            /// </summary>
            /// <param name="projectCode">The project code.</param>
            /// <returns></returns>
			public static Project GetProjectByCode(string  projectCode) 
			{
				// validate input
				if (string.IsNullOrEmpty(projectCode))
					throw (new ArgumentOutOfRangeException("projectCode"));

				
				return DataProviderManager.Provider.GetProjectByCode(projectCode);
			}

            /// <summary>
            /// Gets all projects.
            /// </summary>
            /// <returns></returns>
			public static List<Project> GetAllProjects()
			{				
				return DataProviderManager.Provider.GetAllProjects();
			}

            /// <summary>
            /// Gets the public projects.
            /// </summary>
            /// <returns></returns>
			public static List<Project> GetPublicProjects()
			{
						
				return DataProviderManager.Provider.GetPublicProjects();
			}

            /// <summary>
            /// Gets the name of the projects by user.
            /// </summary>
            /// <param name="userName">Name of the user.</param>
            /// <returns></returns>
			public static List<Project> GetProjectsByMemberUserName(string userName) 
			{
				if (String.IsNullOrEmpty(userName))
					throw (new ArgumentOutOfRangeException("userName"));
				
				return GetProjectsByMemberUserName(userName,  true);
			}

            /// <summary>
            /// Gets the name of the projects by user.
            /// </summary>
            /// <param name="userName">Name of the user.</param>
            /// <param name="activeOnly">if set to <c>true</c> [active only].</param>
            /// <returns></returns>
            public static List<Project> GetProjectsByMemberUserName(string userName, bool activeOnly) 
			{
                if (String.IsNullOrEmpty(userName))
                    throw (new ArgumentOutOfRangeException("userName"));

						
				return DataProviderManager.Provider.GetProjectsByMemberUserName(userName,activeOnly);
				
			}

            /// <summary>
            /// Adds the user to project.
            /// </summary>
            /// <param name="userName">Name of the user.</param>
            /// <param name="projectId">The project id.</param>
            /// <returns></returns>
			public static bool AddUserToProject(string userName, int projectId) 
			{
                if (String.IsNullOrEmpty(userName))
                    throw new ArgumentOutOfRangeException("userName");
                if (projectId <= Globals.NewId)
                    throw new ArgumentOutOfRangeException("projectId");
				
						
				return DataProviderManager.Provider.AddUserToProject(userName,projectId);
			}

            /// <summary>
            /// Removes the user from project.
            /// </summary>
            /// <param name="userName">Name of the user.</param>
            /// <param name="projectId">The project id.</param>
            /// <returns></returns>
			public static bool RemoveUserFromProject(string userName, int projectId) 
			{
                if (String.IsNullOrEmpty(userName))
                    throw new ArgumentOutOfRangeException("userName");
                if (projectId <= Globals.NewId)
                    throw new ArgumentOutOfRangeException("projectId");

						
				return DataProviderManager.Provider.RemoveUserFromProject(userName,projectId);
			}

            /// <summary>
            /// Determines whether [is project member] [the specified user id].
            /// </summary>
            /// <param name="userName">Name of the user.</param>
            /// <param name="projectId">The project id.</param>
            /// <returns>
            /// 	<c>true</c> if [is project member] [the specified user id]; otherwise, <c>false</c>.
            /// </returns>
            public static bool IsUserProjectMember(string userName, int projectId)
            {
                if (String.IsNullOrEmpty(userName))
                    throw new ArgumentOutOfRangeException("userName");
                if (projectId <= Globals.NewId)
                    throw new ArgumentOutOfRangeException("projectId");

                
                return DataProviderManager.Provider.IsUserProjectMember(userName, projectId);
            }

            /// <summary>
            /// Deletes the project.
            /// </summary>
            /// <param name="projectId">The project id.</param>
            /// <returns></returns>
			public static bool DeleteProject (int projectId) 
			{
				if (projectId <= Globals.NewId )
					throw (new ArgumentOutOfRangeException("projectId"));

				
                string uploadpath = GetProjectById(projectId).UploadPath;

                if (DataProviderManager.Provider.DeleteProject(projectId))
                {
                    try
                    {
                        System.IO.Directory.Delete(HttpContext.Current.Server.MapPath("~\\Uploads\\" + uploadpath), true);
                    }
                    catch { }
                  
                    return true;
                }
                return false;
			}

          

            /// <summary>
            /// Clones the project.
            /// </summary>
            /// <param name="projectId">The project id.</param>
            /// <param name="projectName">Name of the project.</param>
            /// <returns></returns>
            public static bool CloneProject(int projectId, string projectName)
            {
                if (projectId <= Globals.NewId)
                    throw (new ArgumentOutOfRangeException("projectId"));
                if(string.IsNullOrEmpty(projectName))
                    throw new ArgumentNullException("projectName");

                return DataProviderManager.Provider.CloneProject(projectId, projectName);
            }

            /// <summary>
            /// Gets the road map.
            /// </summary>
            /// <param name="projectId">The project id.</param>
            /// <returns></returns>
            public static List<Issue> GetRoadMap(int projectId)
            {
                if (projectId <= Globals.NewId)
                    throw (new ArgumentOutOfRangeException("projectId"));
       
                return DataProviderManager.Provider.GetProjectRoadmap(projectId);
            }

            /// <summary>
            /// Gets the road map progress.
            /// </summary>
            /// <param name="projectId">The project id.</param>
            /// <param name="milestoneId">The milestone id.</param>
            /// <returns>total number of issues and total number of close issues</returns>
            public static int[] GetRoadMapProgress(int projectId, int milestoneId)
            {
                if (projectId <= Globals.NewId)
                    throw (new ArgumentOutOfRangeException("projectId"));
                if (milestoneId < -1)
                    throw new ArgumentNullException("milestoneId");

                return DataProviderManager.Provider.GetProjectRoadmapProgress(projectId,milestoneId);
            }

            /// <summary>
            /// Gets the change log.
            /// </summary>
            /// <param name="projectId">The project id.</param>
            /// <returns></returns>
            public static List<Issue> GetChangeLog(int projectId)
            {
                if (projectId <= Globals.NewId)
                    throw (new ArgumentOutOfRangeException("projectId"));

                return DataProviderManager.Provider.GetProjectChangeLog(projectId);
            }
			
		#endregion

        /// <summary>
        /// Returns a <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>.
        /// </returns>
		public override string ToString()
		{
			return _Name;
		}

	
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -