Example #1
0
 /// <summary>
 /// Reader returns fields:
 ///		GroupId, GroupName
 /// </summary>
 public static IDataReader GetListGroupsWithParameters(bool IncludeEveryone,
                                                       bool IncludeAdmin, bool IncludePM, bool IncludePPM, bool IncludeHDM,
                                                       bool IncludePartner, bool IncludeSubPartners, bool IncludeExecutive,
                                                       bool IncludeRoles, bool IncludeIntranet, bool IncludeTM)
 {
     return(DBGroup.GetListGroupsWithParameters(IncludeEveryone, IncludeAdmin, IncludePM, IncludePPM, IncludeHDM, IncludePartner, IncludeSubPartners, IncludeExecutive, IncludeRoles, IncludeIntranet, IncludeTM));
 }
Example #2
0
        public static int CreatePartner(string name, PrimaryKeyId contactUid, PrimaryKeyId orgUid, ArrayList VisibleGroups, byte[] IMGroupLogo)
        {
            if (!Security.IsUserInGroup(InternalSecureGroups.Administrator))
            {
                throw new AccessDeniedException();
            }

            int PartnerId = -1;

            using (DbTransaction tran = DbTransaction.Begin())
            {
                PartnerId = DBGroup.Create((int)InternalSecureGroups.Partner, name);
                foreach (int GroupId in VisibleGroups)
                {
                    DBGroup.AddPartnerGroup(PartnerId, GroupId);
                }

                int IMGroupId = IMGroup.Create(name, "2B6087", true, IMGroupLogo, new ArrayList(), new ArrayList());

                DBGroup.UpdateIMGroupId(PartnerId, IMGroupId);
                DBGroup.UpdateClient(PartnerId, contactUid, orgUid);

                tran.Commit();
            }

            return(PartnerId);
        }
Example #3
0
        public static void Delete(int group_id)
        {
            if (!CanDelete(group_id))
            {
                throw new AccessDeniedException();
            }

            int IMGroupId = -1;

            using (IDataReader reader = DBGroup.GetGroup(group_id))
            {
                if (reader.Read())
                {
                    if (reader["IMGroupId"] != DBNull.Value)
                    {
                        IMGroupId = (int)reader["IMGroupId"];
                    }
                }
            }

            using (DbTransaction tran = DbTransaction.Begin())
            {
                DBGroup.Delete(group_id);

                if (IMGroupId > 0)
                {
                    IMGroup.Delete(IMGroupId);
                }

                tran.Commit();
            }
        }
Example #4
0
        /// <summary>
        /// Reader returns fields:
        ///		GroupId, GroupName, HasChildren
        /// </summary>
        public static IDataReader GetListChildGroups(int group_id)
        {
            if (!CanRead(group_id))
            {
                throw new AccessDeniedException();
            }

            return(DBGroup.GetListChildGroups(group_id));
        }
Example #5
0
        public static void UpdateGroup(int group_id, int parent_group_id)
        {
            if (!CanMove(group_id))
            {
                throw new AccessDeniedException();
            }

            DBGroup.ChangeParent(group_id, parent_group_id);
        }
Example #6
0
        public static void UpdateGroup(int group_id, string name)
        {
            if (!CanUpdate() || group_id <= 9)
            {
                throw new AccessDeniedException();
            }

            DBGroup.Update(group_id, name);
        }
Example #7
0
        public static int Create(int parent_group_id, string name)
        {
            if (!CanCreate(parent_group_id))
            {
                throw new AccessDeniedException();
            }

            return(DBGroup.Create(parent_group_id, name));
        }
Example #8
0
 /// <summary>
 /// Reader returns fields:
 ///		GroupId, GroupName, HasChildren
 /// </summary>
 public static IDataReader GetListGroupsBySubstring(string SubString)
 {
     if (!Security.IsUserInGroup(InternalSecureGroups.Partner))
     {
         return(DBGroup.GetListGroupsBySubstring(SubString));
     }
     else
     {
         return(DBGroup.GetListGroupsBySubstringForPartner(SubString, Security.CurrentUser.UserID));
     }
 }
Example #9
0
 /// <summary>
 /// Reader returns fields:
 ///		GroupId, GroupName
 /// </summary>
 public static IDataReader GetListAvailableGroups()
 {
     if (!Security.IsUserInGroup(InternalSecureGroups.Partner))
     {
         return(DBGroup.GetListAvailableGroups());
     }
     else
     {
         return(DBGroup.GetListAvailableGroupsForPartner(Security.CurrentUser.UserID));
     }
 }
Example #10
0
        public static IDataReader GetListAllActiveUsersInGroup(int group_id, bool check_security)
        {
            if (check_security)
            {
                if (!CanRead(group_id))
                {
                    throw new AccessDeniedException();
                }
            }

            return(DBGroup.GetListAllActiveUsersInGroup(group_id));
        }
Example #11
0
 /// <summary>
 /// Reader returns fields:
 ///		GroupId, GroupName, Level
 /// </summary>
 public static IDataReader GetListGroupsAsTreeForIBN()
 {
     if (!Security.IsUserInGroup(InternalSecureGroups.Partner))
     {
         return(DBGroup.GetListGroupsAsTreeForIBN());
     }
     else
     {
         int PartnerGroupId = DBGroup.GetGroupForPartnerUser(Security.CurrentUser.UserID);
         return(DBGroup.GetListGroupsByPartner(PartnerGroupId, true, false));
     }
 }
Example #12
0
        public static string GetGroupName(int group_id)
        {
            string GroupName = "";

            using (IDataReader reader = DBGroup.GetGroup(group_id))
            {
                if (reader.Read())
                {
                    GroupName = reader["GroupName"].ToString();
                }
            }

            return(GroupName);
        }
Example #13
0
        public static void UpdatePartner(int PartnerId, PrimaryKeyId contactUid, PrimaryKeyId orgUid, string Name, ArrayList VisibleGroups)
        {
            if (!Security.IsUserInGroup(InternalSecureGroups.Administrator))
            {
                throw new AccessDeniedException();
            }

            // VisibleGroups
            ArrayList NewGroups     = new ArrayList(VisibleGroups);
            ArrayList DeletedGroups = new ArrayList();

            using (IDataReader reader = DBGroup.GetListGroupsByPartner(PartnerId, false, true))
            {
                while (reader.Read())
                {
                    int GroupId = (int)reader["GroupId"];
                    if (NewGroups.Contains(GroupId))
                    {
                        NewGroups.Remove(GroupId);
                    }
                    else
                    {
                        DeletedGroups.Add(GroupId);
                    }
                }
            }

            using (DbTransaction tran = DbTransaction.Begin())
            {
                DBGroup.Update(PartnerId, Name);

                // Remove Groups
                foreach (int GroupId in DeletedGroups)
                {
                    DBGroup.DeletePartnerGroup(PartnerId, GroupId);
                }

                // Add Groups
                foreach (int GroupId in NewGroups)
                {
                    DBGroup.AddPartnerGroup(PartnerId, GroupId);
                }

                DBGroup.UpdateClient(PartnerId, contactUid, orgUid);

                tran.Commit();
            }
        }
Example #14
0
        /// <summary>
        ///		GroupId, GroupName
        /// </summary>
        public static DataTable GetListGroupsAsTreeDataTable()
        {
            DataTable dt;

            if (!Security.IsUserInGroup(InternalSecureGroups.Partner))
            {
                dt = new DataTable();
                dt.Columns.Add("GroupId", typeof(int));
                dt.Columns.Add("GroupName", typeof(string));
                GenerateTree(1, 0, ref dt);
            }
            else
            {
                int PartnerGroupId = DBGroup.GetGroupForPartnerUser(Security.CurrentUser.UserID);
                dt = DBGroup.GetListGroupsByPartnerDataTable(PartnerGroupId, true, false);
            }

            return(dt);
        }
Example #15
0
        private static void GenerateTree(int ParentGroupId, int CurrentLevel, ref DataTable dt)
        {
            List <GroupInfo> groups = new List <GroupInfo>();

            using (IDataReader reader = DBGroup.GetListChildGroups(ParentGroupId))
            {
                while (reader.Read())
                {
                    GroupInfo gi = new GroupInfo((int)reader["GroupId"], Common.GetWebResourceString(reader["GroupName"].ToString()), (bool)reader["HasChildren"]);
                    groups.Add(gi);
                }
            }

            // sorting
            groups.Sort(delegate(GroupInfo x, GroupInfo y) { return(x.GroupName.CompareTo(y.GroupName)); });

            string Prefix = "";

            for (int i = 0; i < CurrentLevel; i++)
            {
                Prefix += "  ";
            }

            CurrentLevel++;

            foreach (GroupInfo group in groups)
            {
                DataRow dr = dt.NewRow();
                dr["GroupId"]   = group.GroupId;
                dr["GroupName"] = Prefix + group.GroupName;
                dt.Rows.Add(dr);

                if (group.HasChildren)
                {
                    GenerateTree(group.GroupId, CurrentLevel, ref dt);
                }
            }
        }
Example #16
0
        public static bool CanRead(int GroupId)
        {
            bool RetVal = false;

            if (Security.IsUserInGroup(InternalSecureGroups.Partner))
            {
                int PartnerGroupId = DBGroup.GetGroupForPartnerUser(Security.CurrentUser.UserID);

                if (PartnerGroupId > 0)
                {
                    do
                    {
                        RetVal  = DBGroup.CheckGroupVisibilityForPartnerGroup(PartnerGroupId, GroupId);
                        GroupId = GetParentGroup(GroupId);
                    }while (!(GroupId <= 0 || RetVal));
                }
            }
            else
            {
                RetVal = true;
            }

            return(RetVal);
        }
Example #17
0
 /// <summary>
 /// Reader returns fields:
 ///		PartnerId, GroupId, GroupName
 /// </summary>
 public static IDataReader GetListGroupsByPartner(int PartnerId)
 {
     return(DBGroup.GetListGroupsByPartner(PartnerId, false, true));
 }
Example #18
0
 /// <summary>
 /// Reader returns fields:
 ///		GroupId, GroupName, IMGroupId, ContactUid, OrgUid
 /// </summary>
 public static IDataReader GetGroup(int group_id)
 {
     return(DBGroup.GetGroup(group_id));
 }
Example #19
0
 public static int GetParentGroup(int group_id)
 {
     return(DBGroup.GetParentGroup(group_id));
 }
Example #20
0
 /// <summary>
 /// Reader returns fields:
 ///		UserId, Login, FirstName, LastName, Email, IMGroupId, CreatedBy, Activity, IsExternal
 /// </summary>
 public static IDataReader GetListAllUsersIn2Group(int Group1Id, int Group2Id)
 {
     return(DBGroup.GetListAllUsersIn2Group(Group1Id, Group2Id));
 }
Example #21
0
 public static bool CheckChildren(int group_id)
 {
     return((DBGroup.CheckChildren(group_id) == 1)?true:false);
 }
Example #22
0
 /// <summary>
 /// Reader returns fields:
 ///		GroupId, GroupName
 /// </summary>
 public static IDataReader GetListGroupsForMove(int group_id)
 {
     return(DBGroup.GetListGroupsForMove(group_id));
 }