Наследование: System.Web.Services.Protocols.SoapHttpClientProtocol
Пример #1
0
        //
        // GET: /Report/Home/
        public ActionResult Index()
        {
            var rs = new ReportingService2010
            {
                Credentials = System.Net.CredentialCache.DefaultCredentials,
                //Url = "http://USER-PC/ReportServer/ReportService2010.asmx"
            };

            //var folders = rs.ListChildren("/", false);

            //var reportFolders = new List<ReportFolder>();

            //foreach (var folder in folders)
            //{
            //    var reportFolder = new ReportFolder {Name = folder.Name, URL = folder.Path};

            //    var reports = rs.ListChildren("/" + folder.Name + "/", false);
            //    foreach (var report in reports)
            //    {
            //        var reportObj = new ReportObj {Name = report.Name, URL = report.Path};
            //        reportFolder.Reports.Add(reportObj);
            //    }
            //    reportFolders.Add(reportFolder);
            //}
            var reportFolders = new List<ReportFolder>()
                {
                    new ReportFolder{ Name = "EarlyWarning", URL = "/EarlyWarning", Reports = new List<ReportObj>{new ReportObj{Name = "StockStatus", URL = "/EarlyWarning/StockStatus", Description = "Sample Desc 1"}}},
                    new ReportFolder{ Name = "PSNP", URL = "/PSNP", Reports = new List<ReportObj>{new ReportObj{Name = "StockStatus", URL = "/EarlyWarning/StockStatus", Description = "Sample Desc 1"}}},
                    new ReportFolder{ Name = "Logistics", URL = "/Logistics", Reports = new List<ReportObj>{new ReportObj{Name = "StockStatus", URL = "/EarlyWarning/StockStatus", Description = "Sample Desc 1"}}},
                    new ReportFolder{ Name = "Procurement", URL = "/Procurement", Reports = new List<ReportObj>{new ReportObj{Name = "StockStatus", URL = "/EarlyWarning/StockStatus", Description = "Sample Desc 1"}}},
                };
            return View(reportFolders);
        }
Пример #2
0
        public static string ReportMenu()
        {
            var html = string.Empty;
            var userName = System.Configuration.ConfigurationManager.AppSettings["CatsReportUserName"];
            var password = System.Configuration.ConfigurationManager.AppSettings["CatsReportPassword"];
            try
            {
                var rs = new ReportingService2010
                {
                    Credentials = new NetworkCredential(userName, password)
                };

                var folders = rs.ListChildren("/", false);
                html += "<ul class='dropdown-menu'>";
                foreach (var folder in folders)
                {
                    if (folder.TypeName == "Folder" && folder.Name != "Data Sources" && folder.Name != "Datasets")
                    {
                        var reports = rs.ListChildren("/" + folder.Name, false);

                        html += "<li class='dropdown-submenu'>";
                        html += "<a href='#' data-toggle='dropdown'>" + folder.Name + "</a>";
                        html += "<ul class='dropdown-menu'>";
                        foreach (var report in reports)
                        {
                            var baseUrl = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.ApplicationPath.TrimEnd('/') + "/";
                            html += "<li><a href=' " + baseUrl + "ReportViewer.aspx?path=" + report.Path + "'>" + report.Name + "</a></li>";
                        }
                        html += "</ul>";
                        html += "</li>";
                    }
                }
                html += "</ul>";
            }
            catch(Exception ex)
            {
                html = "";
            }

            return html;
        }
Пример #3
0
        public static string ReportList()
        {
            var html = string.Empty;
            var userName = System.Configuration.ConfigurationManager.AppSettings["CatsReportUserName"];
            var password = System.Configuration.ConfigurationManager.AppSettings["CatsReportPassword"];
            var user = (UserIdentity)HttpContext.Current.User.Identity;
            var role = UserRoleHelper.GetUserRole(user.Profile.UserName);
            var lang = user.Profile.LanguageCode;
            var currentUser = UserAccountHelper.GetCurrentUser();

            try
            {
                var rs = new ReportingService2010
                {
                    Credentials = new NetworkCredential(userName, password)
                };

                //var folders = rs.ListChildren("/", false);
                ////html += "<ul class='dropdown-menu'>";
                //foreach (var folder in folders)
                //{
                    //if (folder.TypeName == "Folder" && folder.Name != "Data Sources" && folder.Name != "Datasets")
                    //{
                        var reports = new CatalogItem[100];
                        if(currentUser.RegionalUser)
                        {
                            reports = rs.ListChildren("/Regional", false);
                        }
                        else if (currentUser.DefaultHub != null)
                        {
                            reports = rs.ListChildren("/Hub", false);
                        }
                        else if (currentUser.CaseTeam != null)
                        {
                            switch (currentUser.CaseTeam)
                            {
                                case (int)UserType.CASETEAM.EARLYWARNING:
                                    reports = rs.ListChildren("/Early Warning", false);
                                    break;
                                case (int)UserType.CASETEAM.PSNP:
                                    reports = rs.ListChildren("/FSCD", false);
                                    break;
                                case (int)UserType.CASETEAM.LOGISTICS:
                                    reports = rs.ListChildren("/Logistics", false);
                                    break;
                                case (int)UserType.CASETEAM.PROCUREMENT:
                                    reports = rs.ListChildren("/Procurement", false);
                                    break;
                                case (int)UserType.CASETEAM.FINANCE:
                                    reports = rs.ListChildren("/Finance", false);
                                    break;
                            }
                        }

                        //html += "<li class='dropdown-submenu'>";
                        //html += "<a href='#' data-toggle='dropdown'>" + folder.Name + "</a>";
                        //html += "<ul class='dropdown-menu'>";
                        html += "<div> <table class='table table-bordered'>  <thead>  <tr>  <th>Report</th>  <th>Description</th>  </tr>  </thead>  <tbody>";
                        //html += "<div id='list8'><ul>";

                        foreach (var report in reports)
                        {

                            html += "<tr> <td>";
                            var baseUrl = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.ApplicationPath.TrimEnd('/') + "/";
                            html += "<a href=' " + baseUrl + "ReportViewer.aspx?path=" + report.Path + "' target='_blank'>" + report.Name + "</a>";
                            var desc = report.Description;
                            html += "</td>  <td>" + desc+ "</td>  </tr>";
                        }
                        //html += "</ul>";
                        html += "</tbody> </table> </div>";
                    //}
                //}
                //html += "</ul>";
            }
            catch(Exception ex)
            {
                html = "";
            }

            return html;
        }