日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Reporting Service

發(fā)布時間:2025/4/16 编程问答 17 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Reporting Service 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

研究了一下reportServices,還沒有完全得其精髓,東拼西湊一個小例子如下:(實現(xiàn)搜索報表,保存報表,以及現(xiàn)實在form上),希望對初學(xué)者有些幫助。



***********************************************
using?System;
using?System.Drawing;
using?System.Collections;
using?System.ComponentModel;
using?System.Windows.Forms;
using?System.Data;
using?System.IO;
using?System.Web.Services.Protocols;
using?System.Diagnostics;

namespace?myApplication1
{
????
/**////?<summary>
????
///?Summary?description?for?Form1.
????
///?</summary>

????public?class?Form1?:?System.Windows.Forms.Form
????
{
????????
private?myApplication1.ReportService.ReportingService?myReportService?=new?myApplication1.ReportService.ReportingService();
????????
private?static?myApplication1.ReportService.CatalogItem[]?items?=?null;
????????
private?System.Windows.Forms.ComboBox?comboBox1;
????????
private?AxSHDocVw.AxWebBrowser?axWebBrowser1;

????????
/**////?<summary>
????????
///?Required?designer?variable.
????????
///?</summary>

????????private?System.ComponentModel.Container?components?=?null;

????????
public?Form1()
????????
{
????????????
//
????????????
//?Required?for?Windows?Form?Designer?support
????????????
//
????????????InitializeComponent();
????
????????????
//
????????????
//?TODO:?Add?any?constructor?code?after?InitializeComponent?call
????????????
//
????????????
//?ReportService?URL=http://localhost/ReportServer/ReportService.asmx?wsdl"%20filename="ReportService.wsdl
????????????
//
????????????myApplication1.ReportService.ReportingService?rs?=?new?myApplication1.ReportService.ReportingService();
????????????rs.Credentials?
=?System.Net.CredentialCache.DefaultCredentials;
????????????????????????
????????????myApplication1.ReportService.SearchCondition?condition?
=?new?myApplication1.ReportService.SearchCondition();
????????????condition.Condition?
=?myApplication1.ReportService.ConditionEnum.Contains;
????????????condition.ConditionSpecified?
=?true;
????????????condition.Name?
=?"Name";
????????????condition.Value?
=?"Report_A1";

????????????myApplication1.ReportService.SearchCondition[]?conditions?
=?new?myApplication1.ReportService.SearchCondition[1];
????????????conditions[
0]?=?condition;

????????????
try
????????????
{
????????????????items?
=?rs.FindItems(?"/",?myApplication1.ReportService.BooleanOperatorEnum.Or,?conditions?);
????????????????
if?(?items?!=?null?)
????????????????
{
????????????????????
foreach?(?myApplication1.ReportService.CatalogItem?ci?in?items)
????????????????????
{
????????????????????????Console.WriteLine(?
"Item?{0}?found?at?{1}",?ci.Name,?ci.Path?);
????????????????????????comboBox1.Items.Add(ci.Name);
????????????????????}

????????????????}

????????????}

????????????
catch?(?SoapException?e?)
????????????
{
????????????????Console.WriteLine(?e.Detail.InnerXml.ToString()?);?
????????????}

????????}


????????
/**////?<summary>
????????
///?Clean?up?any?resources?being?used.
????????
///?</summary>

????????protected?override?void?Dispose(?bool?disposing?)
????????
{
????????????
if(?disposing?)
????????????
{
????????????????
if?(components?!=?null)?
????????????????
{
????????????????????components.Dispose();
????????????????}

????????????}

????????????
base.Dispose(?disposing?);
????????}


????????
Windows?Form?Designer?generated?code#region?Windows?Form?Designer?generated?code
????????
/**////?<summary>
????????
///?Required?method?for?Designer?support?-?do?not?modify
????????
///?the?contents?of?this?method?with?the?code?editor.
????????
///?</summary>

????????private?void?InitializeComponent()
????????
{
????????????System.Resources.ResourceManager?resources?
=?new?System.Resources.ResourceManager(typeof(Form1));
????????????
this.comboBox1?=?new?System.Windows.Forms.ComboBox();
????????????
this.axWebBrowser1?=?new?AxSHDocVw.AxWebBrowser();
????????????((System.ComponentModel.ISupportInitialize)(
this.axWebBrowser1)).BeginInit();
????????????
this.SuspendLayout();
????????????
//?
????????????
//?comboBox1
????????????
//?
????????????this.comboBox1.Location?=?new?System.Drawing.Point(24,?32);
????????????
this.comboBox1.Name?=?"comboBox1";
????????????
this.comboBox1.Size?=?new?System.Drawing.Size(200,?21);
????????????
this.comboBox1.TabIndex?=?1;
????????????
this.comboBox1.SelectedIndexChanged?+=?new?System.EventHandler(this.comboBox1_SelectedIndexChanged);
????????????
//?
????????????
//?axWebBrowser1
????????????
//?
????????????this.axWebBrowser1.Anchor?=?((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top?|?System.Windows.Forms.AnchorStyles.Bottom)?
????????????????
|?System.Windows.Forms.AnchorStyles.Left)?
????????????????
|?System.Windows.Forms.AnchorStyles.Right)));
????????????
this.axWebBrowser1.Enabled?=?true;
????????????
this.axWebBrowser1.Location?=?new?System.Drawing.Point(32,?96);
????????????
this.axWebBrowser1.OcxState?=?((System.Windows.Forms.AxHost.State)(resources.GetObject("axWebBrowser1.OcxState"));
????????????
this.axWebBrowser1.Size?=?new?System.Drawing.Size(576,?232);
????????????
this.axWebBrowser1.TabIndex?=?2;
????????????
//?
????????????
//?Form1
????????????
//?
????????????this.AutoScaleBaseSize?=?new?System.Drawing.Size(5,?13);
????????????
this.ClientSize?=?new?System.Drawing.Size(648,?397);
????????????
this.Controls.Add(this.axWebBrowser1);
????????????
this.Controls.Add(this.comboBox1);
????????????
this.Name?=?"Form1";
????????????
this.Text?=?"Form1";
????????????((System.ComponentModel.ISupportInitialize)(
this.axWebBrowser1)).EndInit();
????????????
this.ResumeLayout(false);

????????}

????????
#endregion


????????
/**////?<summary>
????????
///?The?main?entry?point?for?the?application.
????????
///?</summary>

????????[STAThread]
????????
static?void?Main()?
????????
{
????????????Application.Run(
new?Form1());
????????}



????????
private?void?comboBox1_SelectedIndexChanged(object?sender,?System.EventArgs?e)
????????
{????????????
????????????myApplication1.ReportService.ReportingService?rs?
=?new?myApplication1.ReportService.ReportingService();
????????????rs.Credentials?
=?System.Net.CredentialCache.DefaultCredentials;

????????????
//?Render?arguments
????????????byte[]?result?=?null;
????????????
string?reportPath?=?items[comboBox1.SelectedIndex].Path;?
????????????
string?format?=?"HTML4.0";
????????????
string?historyID?=?null;
????????????
string?devInfo?=?@"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";

????????????
//?Prepare?report?parameter.
????????????myApplication1.ReportService.ParameterValue[]?parameters?=?null;

????????????myApplication1.ReportService.DataSourceCredentials[]?credentials?
=?null;
????????????
string?showHideToggle?=?null;
????????????
string?encoding;
????????????
string?mimeType;
????????????myApplication1.ReportService.Warning[]?warnings?
=?null;
????????????myApplication1.ReportService.ParameterValue[]?reportHistoryParameters?
=?null;
????????????
string[]?streamIDs?=?null;
????????????myApplication1.ReportService.SessionHeader?sh?
=
????????????????
new?myApplication1.ReportService.SessionHeader();
????????????rs.SessionHeaderValue?
=?sh;

????????????
try{
????????????????result?
=?rs.Render(reportPath,?format,?historyID,?devInfo,?parameters,?credentials,?
????????????????????showHideToggle,?
out?encoding,?out?mimeType,?out?reportHistoryParameters,?out?warnings,
????????????????????
out?streamIDs);
????????????????sh.SessionId?
=?rs.SessionHeaderValue.SessionId;
????????????????Console.WriteLine(
"SessionID?after?call?to?Render:?{0}",?
????????????????????rs.SessionHeaderValue.SessionId);
????????????????Console.WriteLine(
"Execution?date?and?time:?{0}",
????????????????????rs.SessionHeaderValue.ExecutionDateTime);
????????????????Console.WriteLine(
"Is?new?execution:?{0}",
????????????????????rs.SessionHeaderValue.IsNewExecution);
????????????}

????????????
catch(SoapException?err?)
????????????
{
????????????????Console.WriteLine(err.Detail.OuterXml);
????????????}

????????????
//?Write?the?contents?of?the?report?to?an?HTML?file.
????????????try
????????????
{
????????????????FileStream?stream?
=?File.Create(?"report.htm",?result.Length?);????????
????????????????Console.WriteLine(?
"File?created."?);
????????????????stream.Write(?result,?
0,?result.Length?);
????????????????Console.WriteLine(?
"Result?written?to?the?file."?);
????????????????stream.Close();
????????????????
//axPdf1.src?=?"report.pdf";
????????????????int?zero=0;
????????????????
object?oZero=?zero;
????????????????
string?str?=?"";
????????????????
object?oStr?=?str;
????????????????axWebBrowser1.Navigate(
"http://localhost/ReportServer?%2freport+sample%2fReport_A1&rs:Command=Render",
ref?oZero,
ref?oStr,
????????????????????????
ref?oStr,
????????????????????????
ref?oStr);
????????????}

????????????
catch?(?Exception?err?)
????????????
{
????????????????Console.WriteLine(?err.Message?);
????????????}


????????}

????}

}

轉(zhuǎn)載于:https://www.cnblogs.com/applegreen/archive/2005/04/26/145409.html

總結(jié)

以上是生活随笔為你收集整理的Reporting Service的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。