示例#1
0
    protected void lnkAttributes_Click(object sender, EventArgs e)
    {
        var lnkBtn = sender as ImageLinkButton;

        if (lnkBtn == null)
        {
            return;
        }

        var nodeKeyObject = NodeKeyObject.Parse(lnkBtn.CommandArgument);

        if (nodeKeyObject == null)
        {
            return;
        }

        ResetGroupAttributesForm();

        var group = DataContext.UM_Groups.FirstOrDefault(n => n.ID == nodeKeyObject.GroupID);

        if (group == null)
        {
            return;
        }

        var project = group.Project;

        if (lnkBtn.CommandName == "lnkAttributes")
        {
            hdAttributeGroupID.Value = nodeKeyObject.GroupID.ToString();

            cmbAttributeSchemas.Items.Clear();
            cmbAttributeSchemas.Items.Add(new ListEditItem("-- select schema --", Guid.Empty.ToString()));
            cmbAttributeSchemas.DataSource = project.AttributesSchemas.Where(n => n.DateDeleted == null).ToList();
            cmbAttributeSchemas.DataBind();

            cmbAttributeSchemaNodes.Items.Clear();
            cmbAttributeSchemaNodes.Items.Add(new ListEditItem("-- select node --", Guid.Empty.ToString()));
            cmbAttributeSchemaNodes.Enabled = false;

            upnlGroupAttributes.Update();
            mpeGroupAttributes.Show();
        }
        else if (lnkBtn.CommandName == "ShowAttributes")
        {
            dwAttributeSchemaNodes.DataSource = String.Empty;
            dwAttributeSchemaNodes.DataBind();

            cmbShowAttributeSchemas.Items.Clear();
            cmbShowAttributeSchemas.Items.Add(new ListEditItem("-- select schema --", Guid.Empty.ToString()));
            cmbShowAttributeSchemas.DataSource = project.AttributesSchemas.Where(n => n.DateDeleted == null).ToList();
            cmbShowAttributeSchemas.DataBind();


            hdGroupIDShow.Value = nodeKeyObject.GroupID.ToString();

            upnlShowGroupAttributes.Update();
            mpeShowGroupAttributes.Show();
        }
    }
示例#2
0
    protected void AddUser()
    {
        var loginName = tbLoginName.Text.Trim();
        var password  = tbPassword.Text.Trim();
        var firstName = tbFirstName.Text.Trim();
        var lastName  = tbLastName.Text.Trim();
        var email     = tbEmail.Text.Trim();
        var address   = tbAddress.Text.Trim();
        var passwordExpirationDate = DataConverter.ToDateTime(tbPasswordExpirationDate.Text);
        var activate = chkActivate.Checked;

        var user = InitializeUser
                   (
            loginName,
            password,
            firstName,
            lastName,
            email,
            address,
            passwordExpirationDate,
            activate
                   );

        DataContext.UM_Users.InsertOnSubmit(user);

        var nodes = tlGroups.GetSelectedNodes();

        foreach (var treeListNode in nodes)
        {
            var nodeObject = treeListNode.Key;
            var group      = NodeKeyObject.Parse(nodeObject);

            var groupUser = new UM_GroupUser
            {
                ID          = Guid.NewGuid(),
                DateCreated = DateTime.Now,
                GroupID     = @group.GroupID,
                UserID      = user.ID,
                AccessLevel = (int)Enum.Parse(typeof(AccessLevelEnum), ddlAccessLevels.SelectedItem.Value.ToString())
            };

            user.GroupUsers.Add(groupUser);
        }

        try
        {
            DataContext.SubmitChanges();
        }
        catch (Exception e)
        {
            Response.Write(e.Message);
        }

        ResetFields();
    }
示例#3
0
    protected void lnkDelete_Click(object sender, EventArgs e)
    {
        var lnkBtn = sender as ImageLinkButton;

        if (lnkBtn == null)
        {
            return;
        }

        var nodeKeyObject = NodeKeyObject.Parse(lnkBtn.CommandArgument);

        if (nodeKeyObject == null)
        {
            return;
        }

        if (nodeKeyObject.IsProjectType())
        {
            return;
        }

        if (nodeKeyObject.IsGroupType() || nodeKeyObject.IsChildType())
        {
            var @group = DataContext.UM_Groups.FirstOrDefault(n => n.ID == nodeKeyObject.GroupID);
            if (@group != null)
            {
                foreach (var groupUser in @group.GroupUsers)
                {
                    groupUser.DateDeleted = DateTime.Now;
                }

                @group.DateDeleted = DateTime.Now;
            }

            DataContext.SubmitChanges();
        }
        else if (nodeKeyObject.IsUserType())
        {
            var groupUsers = (from n in DataContext.UM_GroupUsers
                              where n.DateDeleted == null &&
                              n.GroupID == nodeKeyObject.GroupID &&
                              n.UserID == nodeKeyObject.UserID
                              select n).ToList();

            foreach (var groupUser in groupUsers)
            {
                groupUser.DateDeleted = DateTime.Now;
            }

            DataContext.SubmitChanges();
        }

        CacheEntitiesUtil.ResetAll();
        tlGroups.RefreshVirtualTree();
    }
示例#4
0
    protected void tlGroups_VirtualModeCreateChildren(object sender, TreeListVirtualModeCreateChildrenEventArgs e)
    {
        var nodeKeyObject = e.NodeObject as NodeKeyObject;

        if (nodeKeyObject == null)
        {
            var query = (from n in CacheEntitiesUtil.UmProjects.Values
                         where n.DateDeleted == null
                         select NodeKeyObject.CreateForProject(n));


            var lookup   = query.ToLookup(n => n.ToString());
            var projects = lookup.Select(n => n.First()).ToList();

            e.Children = projects;
            return;
        }

        if (nodeKeyObject.IsProjectType())
        {
            var query = from n in CacheEntitiesUtil.UmGroups.Values
                        let project = CacheEntitiesUtil.UmProjects.GetValueOrDefault(n.ProjectID)
                                      where n.DateDeleted == null && n.ProjectID == nodeKeyObject.ProjectID
                                      let parentGroup = GetParent(n)
                                                        select NodeKeyObject.CreateForGroup(project, parentGroup);

            var lookup = query.ToLookup(n => n.ToString());
            var groups = lookup.Select(n => n.First()).ToList();

            e.Children = groups;
        }
        else if (nodeKeyObject.IsGroupType() || nodeKeyObject.IsChildType())
        {
            var queryChildren = from n in CacheEntitiesUtil.UmGroups.Values
                                let project = CacheEntitiesUtil.UmProjects.GetValueOrDefault(n.ProjectID)
                                              where n.DateDeleted == null &&
                                              n.ProjectID == nodeKeyObject.ProjectID &&
                                              n.ParentID == nodeKeyObject.GroupID
                                              select NodeKeyObject.CreateForGroup(project, n, n.ParentID.GetValueOrDefault());

            var lookupChildren = queryChildren.ToLookup(n => n.ToString());
            var children       = lookupChildren.Select(n => n.First()).ToList();

            e.Children = children;
        }

        else if (nodeKeyObject.IsUserType())
        {
            return;
        }
    }
示例#5
0
    protected void tlGroups_VirtualModeNodeCreated(object sender, TreeListVirtualNodeEventArgs e)
    {
        var nodeKeyObject = NodeKeyObject.Parse(e.NodeObject);

        if (nodeKeyObject == null)
        {
            return;
        }

        if (nodeKeyObject.IsProjectType())
        {
            e.Node.AllowSelect = false;
        }
    }
示例#6
0
    protected void lnkEdit_Click(object sender, EventArgs e)
    {
        var lnkBtn = sender as ImageLinkButton;

        if (lnkBtn == null)
        {
            return;
        }

        var nodeKeyObject = NodeKeyObject.Parse(lnkBtn.CommandArgument);

        if (nodeKeyObject == null)
        {
            return;
        }

        if (nodeKeyObject.IsProjectType())
        {
            return;
        }

        if (nodeKeyObject.IsGroupType() || nodeKeyObject.IsChildType())
        {
            ResetGroupForm();

            var group = DataContext.UM_Groups.FirstOrDefault(n => n.ID == nodeKeyObject.GroupID);
            if (group == null)
            {
                return;
            }

            FillGroupForm(group);

            context.Text = "ჯგუფის რედაქტირება";
            upnlGroup.Update();
            mpeGroup.Show();
        }
        else if (nodeKeyObject.IsUserType())
        {
            return;
        }

        CacheEntitiesUtil.ResetAll();
        // tlGroups.RefreshVirtualTree();
    }
示例#7
0
    protected void lnkMessage_Click(object sender, EventArgs e)
    {
        var lnkBtn = sender as Button;

        if (lnkBtn == null)
        {
            return;
        }

        var nodeKeyObject = NodeKeyObject.Parse(lnkBtn.CommandArgument);

        if (nodeKeyObject == null)
        {
            return;
        }

        ucMessage.ObjectId = nodeKeyObject.GroupID;
        ucMessage.Show();
        ucMessage.Update();
    }
示例#8
0
    protected void tlGroups_VirtualModeCreateChildren(object sender, TreeListVirtualModeCreateChildrenEventArgs e)
    {
        var nodeKeyObject = e.NodeObject as NodeKeyObject;

        if (nodeKeyObject == null)
        {
            var query = from n in CacheEntitiesUtil.UmProjects.Values
                        select NodeKeyObject.CreateForProject(n);



            var lookup   = query.ToLookup(n => n.ToString());
            var projects = lookup.Select(n => n.First()).ToList();

            projects = projects.OrderBy(n => n.Project.Name, new StringLogicalComparer()).ToList();

            e.Children = projects;
            return;
        }

        if (nodeKeyObject.IsProjectType())
        {
            var query = from n in CacheEntitiesUtil.UmGroups.Values
                        let project = CacheEntitiesUtil.UmProjects.GetValueOrDefault(n.ProjectID)
                                      where n.DateDeleted == null && n.ProjectID == nodeKeyObject.ProjectID
                                      let parentGroup = GetParent(n)
                                                        select NodeKeyObject.CreateForGroup(project, parentGroup);



            var lookup = query.ToLookup(n => n.ToString());
            var groups = lookup.Select(n => n.First()).ToList();

            groups = groups.OrderBy(n => n.Group.Name, new StringLogicalComparer()).ToList();

            e.Children = groups;
        }
        else if (nodeKeyObject.IsGroupType() || nodeKeyObject.IsChildType())
        {
            var queryChildren = from n in CacheEntitiesUtil.UmGroups.Values
                                let project = CacheEntitiesUtil.UmProjects.GetValueOrDefault(n.ProjectID)
                                              where n.DateDeleted == null &&
                                              n.ProjectID == nodeKeyObject.ProjectID &&
                                              n.ParentID == nodeKeyObject.GroupID
                                              select NodeKeyObject.CreateForGroup(project, n, n.ParentID.GetValueOrDefault());

            var lookupChildren = queryChildren.ToLookup(n => n.ToString());
            var children       = lookupChildren.Select(n => n.First()).ToList();

            e.Children = children;

            var queryUsers = from groupUser in CacheEntitiesUtil.UmGroupUsers.Values
                             where groupUser != null
                             let @group = CacheEntitiesUtil.UmGroups.GetValueOrDefault(groupUser.GroupID)
                                          where @group != null
                                          let project = CacheEntitiesUtil.UmProjects.GetValueOrDefault(@group.ProjectID)
                                                        where project != null
                                                        let user = CacheEntitiesUtil.UmUsers.GetValueOrDefault(groupUser.UserID)
                                                                   where user != null &&
                                                                   groupUser.DateDeleted == null &&
                                                                   groupUser.GroupID == nodeKeyObject.GroupID
                                                                   select NodeKeyObject.CreateForUser(project, @group, user);

            var lookupUsers = queryUsers.ToLookup(n => n.ToString());

            var users = lookupUsers.Select(n => n.First()).ToList();
            users = users.OrderBy(n => n.User.LoginName, new StringLogicalComparer()).ToList();

            foreach (var user in users)
            {
                e.Children.Add(user);
            }
        }
        else if (nodeKeyObject.IsUserType())
        {
            return;
        }
    }
示例#9
0
    protected void lnkNew_Click(object sender, EventArgs e)
    {
        var lnkBtn = sender as LinkButton;

        if (lnkBtn == null)
        {
            return;
        }

        var nodeKeyObject = NodeKeyObject.Parse(lnkBtn.CommandArgument);

        if (nodeKeyObject == null)
        {
            return;
        }

        if (nodeKeyObject.IsProjectType())
        {
            var project = DataContext.UM_Projects.FirstOrDefault(n => n.ID == nodeKeyObject.ProjectID);
            if (project == null)
            {
                return;
            }

            hdMainGroupParentID.Value = project.ID.ToString();
            hdParentID.Value          = null;

            context.Text = "ჯგუფის დამატება";
            upnlGroup.Update();
            mpeGroup.Show();
        }

        else if (nodeKeyObject.IsGroupType() || nodeKeyObject.IsChildType())
        {
            if (lnkBtn.CommandName == "AddSubGroup")
            {
                var project = DataContext.UM_Projects.FirstOrDefault(n => n.ID == nodeKeyObject.ProjectID);
                if (project == null)
                {
                    return;
                }

                ResetGroupForm();

                hdMainGroupParentID.Value = project.ID.ToString();
                hdParentID.Value          = nodeKeyObject.GroupID.ToString();

                context.Text = "ჯგუფის დამატება";
                upnlGroup.Update();
                mpeGroup.Show();
            }
            else if (lnkBtn.CommandName == "AddUser")
            {
                ResetUsersForm();

                hdUsersGroupID.Value = nodeKeyObject.GroupID.ToString();

                upnlUsers.Update();
                mpeUsers.Show();
            }
        }
    }