コード例 #1
0
ファイル: adreports.aspx.cs プロジェクト: jaytem/minGit
    private void GetGroupsForSync()
    {
        try
            {
                TR_count.Visible = true;
                GroupData[] group_data;
                if (Request.QueryString["max"] != null)
                {
                    if (Request.QueryString["max"] != "")
                    {
                        m_intMax = Convert.ToInt32(Request.QueryString["max"]);
                    }
                }
                m_refSiteApi = new SiteAPI();
                m_refUserApi = new UserAPI();
                settings_data = m_refSiteApi.GetSiteVariables(m_refSiteApi.UserId);
                group_data = m_refUserApi.GetCMSGroupsToSync(m_intMax);
                if (group_data == null)
                {
                    Response.Redirect("adreports.aspx?action=ViewAllReportTypes", false);
                    return;
                }
                System.Web.UI.WebControls.BoundColumn colBound = new System.Web.UI.WebControls.BoundColumn();
                colBound.DataField = "CMSUSER";
                colBound.HeaderText = m_refMsg.GetMessage("cms group name");
                colBound.HeaderStyle.CssClass = "title-header";
                colBound.HeaderStyle.Width = Unit.Percentage(20);
                colBound.ItemStyle.Wrap = false;
                colBound.ItemStyle.VerticalAlign = VerticalAlign.Top;
                AdReportsGrid.Columns.Add(colBound);

                colBound = new System.Web.UI.WebControls.BoundColumn();
                colBound.DataField = "ADUSER";
                colBound.HeaderText = m_refMsg.GetMessage("ad group name");
                colBound.HeaderStyle.CssClass = "title-header";
                colBound.HeaderStyle.Width = Unit.Percentage(20);
                colBound.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
                colBound.ItemStyle.Wrap = false;
                colBound.ItemStyle.VerticalAlign = VerticalAlign.Top;
                AdReportsGrid.Columns.Add(colBound);

                colBound = new System.Web.UI.WebControls.BoundColumn();
                colBound.DataField = "AT";
                colBound.HeaderText = "@";
                colBound.HeaderStyle.CssClass = "title-header";
                colBound.HeaderStyle.Width = Unit.Percentage(2);
                colBound.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
                colBound.ItemStyle.Wrap = false;
                colBound.ItemStyle.VerticalAlign = VerticalAlign.Top;
                AdReportsGrid.Columns.Add(colBound);

                colBound = new System.Web.UI.WebControls.BoundColumn();
                colBound.DataField = "DOMAIN";
                colBound.HeaderText = m_refMsg.GetMessage("ad domain");
                colBound.HeaderStyle.CssClass = "title-header";
                colBound.HeaderStyle.Width = Unit.Percentage(25);
                colBound.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
                colBound.ItemStyle.Wrap = false;
                colBound.ItemStyle.VerticalAlign = VerticalAlign.Top;
                AdReportsGrid.Columns.Add(colBound);

                colBound = new System.Web.UI.WebControls.BoundColumn();
                colBound.DataField = "SEARCH";
                colBound.HeaderText = m_refMsg.GetMessage("generic Search");
                colBound.HeaderStyle.CssClass = "title-header";
                colBound.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
                colBound.ItemStyle.Wrap = false;
                colBound.ItemStyle.VerticalAlign = VerticalAlign.Top;
                colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
                AdReportsGrid.Columns.Add(colBound);

                colBound = new System.Web.UI.WebControls.BoundColumn();
                colBound.DataField = "DELETE";
                colBound.HeaderText = m_refMsg.GetMessage("generic Delete title");
                colBound.HeaderStyle.CssClass = "title-header";
                colBound.ItemStyle.Wrap = false;
                colBound.ItemStyle.VerticalAlign = VerticalAlign.Top;
                AdReportsGrid.Columns.Add(colBound);

                DataTable dt = new DataTable();
                DataRow dr;
                dt.Columns.Add(new DataColumn("CMSUSER", typeof(string)));
                dt.Columns.Add(new DataColumn("ADUSER", typeof(string)));
                dt.Columns.Add(new DataColumn("AT", typeof(string)));
                dt.Columns.Add(new DataColumn("DOMAIN", typeof(string)));
                dt.Columns.Add(new DataColumn("SEARCH", typeof(string)));
                dt.Columns.Add(new DataColumn("DELETE", typeof(string)));
                int e1count = 3;
                int e2count = 4;
                string[] domainArray;
                int i = 0;
                int arrayCount = 0;
                long currentUserID = m_refUserApi.UserId;
                if (group_data.Length == m_intMax)
                {
                    TD_count.InnerHtml = m_intMax + " " + m_refMsg.GetMessage("ad groups displayed") + " <a href=\"adreports.aspx?action=GetGroupsForSynch&max=0\">" + m_refMsg.GetMessage("generic Show All") + "</a><br><br>";
                }
                if (settings_data.ADIntegration)
                {
                    for (i = 0; i <= group_data.Length - 1; i++)
                    {
                        dr = dt.NewRow();
                        domainArray = Strings.Split(group_data[i].AdGroupDomain, ",", -1, 0);
                        if (group_data[i].IsMemberShipGroup)
                        {
                            dr[0] = MemberShipGroupIcon + group_data[i].GroupName;
                        }
                        else
                        {
                            dr[0] = CmsGroupIcon + group_data[i].GroupName;
                        }
                        dr[0] += "<input type=\"hidden\" name=\"userid" + (i + 1) + "\" value=\"" + group_data[i].GroupId + "\">";
                        dr[1] = "<input type=\"text\" class=\"" + INPUTCLASS + "\" name=\"username" + (i + 1) + "\" id=\"username" + (i + 1) + "\" value=\"" + group_data[i].AdGroupName + "\" maxlength=\"255\"></td>";
                        dr[2] = "@";
                        dr[3] += "";
                        if ((domainArray.Length - 1) > 0)
                        {
                            dr[3] += "<select name=\"sel_domain" + (i + 1) + "\" onchange=\"javascript:document.forms[0].domain" + (i + 1) + ".value = document.forms.synchusers.sel_domain" + (i + 1) + ".options[document.forms[0].sel_domain" + (i + 1) + ".selectedIndex].value;\">";
                            dr[3] += "<option value=\"\" selected>" + m_refMsg.GetMessage("multiples found");
                            for (arrayCount = 0; arrayCount <= (domainArray.Length - 1); arrayCount++)
                            {
                                dr[3] += "<option value=\"" + domainArray[arrayCount] + "\">" + domainArray[arrayCount];
                            }
                            dr[3] += "</select><br>";
                            dr[3] += "<input type=\"text\" class=\"" + INPUTCLASS + "\" name=\"domain" + (i + 1) + "\" id=\"domain" + (i + 1) + "\" maxlength=\"255\">";
                        }
                        else
                        {
                            //dr(3)+="<input type=""hidden"">")
                            dr[3] += "<input type=\"text\" class=\"" + INPUTCLASS + "\" name=\"domain" + (i + 1) + "\" id=\"domain" + (i + 1) + "\" value=\"" + group_data[i].AdGroupDomain + "\" maxlength=\"255\">";
                        }
                        dr[4] = "<a href=\"#\" OnClick=\"javascript:PopUpWindow(\'users.aspx?action=MapCMSUserGroupToAD&id=" + group_data[i].GroupId + "&f=0&e1=" + "username" + (i + 1) + "&e2=" + "domain" + (i + 1) + "&rp=3\',\'Summary\',690,380,1,1);\">" + m_refMsg.GetMessage("generic Search") + "</a>";
                        if (group_data[i].GroupId == (int) currentUserID)
                        {
                            dr[5] = "<input type=\"checkbox\" name=\"delete" + (i + 1) + "\" value=\"delete\" disabled onClick=\"return false;\">";
                        }
                        else
                        {
                            dr[5] = "<input type=\"checkbox\" name=\"delete" + (i + 1) + "\" value=\"delete\">";
                        }
                        dt.Rows.Add(dr);
                        e1count = e1count + 4;
                        e2count = e2count + 4;
                    }
                    AdReportsGrid.ShowFooter = true;
                }
                usercount.Value = i.ToString() + 1;
                DataView dv = new DataView(dt);
                AdReportsGrid.DataSource = dv;
                AdReportsGrid.DataBind();
                GetGroupsForSyncToolBar();
            }
            catch (Exception ex)
            {
                throw (new Exception(ex.Message));
            }
    }