2011-04-08 49 views
1

我有一個批處理文件,用於部署.rss文件。 rss文件具有爲10個報告創建訂閱的腳本。一旦部署了批處理文件,就會觸發.rss文件,從而在「報告管理器」中創建訂閱(對於所有10個報告)。 我的問題是,每次部署批處理文件時都會創建一組新的訂閱。即)而不是覆蓋現有的訂閱,而是創建一組新的副本。我最終獲得了單個報告的許多訂閱。 我需要一個覆蓋部署中的現有文件的腳本。我必須使用任何方法嗎? 幫助需要..覆蓋訂閱中的現有文件名

代碼來創建訂閱:這是相當混亂包涵.. :)

子的Main()

rs.Credentials = System.Net.CredentialCache.DefaultCredentials 

    'The name of the report for which the DDS are to be created 

    Dim fullpath As String = rootpath 


    'set extension as Windows File Share 

    Dim settings as new ExtensionSettings() 
    settings.Extension = "Report Server FileShare" 

    'Retrieve rdl files deployed in the server 

Dim report As String 
Dim desc As String 
Dim eventType As String = "TimedSubscription" 
Dim destpath As String = Path 

Dim i as Integer = 0 

Dim items As CatalogItem() = rs.ListChildren(fullpath, False) 
    For Each item As CatalogItem In items 
     If item.Type = ItemTypeEnum.Report Then 
    i = i + 1 
    desc = item.name     
    report = fullpath &"/" & desc 

    Dim drp As DataRetrievalPlan  
Dim ser As Serialization.XmlSerializer = New Serialization.XmlSerializer(GetType(DataRetrievalPlan)) 
Dim sr As New StringReader("<?xml version=""1.0"" encoding=""utf-16""?>" + Microsoft.VisualBasic.ControlChars.CrLf + "<DataRetrievalPlan xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">" + Microsoft.VisualBasic.ControlChars.CrLf + " <DataSourceDefinition xmlns=""http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices"">" + Microsoft.VisualBasic.ControlChars.CrLf + " <Extension>SQL</Extension>" + Microsoft.VisualBasic.ControlChars.CrLf + " <ConnectString>Data Source="& DBServer & ";Initial Catalog=ClearviewBilling</ConnectString>" + Microsoft.VisualBasic.ControlChars.CrLf + " <UseOriginalConnectString>false</UseOriginalConnectString>" + Microsoft.VisualBasic.ControlChars.CrLf + " <OriginalConnectStringExpressionBased>false</OriginalConnectStringExpressionBased>" + Microsoft.VisualBasic.ControlChars.CrLf + " <CredentialRetrieval>Store</CredentialRetrieval>" + Microsoft.VisualBasic.ControlChars.CrLf + " <WindowsCredentials>false</WindowsCredentials>" + Microsoft.VisualBasic.ControlChars.CrLf + " <ImpersonateUser>false</ImpersonateUser>" + Microsoft.VisualBasic.ControlChars.CrLf + " <Prompt>Enter a user name and password to access the data source:</Prompt>" + Microsoft.VisualBasic.ControlChars.CrLf + " <UserName>RptSrvr</UserName>" + Microsoft.VisualBasic.ControlChars.CrLf + " <Password>deploy1</Password>" + Microsoft.VisualBasic.ControlChars.CrLf + " <Enabled>true</Enabled>" + Microsoft.VisualBasic.ControlChars.CrLf + " </DataSourceDefinition>" + Microsoft.VisualBasic.ControlChars.CrLf + " <DataSet xmlns=""http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices"">" + Microsoft.VisualBasic.ControlChars.CrLf + " <Fields>" + Microsoft.VisualBasic.ControlChars.CrLf + "  <Field>" + Microsoft.VisualBasic.ControlChars.CrLf + "  <Alias>ReportID</Alias>" + Microsoft.VisualBasic.ControlChars.CrLf + "  <Name>ReportID</Name>" + Microsoft.VisualBasic.ControlChars.CrLf + "  </Field>" + Microsoft.VisualBasic.ControlChars.CrLf + "  <Field>" + Microsoft.VisualBasic.ControlChars.CrLf + "  <Alias>ReportName</Alias>" + Microsoft.VisualBasic.ControlChars.CrLf + "  <Name>ReportName</Name>" + Microsoft.VisualBasic.ControlChars.CrLf + "  </Field>" + Microsoft.VisualBasic.ControlChars.CrLf + "  <Field>" + Microsoft.VisualBasic.ControlChars.CrLf + "  <Alias>Path</Alias>" + Microsoft.VisualBasic.ControlChars.CrLf + "  <Name>Path</Name>" + Microsoft.VisualBasic.ControlChars.CrLf + "  </Field>" + Microsoft.VisualBasic.ControlChars.CrLf + " </Fields>" + Microsoft.VisualBasic.ControlChars.CrLf + " <Query>" + Microsoft.VisualBasic.ControlChars.CrLf + "  <CommandType>Text</CommandType>" + Microsoft.VisualBasic.ControlChars.CrLf + "  <CommandText>exec uspSetSubscriptionParameters "& i & ",'"& destpath &"'</CommandText>" + Microsoft.VisualBasic.ControlChars.CrLf + "  <Timeout>30</Timeout>" + Microsoft.VisualBasic.ControlChars.CrLf + " </Query>" + Microsoft.VisualBasic.ControlChars.CrLf + " <CaseSensitivity>False</CaseSensitivity>" + Microsoft.VisualBasic.ControlChars.CrLf + " <AccentSensitivity>False</AccentSensitivity>" + Microsoft.VisualBasic.ControlChars.CrLf + " <KanatypeSensitivity>False</KanatypeSensitivity>" + Microsoft.VisualBasic.ControlChars.CrLf + " <WidthSensitivity>False</WidthSensitivity>" + Microsoft.VisualBasic.ControlChars.CrLf + " </DataSet>" + Microsoft.VisualBasic.ControlChars.CrLf + "</DataRetrievalPlan>") 
drp = ser.Deserialize(sr) 

Dim parameters(0) As ParameterValueOrFieldReference 

Dim parameter1 As New ParameterFieldReference() 
parameter1.ParameterName = "ReportID" 
parameter1.FieldAlias = "ReportID" 
parameters(0) = parameter1 


Dim extensionParams(6) As ParameterValueOrFieldReference 

extensionParams(0) = New ParameterFieldReference() 
CType(extensionParams(0),ParameterFieldReference).FieldAlias = "ReportName" 
CType(extensionParams(0),ParameterFieldReference).ParameterName = "FILENAME" 

extensionParams(1) = New ParameterFieldReference() 
CType(extensionParams(1),ParameterFieldReference).FieldAlias = "Path" 
CType(extensionParams(1),ParameterFieldReference).ParameterName = "PATH" 

extensionParams(2) = New ParameterValue() 
CType(extensionParams(2),ParameterValue).Name = "RENDER_FORMAT" 
CType(extensionParams(2),ParameterValue).Label = "" 
CType(extensionParams(2),ParameterValue).Value = "PDF" 

extensionParams(3) = New ParameterValue() 
CType(extensionParams(3),ParameterValue).Name = "WRITEMODE" 
CType(extensionParams(3),ParameterValue).Label = "" 
CType(extensionParams(3),ParameterValue).Value = "OverWrite" 

extensionParams(4) = New ParameterValue() 
CType(extensionParams(4),ParameterValue).Name = "FILEEXTN" 
CType(extensionParams(4),ParameterValue).Label = "" 
CType(extensionParams(4),ParameterValue).Value = "True" 

extensionParams(5) = New ParameterValue() 
CType(extensionParams(5),ParameterValue).Name = "USERNAME" 
CType(extensionParams(5),ParameterValue).Label = "" 
CType(extensionParams(5),ParameterValue).Value = "SQL_Test" 

extensionParams(6) = New ParameterValue() 
CType(extensionParams(6),ParameterValue).Name = "PASSWORD" 
CType(extensionParams(6),ParameterValue).Label = "" 
CType(extensionParams(6),ParameterValue).Value = "Rfgh" 


Dim extSettings As New ExtensionSettings() 
extSettings.ParameterValues = extensionParams 
extSettings.Extension = "Report Server FileShare" 


Dim matchData As String = "<ScheduleDefinition xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""><StartDateTime xmlns=""http://schemas.microsoft.com/sqlserver/2006/03/15/reporting/reportingservices"">2011-02-14T01:00:00.000-05:00</StartDateTime></ScheduleDefinition>" 
Try 
    rs.CreateDataDrivenSubscription(report, extSettings, drp, desc, eventType, matchData, parameters) 
    Console.WriteLine("Subscription created successfully for "&desc) 

catch ex as System.Exception 
    Console.WriteLine(ex) 
end try 


     End If 

    Next 

末次

+1

我已經重新標記了您的問題。請注意,您沒有像「真正簡單的整合」那樣使用RSS;相反,我們正在討論Reporting Services腳本文件。提到Reporting Services,並指定你使用的是什麼版本,可能會在你的問題上獲得更多正確的眼球。 – 2011-04-08 14:59:52

+0

左邊的也許。 – 2011-04-08 15:57:39

回答

1

也許它只是!管道錯誤,使用>>而不是>。一個代碼示例會很好。

+0

哦..它是一個非常大的代碼!!創建訂閱的那個!無論如何,我試圖把它包括在這裏 – Iswarya 2011-04-08 12:51:24