コード例 #1
0
ファイル: Project.cs プロジェクト: dineshkummarc/BugNet
 /// <summary>
 /// Initializes a new instance of the <see cref="Project"/> class.
 /// </summary>
 /// <param name="projectId">The project id.</param>
 /// <param name="imageContent">Content of the image.</param>
 /// <param name="imageFileName">Name of the image file.</param>
 /// <param name="imageFileLength">Length of the image file.</param>
 /// <param name="imageContentType">Type of the image content.</param>
 //public Project(int projectId,byte[] imageContent, string imageFileName, long imageFileLength, string imageContentType)
 //{
 //    _ImageContent = imageContent;
 //    _ImageFileName = imageFileName;
 //    _ImageFileLength = imageFileLength;
 //    _ImageContentType = imageContentType;
 //}
 /// <summary>
 /// Initializes a new instance of the <see cref="Project"/> class.
 /// </summary>
 /// <param name="projectId">The project id.</param>
 /// <param name="name">The name.</param>
 /// <param name="code">The code.</param>
 /// <param name="description">The description.</param>
 /// <param name="managerUserName">Name of the manager user.</param>
 /// <param name="managerDisplayName">Display name of the manager.</param>
 /// <param name="creatorUserName">Name of the creator user.</param>
 /// <param name="creatorDisplayName">Display name of the creator.</param>
 /// <param name="uploadPath">The upload path.</param>
 /// <param name="accessType">Type of the access.</param>
 /// <param name="disabled">if set to <c>true</c> [disabled].</param>
 /// <param name="allowAttachments">if set to <c>true</c> [allow attachments].</param>
 /// <param name="attachmentStorageType">Type of the attachment storage.</param>
 /// <param name="svnRepositoryUrl">The SVN repository URL.</param>
 /// <param name="allowIssueVoting">if set to <c>true</c> [allow issue voting].</param>
 /// <param name="imageContent">Content of the image.</param>
 /// <param name="imageFileName">Name of the image file.</param>
 /// <param name="imageFileLength">Length of the image file.</param>
 /// <param name="imageContentType">Type of the image content.</param>
 public Project(int projectId, string name, string code, string description, string managerUserName, string managerDisplayName, string creatorUserName, string creatorDisplayName, string uploadPath, Globals.ProjectAccessType accessType, bool disabled, bool allowAttachments,
     IssueAttachmentStorageType attachmentStorageType, string svnRepositoryUrl, bool allowIssueVoting, ProjectImage projectImage)
     : this(projectId, name, code, description, managerUserName, managerDisplayName, creatorUserName, creatorDisplayName, uploadPath, DateTime.Now, accessType, disabled, allowAttachments, Guid.Empty, attachmentStorageType, svnRepositoryUrl, allowIssueVoting, projectImage)
 {
 }
コード例 #2
0
        /// <summary>
        /// Updates this instance.
        /// </summary>
        /// <returns></returns>
        public bool Update()
        {
            if (Page.IsValid)
            {
                Globals.ProjectAccessType at = (rblAccessType.SelectedValue == "Public") ? Globals.ProjectAccessType.Public : Globals.ProjectAccessType.Private;
                IssueAttachmentStorageType attachmentStorageType = (AttachmentStorageType.SelectedValue == "2") ? IssueAttachmentStorageType.Database : IssueAttachmentStorageType.FileSystem;
                Project newProject = null;

                // get the current file
                HttpPostedFile uploadFile = ProjectImageUploadFile.PostedFile;
                HttpContext context = HttpContext.Current;

                // if there was a file uploaded
                if (uploadFile.ContentLength > 0)
                {
                    bool isFileOk = false;
                    string[] AllowedFileTypes = new string[3] { ".gif", ".png", ".jpg" };
                    string fileExt = System.IO.Path.GetExtension(uploadFile.FileName).ToLower();
                    string uploadedFileName = Path.GetFileName(uploadFile.FileName).ToLower();

                    foreach (string fileType in AllowedFileTypes)
                    {
                        string newfileType = fileType.Substring(fileType.LastIndexOf("."));
                        if (newfileType.CompareTo(fileExt) == 0)
                            isFileOk = true;
                    }

                    //file type is not valid
                    if (!isFileOk)
                    {
                        if (Log.IsErrorEnabled) Log.Error(string.Format(Logging.GetErrorMessageResource("InvalidFileType"), uploadedFileName));
                        return false;
                    }

                    //check for illegal filename characters
                    if (uploadedFileName.IndexOfAny(System.IO.Path.GetInvalidFileNameChars()) != -1)
                    {
                        if (Log.IsErrorEnabled) Log.Error(string.Format(Logging.GetErrorMessageResource("InvalidFileName"), uploadedFileName));
                        return false;
                    }

                    //if the file is ok save it.
                    if (isFileOk)
                    {
                        int fileSize = uploadFile.ContentLength;
                        byte[] fileBytes = new byte[fileSize];
                        System.IO.Stream myStream = uploadFile.InputStream;
                        myStream.Read(fileBytes, 0, fileSize);

                        ProjectImage projectImage = new ProjectImage(ProjectId, fileBytes, uploadedFileName, fileSize, uploadFile.ContentType);

                        // In High Security Mode, attachments can only go into the database.
                        if (SecurityModes.isHighSecurityMode())
                            attachmentStorageType = IssueAttachmentStorageType.Database;

                        newProject = new Project(ProjectId, txtName.Text.Trim(), ProjectCode.Text.Trim(), ProjectDescriptionHtmlEditor.Text.Trim(), ProjectManager.SelectedValue, string.Empty,
                        Page.User.Identity.Name, string.Empty, txtUploadPath.Text.Trim(), at, false, AllowAttachments.Checked, attachmentStorageType, string.Empty, chkAllowIssueVoting.Checked,
                        projectImage);

                    }
                }
                else
                {
                    // In High Security Mode, attachments can only go into the database.
                    if (SecurityModes.isHighSecurityMode())
                        attachmentStorageType = IssueAttachmentStorageType.Database;

                    newProject = new Project(ProjectId, txtName.Text.Trim(), ProjectCode.Text.Trim(), ProjectDescriptionHtmlEditor.Text.Trim(), ProjectManager.SelectedValue, string.Empty,
                        Page.User.Identity.Name, string.Empty, txtUploadPath.Text.Trim(), at, false, AllowAttachments.Checked, attachmentStorageType, string.Empty, chkAllowIssueVoting.Checked);

                }

                if (newProject.Save())
                {
                    ProjectId = newProject.Id;
                    return true;
                }
                else
                    lblError.Text = Logging.GetErrorMessageResource("SaveProjectError");

            }
            return false;
        }
コード例 #3
0
ファイル: Project.cs プロジェクト: dineshkummarc/BugNet
        /// <summary>
        /// Initializes a new instance of the <see cref="Project"/> class.
        /// </summary>
        /// <param name="projectId">The project id.</param>
        /// <param name="name">The name.</param>
        /// <param name="code">The code.</param>
        /// <param name="description">The description.</param>
        /// <param name="managerUserName">Name of the manager user.</param>
        /// <param name="creatorUserName">Name of the creator user.</param>
        /// <param name="uploadPath">The upload path.</param>
        /// <param name="dateCreated">The date created.</param>
        /// <param name="accessType">Type of the access.</param>
        /// <param name="active">The active.</param>
        /// <param name="allowAttachments">if set to <c>true</c> [allow attachments].</param>
        public Project(int projectId, string name, string code, string description, string managerUserName, string managerDisplayName,
                string creatorUserName, string creatorDisplayName, string uploadPath, DateTime dateCreated, Globals.ProjectAccessType accessType,
                bool disabled, bool allowAttachments, Guid managerId, IssueAttachmentStorageType attachmentStorageType, string svnRepositoryUrl, bool allowIssueVoting,
                ProjectImage projectImage)
        {
            // Validate Mandatory Fields//
            if (name == null || name.Length == 0)
                throw (new ArgumentOutOfRangeException("name"));

            _Id = projectId;
            _Description = description;
            _Name = name;
            _Code = code;
            _ManagerUserName = managerUserName;
            _ManagerDisplayName = managerDisplayName;
            _ManagerId = managerId;
            _CreatorUserName = creatorUserName;
            _CreatorDisplayName = creatorDisplayName;
            _DateCreated = dateCreated;
            _UploadPath = uploadPath;
            _Disabled = disabled;
            _AccessType = accessType;
            _AllowAttachments = allowAttachments;
            _AttachmentStorageType = attachmentStorageType;
            _SvnRepositoryUrl = svnRepositoryUrl;
            _AllowIssueVoting = allowIssueVoting;
            _ProjectImage = projectImage;
        }