private void CreateLinkedReport(string ReportServerPath, string UserName, string UserPassword, ReportServerMode ReportMode , HttpClientCredentialType ReportHttpClientCredentialType , string ReportFolder, string ReportName , string LinkedReportPath , ReportingService2010.Property[] LinkedReportProperties , XElement xLinkedReportParameters //, string ParameterLanguage ) { string serviceUrl; string execUrl; BasicHttpBinding basicHttpBinding; ConfigureReportServerBinding(ReportServerPath, ReportMode, ReportHttpClientCredentialType, out serviceUrl, out execUrl, out basicHttpBinding); using (ReportingService2010.ReportingService2010SoapClient rsService = new ReportingService2010.ReportingService2010SoapClient(basicHttpBinding, new EndpointAddress(serviceUrl))) { ReportingService2010.TrustedUserHeader trusteduserHeader; ReportExecution2005.TrustedUserHeader userHeader; GetHeaders(UserName, UserPassword, rsService, null, out trusteduserHeader, out userHeader); ReportingService2010.SearchCondition condition = new ReportingService2010.SearchCondition(); condition.Condition = ReportingService2010.ConditionEnum.Equals; condition.ConditionSpecified = true; condition.Name = "Name"; ReportingService2010.SearchCondition[] conditions = new ReportingService2010.SearchCondition[1]; conditions[0] = condition; ReportingService2010.CatalogItem[] foundItems = null; condition.Values = new string[] { ReportName.TrimStart('/').TrimEnd('/') }; rsService.FindItems(trusteduserHeader , "/" + ReportFolder.TrimStart('/').TrimEnd('/') , ReportingService2010.BooleanOperatorEnum.And , new ReportingService2010.Property[0] , conditions , out foundItems); if (foundItems != null && foundItems.Count() > 0) { foreach (var item in foundItems) { if (item.Path == "/" + ReportFolder.TrimStart('/').TrimEnd('/') + "/" + ReportName) { string parentReportPath = item.Path; try { string linkedReportName = LinkedReportPath.Substring(LinkedReportPath.LastIndexOf('/') + 1).TrimStart('/').TrimEnd('/'); string linkedReportFolderPath = LinkedReportPath.Substring(0, LinkedReportPath.LastIndexOf('/')).TrimEnd('/'); CheckLinkedFolderExists(rsService, trusteduserHeader, condition, conditions, linkedReportFolderPath); ReportingService2010.CatalogItem[] foundLinkedItems = null; condition.Values = new string[] { linkedReportName }; rsService.FindItems(trusteduserHeader , linkedReportFolderPath , ReportingService2010.BooleanOperatorEnum.And , new ReportingService2010.Property[0] , conditions , out foundLinkedItems); if (foundLinkedItems == null || (foundLinkedItems != null && foundLinkedItems.Count() == 0)) { rsService.CreateLinkedItem(trusteduserHeader , linkedReportName , linkedReportFolderPath , parentReportPath , LinkedReportProperties); } if (xLinkedReportParameters != null) { //// List of properties to copy from parent to linked reports. ??? //var requestedProperties = new ReportingService2010.Property[] { // new ReportingService2010.Property { Name = "PageHeight" }, // new ReportingService2010.Property { Name = "PageWidth" }, // new ReportingService2010.Property { Name = "TopMargin" }, // new ReportingService2010.Property { Name = "BottomMargin" }, // new ReportingService2010.Property { Name = "LeftMargin" }, // new ReportingService2010.Property { Name = "RightMargin" } //}; IEnumerable<XElement> linkedReportParams = xLinkedReportParameters.Descendants("Param"); if (linkedReportParams.Count() > 0) { List<ReportingService2010.ItemParameter> ItemParamsList = new List<ReportingService2010.ItemParameter>(); foreach (var linkedReportParam in linkedReportParams) { string defaultValues = linkedReportParam.Attribute("DefaultValues").Value; if (!string.IsNullOrEmpty(defaultValues)) { ReportingService2010.ItemParameter[] parentReportParams = null; rsService.GetItemParameters(trusteduserHeader , parentReportPath , null , false, null, null, out parentReportParams); bool paramExists = false; ReportingService2010.ItemParameter ip = new ReportingService2010.ItemParameter(); ip.Name = linkedReportParam.Attribute("Name").Value; foreach (var parentReportParam in parentReportParams) { if (parentReportParam.Name == ip.Name) { ip.AllowBlank = parentReportParam.AllowBlank; ip.MultiValue = parentReportParam.MultiValue; ip.Nullable = parentReportParam.Nullable; ip.Prompt = parentReportParam.Prompt; ip.PromptUser = parentReportParam.PromptUser; ip.PromptUserSpecified = parentReportParam.PromptUserSpecified; paramExists = true; break; } } if (paramExists) { ip.DefaultValues = defaultValues.Split(','); if (linkedReportParam.Attribute("Hide") != null && linkedReportParam.Attribute("Hide").Value.ToLower() == "true") { //hide the paramerter using combination of parameters. There is no Hide property which reflects UI Hide checkbox ip.PromptUser = false; ip.PromptUserSpecified = false; ip.Prompt = null; } ItemParamsList.Add(ip); } } } rsService.SetItemParameters(trusteduserHeader, LinkedReportPath, ItemParamsList.ToArray()); } } } catch (SoapException ex) { LogMessage("Not able to create linked report " + LinkedReportPath + " Error: " + ex.Message); throw; } break; } } } } }
private static void CreateReports(ReportingService2010 reportingService, string path) { if (reportingService == null) { throw new ArgumentNullException("reportingService"); } if (string.IsNullOrEmpty(path)) { throw new ArgumentException("path"); } foreach (ReportItem report in SetupReportItems) { string fullPath = string.Format(report.Path, path); string parent = TesterUtility.GetParentPath(fullPath); Warning[] warnings; reportingService.CreateCatalogItem("Report", report.Name, parent, true, report.Definition, null, out warnings); } }
private static void ResetTheDataSource_for_a_Report(string sPathAndFileNameOfTheReport, string sPathAndFileNameForDataSource) { //from: http://stackoverflow.com/questions/13144604/ssrs-reportingservice2010-change-embedded-datasource-to-shared-datasource ReportingService2010 rs = new ReportingService2010(); rs.Credentials = System.Net.CredentialCache.DefaultCredentials; string reportPathAndName = sPathAndFileNameOfTheReport; //example of sPathAndFileNameOfTheReport "/0_Contacts/207_Practices_County_CareManager_Role_ContactInfo"; List <ReportService2010.ItemReference> itemRefs = new List <ReportService2010.ItemReference>(); ReportService2010.DataSource[] itemDataSources = rs.GetItemDataSources(reportPathAndName); foreach (ReportService2010.DataSource itemDataSource in itemDataSources) { ReportService2010.ItemReference itemRef = new ReportService2010.ItemReference(); itemRef.Name = itemDataSource.Name; //example of DataSource i.e. 'itemRef.Reference': "/DataSources/SharedDataSource_DB2_CRM"; itemRef.Reference = sPathAndFileNameForDataSource; itemRefs.Add(itemRef); } rs.SetItemReferences(reportPathAndName, itemRefs.ToArray()); }
public static void SetDataSource(string itemPath, ReportingService2010 report) { if (report == null) { throw new ArgumentNullException($"report"); } if (itemPath == null) { throw new ArgumentNullException($"itemPath"); } List <DataSource> lstDs = new List <DataSource>(); foreach (DataSource ds in report.GetItemDataSources(itemPath)) { DataSourceDefinition dataDef = (DataSourceDefinition)ds.Item; DataSource dsNew = new DataSource(); DataSourceDefinition dfNew = new DataSourceDefinition(); dfNew.CredentialRetrieval = CredentialRetrievalEnum.Integrated; dfNew.WindowsCredentials = false; dfNew.UseOriginalConnectString = false; dfNew.Extension = dataDef.Extension; dsNew.Name = ds.Name; dsNew.Item = dataDef; lstDs.Add(dsNew); } report.SetItemDataSources(itemPath, lstDs.ToArray()); }
//Report Web Service static void Main(string[] args) { ReportingService2010 rs = new ReportingService2010(); rs.Credentials = System.Net.CredentialCache.DefaultCredentials; rs.Url = "http://1MJMPQB/ReportServer2019/ReportService2010.asmx"; Property name = new Property(); name.Name = "Name"; Property description = new Property(); description.Name = "Description"; Property[] properties = new Property[2]; properties[0] = name; properties[1] = description; try { Property[] returnProperties = rs.GetProperties( "/Reports2019/AuthorizationForm", properties); foreach (Property p in returnProperties) { Console.WriteLine(p.Name + ": " + p.Value); } } catch (Exception e) { Console.WriteLine(e.Message); } }
public static string CreateSubscription(string reportPath, string routeClass, string driverName) { //Create a new subscription string subscriptionID = ""; try { //Create reporting service web client proxy _Client = new ReportingService2010(); _Client.Credentials = System.Net.CredentialCache.DefaultCredentials; // ExtensionSettings extSettings = setExtSettings(); string description = "Send e-mail to [email protected]"; string eventType = "TimedSubscription"; string matchData = setMatchData(DateTime.Today); ParameterValue pv1 = new ParameterValue(); pv1.Name = "RouteDate"; pv1.Value = null; ParameterValue pv2 = new ParameterValue(); pv2.Name = "RouteClass"; pv2.Value = routeClass; ParameterValue pv3 = new ParameterValue(); pv3.Name = "DriverName"; pv3.Value = driverName; ParameterValue[] parameters = new ParameterValue[] { pv1, pv2, pv3 }; subscriptionID = _Client.CreateSubscription(reportPath, extSettings, description, eventType, matchData, parameters); } catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException fe) { _Client.Abort(); throw new ApplicationException(fe.Message); } catch (CommunicationException ce) { _Client.Abort(); throw new ApplicationException(ce.Message); } return(subscriptionID); }
public List <ReportInfo> GetReportsInfo() { var service = new ReportingService2010(); service.Credentials = Credentials; CatalogItem[] items = service.ListChildren("/", true); var reportsInfo = new List <ReportInfo>(); foreach (var item in items) { if (item.TypeName != "Report") { continue; } var parameters = service.GetItemParameters(item.Path, null, true, null, null); reportsInfo.Add(new ReportInfo { Name = item.Name, Path = item.Path, Parameters = parameters.Select(p => new ReportParameter { Name = p.Name, Prompt = p.Prompt, ValueType = Type.GetType($"System.{p.ParameterTypeName}", true, true).GetType(), DefaultValue = p.DefaultValues?.FirstOrDefault() }).ToList() }); } return(reportsInfo); }
/// <summary> /// Create DataSource /// </summary> /// <param name="client"></param> /// <param name="connectionString"></param> /// <param name="folderName"></param> private static void CreateDataSource(ReportingService2010 client, string connectionString, string folderName) { try { string name = "ReportDataSource"; string parent = $"/{folderName}"; DataSourceDefinition definition = new DataSourceDefinition { CredentialRetrieval = CredentialRetrievalEnum.Integrated, ConnectString = connectionString, Enabled = true, EnabledSpecified = true, Extension = "SQL", ImpersonateUserSpecified = false, Prompt = null, WindowsCredentials = false }; //Use the default prompt string. try { client.CreateDataSource(name, parent, true, definition, null); } catch (SoapException e) { Console.WriteLine(e.Detail.InnerXml.ToString()); throw e; } } catch (Exception e) { Console.WriteLine(e); throw; } }
/// <summary> /// Gets the reporting service object. /// </summary> /// <param name="url">The URL.</param> /// <param name="credentials">The credentials.</param> /// <returns></returns> /// <exception cref="System.ArgumentException">url</exception> private static ReportingService2010 GetReportingService(string url, ICredentials credentials) { if (string.IsNullOrEmpty(url)) { throw new ArgumentException("url"); } if (credentials == null) { credentials = CredentialCache.DefaultNetworkCredentials; } if (!url.EndsWith("reportservice2010.asmx")) { if (url.EndsWith("/")) { url = url.Substring(0, url.Length - 1); } url = string.Format("{0}/reportservice2010.asmx", url); } ReportingService2010 service = new ReportingService2010(); service.Url = url; service.Credentials = credentials; service.PreAuthenticate = true; service.UseDefaultCredentials = true; return(service); }
public MsReportingServices(string reportingServicesUrl, string networkDomain, string networkLogin, string networkPassword) { Uri reportingServicesUri; Log("Creating MsReportingServices instance"); if (!Uri.TryCreate(reportingServicesUrl, UriKind.RelativeOrAbsolute, out reportingServicesUri)) { throw new UriFormatException(string.Format("reporting services uri of '{0}' is invalid!", reportingServicesUri)); } if (string.IsNullOrWhiteSpace(networkPassword)) { throw new NullReferenceException("networkPassword is null or empty!"); } if (string.IsNullOrWhiteSpace(networkDomain)) { throw new NullReferenceException("networkDomain is null or empty!"); } if (string.IsNullOrWhiteSpace(networkLogin)) { throw new NullReferenceException("networkLogin is null or empty!"); } rs = new ReportingService2010 { Url = reportingServicesUri.AbsoluteUri, Credentials = new NetworkCredential(networkLogin, networkPassword, networkDomain) }; }
private void _UpdateParameterListForSelectedReport() { List <ReportParameter> tmpParamList = new List <ReportParameter>(m_ParamList); ReportingService2010 rs = new ReportingService2010(); rs.Credentials = System.Net.CredentialCache.DefaultCredentials; rs.Url = m_AppSettings.GetReportServerUrl.ToString(); string historyId = null; Reportingservice2010.ParameterValue[] values = null; Reportingservice2010.DataSourceCredentials[] credentials = null; string rptName = string.Format("/{0}/{1}", m_AppSettings.GetReportsRootFolder, Session["SelectedReport"]); var parameters = rs.GetItemParameters(string.Format("/{0}/{1}", m_AppSettings.GetReportsRootFolder, Session["SelectedReport"]), historyId, true, values, credentials); foreach (ReportParameter apParm in tmpParamList) { bool belongs = false; string apName = apParm.Name; foreach (var svrParm in parameters) { string svrName = svrParm.Name; if (apName == svrName) { belongs = true; break; } } if (belongs == false) { m_ParamList.Remove(apParm); } } }
public static string CreateSubscription(string agentNumber, string agentRepEmail) { //Create a new subscription string reportPath = "/Customer Service/Internal Delivery Window By Store"; string subscriptionID = ""; try { //Create reporting service web client proxy _Client = new ReportingService2010(); _Client.Credentials = System.Net.CredentialCache.DefaultCredentials; // ExtensionSettings extSettings = setExtSettings(agentRepEmail); string description = "Send e-mail to " + agentRepEmail; string eventType = "TimedSubscription"; string matchData = setMatchData(DateTime.Today); ParameterValue pv1 = new ParameterValue(); pv1.Name = "AgentNumber"; pv1.Value = agentNumber; ParameterValue pv2 = new ParameterValue(); pv2.Name = "EndDate"; pv2.Value = null; ParameterValue pv3 = new ParameterValue(); pv3.Name = "ClientNumber"; pv3.Value = null; ParameterValue pv4 = new ParameterValue(); pv4.Name = "Division"; pv4.Value = null; ParameterValue pv5 = new ParameterValue(); pv5.Name = "District"; pv5.Value = null; ParameterValue pv6 = new ParameterValue(); pv6.Name = "Region"; pv6.Value = null; ParameterValue pv7 = new ParameterValue(); pv7.Name = "StoreNumber"; pv7.Value = null; ParameterValue[] parameters = new ParameterValue[] { pv4, pv1, pv5, pv6, pv7, pv3 }; subscriptionID = _Client.CreateSubscription(reportPath, extSettings, description, eventType, matchData, parameters); } catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException(te.Message); } return(subscriptionID); }
private bool ValidateConnection(string reportingServiceUrl) { bool connectionStatus = false; using (ReportingService2010 rs = new ReportingService2010()) { rs.Credentials = CredentialCache.DefaultCredentials; rs.Url = string.Format("{0}/ReportService2010.asmx?wsdl", reportingServiceUrl); var serviceRequest = (HttpWebRequest)WebRequest.Create(rs.Url); serviceRequest.Credentials = CredentialCache.DefaultCredentials; try { var response = (HttpWebResponse)serviceRequest.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { connectionStatus = true; } } catch { connectionStatus = false; } } return(connectionStatus); }
public ActionResult Login(Login model, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } LoggingHelper.LogInformation("User signing in..."); if (Membership.ValidateUser(model.UserName, model.Password)) { LoginUser.UserName = model.UserName; LoginUser.Password = model.Password; FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); ReportingService2010 reportingSvc = new ReportingService2010(); reportingSvc.Credentials = new System.Net.NetworkCredential(model.UserName, model.Password, Domain); HttpContext.Session.Add(Helpers.ReportServer.REPORTSERVERNAME, reportingSvc); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { LoggingHelper.LogInformation("User redirecting..."); return(Redirect(returnUrl)); } LoggingHelper.LogInformation("User goes to the main page..."); return(RedirectToAction("Index", "Grids")); } LoginUser.UserName = string.Empty; LoginUser.Password = string.Empty; ModelState.AddModelError(string.Empty, @"The user name or password is incorrect"); return(View(model)); }
public bool CreateDataSet(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, string name, string parent) { bool objReturn = false; XmlSerializer serializer = null; SharedDataSet dataSet = null; MemoryStream stream = null; try { if (!CheckItemExists("DataSet", parent + "/" + name)) { if (rsMain == null) { rsMain = new ReportingService2010() { Url = ReportServiceUrl, Credentials = System.Net.CredentialCache.DefaultCredentials } } ; serializer = new XmlSerializer(typeof(SharedDataSet)); dataSet = new SharedDataSet(CURRENT_REGISTRY_ID); stream = new MemoryStream(); serializer.Serialize(stream, dataSet); byte[] definition = stream.ToArray(); Warning[] warnings = null; LogDetails logDetails = new LogDetails(String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), CURRENT_USER, CURRENT_REGISTRY_ID); CatalogItem item = rsMain.CreateCatalogItem("DataSet", name, parent, false, definition, null, out warnings); LogManager.LogTiming(logDetails); if (item != null) { objReturn = true; } } else { objReturn = true; } } catch (Exception ex) { LogManager.LogError(ex.Message, String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), CURRENT_USER, CURRENT_REGISTRY_ID); throw ex; } finally { if (stream != null) { stream.Close(); stream.Dispose(); stream = null; } } return(objReturn); }
protected override IReportServerRepository CreateInstance(IContext context) { string url = Properties.Settings.Default.ReportServer2008R2WebServiceUrl; string path = Properties.Settings.Default.DestinationPath; if (!url.EndsWith("reportservice2010.asmx")) { if (url.EndsWith("/")) { url = url.Substring(0, url.Length - 1); } url = string.Format("{0}/reportservice2010.asmx", url); } ReportingService2010 service = new ReportingService2010(); service.Url = url; service.Credentials = CredentialCache.DefaultNetworkCredentials; service.PreAuthenticate = true; service.UseDefaultCredentials = true; return(new ReportServer2010Repository(path, service, new ReportingService2010DataMapper())); }
static void Main(string[] args) { ReportingService2010 rs = new ReportingService2010(); rs.Url = "http://<Server Name>" + "/_vti_bin/ReportServer/ReportService2010.asmx"; rs.Credentials = System.Net.CredentialCache.DefaultCredentials; string name = "AdventureWorks.rsds"; string parent = "http://<Server Name>/Docs/Documents/"; // Define the data source definition. DataSourceDefinition definition = new DataSourceDefinition(); definition.CredentialRetrieval = CredentialRetrievalEnum.Integrated; definition.ConnectString = "data source=(local);initial catalog=AdventureWorks"; definition.Enabled = true; definition.EnabledSpecified = true; definition.Extension = "SQL"; definition.ImpersonateUserSpecified = false; //Use the default prompt string. definition.Prompt = null; definition.WindowsCredentials = false; try { rs.CreateDataSource(name, parent, false, definition, null); } catch (SoapException e) { Console.WriteLine(e.Detail.InnerXml.ToString()); } }
//Interface static ReportingGateway() { // _Client = new ReportingService2010(); _state = true; _address = _Client.Url; }
private void SetPTODataSource(string DbName) { ReportingService2010 rs = new ReportingService2010(); rs.Url = SSRSWS; rs.Credentials = System.Net.CredentialCache.DefaultCredentials; DataSourceDefinition definition = new DataSourceDefinition(); definition.CredentialRetrieval = CredentialRetrievalEnum.Integrated; definition.ConnectString = "Data Source=" + SqlServer + ";Initial Catalog=" + DbName; definition.Enabled = true; definition.EnabledSpecified = true; definition.Extension = "SQL"; definition.ImpersonateUser = false; definition.ImpersonateUserSpecified = true; definition.Prompt = null; definition.WindowsCredentials = false; try { rs.SetDataSourceContents("/Data Sources/SQLPTO", definition); } catch { //Console.WriteLine(e.Detail.OuterXml); } }
//list reporting service catalog items private CatalogItem[] GetCatalogItems(ReportingService2010 rs2010, string value) { CatalogItem[] items; SearchCondition condition = new SearchCondition(); condition.Condition = ConditionEnum.Contains; condition.ConditionSpecified = true; condition.Name = "Name"; condition.Values = new string[] { value }; try { items = rs2010.FindItems("/", BooleanOperatorEnum.And, new Property[] { new Property() { Name = "Recursive", Value = "True" } }, new SearchCondition[] { condition }); return(items); } catch (Exception ex) { MessageBox.Show(ex.Message); return(null); } }
private static void CreateReport(ReportingService2010 reportingService, ReportItem report) { if (reportingService == null) { throw new ArgumentNullException("reportingService"); } if (report == null) { throw new ArgumentNullException("report"); } string parent = TesterUtility.GetParentPath(report.Path); ReportingService2010TestEnvironment.CreateFolderFromPath(reportingService, parent); Warning[] warnings; reportingService.CreateCatalogItem("Report", report.Name, parent, true, report.Definition, null, out warnings); }
public JsonResult Index(string username, string password) { try { string url = WebConfigurationManager.AppSettings["ReportingServerURL"]; ReportingService2010 rs = new ReportingService2010(); //rs.Credentials = System.Net.CredentialCache.DefaultCredentials; rs.Credentials = new System.Net.NetworkCredential(username, password, url); var items = rs.ListChildren("/", true);//Hoxworth int f = 0; for (int i = 0; i < items.Length; i++) { if (items[i].TypeName.Equals("Report")) { f = 1; break; } } if (f == 0) { return(Json("failure")); } User user = new User { Username = username, Password = password, IsLoggedIn = true }; Session["user"] = user; Session.Timeout = 20; return(Json("success")); } catch (Exception ex) { return(Json("failure")); } }
/// <summary> /// Teardowns the environment. /// </summary> /// <param name="url">The URL.</param> /// <param name="credentials">The credentials.</param> /// <param name="path">The path to delete.</param>/param> /// <exception cref="System.ArgumentException"> /// url /// or /// path /// </exception> public static void TeardownEnvironment(string url, ICredentials credentials, string path) { if (string.IsNullOrEmpty(url)) { throw new ArgumentException("url"); } if (string.IsNullOrEmpty(path)) { throw new ArgumentException("path"); } ReportingService2010 service = ReportingService2010TestEnvironment.GetReportingService(url, credentials); // If the path exists, delete it to clean up after the tests if (ReportingService2010TestEnvironment.ItemExists(service, path, "Folder")) { service.DeleteItem(path); } if (ReportingService2010TestEnvironment.ItemExists(service, path, "Folder")) { service.DeleteItem(path); } }
private static void Main(string[] args) { var reportingService = new ReportingService2010 { Credentials = CredentialCache.DefaultCredentials, Url = "http://SQLREPORTS/ReportServer/ReportService2010.asmx" }; var items = reportingService.FindItems("/", BooleanOperatorEnum.And, new Property[] { }, new SearchCondition[] { }); var reports = from item in items let typeName = item.TypeName where typeName == "Report" && item.Hidden != true select item; using (var writer = new StreamWriter(File.OpenWrite("ReportParameter.csv"))) { writer.WriteLine("ReportName,ParameterName"); foreach (var report in reports) { Debug.WriteLine(report.Name); var parameters = reportingService.GetItemParameters(report.Path, null, false, null, null); foreach (var parameter in parameters) { Debug.WriteLine("{0} - {1}", report.Name, parameter.Name); writer.WriteLine("{0},{1}", report.Name, parameter.Name); } } } }
public static ReportingService2010 ReportWebServiceInstance(System.Web.HttpContextBase httpContext) { if (instance == null) { instance = (ReportingService2010)httpContext.Session[REPORTSERVERNAME]; } return(instance); }
public void Dispose() { if (rsMain != null) { rsMain.Dispose(); rsMain = null; } }
public bool AddSystemAdmin(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, string username) { bool objReturn = false; try { if (rsMain == null) { rsMain = new ReportingService2010() { Url = ReportServiceUrl, Credentials = System.Net.CredentialCache.DefaultCredentials } } ; LogDetails logDetails = new LogDetails(String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), CURRENT_USER, CURRENT_REGISTRY_ID); Role[] roles = rsMain.ListRoles("System", string.Empty); if (roles != null) { bool foundUser = false; Policy[] policies = rsMain.GetSystemPolicies(); if (policies != null) { foreach (Policy policy in policies) { if (policy.GroupUserName.Equals(username, StringComparison.InvariantCultureIgnoreCase)) { foundUser = true; policy.Roles = roles; break; } } } if (!foundUser) { Policy policy = new Policy(); policy.GroupUserName = username; policy.Roles = roles; AddToArray(ref policies, policy); } rsMain.SetSystemPolicies(policies); objReturn = true; } LogManager.LogTiming(logDetails); } catch (Exception ex) { LogManager.LogError(ex.Message, String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), CURRENT_USER, CURRENT_REGISTRY_ID); throw ex; } return(objReturn); }
// // GET: /Report/Home/ public ActionResult Index() { var rs = new ReportingService2010 { Credentials = System.Net.CredentialCache.DefaultCredentials, //Url = "http://USER-PC/ReportServer/ReportService2010.asmx" }; //var folders = rs.ListChildren("/", false); //var reportFolders = new List<ReportFolder>(); //foreach (var folder in folders) //{ // var reportFolder = new ReportFolder {Name = folder.Name, URL = folder.Path}; // var reports = rs.ListChildren("/" + folder.Name + "/", false); // foreach (var report in reports) // { // var reportObj = new ReportObj {Name = report.Name, URL = report.Path}; // reportFolder.Reports.Add(reportObj); // } // reportFolders.Add(reportFolder); //} var reportFolders = new List <ReportFolder>() { new ReportFolder { Name = "EarlyWarning", URL = "/EarlyWarning", Reports = new List <ReportObj> { new ReportObj { Name = "StockStatus", URL = "/EarlyWarning/StockStatus", Description = "Sample Desc 1" } } }, new ReportFolder { Name = "PSNP", URL = "/PSNP", Reports = new List <ReportObj> { new ReportObj { Name = "StockStatus", URL = "/EarlyWarning/StockStatus", Description = "Sample Desc 1" } } }, new ReportFolder { Name = "Logistics", URL = "/Logistics", Reports = new List <ReportObj> { new ReportObj { Name = "StockStatus", URL = "/EarlyWarning/StockStatus", Description = "Sample Desc 1" } } }, new ReportFolder { Name = "Procurement", URL = "/Procurement", Reports = new List <ReportObj> { new ReportObj { Name = "StockStatus", URL = "/EarlyWarning/StockStatus", Description = "Sample Desc 1" } } }, }; return(View(reportFolders)); }
private static void CreateFolders(ReportingService2010 reportingService, string path) { foreach (FolderItem folder in SetupFolderItems) { string fullPath = string.Format(folder.Path, path); ReportingService2010TestEnvironment.CreateFolderFromPath(reportingService, fullPath); } }
public ReportSubscriptionManager() { rs = new ReportingService2010(); rs.Url = ConfigurationManager.AppSettings[ReportServerURL]; rs.Credentials = System.Net.CredentialCache.DefaultCredentials; rs.UseDefaultCredentials = true; }
//initialise reporting service private ReportingService2010 GetReportingService(string url) { ReportingService2010 RS2010 = new ReportingService2010(); RS2010.Url = url; RS2010.Credentials = System.Net.CredentialCache.DefaultCredentials; return(RS2010); }
public SSRSExport(string username, string password, string domain, bool defaultCredentials, string webServiceUrl) { this.mUsername = username; this.mPassword = password; this.mDomain = domain; this.mDefaultCredentials = defaultCredentials; this.mWebServiceUrl = webServiceUrl; this.mReportingService = new ReportingService2010(); if (!this.mWebServiceUrl.EndsWith("asmx")) this.mReportingService.Url = string.Format("{0}\\{1}", this.mWebServiceUrl, this.mWebServiceEndPoint); else this.mReportingService.Url = this.mWebServiceUrl; }
public SSRSExport() { this.mReportingService = new ReportingService2010(); }
private static DataSource[] GetSharedDataSource(ReportingService2010.ReportingService2010 rs, string reportsFolder, string reportName) { V4Utils.Logger logger; logger = V4Utils.Logger.GetLogger("SSRSTest"); try { DataSourceReference reference = new DataSourceReference(); DataSource ds = new DataSource(); reference.Reference = @"/"; //+ reportsFolder + "/" + "SharedDataSource"; ds.Item = (DataSourceDefinitionOrReference)reference; //Get original report Data Source Name DataSource[] reportDataSource = rs.GetItemDataSources(@"/" + reportsFolder + @"/" + reportName); ds.Name = reportDataSource[0].Name; //Testing: change existing data source name to match shared data source //ds.Name = "V4_SPPS_V6"; return new DataSource[] { ds }; } catch (System.Web.Services.Protocols.SoapException Err) { logger.LogMsg(Err.Detail.InnerXml.ToString(), Logger.LogLevel.LogIsErr); //WriteLog(Err.Detail.InnerXml.ToString()); } return null; }
public ReportsService() { _reportingService = new ReportingService2010 { Credentials = System.Net.CredentialCache.DefaultCredentials }; ServerUrl = ConfigurationManager.AppSettings["ReportServerUrl"]; }
private static void GetHeaders(string UserName, string UserPassword, ReportingService2010.ReportingService2010SoapClient rsService, ReportExecution2005.ReportExecutionServiceSoapClient rsExec, out ReportingService2010.TrustedUserHeader trusteduserHeader, out ReportExecution2005.TrustedUserHeader userHeader) { rsService.ClientCredentials.SupportInteractive = false; rsService.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials; rsService.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; System.Net.NetworkCredential clientCredentials = new System.Net.NetworkCredential(UserName, UserPassword); if (!string.IsNullOrEmpty(UserName) && !string.IsNullOrEmpty(UserPassword) && UserName != "@UserName" && UserPassword != "@UserPassword") { rsService.ClientCredentials.Windows.ClientCredential = clientCredentials; rsService.ClientCredentials.UserName.UserName = UserName; rsService.ClientCredentials.UserName.UserName = UserPassword; } trusteduserHeader = new ReportingService2010.TrustedUserHeader(); trusteduserHeader.UserName = clientCredentials.UserName; userHeader = new ReportExecution2005.TrustedUserHeader(); userHeader.UserName = clientCredentials.UserName; if (rsExec != null) { rsExec.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation; //rsExec.ClientCredentials.Windows.ClientCredential = credentials.GetCredential(new Uri(baseUrl), "NTLM"); } }
private ReportingService2010 CreateWebClient() { var result = new ReportingService2010(); result.Url = this.Url; result.UseDefaultCredentials = true; result.PreAuthenticate = true; return result; }
public SubscriptionManager(ReportingService2010 client) { this.client = client; }
private void CheckLinkedFolderExists(ReportingService2010.ReportingService2010SoapClient rsService , ReportingService2010.TrustedUserHeader trusteduserHeader , ReportingService2010.SearchCondition condition , ReportingService2010.SearchCondition[] conditions , string linkedReportFolderPath ) { string parentFolderPath = @"/"; string[] folders = linkedReportFolderPath.Split('/'); for (int i = 0; i < folders.Length; i++) { if (!string.IsNullOrEmpty(folders[i])) { ReportingService2010.CatalogItem[] foundItems = null; condition.Values = new string[] { folders[i] }; rsService.FindItems(trusteduserHeader , parentFolderPath , ReportingService2010.BooleanOperatorEnum.And , new ReportingService2010.Property[0] , conditions , out foundItems); if (foundItems == null || (foundItems != null && foundItems.Count() == 0)) { ReportingService2010.CatalogItem linkedFolder = new ReportingService2010.CatalogItem(); rsService.CreateFolder(trusteduserHeader , folders[i] , parentFolderPath , new ReportingService2010.Property[0] , out linkedFolder ); } parentFolderPath = parentFolderPath.TrimEnd('/') + @"/" + folders[i]; } } }