コード例 #1
0
ファイル: AddGroup.ascx.cs プロジェクト: alex765022/IBN
        protected void btnSave_ServerClick(object sender, System.EventArgs e)
        {
            Page.Validate();
            if (!Page.IsValid)
            {
                return;
            }

            string    sGroups  = iGroups.Value;
            ArrayList alGroups = new ArrayList();

            while (sGroups.Length > 0)
            {
                alGroups.Add(Int32.Parse(sGroups.Substring(0, sGroups.IndexOf(","))));
                sGroups = sGroups.Remove(0, sGroups.IndexOf(",") + 1);
            }

            // Client
            PrimaryKeyId orgUid     = PrimaryKeyId.Empty;
            PrimaryKeyId contactUid = PrimaryKeyId.Empty;

            if (ClientControl.ObjectType == OrganizationEntity.GetAssignedMetaClassName())
            {
                orgUid = ClientControl.ObjectId;
            }
            else if (ClientControl.ObjectType == ContactEntity.GetAssignedMetaClassName())
            {
                contactUid = ClientControl.ObjectId;
            }

            if (edit == "1")
            {
                if (groupId == (int)InternalSecureGroups.Partner || SecureGroup.IsPartner(groupId))
                {
                    SecureGroup.UpdatePartner(groupId, contactUid, orgUid, tbGroupTitle.Text, alGroups);
                }
                else
                {
                    SecureGroup.UpdateGroup(groupId, tbGroupTitle.Text);
                }
                Response.Redirect("../Directory/Directory.aspx?Tab=0&SGroupID=" + groupId.ToString());
            }
            else
            {
                int newGroupId = 1;
                if (groupId == (int)InternalSecureGroups.Partner || SecureGroup.IsPartner(groupId))
                {
                    byte[] groupLogo = null;

                    FileInfo   fi = new FileInfo(Server.MapPath(GlobalResourceManager.Strings["IMGroupLogoUrl"]));
                    FileStream fs = fi.OpenRead();
                    groupLogo = new byte[fi.Length];
                    int nBytesRead = fs.Read(groupLogo, 0, (int)fi.Length);

                    newGroupId = SecureGroup.CreatePartner(tbGroupTitle.Text, contactUid, orgUid, alGroups, groupLogo);
                }
                else
                {
                    newGroupId = SecureGroup.Create(groupId, tbGroupTitle.Text);
                }
                Response.Redirect("../Directory/Directory.aspx?Tab=0");
            }
        }