diff --git a/PROMS/VEPROMS User Interface/dlgManageSecurity.Designer.cs b/PROMS/VEPROMS User Interface/dlgManageSecurity.Designer.cs new file mode 100644 index 00000000..62dd9f2e --- /dev/null +++ b/PROMS/VEPROMS User Interface/dlgManageSecurity.Designer.cs @@ -0,0 +1,401 @@ +namespace VEPROMS +{ + partial class dlgManageSecurity + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.tcSecurity = new System.Windows.Forms.TabControl(); + this.tpGroupUsers = new System.Windows.Forms.TabPage(); + this.lstUserGroups = new System.Windows.Forms.ListBox(); + this.cmGroupMembers = new System.Windows.Forms.ContextMenuStrip(this.components); + this.addMemberToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.removeMemberToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.label7 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.tvFolders = new System.Windows.Forms.TreeView(); + this.cmFolders = new System.Windows.Forms.ContextMenuStrip(this.components); + this.createSetAdministratorGroupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.createWriterGroupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.createROEToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.createReviewerGroupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.lstUsers = new System.Windows.Forms.ListBox(); + this.cmUsers = new System.Windows.Forms.ContextMenuStrip(this.components); + this.addUserToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.editUserToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.deleteUserToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.label5 = new System.Windows.Forms.Label(); + this.lstGroupUsers = new System.Windows.Forms.ListBox(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.lstGroups = new System.Windows.Forms.ListBox(); + this.tpDefault = new System.Windows.Forms.TabPage(); + this.label8 = new System.Windows.Forms.Label(); + this.pnlGroups = new System.Windows.Forms.Panel(); + this.cmGroups = new System.Windows.Forms.ContextMenuStrip(this.components); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.deleteGroupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.tcSecurity.SuspendLayout(); + this.tpGroupUsers.SuspendLayout(); + this.cmGroupMembers.SuspendLayout(); + this.cmFolders.SuspendLayout(); + this.cmUsers.SuspendLayout(); + this.tpDefault.SuspendLayout(); + this.cmGroups.SuspendLayout(); + this.SuspendLayout(); + // + // tcSecurity + // + this.tcSecurity.Controls.Add(this.tpGroupUsers); + this.tcSecurity.Controls.Add(this.tpDefault); + this.tcSecurity.Dock = System.Windows.Forms.DockStyle.Fill; + this.tcSecurity.Location = new System.Drawing.Point(0, 0); + this.tcSecurity.Name = "tcSecurity"; + this.tcSecurity.SelectedIndex = 0; + this.tcSecurity.Size = new System.Drawing.Size(784, 564); + this.tcSecurity.TabIndex = 0; + // + // tpGroupUsers + // + this.tpGroupUsers.BackColor = System.Drawing.SystemColors.ButtonFace; + this.tpGroupUsers.Controls.Add(this.lstUserGroups); + this.tpGroupUsers.Controls.Add(this.label7); + this.tpGroupUsers.Controls.Add(this.label6); + this.tpGroupUsers.Controls.Add(this.tvFolders); + this.tpGroupUsers.Controls.Add(this.lstUsers); + this.tpGroupUsers.Controls.Add(this.label5); + this.tpGroupUsers.Controls.Add(this.lstGroupUsers); + this.tpGroupUsers.Controls.Add(this.label4); + this.tpGroupUsers.Controls.Add(this.label3); + this.tpGroupUsers.Controls.Add(this.lstGroups); + this.tpGroupUsers.Location = new System.Drawing.Point(4, 22); + this.tpGroupUsers.Name = "tpGroupUsers"; + this.tpGroupUsers.Padding = new System.Windows.Forms.Padding(3); + this.tpGroupUsers.Size = new System.Drawing.Size(776, 538); + this.tpGroupUsers.TabIndex = 2; + this.tpGroupUsers.Text = "Folders, Groups and Users"; + // + // lstUserGroups + // + this.lstUserGroups.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.lstUserGroups.ContextMenuStrip = this.cmGroupMembers; + this.lstUserGroups.FormattingEnabled = true; + this.lstUserGroups.Location = new System.Drawing.Point(530, 318); + this.lstUserGroups.Name = "lstUserGroups"; + this.lstUserGroups.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; + this.lstUserGroups.Size = new System.Drawing.Size(238, 212); + this.lstUserGroups.TabIndex = 9; + // + // cmGroupMembers + // + this.cmGroupMembers.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.addMemberToolStripMenuItem, + this.removeMemberToolStripMenuItem}); + this.cmGroupMembers.Name = "cmGroupMembers"; + this.cmGroupMembers.Size = new System.Drawing.Size(166, 48); + // + // addMemberToolStripMenuItem + // + this.addMemberToolStripMenuItem.Name = "addMemberToolStripMenuItem"; + this.addMemberToolStripMenuItem.Size = new System.Drawing.Size(165, 22); + this.addMemberToolStripMenuItem.Text = "Add Member"; + this.addMemberToolStripMenuItem.Click += new System.EventHandler(this.addMemberToolStripMenuItem_Click); + // + // removeMemberToolStripMenuItem + // + this.removeMemberToolStripMenuItem.Name = "removeMemberToolStripMenuItem"; + this.removeMemberToolStripMenuItem.Size = new System.Drawing.Size(165, 22); + this.removeMemberToolStripMenuItem.Text = "Remove Member"; + this.removeMemberToolStripMenuItem.Click += new System.EventHandler(this.removeMemberToolStripMenuItem_Click); + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(527, 302); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(103, 13); + this.label7.TabIndex = 8; + this.label7.Text = "Current User Groups"; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(8, 5); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(41, 13); + this.label6.TabIndex = 7; + this.label6.Text = "Folders"; + // + // tvFolders + // + this.tvFolders.ContextMenuStrip = this.cmFolders; + this.tvFolders.HideSelection = false; + this.tvFolders.Location = new System.Drawing.Point(8, 21); + this.tvFolders.Name = "tvFolders"; + this.tvFolders.Size = new System.Drawing.Size(370, 511); + this.tvFolders.TabIndex = 6; + this.tvFolders.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.tvFolders_NodeMouseClick); + // + // cmFolders + // + this.cmFolders.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.createSetAdministratorGroupToolStripMenuItem, + this.createWriterGroupToolStripMenuItem, + this.createROEToolStripMenuItem, + this.createReviewerGroupToolStripMenuItem}); + this.cmFolders.Name = "cmFolders"; + this.cmFolders.Size = new System.Drawing.Size(249, 92); + // + // createSetAdministratorGroupToolStripMenuItem + // + this.createSetAdministratorGroupToolStripMenuItem.Name = "createSetAdministratorGroupToolStripMenuItem"; + this.createSetAdministratorGroupToolStripMenuItem.Size = new System.Drawing.Size(248, 22); + this.createSetAdministratorGroupToolStripMenuItem.Text = "Create a Set Administrator Group"; + this.createSetAdministratorGroupToolStripMenuItem.Click += new System.EventHandler(this.createGroupMenuItem); + // + // createWriterGroupToolStripMenuItem + // + this.createWriterGroupToolStripMenuItem.Name = "createWriterGroupToolStripMenuItem"; + this.createWriterGroupToolStripMenuItem.Size = new System.Drawing.Size(248, 22); + this.createWriterGroupToolStripMenuItem.Text = "Create a Writer Group"; + this.createWriterGroupToolStripMenuItem.Click += new System.EventHandler(this.createGroupMenuItem); + // + // createROEToolStripMenuItem + // + this.createROEToolStripMenuItem.Name = "createROEToolStripMenuItem"; + this.createROEToolStripMenuItem.Size = new System.Drawing.Size(248, 22); + this.createROEToolStripMenuItem.Text = "Create a RO Editor Group"; + this.createROEToolStripMenuItem.Click += new System.EventHandler(this.createGroupMenuItem); + // + // createReviewerGroupToolStripMenuItem + // + this.createReviewerGroupToolStripMenuItem.Name = "createReviewerGroupToolStripMenuItem"; + this.createReviewerGroupToolStripMenuItem.Size = new System.Drawing.Size(248, 22); + this.createReviewerGroupToolStripMenuItem.Text = "Create a Reviewer Group"; + this.createReviewerGroupToolStripMenuItem.Click += new System.EventHandler(this.createGroupMenuItem); + // + // lstUsers + // + this.lstUsers.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.lstUsers.ContextMenuStrip = this.cmUsers; + this.lstUsers.FormattingEnabled = true; + this.lstUsers.Location = new System.Drawing.Point(630, 21); + this.lstUsers.Name = "lstUsers"; + this.lstUsers.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; + this.lstUsers.Size = new System.Drawing.Size(140, 277); + this.lstUsers.TabIndex = 5; + this.lstUsers.SelectedIndexChanged += new System.EventHandler(this.lstUsers_SelectedIndexChanged); + // + // cmUsers + // + this.cmUsers.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.addUserToolStripMenuItem, + this.editUserToolStripMenuItem, + this.deleteUserToolStripMenuItem}); + this.cmUsers.Name = "cmUsers"; + this.cmUsers.Size = new System.Drawing.Size(134, 70); + // + // addUserToolStripMenuItem + // + this.addUserToolStripMenuItem.Name = "addUserToolStripMenuItem"; + this.addUserToolStripMenuItem.Size = new System.Drawing.Size(133, 22); + this.addUserToolStripMenuItem.Text = "Add User"; + this.addUserToolStripMenuItem.Click += new System.EventHandler(this.addUserToolStripMenuItem_Click); + // + // editUserToolStripMenuItem + // + this.editUserToolStripMenuItem.Name = "editUserToolStripMenuItem"; + this.editUserToolStripMenuItem.Size = new System.Drawing.Size(133, 22); + this.editUserToolStripMenuItem.Text = "Edit User"; + this.editUserToolStripMenuItem.Click += new System.EventHandler(this.editUserToolStripMenuItem_Click); + // + // deleteUserToolStripMenuItem + // + this.deleteUserToolStripMenuItem.Name = "deleteUserToolStripMenuItem"; + this.deleteUserToolStripMenuItem.Size = new System.Drawing.Size(133, 22); + this.deleteUserToolStripMenuItem.Text = "Delete User"; + this.deleteUserToolStripMenuItem.Click += new System.EventHandler(this.deleteUserToolStripMenuItem_Click); + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(630, 6); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(34, 13); + this.label5.TabIndex = 4; + this.label5.Text = "Users"; + // + // lstGroupUsers + // + this.lstGroupUsers.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.lstGroupUsers.ContextMenuStrip = this.cmGroupMembers; + this.lstGroupUsers.FormattingEnabled = true; + this.lstGroupUsers.Location = new System.Drawing.Point(384, 318); + this.lstGroupUsers.Name = "lstGroupUsers"; + this.lstGroupUsers.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; + this.lstGroupUsers.Size = new System.Drawing.Size(140, 212); + this.lstGroupUsers.TabIndex = 3; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(384, 302); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(103, 13); + this.label4.TabIndex = 2; + this.label4.Text = "Current Group Users"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(381, 6); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(41, 13); + this.label3.TabIndex = 1; + this.label3.Text = "Groups"; + // + // lstGroups + // + this.lstGroups.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.lstGroups.ContextMenuStrip = this.cmGroups; + this.lstGroups.FormattingEnabled = true; + this.lstGroups.Location = new System.Drawing.Point(384, 21); + this.lstGroups.Name = "lstGroups"; + this.lstGroups.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; + this.lstGroups.Size = new System.Drawing.Size(240, 277); + this.lstGroups.TabIndex = 0; + this.lstGroups.SelectedIndexChanged += new System.EventHandler(this.lstGroups_SelectedIndexChanged); + // + // tpDefault + // + this.tpDefault.BackColor = System.Drawing.SystemColors.ButtonFace; + this.tpDefault.Controls.Add(this.label8); + this.tpDefault.Controls.Add(this.pnlGroups); + this.tpDefault.Location = new System.Drawing.Point(4, 22); + this.tpDefault.Name = "tpDefault"; + this.tpDefault.Padding = new System.Windows.Forms.Padding(3); + this.tpDefault.Size = new System.Drawing.Size(776, 538); + this.tpDefault.TabIndex = 0; + this.tpDefault.Text = "Default Group"; + // + // label8 + // + this.label8.Location = new System.Drawing.Point(234, 6); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(534, 172); + this.label8.TabIndex = 5; + this.label8.Text = "label8"; + // + // pnlGroups + // + this.pnlGroups.AutoScroll = true; + this.pnlGroups.Location = new System.Drawing.Point(3, 6); + this.pnlGroups.Name = "pnlGroups"; + this.pnlGroups.Size = new System.Drawing.Size(227, 526); + this.pnlGroups.TabIndex = 4; + // + // cmGroups + // + this.cmGroups.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.deleteGroupToolStripMenuItem}); + this.cmGroups.Name = "cmGroups"; + this.cmGroups.Size = new System.Drawing.Size(144, 26); + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(61, 4); + // + // deleteGroupToolStripMenuItem + // + this.deleteGroupToolStripMenuItem.Name = "deleteGroupToolStripMenuItem"; + this.deleteGroupToolStripMenuItem.Size = new System.Drawing.Size(191, 22); + this.deleteGroupToolStripMenuItem.Text = "Delete Group"; + this.deleteGroupToolStripMenuItem.Click += new System.EventHandler(this.deleteGroupToolStripMenuItem_Click); + // + // dlgManageSecurity + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.ClientSize = new System.Drawing.Size(784, 564); + this.Controls.Add(this.tcSecurity); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "dlgManageSecurity"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Manage Security"; + this.Load += new System.EventHandler(this.dlgManageSecurity_Load); + this.tcSecurity.ResumeLayout(false); + this.tpGroupUsers.ResumeLayout(false); + this.tpGroupUsers.PerformLayout(); + this.cmGroupMembers.ResumeLayout(false); + this.cmFolders.ResumeLayout(false); + this.cmUsers.ResumeLayout(false); + this.tpDefault.ResumeLayout(false); + this.cmGroups.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TabControl tcSecurity; + private System.Windows.Forms.TabPage tpDefault; + private System.Windows.Forms.TabPage tpGroupUsers; + private System.Windows.Forms.ListBox lstGroups; + private System.Windows.Forms.ListBox lstGroupUsers; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.ContextMenuStrip cmGroups; + private System.Windows.Forms.ListBox lstUsers; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.ContextMenuStrip cmUsers; + private System.Windows.Forms.ToolStripMenuItem addUserToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem editUserToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem deleteUserToolStripMenuItem; + private System.Windows.Forms.ContextMenuStrip cmGroupMembers; + private System.Windows.Forms.ToolStripMenuItem addMemberToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem removeMemberToolStripMenuItem; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.TreeView tvFolders; + private System.Windows.Forms.ContextMenuStrip cmFolders; + private System.Windows.Forms.ToolStripMenuItem createSetAdministratorGroupToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem createWriterGroupToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem createROEToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem createReviewerGroupToolStripMenuItem; + private System.Windows.Forms.ListBox lstUserGroups; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Panel pnlGroups; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.ToolStripMenuItem deleteGroupToolStripMenuItem; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + } +} \ No newline at end of file diff --git a/PROMS/VEPROMS User Interface/dlgManageSecurity.cs b/PROMS/VEPROMS User Interface/dlgManageSecurity.cs new file mode 100644 index 00000000..fb19c163 --- /dev/null +++ b/PROMS/VEPROMS User Interface/dlgManageSecurity.cs @@ -0,0 +1,405 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using VEPROMS.CSLA.Library; +using Volian.Base.Library; + + +namespace VEPROMS +{ + public partial class dlgManageSecurity : Form + { + #region Log4Net + private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + #endregion + private User myUser; + private GroupInfoList myGroupInfoList; + private UserInfoList myUserInfoList; + private List myMembershipInfoList; + //private FolderInfo myFolderInfo; + private Folder myFolder; + + public dlgManageSecurity() + { + InitializeComponent(); + } + + //private void btnApplyPassword_Click(object sender, EventArgs e) + //{ + // string pw = txtVolianPassword.Text; + // if (pw == "V3Pr0m5") + // { + // MessageBox.Show("You have entered the correct password. You will now be defined as the Administrator for VEPROMS", "Correct Password"); + // User user = User.MakeUser(VlnSettings.UserID, "", "", "", "", "", "", "", "", "", "", DateTime.Now, VlnSettings.UserID); + // Group group = Group.GetByGroupName("Administrators"); + // Membership m = Membership.MakeMembership(user, group, null, ""); + // tcSecurity.TabPages.Add(tpGroupUsers); + // tcSecurity.TabPages.Remove(tpDefault); + // SetupSecurity(); + // } + // else + // { + // MessageBox.Show("You have entered an incorrect password", "Incorrect Password"); + // this.Close(); + // } + //} + + private void dlgManageSecurity_Load(object sender, EventArgs e) + { + myFolder = Folder.Get(1); + SetupSecurity(); + SetupGroups(); + } + private void SetupGroups() + { + pnlGroups.Controls.Clear(); + //GroupInfoList gil = GroupInfoList.Get(); + foreach (GroupInfo gi in myGroupInfoList) + { + RadioButton rb = new RadioButton(); + rb.Text = gi.GroupName; + rb.Parent = pnlGroups; + rb.Dock = DockStyle.Top; + rb.Tag = gi; + rb.CheckedChanged += new EventHandler(rb_CheckedChanged); + pnlGroups.Controls.Add(rb); + rb.BringToFront(); + if (myFolder.FolderConfig.Security_Group == 0 && gi.GID == 1) + { + myFolder.FolderConfig.Security_Group = gi.GID; + rb.Checked = true; + myFolder.Save(); + } + else if (myFolder.FolderConfig.Security_Group == gi.GID) + { + rb.Checked = true; + } + } + } + + void rb_CheckedChanged(object sender, EventArgs e) + { + RadioButton rb = sender as RadioButton; + GroupInfo gi = rb.Tag as GroupInfo; + label8.Text = gi.GroupAssignments[0].MyRole.Title + " for " + gi.GroupAssignments[0].MyFolder.Name; + myFolder.FolderConfig.Security_Group = gi.GID; + myFolder.Save(); + } + private void SetupSecurity() + { + if (tvFolders.Nodes.Count == 0) + { + FolderInfo fi = FolderInfo.Get(1); + LoadChildFolders(fi, null); + } + lstGroupUsers.Items.Clear(); + lstUsers.Items.Clear(); + lstGroups.Items.Clear(); + GroupInfoList.Reset(); + UserInfoList.Reset(); + myGroupInfoList = GroupInfoList.Get(); + myUserInfoList = UserInfoList.Get(); + foreach (GroupInfo gi in myGroupInfoList) + lstGroups.Items.Add(gi.GroupName); + lstGroups.SelectedIndex = 0; + foreach (UserInfo ui in myUserInfoList) + lstUsers.Items.Add(ui.UserID); + lstGroups.SelectedIndex = -1; + lstUsers.SelectedIndex = -1; + } + + private void LoadChildFolders(FolderInfo fi, TreeNode tn) + { + if (tn == null) + { + tn = tvFolders.Nodes.Add(fi.Name); + tn.Tag = fi; + } + else + { + tn = tn.Nodes.Add(fi.Name); + tn.Tag = fi; + } + if (fi.ChildFolderCount > 0) + { + foreach (FolderInfo fic in fi.ChildFolders) + { + LoadChildFolders(fic, tn); + } + } + } + + private void lstGroups_SelectedIndexChanged(object sender, EventArgs e) + { + myMembershipInfoList = new List(); + lstGroupUsers.Items.Clear(); + if (lstGroups.SelectedIndex > -1) + { + GroupInfo gi = myGroupInfoList[lstGroups.SelectedIndex]; + if (gi.GroupMembershipCount > 0) + foreach (MembershipInfo mi in gi.GroupMemberships) + { + if (mi.EndDate == null || mi.EndDate == string.Empty) + { + myMembershipInfoList.Add(mi); + lstGroupUsers.Items.Add(mi.MyUser.UserID); + } + } + } + } + + private void addMemberToolStripMenuItem_Click(object sender, EventArgs e) + { + if (lstGroups.SelectedIndices.Count < 1) + { + MessageBox.Show(this, "You must select at least one Group to proceed", "Missing Group"); + return; + } + if (lstUsers.SelectedIndices.Count < 1) + { + MessageBox.Show(this, "You must select at least one User to proceed", "Missing User"); + return; + } + int groupIndex = lstGroups.SelectedIndex; + int userIndex = lstUsers.SelectedIndex; + foreach (int gg in lstGroups.SelectedIndices) + { + foreach (int uu in lstUsers.SelectedIndices) + { + GroupInfo gi = myGroupInfoList[gg]; + UserInfo ui = myUserInfoList[uu]; + bool addOK = true; + if (gi.GroupMembershipCount > 0) + { + foreach (MembershipInfo mi in gi.GroupMemberships) + if (mi.MyUser.UID == ui.UID && (mi.EndDate == null || mi.EndDate == string.Empty)) + { + addOK = false; + break; + } + } + if (addOK) + { + Membership.MakeMembership(User.Get(ui.UID), Group.Get(gi.GID), null, ""); + } + else + MessageBox.Show(this, string.Format("User {0} is already a member of group {1}", ui.UserID, gi.GroupName), "User In Group"); + } + } + SetupSecurity(); + lstGroups.SelectedIndex = groupIndex; + lstUsers.SelectedIndex = userIndex; + } + + private void removeMemberToolStripMenuItem_Click(object sender, EventArgs e) + { + if (lstGroups.SelectedIndices.Count < 1) + { + MessageBox.Show(this, "You must select at least one Group to proceed", "Missing Group"); + return; + } + if (lstGroupUsers.SelectedIndices.Count < 1) + { + MessageBox.Show(this, "You must select at least one Group Member to proceed", "Missing Group Member"); + return; + } + string msg = lstGroupUsers.SelectedIndices.Count > 1 ? "Are you sure you want to remove these Group Members?" : "Are you sure you want to remove this Group Member?"; + if (MessageBox.Show(this, msg, "Confirm Group Member Removal", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) + { + foreach (int gg in lstGroups.SelectedIndices) + { + GroupInfo gi = myGroupInfoList[gg]; + foreach (MembershipInfo mi in gi.GroupMemberships) + { + foreach (int mm in lstGroupUsers.SelectedIndices) + { + MembershipInfo mig = myMembershipInfoList[mm]; + if (mi.MyUser.UID == mig.MyUser.UID) + { + Membership m = Membership.Get(mi.UGID); + m.EndDate = DateTime.Now.ToShortDateString(); + m.Save(); + } + } + } + } + SetupSecurity(); + } + } + + private void addUserToolStripMenuItem_Click(object sender, EventArgs e) + { + //to do add user manually + /* + * create new input form + * get userid + * create user + * add to default group + * + */ + User u = User.MakeUser("[Enter New UserID]","", "", "", "", "", "", "", "", "", "",DateTime.Now,""); + frmManageUser frm = new frmManageUser(); + frm.MyUser = u; + if (frm.ShowDialog(this) == DialogResult.OK) + { + u = frm.MyUser; + u.Save(); + Membership.MakeMembership(u, Group.Get(myFolder.FolderConfig.Security_Group), "", ""); + SetupSecurity(); + } + else + { + u.Delete(); + } + } + + private void editUserToolStripMenuItem_Click(object sender, EventArgs e) + { + if (lstUsers.SelectedIndex == -1) + { + MessageBox.Show("You must select a user to edit", "No User Selected", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + UserInfo ui = myUserInfoList[lstUsers.SelectedIndex]; + using (User u = User.Get(ui.UID)) + { + frmManageUser frm = new frmManageUser(); + frm.MyUser = u; + if (frm.ShowDialog(this) == DialogResult.OK) + { + frm.MyUser.Save(); + } + } + } + + private void deleteUserToolStripMenuItem_Click(object sender, EventArgs e) + { + if (lstUsers.SelectedIndex == -1) + { + MessageBox.Show("You must select a user to delete", "No User Selected", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + UserInfo ui = myUserInfoList[lstUsers.SelectedIndex]; + SessionInfoList sil = SessionInfoList.Get(); + foreach (SessionInfo si in sil) + { + if (si.UserID == ui.UserID) + { + MessageBox.Show("The user selected has an active session. You may not delete the user at this time.", "User Active Session", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + } + int k = 0; + foreach (MembershipInfo mi in ui.UserMemberships) + { + if (mi.EndDate == null || mi.EndDate == string.Empty) + k++; + } + if (k > 0) + { + MessageBox.Show("You must remove user from all groups that user is a member of in order to delete user", "User Has Memberships", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + if (MessageBox.Show("Are you sure you want to delete this user?", "Confirm Deleting User", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) + { + User.Delete(ui.UID); + SetupSecurity(); + } + //to do delete user + //end date user memberships + //delete user + } + + private void createGroupMenuItem(object sender, EventArgs e) + { + try + { + ToolStripDropDownItem tsddi = sender as ToolStripDropDownItem; + TreeNode tn = tvFolders.SelectedNode; + FolderInfo fi = tn.Tag as FolderInfo; + AddNewGroup(tsddi.Text, fi); + SetupSecurity(); + } + catch (Exception ex) + { + _MyLog.Warn("createGroupMenuItem", ex); + } + } + + private void AddNewGroup(string txt, FolderInfo fi) + { + txt = txt.Replace("Create", "").Replace(" a ", "").Replace("Group", "").Trim(); + RoleInfoList ril = RoleInfoList.Get(); + foreach(RoleInfo ri in ril) + { + if (ri.Name == txt) + { + string gin = string.Format("{0}s - {1}", ri.Name, fi.Name); + bool addOK = true; + foreach (GroupInfo gi in myGroupInfoList) + { + if (gin == gi.GroupName) + { + addOK = false; + break; + } + } + if (addOK) + { + Group group = Group.MakeGroup(gin, null, null); + Assignment.MakeAssignment(group, Role.Get(ri.RID), Folder.Get(fi.FolderID), null); + } + } + } + GroupInfoList.Reset(); + myGroupInfoList = GroupInfoList.Get(); + SetupGroups(); + } + + private void lstUsers_SelectedIndexChanged(object sender, EventArgs e) + { + /* + myMembershipInfoList = new List(); + lstGroupUsers.Items.Clear(); + GroupInfo gi = myGroupInfoList[lstGroups.SelectedIndex]; + if(gi.GroupMembershipCount > 0) + foreach (MembershipInfo mi in gi.GroupMemberships) + { + if (mi.EndDate == null || mi.EndDate == string.Empty) + { + myMembershipInfoList.Add(mi); + lstGroupUsers.Items.Add(mi.MyUser.UserID); + } + } + */ + lstUserGroups.Items.Clear(); + if(lstUsers.SelectedIndex > -1){ + UserInfo ui = myUserInfoList[lstUsers.SelectedIndex]; + if (ui.UserMembershipCount > 0) + { + foreach (MembershipInfo mi in ui.UserMemberships) + { + if (mi.EndDate == null || mi.EndDate == string.Empty) + { + lstUserGroups.Items.Add(mi.MyGroup.GroupName); + } + } + } + } + } + + private void tvFolders_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) + { + tvFolders.SelectedNode = e.Node; + } + + private void deleteGroupToolStripMenuItem_Click(object sender, EventArgs e) + { + MessageBox.Show("here"); + } + } +} \ No newline at end of file