void AddUserRow(ExtUserRightInfo tag) { int index = dgvUsers.Rows.Add(string.Format(VCAPI.GetPrettyUserName(tag.userInfo)), tag.hasProjectAdminRight, tag.defaultUnitRight == VCAPI.VC_ACCESS_RIGHTS.UPLOAD ? VC_ACCESS_UPLOAD : (tag.defaultUnitRight == VCAPI.VC_ACCESS_RIGHTS.DOWNLOAD ? VC_ACCESS_DOWNLOAD : VC_ACCESS_NONE)); dgvUsers.Rows[index].Tag = tag; }
internal VCUsers(VCAPI vcAPI) { InitializeComponent(); _vcAPI = vcAPI; colRefineRights.Visible = false; colDefaultRight.ReadOnly = false; List <UserInfo> userInfos; List <bool> adminRights; List <VCAPI.VC_ACCESS_RIGHTS> defaultRights; if (!_vcAPI.GetProjectUserRights(_vcAPI.vc_projectInfo.ProjectId, out userInfos, out adminRights, out defaultRights)) { UserInfoHandler.ShowError(_vcAPI.GetErrorMessage()); return; } colDefaultRight.Items.Add(VC_ACCESS_DOWNLOAD); colDefaultRight.Items.Add(VC_ACCESS_UPLOAD); for (int i = 0; i < userInfos.Count; ++i) { ExtUserRightInfo tag = new ExtUserRightInfo { userInfo = userInfos.ElementAt(i) }; tag.defaultUnitRight = defaultRights.ElementAt(i); tag.hasProjectAdminRight = adminRights.ElementAt(i); AddUserRow(tag); } }
internal void Init(VCAdministrator vcAdministrator, bool statusVisible, bool versionsVisible, bool commentsVisible) { _vcAdministrator = vcAdministrator; _vcAPI = _vcAdministrator._vcAPI; colStatus.Visible = statusVisible; colRemoteVersions.Visible = versionsVisible; colComment.Visible = commentsVisible; Fill(); }
internal VCRemoveBundle(VCAPI vcAPI, bool removeRelease) { InitializeComponent(); _vcAPI = vcAPI; _removeReleases = removeRelease; Cursor = Cursors.WaitCursor; List <ReleaseInfo> bundles = new List <ReleaseInfo>(); if (_removeReleases && !_vcAPI.GetReleases(out bundles)) { Cursor = Cursors.Default; UserInfoHandler.ShowError(_vcAPI.GetErrorMessage()); return; } lvBundles.Columns.Add("Generated"); if (_removeReleases) { lvBundles.Columns.Add("Name"); } lvBundles.Columns.Add("Info"); lvBundles.Columns.Add("Author"); foreach (ReleaseInfo bundle in bundles) { ListViewItem bundleDescription = new ListViewItem(); bundleDescription.Text = bundle.Date.ToString(); if (_removeReleases) { bundleDescription.SubItems.Add(bundle.Name); } bundleDescription.SubItems.Add(bundle.Message); bundleDescription.SubItems.Add(bundle.Author); bundleDescription.Tag = bundle; lvBundles.Items.Add(bundleDescription); } lvBundles.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); int indexInfoCol = _removeReleases ? 2 : 1; lvBundles.AutoResizeColumn(indexInfoCol, ColumnHeaderAutoResizeStyle.HeaderSize); lvBundles.Columns[indexInfoCol].Width = 250; if (lvBundles.Items.Count > 0) { lvBundles.Items[0].Selected = true; lvBundles.Items[0].Focused = true; lvBundles.Select(); lvBundles.Focus(); } Cursor = Cursors.Default; }
internal VCUserUnitRights(VCAPI vcAPI, UserInfo userInfo, VCAPI.VC_ACCESS_RIGHTS defaultRight, Dictionary <long, VCAPI.VC_ACCESS_RIGHTS> initialRights) { InitializeComponent(); _userId = userInfo.userId; _vcAPI = vcAPI; _defaultRight = defaultRight; _initialRights = initialRights; this.Text = this.Text + userInfo.username; List <VersionControlUnitInfo> units; if (!_vcAPI.GetRemoteUnits(_vcAPI.vc_projectInfo.ProjectId, out units)) { UserInfoHandler.ShowError(_vcAPI.GetErrorMessage()); return; } if (defaultRight == VCAPI.VC_ACCESS_RIGHTS.UPLOAD) { colWrite.HeaderText = btnAllWrite.Text = "Default"; } if (defaultRight == VCAPI.VC_ACCESS_RIGHTS.DOWNLOAD) { colRead.HeaderText = btnAllRead.Text = "Default"; } if (defaultRight == VCAPI.VC_ACCESS_RIGHTS.NONE) { colNone.HeaderText = btnAllNone.Text = "Default"; } foreach (VersionControlUnitInfo unit in units) { long unitId = unit.UnitId; VCAPI.VC_ACCESS_RIGHTS right = (_initialRights != null && _initialRights.ContainsKey(unitId)) ? _initialRights[unitId] : defaultRight; int index = dgvUnits.Rows.Add(unit.Name, unit.UnitType, right == VCAPI.VC_ACCESS_RIGHTS.UPLOAD, right == VCAPI.VC_ACCESS_RIGHTS.DOWNLOAD, right != VCAPI.VC_ACCESS_RIGHTS.UPLOAD && right != VCAPI.VC_ACCESS_RIGHTS.DOWNLOAD); dgvUnits.Rows[index].Tag = unit.UnitId; dgvUnits.Rows[index].Cells[colWrite.Index].ReadOnly = //to handle ticking manually (see dgvUnits_CellContentClick) dgvUnits.Rows[index].Cells[colRead.Index].ReadOnly = dgvUnits.Rows[index].Cells[colNone.Index].ReadOnly = true; } }
internal VCSelectProject(VCAPI vcApi, string caption, bool checkAdminRights) { InitializeComponent(); this.Text = caption; List <ProjectNode> projectInfos; List <ProjectNode> filteredProjectInfo = new List <ProjectNode>(); // If you cannot get the list of projects, then no point in opening this form if (!vcApi.GetProjectList(out projectInfos, false)) { UserInfoHandler.ShowError(vcApi.GetErrorMessage()); DialogResult = DialogResult.Cancel; Load += (s, e) => Close(); return; } foreach (ProjectNode projectInfo in projectInfos) { if (!checkAdminRights || (checkAdminRights && vcApi.HasCurrentUserProjectAdminRight(projectInfo.Id))) { lstProjects.Items.Add(string.Format("{0} {1}", projectInfo.Id, projectInfo.Name)); filteredProjectInfo.Add(projectInfo); } } if (projectInfos.Count > 0 && lstProjects.Items.Count == 0) { UserInfoHandler.ShowError("You need to have administrator rights in a project to remove it. No projects available!"); return; } lstProjects.Tag = filteredProjectInfo; if (filteredProjectInfo.Count > 0) { lstProjects.SelectedIndex = 0; lstProjects.Focus(); } }
void btnAddUsers_Click(object sender, EventArgs e) { List <UserInfo> potUserInfos = new List <UserInfo>(); List <string> potUserNames = new List <string>(); List <long> inProUserIds = new List <long>(); List <UserInfo> allUsers; foreach (DataGridViewRow row in dgvUsers.Rows) { inProUserIds.Add((row.Tag as ExtUserRightInfo).userInfo.userId); } if (!_vcAPI.GetAllUsers(out allUsers)) { UserInfoHandler.ShowError(_vcAPI.GetErrorMessage()); return; } foreach (UserInfo userInfo in allUsers) { if (!inProUserIds.Contains(userInfo.userId)) { potUserInfos.Add(userInfo); potUserNames.Add(string.Format(VCAPI.GetPrettyUserName(userInfo))); } } VCUsersAdd vcUsersAdd = new VCUsersAdd(potUserNames); if (vcUsersAdd.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) { return; } List <int> selectedIndices = vcUsersAdd.GetSelectedIndices(); if (selectedIndices.Count == 0) { return; } foreach (int selIndex in selectedIndices) { UserInfo addUserInfo = potUserInfos[selIndex]; ExtUserRightInfo tag = null; for (int remIndex = 0; remIndex < _usersToRemove.Count; ++remIndex) //check if user was in fact deleted during this section and is now re-added { if (_usersToRemove[remIndex].userInfo.userId == addUserInfo.userId) { tag = _usersToRemove[remIndex]; _usersToRemove.RemoveAt(remIndex); break; } } if (tag == null) { tag = new ExtUserRightInfo { userInfo = addUserInfo, added = true, defaultUnitRight = VCAPI.VC_ACCESS_RIGHTS.DOWNLOAD } } ; AddUserRow(tag); } } }