Groups | Blog | Home
all groups > sql server reporting services > january 2005 >

sql server reporting services : Using RS Web Service


Hari
1/19/2005 9:39:01 PM
Hi all
I am using Reporting Services's web services to migrate
reports across environments. I have a report path from the source which i
need to migrate .
ex say reportPath1 = "/abc/xyz/report1"
Before calling the create report i have to create the folders. I know there
is a method called as CreatFolder, But i need to check as to if the folder
doesn't exits create it else dont create. There is no method which tells
whether the folder exists or not. Can some one help me solving this prob

Daniel Reib [MSFT]
1/20/2005 8:39:22 AM
You could also call ListChildren passing in the folder you want to check.
The method will throw and error if the item does not exist.

--
-Daniel
This posting is provided "AS IS" with no warranties, and confers no rights.


[quoted text, click to view]

Adrian M.
1/20/2005 8:50:28 AM
Try something like:

private bool DoesFolderExist (string folder)
{
SearchCondition condition = new SearchCondition();
condition.Condition = ConditionEnum.Contains;
condition.ConditionSpecified = true;
condition.Name = "Name";
condition.Value =folder;

SearchCondition[] conditions;
conditions = new SearchCondition[1];
conditions[0] = condition;

CatalogItem[] returnedItems = m_ReportingService.FindItems( "/",
BooleanOperatorEnum.Or, conditions );

if (returnedItems != null && returnedItems.Length != 0)
foreach ( CatalogItem ci in returnedItems)
if (ci.Type == ItemTypeEnum.Folder)
if (ci.Name == folder) return true;

return false;
}

folder is the name of the folder you are checking to see if it exists.

Adrian M.

[quoted text, click to view]

Hari
1/20/2005 6:39:01 PM
Thanks for your reply Adrian.
I know about the FindiTems method. I wanted to check whether a folder exists
in the current folder i am looking at. But find items will search the entire
heirarchy and if there is any folder somewhere else but not in the folder i
wanted to search in it would still give me a true value, which is not true.


[quoted text, click to view]
Adrian M.
1/21/2005 8:42:43 AM
Hari,

FindItems should work fine. Just pass in the full path of the folder you
want to search. You don't necessarily have to start from the root.

If you want to search the root:
CatalogItem[] returnedItems = m_ReportingService.FindItems( "/",
BooleanOperatorEnum.Or, conditions );

If you want to search a folder called Test:
CatalogItem[] returnedItems = m_ReportingService.FindItems( "/Test",
BooleanOperatorEnum.Or, conditions );

....etc

[quoted text, click to view]

AddThis Social Bookmark Button