Example #1
0
 /// <summary>
 /// Gets the groups for the specified organization, excluding marked as deleted.
 /// </summary>
 /// <param name="organizationId">The identifier of the organization.</param>
 /// <returns>The table object that contains groups.</returns>
 public static ClientDataSet.GroupDataTable GetGroups(Guid organizationId)
 {
     using (GroupTableAdapter adapter = new GroupTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
     {
         return(adapter.GetGroups(organizationId));
     }
 }
Example #2
0
        /// <summary>
        /// Creates new group with specified details in specified organization.
        /// </summary>
        /// <param name="name">The name of the group.</param>
        /// <param name="description">The group description.</param>
        /// <param name="organizationId">The identifier of the organization.</param>
        /// <param name="builtIn">Whether the group is built-in.</param>
        /// <returns>The System.Guid that represents the identifier of the newly created group.</returns>
        internal static Guid InsertGroup(string name, string description, Guid organizationId, bool builtIn)
        {
            ClientDataSet.GroupDataTable table = new ClientDataSet.GroupDataTable();
            ClientDataSet.GroupRow       row   = table.NewGroupRow();

            row.GroupId        = Guid.NewGuid();
            row.Name           = name;
            row.Description    = description;
            row.OrganizationId = organizationId;
            row.BuiltIn        = builtIn;

            try
            {
                table.AddGroupRow(row);
            }
            catch (ConstraintException ex)
            {
                throw new ConstraintException(string.Format(CultureInfo.CurrentCulture, Resources.GroupProvider_ErrorMessage_GroupAlreadyExists, name), ex);
            }

            using (GroupTableAdapter adapter = new GroupTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                adapter.Update(row);
            }

            Guid groupId = row.GroupId;

            return(groupId);
        }
Example #3
0
 public static ClientDataSet.GroupRow GetGroupRow(Guid groupId)
 {
     using (GroupTableAdapter adapter = new GroupTableAdapter(OrganizationProvider.GetConnectionString(UserContext.Current.OrganizationId)))
     {
         ClientDataSet.GroupDataTable table = adapter.GetGroup(groupId);
         return((table.Count > 0) ? table[0] : null);
     }
 }
Example #4
0
        public static void DeleteGroup(Guid groupId)
        {
            ClientDataSet.GroupRow row = GetGroupRow(groupId);
            if (row != null)
            {
                row.Deleted = true;

                using (GroupTableAdapter adapter = new GroupTableAdapter(OrganizationProvider.GetConnectionString(UserContext.Current.OrganizationId)))
                {
                    adapter.Update(row);
                }
            }
        }
Example #5
0
        /// <summary>
        /// Returns the identifier of the group with specified name in the specified organization.
        /// </summary>
        /// <param name="name">The name of the group.</param>
        /// <param name="organizationId">The identifier of the organization which the group belong to.</param>
        /// <returns>The identifier of the group with specified name.</returns>
        public static Guid GetGroupIdByName(string name, Guid organizationId)
        {
            Guid groupId = Guid.Empty;

            if (!string.IsNullOrEmpty(name))
            {
                using (GroupTableAdapter adapter = new GroupTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
                {
                    ClientDataSet.GroupDataTable table = adapter.GetGroupByName(name);
                    if (table.Count > 0)
                    {
                        groupId = table[0].GroupId;
                    }
                }
            }
            return(groupId);
        }
Example #6
0
        /// <summary>
        /// Returns the list of the groups wich have the specified roles in the specified instance.
        /// </summary>
        /// <param name="organizationId">The organizations' identifier.</param>
        /// <param name="instanceId">The instance's identifier.</param>
        /// <param name="roleIdList">An array containing the unique identifiers of the roles.</param>
        /// <returns>The list of the groups.</returns>
        public static ArrayList GetGroupIdList(Guid organizationId, Guid instanceId, ArrayList roleIdList)
        {
            ArrayList groupIdList = new ArrayList();

            if (roleIdList != null)
            {
                if (roleIdList.Count > 0)
                {
                    using (GroupTableAdapter adapter = new GroupTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
                    {
                        foreach (ClientDataSet.GroupRow row in adapter.GetGroupsByRoles(organizationId, ((instanceId == Guid.Empty) ? null : new Guid?(instanceId)), Support.ConvertListToString(roleIdList).ToUpperInvariant()))
                        {
                            if (!groupIdList.Contains(row.GroupId))
                            {
                                groupIdList.Add(row.GroupId);
                            }
                        }
                    }
                }
            }
            return(groupIdList);
        }
Example #7
0
        /// <summary>
        /// Updates the details of specified group in the specified organization.
        /// </summary>
        /// <param name="groupId">The identifier of the group.</param>
        /// <param name="name">The name of the group.</param>
        /// <param name="description">The group description.</param>
        /// <param name="organizationId">The identifier of the organization.</param>
        public static void UpdateGroup(Guid groupId, string name, string description, Guid organizationId)
        {
            ClientDataSet.GroupRow row = GetGroupRow(groupId);
            if (row != null)
            {
                try
                {
                    row.Name = name;
                }
                catch (ConstraintException ex)
                {
                    throw new ConstraintException(string.Format(CultureInfo.CurrentCulture, Resources.GroupProvider_ErrorMessage_GroupAlreadyExists, name), ex);
                }

                row.Description = ((description == null) ? string.Empty : description);

                using (GroupTableAdapter adapter = new GroupTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
                {
                    adapter.Update(row);
                }
            }
        }
Example #8
0
        protected void ClearResultData()
        {
            if (MessageBox.Show("This will remove all Groups and Race results.\n" +
                                "COM Port, Locations and Categories will be left alone.\n\n" +
                                "Are you sure you want to delete Groups and Race results?", "New Race",
                                MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                GroupTableAdapter groupTableAdapter = new GroupTableAdapter();
                groupTableAdapter.Fill(_dataSet.Group);
                groupResultTableAdapter.Fill(_dataSet.GroupResult);

                foreach (DataRow row in _dataSet.Group)
                {
                    row.Delete();
                }
                foreach (DataRow row in _dataSet.GroupResult)
                {
                    row.Delete();
                }

                groupTableAdapter.Update(_dataSet.Group);
                groupResultTableAdapter.Update(_dataSet.GroupResult);
            }
        }
Example #9
0
        /// <summary>
        /// Updates the name of the built-in group that is associated to the specified instance.
        /// </summary>
        /// <param name="ds">The data sourceRow.</param>
        /// <param name="instanceId">The unique identifier of the instance.</param>
        /// <param name="name">The name of the instance.</param>
        internal static void UpdateInstanceAdministratorGroup(Guid organizationId, Guid instanceId, string name)
        {
            using (GroupTableAdapter adapter = new GroupTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                ClientDataSet.GroupDataTable table = adapter.GetGroupsByRoles(organizationId, ((instanceId == Guid.Empty) ? null : new Guid?(instanceId)), RoleProvider.InstanceAdministratorRoleId.ToString().ToUpperInvariant());
                if (table.Count > 0)
                {
                    ClientDataSet.GroupRow row = table[0];

                    try
                    {
                        row.Name = string.Format(CultureInfo.InvariantCulture, Resources.GroupProvider_InstanceAdministratorGroup_Name, name);
                    }
                    catch (ConstraintException ex)
                    {
                        throw new ConstraintException(string.Format(CultureInfo.CurrentCulture, Resources.GroupProvider_ErrorMessage_GroupAlreadyExists, name), ex);
                    }

                    row.Description = Resources.GroupProvider_InstanceAdministratorGroup_Description;

                    adapter.Update(row);
                }
            }
        }