Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        private void GenerateReport()
        {
            var xm = new XmlDocument();

            ConvertToXml(ref xm);
            var xml = xm.InnerXml.ToString();

            rptViewerCustomerLanguage.Visible        = true;
            rptViewerCustomerLanguage.ProcessingMode = ProcessingMode.Remote;
            using (Models.ReportDatabaseEntities db = new Models.ReportDatabaseEntities())
            {
                WebReportServer    rs = db.WebReportServers.SingleOrDefault();
                WebReportCatalogue wc = (reportID != null) ? db.WebReportCatalogues.Where(K => K.ReportId_PK == reportID).SingleOrDefault() : db.WebReportCatalogues.SingleOrDefault();

                rptViewerCustomerLanguage.ServerReport.ReportServerUrl         = new Uri(rs.ServerURL);
                rptViewerCustomerLanguage.ServerReport.ReportServerCredentials = new CustomReportCredentials(rs.UserID, rs.Password, rs.ServerName);
                rptViewerCustomerLanguage.ServerReport.ReportPath = wc.ReportPath + wc.Name;
                ReportDataSource dataSource = new ReportDataSource(rptName, db.Get_CustomerReportLanguages(paramValue));
            }



            //SqlCommand cmd = new SqlCommand();
            //cmd.Parameters.Add(new SqlParameter("@cParams", paramValue));

            //string connectionstring = System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            //SqlConnection conn = new SqlConnection(connectionstring);
            //conn.Open();
            //cmd.Connection = conn;

            //cmd.CommandText = "Get_CustomerReportLanguages";

            //cmd.CommandType = System.Data.CommandType.StoredProcedure;

            //SqlDataAdapter da = new SqlDataAdapter(cmd);

            //DataSet ds = new DataSet();
            //da.Fill(ds);



            //rptViewerCustomerLanguage.ServerReport.datas.Clear();
            //rptViewerCustomerLanguage.LocalReport.DataSources.Add(dataSource);

            System.Collections.Generic.List <ReportParameter> lstParams = new List <ReportParameter>();

            lstParams.Add(new ReportParameter("cParams", xml));



            rptViewerCustomerLanguage.ServerReport.SetParameters(lstParams);

            //Assembly assembly = Assembly.LoadFrom("MyReports.dll");
            //Stream stream = assembly.GetManifestResourceStream("Reports.MyReport.rdlc");
            //rptViewerCustomerLanguage.LocalReport.LoadReportDefinition(stream);

            rptViewerCustomerLanguage.ShowParameterPrompts = false;
            rptViewerCustomerLanguage.ShowPrintButton      = true;


            rptViewerCustomerLanguage.ServerReport.Refresh();
        }
Esempio n. 2
0
        public List<DCControl> Create(Guid reportID)
        {
            ReportDatabaseEntities db = new ReportDatabaseEntities();
            var result = new List<DCControl>();
            var data = (from ctrl in db.WebReportParameters.ToList().OrderBy(k => k.OrderByControl).ToList()
                        join CP in db.WebReportParamCascadeMappings.ToList() on ctrl.RPId_PK equals CP.PRId_FK
                        where CP.ReportId_FK==reportID
                        && ctrl.isActive== true
                        orderby CP.OrderByControl
                        select new { Control = ctrl, CParam = CP});
            foreach(var d in data)
            {
                DCControl ddl;
                switch (d.Control.Name )
                {
                    case "Customer":
                    ddl = new CustomerDropDown();
                    ddl.Name = d.Control.Name;
                    ddl.Title = d.Control.Name;
                    ddl.ControlType.Options = (from c in db.Customers
                                               select new OptionValue
                                               {
                                                   DisplayUniqueID = c.CustomerId_PK,
                                                   DisplayValue = c.FirstName + " " + c.LastName,
                                                   ParentID =  (Guid) c.CountryID_FK

                                               }
                               ).ToList<OptionValue>();
                    ddl.SelectedValue  = ddl.ControlType.Options[0];
                    ddl.ngModel = ddl.SelectedValue.ToString();
                    break;
                    case "Country":
                    ddl = new CountryDropDown();
                    ddl.Name = d.Control.Name;
                    ddl.Title = d.Control.Name;
                    ddl.ControlType.Options = (from c in db.Countries
                                               select new OptionValue
                                               {
                                                   DisplayUniqueID = c.CountryId_PK,
                                                   DisplayValue = c.Name

                                               }
                            ).ToList<OptionValue>();
                    ddl.SelectedValue = ddl.ControlType.Options[0];
                    ddl.ngModel = ddl.SelectedValue.ToString();
                    break;
                    case "State":
                    ddl = new CountryDropDown();
                    ddl.Name = d.Control.Name;
                    ddl.Title = d.Control.Name;
                    ddl.ControlType.Options = (from c in db.States

                                             select new OptionValue
                                               {
                                                   DisplayUniqueID = c.StateId_PK,
                                                   DisplayValue = c.Name,
                                                   ParentID = (Guid) c.CountryID_FK
                                               }
                            ).ToList<OptionValue>();
                    ddl.SelectedValue = ddl.ControlType.Options[0];
                    ddl.ngModel = ddl.SelectedValue.ToString();
                    break;
                    case "City":
                        ddl = new CountryDropDown();
                        ddl.Name = d.Control.Name;
                        ddl.Title = d.Control.Name;
                        ddl.ControlType.Options = (from c in db.Cities

                                                   select new OptionValue
                                                   {
                                                       DisplayUniqueID = c.CityId_PK,
                                                       DisplayValue = c.Name,
                                                       ParentID = (Guid)c.StateID_FK
                                                   }
                                ).ToList<OptionValue>();
                        ddl.SelectedValue = ddl.ControlType.Options[0];
                        ddl.ngModel = ddl.SelectedValue.ToString();
                        break;
                    case "Languages":
                    ddl = new LanguageCheckBox();
                    ddl.Name = d.Control.Name;
                    ddl.Title = d.Control.Name;
                    ddl.ControlType.Options = (from r in
                                                   ((from c in db.Languages
                                                     select new LanguageList
                                                     {
                                                         LanguageId = c.LanguageId_PK,
                                                         Name = c.Name,

                                                     }).ToList())
                                               select new OptionValue
                                               {
                                                   DisplayUniqueID = r.LanguageId,
                                                   DisplayValue = r.Name
                                               }
                            ).ToList<OptionValue>();
                    break;
                    case "DateOfJoining":
                    ddl = new DateTimeBox();
                    ddl.Name = d.Control.Name;
                    ddl.Title = d.Control.Name;
                    break;
                    case "DateOfBirth":
                    ddl = new DateTimeBox();
                    ddl.Name = d.Control.Name;
                    ddl.Title = d.Control.Name;
                    break;
                    default:
                        ddl = null;
                        break;
                }
                if (ddl != null)
                {
                    result.Add(ddl);
                }

            }
            return result;
        }
        /// <summary>
        /// 
        /// </summary>
        private void GenerateReport()
        {
            var xm = new XmlDocument();
            ConvertToXml(ref xm);
            var xml = xm.InnerXml.ToString();
            rptViewerCustomerLanguage.Visible = true;
            rptViewerCustomerLanguage.ProcessingMode = ProcessingMode.Remote;
            using (Models.ReportDatabaseEntities db = new Models.ReportDatabaseEntities())
            {

                WebReportServer rs = db.WebReportServers.SingleOrDefault();
                WebReportCatalogue wc = (reportID != null) ? db.WebReportCatalogues.Where(K=> K.ReportId_PK== reportID).SingleOrDefault() : db.WebReportCatalogues.SingleOrDefault();

                rptViewerCustomerLanguage.ServerReport.ReportServerUrl = new Uri( rs.ServerURL);
                rptViewerCustomerLanguage.ServerReport.ReportServerCredentials = new CustomReportCredentials(rs.UserID,rs.Password,rs.ServerName );
                rptViewerCustomerLanguage.ServerReport.ReportPath = wc.ReportPath + wc.Name;
                ReportDataSource dataSource = new ReportDataSource(rptName, db.Get_CustomerReportLanguages(paramValue));
            }

            //SqlCommand cmd = new SqlCommand();
            //cmd.Parameters.Add(new SqlParameter("@cParams", paramValue));

            //string connectionstring = System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            //SqlConnection conn = new SqlConnection(connectionstring);
            //conn.Open();
            //cmd.Connection = conn;

            //cmd.CommandText = "Get_CustomerReportLanguages";

            //cmd.CommandType = System.Data.CommandType.StoredProcedure;

            //SqlDataAdapter da = new SqlDataAdapter(cmd);

            //DataSet ds = new DataSet();
            //da.Fill(ds);

            //rptViewerCustomerLanguage.ServerReport.datas.Clear();
            //rptViewerCustomerLanguage.LocalReport.DataSources.Add(dataSource);

            System.Collections.Generic.List<ReportParameter> lstParams = new List<ReportParameter>();

            lstParams.Add(new ReportParameter("cParams", xml));

            rptViewerCustomerLanguage.ServerReport.SetParameters(lstParams);

            //Assembly assembly = Assembly.LoadFrom("MyReports.dll");
            //Stream stream = assembly.GetManifestResourceStream("Reports.MyReport.rdlc");
            //rptViewerCustomerLanguage.LocalReport.LoadReportDefinition(stream);

            rptViewerCustomerLanguage.ShowParameterPrompts = false;
            rptViewerCustomerLanguage.ShowPrintButton = true;

            rptViewerCustomerLanguage.ServerReport.Refresh();
        }