protected void btnSet_Click(object sender, EventArgs e) { var permissionKey = GetPermissionKey(); if (permissionKey.GroupID == Guid.Empty || permissionKey.ResourseID == Guid.Empty || permissionKey.ProjectID == Guid.Empty) { return; } var permission = GetRelatedPermission(true); if (permission == null) { permission = new UM_Permission { ID = Guid.NewGuid(), DateCreated = DateTime.Now }; } permission.GroupID = permissionKey.GroupID; permission.ResourceID = permissionKey.ResourseID; permission.RuleValue = GetDecValue(); HbSession.SubmitChanges(permission); DisplayRelatedRule(); }
protected void btnOK_Click(object sender, EventArgs e) { var model = resourceControl.Model; if (String.IsNullOrWhiteSpace(model.Name)) { lblErrorMessage.Text = "შეიყვანეთ სახელი"; mpeResource.Show(); return; } var converter = new ResourceModelEntityConverter(HbSession); var entity = HbSession.Query <UM_Resource>().FirstOrDefault(n => n.ID == model.ID); if (entity == null) { entity = new UM_Resource { ID = Guid.NewGuid(), DateCreated = DateTime.Now }; } converter.FillObject(entity, model); HbSession.SubmitChanges(entity); FillResources(); mpeResource.Hide(); }
protected void lnkDelete_Click(object sender, EventArgs e) { var lnkBtn = sender as ImageLinkButton; if (lnkBtn == null || String.IsNullOrWhiteSpace(lnkBtn.CommandArgument)) { return; } var entityID = DataConverter.ToNullableGuid(lnkBtn.CommandArgument); var permissionParameter = (from n in HbSession.Query <UM_PermissionParameter>() where n.ID == entityID && n.DateDeleted == null select n).FirstOrDefault(); if (permissionParameter == null) { return; } permissionParameter.DateDeleted = DateTime.Now; HbSession.SubmitChanges(permissionParameter); btPermissionParameter_Click(this, EventArgs.Empty); }
protected void btnOK_OnClick(object sender, EventArgs e) { var model = projectControl.Model; if (String.IsNullOrWhiteSpace(model.Name)) { lblErrorMessage.Text = "შეიყვანეთ სახელი"; mpeProject.Show(); return; } var converter = new ProjectModelEntityConverter(HbSession); var project = HbSession.Query <UM_Project>().FirstOrDefault(n => n.ID == model.ID); if (project == null) { project = new UM_Project { ID = Guid.NewGuid(), DateCreated = DateTime.Now }; } converter.FillObject(project, model); HbSession.SubmitChanges(project); FillProjectsGrid(); mpeProject.Hide(); }
protected void btUserOK_Click(object sender, EventArgs e) { var model = selectUserControl.Model; var userID = model.User.UserID; var groupID = model.ParentID; var accessLevel = DataConverter.ToNullableEnum <AccessLevelEnum>(model.AccessLevel); if (userID == null || groupID == null || accessLevel == null) { return; } var group = HbSession.Query <UM_Group>().FirstOrDefault(n => n.ID == groupID); if (group == null) { return; } var user = HbSession.Query <UM_User>().FirstOrDefault(n => n.ID == userID); if (user == null) { return; } var exists = (from n in HbSession.Query <UM_GroupUser>() where n.DateDeleted == null && n.GroupID == groupID && n.UserID == userID select n).Any(); if (exists) { return; } var groupUser = new UM_GroupUser { ID = Guid.NewGuid(), DateCreated = DateTime.Now, GroupID = groupID.Value, UserID = userID.Value, AccessLevel = (int)accessLevel }; HbSession.SubmitChanges(groupUser); FillGroupsTree(); mpeGroup.Hide(); }
protected void btnUserOK_Click(object sender, EventArgs e) { var model = createUserControl.Model; if (!ValidateUser(model)) { mpeUserForm.Show(); return; } if (String.IsNullOrWhiteSpace(model.User.Password)) { model.User.Password = "******"; } var user = HbSession.Query <UM_User>().FirstOrDefault(n => n.ID == model.User.ID); if (user == null) { user = new UM_User { ID = Guid.NewGuid(), DateCreated = DateTime.Now, }; } var converter = new UserModelEntityConverter(HbSession); converter.FillObject(user, model.User); var groups = model.Groups; if (groups != null && groups.Groups != null && groups.Groups.GroupsID != null) { foreach (var groupID in groups.Groups.GroupsID) { var groupUser = new UM_GroupUser { ID = Guid.NewGuid(), DateCreated = DateTime.Now, GroupID = groupID.Value, UserID = user.ID, AccessLevel = groups.AccessLevel }; user.GroupUsers.Add(groupUser); } } HbSession.SubmitChanges(user); FillUserGrid(); }
protected void resourcesControl_OnDelete(object sender, GenericEventArgs <Guid> e) { var entity = HbSession.Query <UM_Resource>().FirstOrDefault(n => n.ID == e.Value); if (entity == null) { return; } entity.DateDeleted = DateTime.Now; HbSession.SubmitChanges(entity); FillResources(); }
protected void btGroupOK_Click(object sender, EventArgs e) { var model = groupControl.Model; if (String.IsNullOrWhiteSpace(model.Name)) { lblGroupError.Text = "შეიყვანეთ სახელი"; mpeGroup.Show(); return; } var parent = HbSession.Query <UM_Group>().FirstOrDefault(n => n.ID == model.ParentID); var project = HbSession.Query <UM_Project>().FirstOrDefault(n => n.ID == model.ProjectID); if (project == null && parent != null) { var grandParent = parent; while (grandParent.Parent != null) { grandParent = grandParent.Parent; } model.ProjectID = grandParent.ProjectID; } var group = HbSession.Query <UM_Group>().FirstOrDefault(n => n.ID == model.ID); if (group == null) { group = new UM_Group { ID = Guid.NewGuid(), DateCreated = DateTime.Now }; } var converter = new GroupModelEntityConverter(HbSession); converter.FillObject(group, model); HbSession.SubmitChanges(group); FillGroupsTree(); mpeGroup.Hide(); }
protected void btAttributeOK_Click(object sender, EventArgs e) { var model = objectAttributeControl.Model; var groupID = model.ParentID; var nodeID = model.FieldID; var group = HbSession.Query <UM_Group>().FirstOrDefault(n => n.ID == groupID); if (group == null) { return; } var node = HbSession.Query <UM_AttributeField>().FirstOrDefault(n => n.ID == nodeID); if (node == null) { return; } var attributeValue = (from v in HbSession.Query <UM_AttributeValue>() where v.ParentID == @group.ID && v.AttributeFieldID == node.ID select v).FirstOrDefault(); if (attributeValue == null) { attributeValue = new UM_AttributeValue { ID = Guid.NewGuid(), DateCreated = DateTime.Now }; } var converter = new AttributeValueModelEntityConverter(HbSession); converter.FillObject(attributeValue, model); HbSession.SubmitChanges(attributeValue); mpeGroupAttributes.Show(); }
protected void btPermissionParameterOK_Click(object sender, EventArgs e) { var permissionID = DataConverter.ToNullableGuid(hdPermissionID.Value); var perParameterName = tbName.Text; var perParameterValue = tbValue.Text; var permissionParameter = new UM_PermissionParameter { ID = Guid.NewGuid(), DateCreated = DateTime.Now, PermissionID = permissionID.Value, Name = perParameterName, Value = perParameterValue }; HbSession.SubmitChanges(permissionParameter); btPermissionParameter_Click(this, EventArgs.Empty); }
protected void btAttributeSchemaNodeOK_Click(object sender, EventArgs e) { var model = attributeFieldControl.Model; var entity = HbSession.Get<UM_AttributeField>(model.ID.GetValueOrDefault()); if (entity == null) { entity = new UM_AttributeField { ID = Guid.NewGuid(), DateCreated = DateTime.Now, }; } var converter = new AttributeFieldModelEntityConverter(HbSession); converter.FillObject(entity, model); HbSession.SubmitChanges(entity); FillAttributesTree(); }
protected void attributesSchemasControl_OnDelete(object sender, GenericEventArgs<Guid> e) { var units = UmSchemasUtil.CreateListOfTree(HbSession); var item = units.FirstOrDefault(n => n.Key == e.Value); if (item == null) return; if (item.Type == "Schema") { var attributeSchema = HbSession.Query<UM_AttributeSchema>().FirstOrDefault(n => n.ID == item.ID); if (attributeSchema != null) { using (var transaction = HbSession.BeginTransaction()) { attributeSchema.DateDeleted = DateTime.Now; HbSession.Update(attributeSchema); foreach (var attributeSchemaNode in attributeSchema.AttributeFields) { attributeSchemaNode.DateDeleted = (attributeSchemaNode.DateDeleted ?? attributeSchema.DateDeleted); HbSession.Update(attributeSchemaNode); } transaction.Commit(); } } } else if (item.Type == "Field") { var attributeSchemaNode = HbSession.Query<UM_AttributeField>().FirstOrDefault(n => n.ID == item.ID); if (attributeSchemaNode != null) { attributeSchemaNode.DateDeleted = DateTime.Now; HbSession.SubmitChanges(attributeSchemaNode); } } FillAttributesTree(); }
protected void btnRemove_Click(object sender, EventArgs e) { var permissionKey = GetPermissionKey(); if (permissionKey.GroupID == Guid.Empty || permissionKey.ResourseID == Guid.Empty || permissionKey.ProjectID == Guid.Empty) { return; } var permission = GetRelatedPermission(true); if (permission == null) { return; } permission.DateDeleted = DateTime.Now; HbSession.SubmitChanges(permission); DisplayRelatedRule(); }