locked
Usar ReportViewer en SharePoint RRS feed

  • Pregunta

  • Hola realemte no se si aqui sea el foro adecuado para hacer esta pregunta, bueno tengo una aplicacion asp.net en la que cree mis propios controles web para mis filtros y estos pasan parametros aun reportviewer dentro del formulario, esto trabaja bien.

    Pero ahora quiero hacer esta pagina asp un webcontrol para integrarlo con Sharepoint, al principio me marcaba este error:

    The type Microsoft.SharePoint.Portal.Analytics.UI.ReportViewerMessages, Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c does not implement IReportViewerMessages or could not be found




    Pero ahora mi webpart no muestra ningun control.
    Este es mi codigo:

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Microsoft.Reporting.WebForms;
    using Telerik.Web.UI;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    
    namespace ReportWebPart
    {
        public class ReportApplication : System.Web.UI.WebControls.WebParts.WebPart
        {
            Hashtable table_values;
            Hashtable table_info;
            Hashtable table_managers;
            ReportViewer reportViewer = new ReportViewer();
            string FromQuarter = null;
            string ToQuarter = null;
            RadSlider timeLine = new RadSlider();
            ListBox managerFilter = new ListBox();
            List<ReportParameter> parameters = new List<ReportParameter>();
            string ConnectionSQL;
            SqlConnection sqlConn;
            SqlDataReader reader;
            ScriptManager scriptManager1 = null;
    
            protected override void OnInit(EventArgs e)
            {
                base.OnInit(e);
                string settings = "Data Source=localhost; Initial Catalog=WorkOrders; User Id=sql_user; Password=sql_password";
                ConnectionSQL = settings;
                sqlConn = new SqlConnection(ConnectionSQL);
                sqlConn.Open();
                setTimeLineInfo();
                setManagerInfo();
            }
    
            protected override void CreateChildControls()
            {
                base.CreateChildControls();
                Panel panel = new Panel();
                panel.BackColor = System.Drawing.Color.WhiteSmoke;
                panel.Visible = true;
                panel.Width = 800;
                Table filter_table = new Table();
    
                reportViewer.ServerReport.ReportPath = "http://localhost/ReporTestLibrary/Report Test.rdl";
                Uri uri = new Uri("http://localhost/ReportServer");
                reportViewer.ServerReport.ReportServerUrl = uri;
                ReportCredentials credentials = new ReportCredentials();
                reportViewer.ServerReport.ReportServerCredentials = credentials;
                reportViewer.ProcessingMode = ProcessingMode.Remote;
                reportViewer.ShowParameterPrompts = false;
                reportViewer.Width = 800;
                reportViewer.Height = 550;
    
                timeLine.ID = "timeLine";
                timeLine.AutoPostBack = true;
                for (int i = 0; i < table_values.Count; i++)
                {
                    string quarter = table_info[i.ToString()].ToString();
                    string year = quarter;
                    quarter = quarter.Substring(8, 1);
                    year = year.Substring(11, 4);
                    timeLine.Items.Add(new RadSliderItem("Q" + quarter + " " + year, i.ToString()));
                }
                timeLine.ItemType = SliderItemType.Item;
                timeLine.MaximumValue = table_values.Count;
                timeLine.MinimumValue = 0;
                timeLine.Width = 500;
                timeLine.Height = 55;
                timeLine.ValueChanged += new EventHandler(Change_Quarter);
                Label timeFilterLabel = new Label();
                timeFilterLabel.Text = "To Quarter";
                timeFilterLabel.Font.Name = "Arial";
                timeFilterLabel.Font.Size = 10;
                timeFilterLabel.Font.Bold = true;
                TableRow rowTimeLine = new TableRow();
                rowTimeLine.Cells.Add(new TableCell());
                rowTimeLine.Cells[0].Controls.Add(timeFilterLabel);
                rowTimeLine.Cells.Add(new TableCell());
                rowTimeLine.Cells[1].Controls.Add(timeLine);
    
                managerFilter.AutoPostBack = true;
                managerFilter.SelectionMode = ListSelectionMode.Multiple;
                managerFilter.Width = 300;
                managerFilter.Height = 100;
                managerFilter.SelectedIndexChanged += new EventHandler(Change_Manager);
                Label managerLabel = new Label();
                managerLabel.Text = "Select Manager";
                managerLabel.Font.Name = "Arial";
                managerLabel.Font.Size = 10;
                managerLabel.Font.Bold = true;
                TableRow rowmanager = new TableRow();
                rowmanager.Cells.Add(new TableCell());
                rowmanager.Cells[0].Controls.Add(managerLabel);
                rowmanager.Cells.Add(new TableCell());
                rowmanager.Cells[1].Controls.Add(managerFilter);
                if (ScriptManager.GetCurrent(this.Page) == null)
                {
                    scriptManager1 = new ScriptManager();
                    scriptManager1.ID = "scriptManager1";
                    scriptManager1.EnablePartialRendering = true;
                }
                filter_table.Rows.AddRange(new TableRow[]{
                        rowTimeLine,
                        rowmanager
                    }
                );
                panel.Controls.Add(filter_table);
                Controls.Add(panel);
                Controls.Add(reportViewer);
            }
    
            private void setTimeLineInfo()
            {
                table_values = new Hashtable();
                table_info = new Hashtable();
                DateTime variable = DateTime.Today;
                string value_parameter = null;
                string timeTemplate = "[Time].[Quarter].&";
                string query = @"SELECT DISTINCT Quarter, Quarter_Name FROM [dbo].[Time]
                    WHERE Year_Name = 'Calendar 2008' OR Year_Name = 'Calendar 2009'";
                SqlCommand sqlCommand = new SqlCommand(query, sqlConn);
                reader = sqlCommand.ExecuteReader();
                int count = 0;
                while (reader.Read())
                {
                    variable = (DateTime)reader[0];
                    value_parameter = variable.ToString("s");
                    table_values.Add(count.ToString(), timeTemplate + "[" + value_parameter + "]");
                    table_info.Add(count.ToString(), reader[1].ToString());
                    count++;
                }
                reader.Close();
            }
    
            protected void Change_Quarter(object sender, EventArgs args)
            {
                int position1 = timeLine.Value;
                int position2 = position1 < 7 ? 0 : (position1 - 6);
    
                FromQuarter = table_values[position2.ToString()].ToString();
                ToQuarter = table_values[position1.ToString()].ToString();
                parameters.Clear();
                ReportParameter fromtime = new ReportParameter("FromTimeQuarter", FromQuarter);
                ReportParameter totime = new ReportParameter("ToTimeQuarter", ToQuarter);
                if (parameters.Exists(TimeFilterExists))
                {
                    parameters.RemoveAll(TimeFilterExists);
                }
                parameters.Add(fromtime);
                parameters.Add(totime);
            }
    
            protected void Change_Manager(object sender, EventArgs args)
            {
                string[] manager_selected = new string[table_managers.Count];
                int;
                for (int i = 0; i < table_managers.Count; i++)
                {
                    if (managerFilter.Items[i].Selected)
                    {
                        manager_selected[selected] =
                            table_managers[managerFilter.Items[i].Value].ToString();
                        selected++;
                    }
                }
                if (manager_selected.Length > 0)
                {
                    ReportParameter parameter = new ReportParameter("DataTablePropertyManager",
                        manager_selected);
                    parameters.Add(parameter);
                }
            }
    
            private static bool TimeFilterExists(ReportParameter s)
            {
                if (s.Name.Equals("FromTimeQuarter") || s.Name.Equals("ToTimeQuarter"))
                    return true;
                else
                    return false;
            }
    
            private void setManagerInfo()
            {
                table_managers = new Hashtable();
                string managerTemplate = "[Data Table].[Property Manager].&";
                string query = "SELECT DISTINCT [Property Manager] FROM DataTable ORDER BY [Property Manager]";
                SqlCommand sqlCommad = new SqlCommand(query, sqlConn);
                reader = sqlCommad.ExecuteReader();
                int count = 0;
                while (reader.Read())
                {
                    table_managers.Add(count.ToString(), managerTemplate + "[" + reader[0].ToString() + "]");
                    managerFilter.Items.Add(new ListItem(reader[0].ToString(), count.ToString()));
                    count++;
                }
                reader.Close();
            }
    
            protected override void OnPreRender(EventArgs e)
            {
                base.OnPreRender(e);
                if (scriptManager1 != null)
                    this.Controls.Add(scriptManager1);
                if (parameters.Count > 0)
                {
                    reportViewer.ServerReport.SetParameters(parameters);
                }
            }
    
            protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)
            {
                
            }
        }
    }

    Alguien tiene idea de porque no puedo ver mis controles en este webpart, sera problema de mi reportviewer?

    Gracias de antemano
    sábado, 6 de junio de 2009 16:36

Respuestas