コード例 #1
0
ファイル: adreports.aspx.cs プロジェクト: jaytem/minGit
    private void GetRelationshipsForSync()
    {
        try
            {
                TR_count.Visible = true;
                UserGroupData[] user_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);
                user_group_data = m_refUserApi.GetCMSRelationshipsToSync(m_intMax);
                if (user_group_data == null)
                {
                    user_group_data = (Ektron.Cms.UserGroupData[])Array.CreateInstance(typeof(UserGroupData), 0);
                }

                if (user_group_data == null)
                {
                    Response.Redirect("adreports.aspx?action=ViewAllReportTypes", false);
                }
                System.Web.UI.WebControls.BoundColumn colBound = new System.Web.UI.WebControls.BoundColumn();
                colBound.DataField = "CMSUSER";
                colBound.HeaderText = m_refMsg.GetMessage("generic Username");
                colBound.HeaderStyle.Width = Unit.Percentage(40);
                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("generic User Group Name");
                colBound.HeaderStyle.Width = Unit.Percentage(50);
                colBound.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
                colBound.ItemStyle.Wrap = false;
                colBound.ItemStyle.VerticalAlign = VerticalAlign.Top;
                AdReportsGrid.Columns.Add(colBound);

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

                DataTable dt = new DataTable();
                DataRow dr = null;
                dt.Columns.Add(new DataColumn("CMSUSER", typeof(string)));
                dt.Columns.Add(new DataColumn("ADUSER", typeof(string)));
                dt.Columns.Add(new DataColumn("DELETE", typeof(string)));
                int e1count = 2;
                int e2count = 3;

                int i = 0;
                long currentUserID = m_refUserApi.UserId;
                if (user_group_data.Length == m_intMax)
                {
                    TD_count.InnerHtml = m_intMax + " " + m_refMsg.GetMessage("ad relationships displayed") + " <a href=\"adreports.aspx?action=GetRelationshipsForSynch&max=0\">" + m_refMsg.GetMessage("generic Show All") + "</a><br><br>";
                }
                if (settings_data.ADIntegration)
                {
                    for (i = 0; i <= user_group_data.Length - 1; i++)
                    {
                        dr = dt.NewRow();
                        dr[0] += "<input type=\"hidden\" name=\"userid" + (i + 1) + "\" value=\"" + user_group_data[i].UserId + "\">";
                        dr[0] += "<input type=\"hidden\" name=\"groupid" + (i + 1) + "\" value=\"" + user_group_data[i].GroupId + "\">";
                        dr[0] += user_group_data[i].UserName;
                        dr[1] = user_group_data[i].GroupName;
                        dr[2] = "<input type=\"checkbox\" name=\"delete" + (i + 1) + "\" value=\"delete\">";
                        dt.Rows.Add(dr);
                    }

                    AdReportsGrid.ShowFooter = true;

                    e1count = e1count + 5;
                    e2count = e2count + 5;

                }
                usercount.Value = i.ToString() + 1;
                DataView dv = new DataView(dt);
                AdReportsGrid.DataSource = dv;
                AdReportsGrid.DataBind();
                GetRelationshipsForSyncToolBar();
            }
            catch (Exception ex)
            {
                throw (new Exception(ex.Message));
            }
    }