Exemple #1
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();
            }
        }
Exemple #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);
        }
Exemple #3
0
        public static void CreateUsers(
            int GroupCount,
            int UserCount,
            string SecurityGroup,
            string GroupName,
            string Login,
            string Password,
            string FirstName,
            string LastName,
            string Email,
            int TimeZoneId,
            int LangID)
        {
            ArrayList SecGroups = new ArrayList();
            ArrayList groups    = new ArrayList();
            ArrayList YouCanSee = new ArrayList();
            ArrayList CanSeeYou = new ArrayList();

            const string NUMBER = "[%=#=%]";

            if (-1 == GroupName.IndexOf(NUMBER))
            {
                GroupName += NUMBER;
            }
            if (-1 == Login.IndexOf(NUMBER))
            {
                Login += NUMBER;
            }
            if (-1 == FirstName.IndexOf(NUMBER))
            {
                FirstName += NUMBER;
            }

            using (DbTransaction tran = DbTransaction.Begin())
            {
                int sg = SecureGroup.Create((int)InternalSecureGroups.Everyone, SecurityGroup);
                SecGroups.Add(sg);

                for (int g = 1; g <= GroupCount; g++)
                {
                    string gName = GroupName.Replace("[%=#=%]", g.ToString());
                    int    gim   = IMGroup.Create(gName, "2B6087", false, null, YouCanSee, CanSeeYou);
                    groups.Add(gim);

                    for (int u = 1; u <= UserCount; u++)
                    {
                        string su = (u + (g - 1) * UserCount).ToString();

                        string login = Login.Replace("[%=#=%]", su);
                        string fName = FirstName.Replace("[%=#=%]", su);
                        string lName = LastName.Replace("[%=#=%]", su);
                        string em    = Email.Replace("[%=#=%]", su);

                        //						HttpContext.Current.Response.Write(su+"<br>");
                        //						HttpContext.Current.Response.Flush();

                        int uim = User.Create(login, Password, fName, lName, em, true,
                                              SecGroups, gim, "", "", "", "", "", "", "", TimeZoneId, LangID, "", null, -1);
                    }
                }

                // Add groups visibility
                foreach (int g1 in groups)
                {
                    foreach (int g2 in groups)
                    {
                        if (g1 != g2)
                        {
                            DBIMGroup.AddDependences(g1, g2);
                            //							DBIMGroup.AddDependences(g2, g1);
                        }
                    }
                }

                //				throw new Exception("Test");
                tran.Commit();
            }
        }