Beispiel #1
0
        public static int Clone(int FromIMGroupId, string IMGroupName, string Color, byte[] IMGroupLogo, ArrayList YouCanSeeGroups, ArrayList CanSeeYouGroups)
        {
            if (!Company.CheckDiskSpace())
            {
                throw new MaxDiskSpaceException();
            }

            if (!CanCreate())
            {
                throw new AccessDeniedException();
            }

            int IMGroupId = -1;

            using (DbTransaction tran = DbTransaction.Begin())
            {
                IMGroupId = DBIMGroup.CreateUpdate(-1, IMGroupName, Color, false);

                if (IMGroupLogo != null)
                {
                    DBIMGroup.UpdateIMGroupLogo(IMGroupId, IMGroupLogo);
                }
                else
                {
                    DBIMGroup.CloneIMGroupLogo(FromIMGroupId, IMGroupId);
                }

                // You Can See Groups
                foreach (int GroupId in YouCanSeeGroups)
                {
                    DBIMGroup.AddDependences(IMGroupId, GroupId);
                }

                // Can See You Groups
                foreach (int GroupId in CanSeeYouGroups)
                {
                    DBIMGroup.AddDependences(GroupId, IMGroupId);
                }
                tran.Commit();
            }

            return(IMGroupId);
        }
Beispiel #2
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();
            }
        }
Beispiel #3
0
        public static void Update(
            int imGroupId
            , string imGroupName
            , string color
            , byte[] imGroupLogo
            , ArrayList youCanSeeGroups
            , ArrayList canSeeYouGroups)
        {
            if (!CanUpdate())
            {
                throw new AccessDeniedException();
            }

            // YouCanSeeGroups
            ArrayList newYouCanSeeGroups     = new ArrayList(youCanSeeGroups);
            ArrayList deletedYouCanSeeGroups = new ArrayList();

            SeparateIems(newYouCanSeeGroups, deletedYouCanSeeGroups, DBIMGroup.GetListIMGroupsYouCanSee(imGroupId, false), "IMGroupId");

            // CanSeeYouGroups
            ArrayList newCanSeeYouGroups     = new ArrayList(canSeeYouGroups);
            ArrayList deletedCanSeeYouGroups = new ArrayList();

            SeparateIems(newCanSeeYouGroups, deletedCanSeeYouGroups, DBIMGroup.GetListIMGroupsCanSeeYou(imGroupId), "IMGroupId");

            using (DbTransaction tran = DbTransaction.Begin())
            {
                DBIMGroup.CreateUpdate(imGroupId, imGroupName, color, false);

                if (imGroupLogo != null)
                {
                    DBIMGroup.UpdateIMGroupLogo(imGroupId, imGroupLogo);
                }

                // You Can See Groups
                foreach (int groupId in deletedYouCanSeeGroups)
                {
                    DBIMGroup.DeleteDependences(imGroupId, groupId);
                }
                foreach (int groupId in newYouCanSeeGroups)
                {
                    DBIMGroup.AddDependences(imGroupId, groupId);
                }

                // Can See You Groups
                foreach (int groupId in deletedCanSeeYouGroups)
                {
                    DBIMGroup.DeleteDependences(groupId, imGroupId);
                }
                foreach (int groupId in newCanSeeYouGroups)
                {
                    DBIMGroup.AddDependences(groupId, imGroupId);
                }

                // IBN
                try
                {
                    IMManager.UpdateGroup(imGroupId);
                    foreach (int groupId in deletedCanSeeYouGroups)
                    {
                        IMManager.UpdateGroup(groupId);
                    }
                    foreach (int groupId in newCanSeeYouGroups)
                    {
                        IMManager.UpdateGroup(groupId);
                    }
                }
                catch (Exception)
                {
                }
                tran.Commit();
            }
        }