예제 #1
0
        public static ReportDocument MakeClientRep(DateTime dtStart, DateTime dtEnd)
        {
            ClientReport             rep = new ClientReport();
            ClientReportTableAdapter ta  = new ClientReportTableAdapter();

            rep.SetDataSource((DataTable)ta.GetData(dtStart, dtEnd));
            (rep.ReportDefinition.ReportObjects["Interval"] as TextObject).Text +=
                string.Format("{0} - {1}", dtStart, dtEnd);
            UserReportTableAdapter uta = new UserReportTableAdapter();

            rep.Subreports[0].SetDataSource((DataTable)uta.GetData(dtStart, dtEnd));
            (rep.Subreports[0].ReportDefinition.ReportObjects["Interval"] as TextObject).Text +=
                string.Format("{0} - {1}", dtStart, dtEnd);
            return(rep);
        }
예제 #2
0
        public static ReportDocument MakeCustomRep(DateTime dtStart, DateTime dtEnd)
        {
            TemplateForm tf = new TemplateForm();

            if (tf.ShowDialog() != DialogResult.OK || tf.template == null)
            {
                return(null);
            }
            CustomReport rep = new CustomReport();

            (rep.ReportDefinition.ReportObjects["Interval"] as TextObject).Text +=
                string.Format("{0} - {1}", dtStart, dtEnd);
            List <string> list = new List <string>();

            foreach (string s in tf.template.arrName)
            {
                switch (s)
                {
                case "По пользователям":
                    GUserReportTableAdapter guta = new GUserReportTableAdapter();
                    rep.Subreports[s].SetDataSource((DataTable)guta.GetData(dtStart, dtEnd));
                    (rep.Subreports[s].ReportDefinition.ReportObjects["Interval"] as TextObject).Text +=
                        string.Format("{0} - {1}", dtStart, dtEnd);
                    break;

                case "По IP адресам":
                    ClientReportTableAdapter cta = new ClientReportTableAdapter();
                    rep.Subreports[s].SetDataSource((DataTable)cta.GetData(dtStart, dtEnd));
                    (rep.Subreports[s].ReportDefinition.ReportObjects["Interval"] as TextObject).Text +=
                        string.Format("{0} - {1}", dtStart, dtEnd);
                    break;

                case "По сайтам":
                    HostReportTableAdapter hta = new HostReportTableAdapter();
                    rep.Subreports[s].SetDataSource((DataTable)hta.GetData(dtStart, dtEnd));
                    (rep.Subreports[s].ReportDefinition.ReportObjects["Interval"] as TextObject).Text +=
                        string.Format("{0} - {1}", dtStart, dtEnd);
                    break;

                case "По дням":
                    GDataReportTableAdapter dta = new GDataReportTableAdapter();
                    rep.Subreports[s].SetDataSource((DataTable)dta.GetData(dtStart, dtEnd));
                    (rep.Subreports[s].ReportDefinition.ReportObjects["Interval"] as TextObject).Text +=
                        string.Format("{0} - {1}", dtStart, dtEnd);
                    break;

                case "По протоколам":
                    GProtocolReportTableAdapter pta = new GProtocolReportTableAdapter();
                    rep.Subreports[s].SetDataSource((DataTable)pta.GetData(dtStart, dtEnd));
                    (rep.Subreports[s].ReportDefinition.ReportObjects["Interval"] as TextObject).Text +=
                        string.Format("{0} - {1}", dtStart, dtEnd);
                    break;
                }
                string[] arrRepName = { "По пользователям", "По IP адресам", "По сайтам",
                                        "По дням",          "По протоколам" };
                string[] arrObjName = { "user", "ip", "host", "day", "protocol" };
                for (int i = 0; i < arrRepName.Length; i++)
                {
                    if (arrRepName[i] == s)
                    {
                        list.Add(arrObjName[i]);
                    }
                }
            }
            foreach (ReportObject ro in rep.ReportDefinition.ReportObjects)
            {
                if (ro.Kind == CrystalDecisions.Shared.ReportObjectKind.SubreportObject &&
                    !list.Contains(ro.Name))
                {
                    ro.ObjectFormat.EnableSuppress = true;
                }
            }
            rep.Refresh();
            return(rep);
        }