Beispiel #1
0
        public static bool CanDelete(int IMGroupId)
        {
            bool retval = Security.IsUserInGroup(InternalSecureGroups.Administrator);

            if (retval)                         // Check for users
            {
                using (IDataReader reader = DBIMGroup.GetListUsers(IMGroupId))
                {
                    if (reader.Read())
                    {
                        retval = false;
                    }
                }
            }

            if (retval)                         // Check for partner
            {
                DataTable table = DBIMGroup.GetIMGroup(IMGroupId, true);
                if (table.Rows.Count > 0)
                {
                    if ((bool)table.Rows[0]["is_partner"])
                    {
                        retval = false;
                    }
                }
            }
            return(retval);
        }
Beispiel #2
0
 public static void Delete(int IMGroupId)
 {
     if (!CanDelete())
     {
         throw new AccessDeniedException();
     }
     DBIMGroup.Delete(IMGroupId);
 }
Beispiel #3
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 #4
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 #5
0
        /// <summary>
        /// DataTable contains columns:
        ///		User_Id, SessionBegin, SessionEnd
        /// </summary>
        public static DataTable GetListIMSessionsByUserAndDate(int userId, DateTime startDate, DateTime endDate)
        {
            int defaultBias = User.GetCurrentBias();

            return(DBIMGroup.GetListIMSessionsByUserAndDate(userId, startDate, endDate, defaultBias));
        }
Beispiel #6
0
 /// <summary>
 /// DataTable contains columns:
 ///		IMGroupId, IMGroupName, color, logo_version, is_partner
 /// </summary>
 public static DataTable GetListIMGroupsWithoutPartners()
 {
     return(DBIMGroup.GetListIMGroupsWithoutPartners());
 }
Beispiel #7
0
 /// <summary>
 /// Reader returns fields:
 ///		client_logo
 /// </summary>
 public static IDataReader GetBinaryClientLogo(int IMGroupId)
 {
     return(DBIMGroup.GetBinaryClientLogo(IMGroupId));
 }
Beispiel #8
0
 /// <summary>
 /// DataTable contains columns:
 ///  IMGroupId, IMGroupName
 /// </summary>
 /// <returns></returns>
 public static DataTable GetListIMGroupsCanSeeYou(int imGroupId)
 {
     return(DBIMGroup.GetListIMGroupsCanSeeYou(imGroupId));
 }
Beispiel #9
0
 /// <summary>
 /// DataTable contains columns:
 ///  IMGroupId, IMGroupName
 /// </summary>
 /// <returns></returns>
 public static DataTable GetListIMGroupsYouCanSee(int IMGroupId)
 {
     return(DBIMGroup.GetListIMGroupsYouCanSee(IMGroupId, false));
 }
Beispiel #10
0
 /// <summary>
 /// Reader returns fields:
 ///		UserId, Login, FirstName, LastName, Email, IsActive, IMGroupId, OriginalId
 /// </summary>
 public static IDataReader GetListUsers(int group_id)
 {
     return(DBIMGroup.GetListUsers(group_id));
 }
Beispiel #11
0
 /// <summary>
 /// DataTable contains columns:
 ///		IMGroupId, IMGroupName, color, logo_version, is_partner
 /// </summary>
 public static DataTable GetListIMGroup()
 {
     return(DBIMGroup.GetIMGroup(0, false));
 }
Beispiel #12
0
 /// <summary>
 /// DataTable contains columns:
 ///		IMGroupId, IMGroupName, color, logo_version, is_partner
 /// </summary>
 public static DataTable GetGroup(int imGroupId)
 {
     return(DBIMGroup.GetIMGroup(imGroupId, true));
 }
Beispiel #13
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();
            }
        }