コード例 #1
0
ファイル: IMGroup.cs プロジェクト: alex765022/IBN
        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);
        }
コード例 #2
0
ファイル: IMGroup.cs プロジェクト: alex765022/IBN
        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();
            }
        }