/// <summary> /// Gets and bulk updates projects. Called when the "Get and bulk update projects" button is pressed. /// Expects the CreateProject method to be run first. /// </summary> private bool GetAndBulkUpdateProjects() { // Prepare the parameters string where = "ProjectName LIKE N'MyNewProject%'"; string orderBy = ""; int topN = 0; string columns = ""; // Get the data DataSet projects = ProjectInfoProvider.GetProjects(where, orderBy, topN, columns); if (!DataHelper.DataSourceIsEmpty(projects)) { // Loop through the individual items foreach (DataRow projectDr in projects.Tables[0].Rows) { // Create object from DataRow ProjectInfo modifyProject = new ProjectInfo(projectDr); // Update the properties modifyProject.ProjectDisplayName = modifyProject.ProjectDisplayName.ToUpper(); // Save the changes ProjectInfoProvider.SetProjectInfo(modifyProject); } return(true); } return(false); }
/// <summary> /// Updates current project info after upload events (upload and delete). /// </summary> private void TouchProjectInfo() { if (ProjectObj != null) { ProjectInfoProvider.SetProjectInfo(ProjectObj); } }
/// <summary> /// Gets and updates project. Called when the "Get and update project" button is pressed. /// Expects the CreateProject method to be run first. /// </summary> private bool GetAndUpdateProject() { // Get the project ProjectInfo updateProject = ProjectInfoProvider.GetProjectInfo("MyNewProject", SiteContext.CurrentSiteID, 0); if (updateProject != null) { // Update the properties updateProject.ProjectDisplayName = updateProject.ProjectDisplayName.ToLowerCSafe(); // Save the changes ProjectInfoProvider.SetProjectInfo(updateProject); return(true); } return(false); }
/// <summary> /// Sets project's security. Called when the "Set project's security" button is pressed. /// Expects the CreateProject method to be run first. /// </summary> private bool SetSecurity() { // Get the project ProjectInfo project = ProjectInfoProvider.GetProjectInfo("MyNewProject", SiteContext.CurrentSiteID, 0); if (project != null) { // Set properties project.AllowCreate = SecurityAccessEnum.AllUsers; project.AllowDelete = SecurityAccessEnum.Owner; project.AllowRead = SecurityAccessEnum.AuthorizedRoles; ProjectInfoProvider.SetProjectInfo(project); return(true); } return(false); }
/// <summary> /// Creates project. Called when the "Create project" button is pressed. /// </summary> private bool CreateProject() { ProjectStatusInfo status = ProjectStatusInfoProvider.GetProjectStatusInfo("NotStarted"); if (status != null) { int currentUserID = MembershipContext.AuthenticatedUser.UserID; // Create new project object ProjectInfo newProject = new ProjectInfo(); // Set the properties newProject.ProjectDisplayName = "My new project"; newProject.ProjectName = "MyNewProject"; newProject.ProjectStatusID = status.StatusID; newProject.ProjectSiteID = SiteContext.CurrentSiteID; newProject.ProjectOwner = currentUserID; newProject.ProjectCreatedByID = currentUserID; // Save the project ProjectInfoProvider.SetProjectInfo(newProject); } return(true); }
public void RaisePostBackEvent(string eventArgument) { if (!CheckPermissions("CMS.ProjectManagement", PERMISSION_MANAGE)) { return; } string[] args = eventArgument.Split(';'); if (args.Length == 2) { // Get info on currently selected item int permission = ValidationHelper.GetInteger(args[0], 0); int access = ValidationHelper.GetInteger(args[1], 0); if (project != null) { // Update project permission access information switch (permission) { case 0: // Set 'AllowRead' permission to specified access project.AllowRead = (SecurityAccessEnum)access; break; case 1: // Set 'AttachCreate' permission to specified access project.AllowCreate = ((SecurityAccessEnum)access); break; case 2: // Set 'AllowModify' permission to specified access project.AllowModify = (SecurityAccessEnum)access; break; case 3: // Set 'AllowDelete' permission to specified access project.AllowDelete = ((SecurityAccessEnum)access); break; default: break; } // Delete permission hash tables ProjectInfoProvider.ClearProjectPermissionTable(ProjectID, CMSContext.CurrentUser); // Use try/catch due to license check try { // Save changes to the project ProjectInfoProvider.SetProjectInfo(project); } catch (Exception ex) { lblError.Visible = true; lblError.Text = ex.Message; } createMatrix = true; } } }
/// <summary> /// Saves control with actual data. /// </summary> public bool Save() { if (!CheckPermissions("CMS.ProjectManagement", CMSAdminControl.PERMISSION_MANAGE)) { return(false); } // Validate the form if (Validate()) { // Indicates whether project is new bool isNew = false; int progress = 0; // Ensure the info object if (this.ProjectObj == null) { // New project ProjectInfo pi = new ProjectInfo(); // First initialization of the Access propery - allow authenticated users pi.ProjectAccess = 1222; pi.ProjectCreatedByID = CMSContext.CurrentUser.UserID; pi.ProjectOwner = 0; if (CommunityGroupID != 0) { pi.ProjectGroupID = CommunityGroupID; // Set default access to the group pi.ProjectAccess = 3333; } mProjectObj = pi; isNew = true; } else { // Existing project // Reset ProjectOrder if checkbox was unchecked if ((this.ProjectObj.ProjectAllowOrdering) && (!this.chkProjectAllowOrdering.Checked)) { ProjectInfoProvider.ResetProjectOrder(this.ProjectObj.ProjectID); } // Clear the hashtables if the codename has been changed if ((this.ProjectObj.ProjectGroupID > 0) && this.ProjectObj.ProjectName != this.txtProjectName.Text) { ProjectInfoProvider.Clear(true); } progress = ProjectInfoProvider.GetProjectProgress(this.ProjectObj.ProjectID); } this.ltrProjectProgress.Text = ProjectTaskInfoProvider.GenerateProgressHtml(progress, true); // Initialize object this.ProjectObj.ProjectSiteID = CMSContext.CurrentSiteID; if (DisplayMode == ControlDisplayModeEnum.Simple) { if (isNew) { this.ProjectObj.ProjectName = ValidationHelper.GetCodeName(txtProjectDisplayName.Text, 50) + ((CommunityGroupID > 0) ? "_group_" : "_general_") + this.CodenameGUID; } } else { this.ProjectObj.ProjectName = this.txtProjectName.Text.Trim(); } this.ProjectObj.ProjectDisplayName = this.txtProjectDisplayName.Text.Trim(); this.ProjectObj.ProjectDescription = this.txtProjectDescription.Text.Trim(); this.ProjectObj.ProjectStartDate = this.dtpProjectStartDate.SelectedDateTime; this.ProjectObj.ProjectDeadline = this.dtpProjectDeadline.SelectedDateTime; this.ProjectObj.ProjectOwner = ValidationHelper.GetInteger(userSelector.UniSelector.Value, 0); this.ProjectObj.ProjectStatusID = ValidationHelper.GetInteger(drpProjectStatus.SelectedValue, 0); this.ProjectObj.ProjectAllowOrdering = this.chkProjectAllowOrdering.Checked; // Set ProjectNodeID if (!this.ShowPageSelector) { // Set current node id for new project if (isNew && (CMSContext.CurrentDocument != null)) { this.ProjectObj.ProjectNodeID = CMSContext.CurrentDocument.NodeID; } } else { TreeProvider treeProvider = new TreeProvider(); TreeNode node = treeProvider.SelectSingleNode(ValidationHelper.GetGuid(this.pageSelector.Value, Guid.Empty), TreeProvider.ALL_CULTURES, CMSContext.CurrentSiteName); if (node != null) { this.ProjectObj.ProjectNodeID = node.NodeID; } else { this.ProjectObj.ProjectNodeID = 0; } } // Use try/catch due to license check try { // Save object data to database ProjectInfoProvider.SetProjectInfo(this.ProjectObj); this.ProjectID = this.ProjectObj.ProjectID; this.ItemID = this.ProjectObj.ProjectID; this.RaiseOnSaved(); // Set the info message this.lblInfo.Text = GetString("general.changessaved"); return(true); } catch (Exception ex) { lblError.Visible = true; lblError.Text = ex.Message; } } return(false); }
/// <summary> /// Updates curent Project info after uploader events (upload and delete). /// </summary> private void TouchProjectInfo() { ProjectInfoProvider.SetProjectInfo(Project); }