SSRS CreateSubscription - setting Locale - ssrs-2008

We have a custom built application, based on silverlight, which manages our report subscriptions. The problem is that whenever you add a new subscription, it sets the Locale value in the Subscriptions table to 'en-US'.
When you create subscriptions directly in Report Manager, the value in the Locale field is determined by your browser language settings (this is exactly what we want to achieve).
We can't find a way to set the Locale field before we call the CreateSubscription method as it doesn't seem to accept the Locale parameter and it defaults to en-US (which I believe is a server setting).
Do you know of any way to set Locale when creating subscriptions in SSRS?

As far as I can see there is no way to do this; I've been using the service via C#.
I decided upon a solution of obtaining the language/locale of the report via the service, and then making the changes directly in the ReportServer database, as an UPDATE statement on the SubscriptionID.
To get the language/locale of the report I use something like:
private static void Main()
{
ReportingService2010 service = new ReportingService2010();
service.Url = "URL of service";
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
string reportItemPath = "Path of report";
string language = GetReportPropertyValue(service, reportItemPath, "Language", "en-GB");
// Create the subscription, then update the database using the returned SubscriptionID.
}
private static string GetReportPropertyValue(ReportingService2010 service, string itemPath, string propertyName, string defaultValue)
{
Property[] properties = service.GetProperties(itemPath, null);
if (properties.Any(p => p.Name == propertyName))
return properties.First(p => p.Name == propertyName).Value;
else
return defaultValue;
}

I haven't tried it via the SOAP API yet, but shouldn't it be possible to set the Accept-Language header?
I'm doing this when rendering reports in different languages. The language of each report is set to =User!Language.
When using WCF to access the reporting service, you can do (example as VB.NET)
Using oReportingService As New ReportingService2010SoapClient
oReportingService.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation
Using oScope As OperationContextScope = New OperationContextScope(oReportingService.InnerChannel)
If i_oSubscription.Language IsNot Nothing Then
' Accept-Language
Dim oHttpRequestProperty As New HttpRequestMessageProperty
oHttpRequestProperty.Headers.Add(HttpRequestHeader.AcceptLanguage, i_oSubscription.Language)
OperationContext.Current.OutgoingMessageProperties(HttpRequestMessageProperty.Name) = oHttpRequestProperty
End If
oReportingService.CreateSubscription(New ReportingService2010.TrustedUserHeader(), i_oSubscription.Path, oExtensionSettings, i_oSubscription.Description, "TimedSubscription", sMatchData, lstParameters.ToArray(), sSubscriptionId)
Return sSubscriptionId
End Using
End Using
Edit: This is the way I'm doing it myself and it seems to work :)
i_oSubscription is just a simple container with properties like Description
Note: this seems to work for the most part. However, the "Days" field in a MonthlyRecurrence is to be formatted locale-dependent (see: https://stackoverflow.com/questions/16011008/ssrs-monthlyrecurrence-formatting-for-different-languages)

Related

Bukkit - Why is it displaying null (using a config file)

So, I am making a custom plugin for my server, and one of my features requires me to set an integer in a gui that shows how many 'CommonPackages' a user has. The issue that I am having is that when I am getting the String from my config (My config uses a custom file creation/management class that was given to me by a friend) it is saying that it is null in the gui, I do not get any errors in the console, please may someone help me? The item in the gui and the code for setting the item in the gui.
Item in the gui
gui creation code:
public static Inventory WhiteBackpack(Player player) {
UUID uuid = player.getUniqueId();
Inventory inv = Bukkit.createInventory(null, 27, (inventoryname));
ItemStack common = new ItemStack(Material.INK_SACK);
common.setDurability((byte) 8);
ItemMeta commonMeta = common.getItemMeta();
commonMeta.setDisplayName(Utils.chat("&fCommon Packages &8ยป &f&l" + Main.pl.getFileControl().getConfig().getString("players." + uuid + ".Packages.Common"))); //How I access my custom configs.
common.setItemMeta(commonMeta);
inv.setItem(10, common);
return inv;
}
Without the code of your method to get the config I can only say that the string in the actual file is not present.
As the Bukkit documentation states:
If the String does not exist and no default value was specified, this will return null.
So either the key just does not exist in the file or you pointed to the wrong file. The configuration should be well formated, too. (no tabs, only spaces)

Get Word's window handle to use with WPF windows

I have a number of WPF dialogs in my Word Add-In. For one of them (and only one, strangely), it is sometimes not focused when opened. I believe I need to set its parent.
I know there is a way to set the owner of a WPF window to a HWND, but is there any way to get a HWND in Word 2010? I found this HWND property but it is Word 2013 and later only. Is there any other way to get Word's HWND, other than using GetForegroundWindow() which does not guarantee the handle for the window I actually want (or any other similar kludge)?
I found something helpful in Get specific window handle using Office interop. But all those answers are based on getting the handle for a window you're newly creating. I modified it somewhat to get an existing window, and stuffed it into a utility method.
doc is the current document.
using System.Windows.Interop;
using System.Diagnostics;
public void SetOwner(System.Windows.Window pd)
{
var wordProcs = Process.GetProcessesByName("winword").ToList();
// in read-only mode, this would be e.g. "1.docx [Read-Only] - Microsoft Word"
var procs = wordProcs.Where(x =>
x.MainWindowTitle.StartsWith(Path.GetFileName(doc.FullName))
&&
x.MainWindowTitle.EndsWith("- Microsoft Word"));
if (procs.Count() >= 1)
{
// would prefer Word 2013's Window.HWND property for this
var handle = procs.First().MainWindowHandle;
WindowInteropHelper wih = new WindowInteropHelper(pd);
wih.Owner = handle;
}
}
Unfortunately it doesn't seem to be possible to account for multiple windows with the same document name (in different folders), because the number of processes is never greater than 1. But I think that's an acceptable limitation.

Crystal reports - server and database

Im using visual studio 2010 + Sql Server 2008.
Im trying to show my reports using CR.. well when i try to use the system in my local machine, everything is ok.
I use store procedures to create reports.
The issue appears when i deploy the system in another PC.. A message appears asking for:
Server: // RETRIEVES ORIGINAL Server(Local)// Its not Correct i need to get Client Server
Database: // RETRIEVES ORIGINAL DB(Local)// Its not Correct i need to get Client DB
Username: I don't use any user , what user ?
Password: I don't use any password, what password?
i saw another solutions, but i can't find what's the data that i must use in Username or password. i use Windows autenthication to login to sql..
Thanks.
Regards.
Edit.. that's my code.. i can't use parameters, i don't receive any error. but system dont recognize the parameter that i send...
Dim NuevoReporte As New CReportNotaPorUsuario
Dim contenido As String
Dim ReportPath As String = My.Application.Info.DirectoryPath & "\CReportNotaPorUsuario.rpt"
Dim ConexionCR As New CrystalDecisions.Shared.ConnectionInfo()
contenido = Servicios.Funciones_Auxiliares.LeerArchivo(My.Application.Info.DirectoryPath & "\configuracion.txt")
ConexionCR.ServerName = Servicios.Funciones_Auxiliares.TextoEntreMarcas(contenido, "<server>", "</server>")
ConexionCR.DatabaseName = Servicios.Funciones_Auxiliares.TextoEntreMarcas(contenido, "<catalog>", "</catalog>")
ConexionCR.IntegratedSecurity = True
CrystalReportViewer1.ReportSource = ReportPath
'NuevoReporte.SetParameterValue("#cod_usuario", cbousuario.SelectedValue)
Dim field1 As ParameterField = Me.CrystalReportViewer1.ParameterFieldInfo(0)
Dim val1 As New ParameterDiscreteValue()
val1.Value = cbousuario.SelectedValue
field1.CurrentValues.Add(val1)
SetDBLogonForReport(ConexionCR)
It appears that you have separate servers and databases between the development and production environment. You need to make sure when you deploy your VS solution that the production server and database get referenced, not the development server and database.
There are some tutorials out there that can help you find a way to achieve this. Check out:
http://msdn.microsoft.com/en-us/library/dd193254(v=vs.100).aspx
Visual Studio 2010 Database Project Deploy to Different Environments
http://www.asp.net/web-forms/tutorials/deployment/advanced-enterprise-web-deployment/customizing-database-deployments-for-multiple-environments
EDIT: This seems to have evolved into a different issue than originally stated in the question. To dynamically get the connection string for CR from the text file, you will have to read teh text file first and put server name and database name into variables. Reading a text file, you can use something like string text = File.ReadAllText(#"C:\Folder\File.txt"); but you will need to extract server name and database name into variables. Then in order to use the variables in your connection string you use ConnectionInfo.Servername = variable1; and ConnectionInfo.DatabaseName = variable2.

Classic ASP: Server.CreateObject not supported

When I call Server.CreateObject(), from my Classic ASP page, I get
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method
I've tried the following (separately):
Server.CreateObject("Microsoft.XMLHTTP")
Server.CreateObject("MSXML2.XMLHTTP")
Server.CreateObject("MSXML.DOMDocument")
I know the ActiveX objects are installed because the following javascript calls work
var test = new ActiveXObject("Microsoft.XMLHTTP");
var test = new ActiveXObject("MSXML2.XMLHTTP");
var test = new ActiveXObject("MSXML.DOMDocument");
I'm calling it from my localhost IIS server. Any ideas how to troubleshoot this?
If you do the following:
Dim x: x = Server.CreateObject("My.ProgID.Here")
...VBScript creates the object and then attempts to access the default property for storing in 'x'. Since none of these objects have a default property defined (specifically an IDispatch-based property with [id(DISPID_VALUE)]), this fails with "Object doesn't support this property or method".
What you actually want is this:
Dim x: Set x = Server.CreateObject("My.ProgID.Here")
How about this one?
Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
Or downloading this component and installing on your webserver?
http://www.microsoft.com/downloads/details.aspx?FamilyId=3144B72B-B4F2-46DA-B4B6-C5D7485F2B42&displaylang=en
Then restarting the server and trying again.
Calling them from the browser doesn't mean that they are installed in IIS.

Setup App.Config As Custom Action in Setup Project

I have a custom application with a simple app.config specifying SQL Server name and Database, I want to prompt the user on application install for application configuration items and then update the app.config file.
I admit I'm totally new to setup projects and am looking for some guidance.
Thank You
Mark Koops
I had problems with the code Gulzar linked to on a 64 bit machine. I found the link below to be a simple solution to getting values from the config ui into the app.config.
http://raquila.com/software/configure-app-config-application-settings-during-msi-install/
check this out - Installer with a custom action for changing settings
App.Config CAN be changed...however it exists in a location akin to HKEY___LOCAL_MACHINE i.e. the average user has read-only access.
So you will need to change it as an administrator - best time would be during installation, where you're (supposed to be) installing with enhanced permissions.
So create an Installer class, use a Custom Action in the setup project to pass in the user's choices (e.g. "/svr=[SERVER] /db=[DB] /uilevel=[UILEVEL]") and, in the AfterInstall event, change the App.Config file using something like:
Public Shared Property AppConfigSetting(ByVal SettingName As String) As Object
Get
Return My.Settings.PropertyValues(SettingName)
End Get
Set(ByVal value As Object)
Dim AppConfigFilename As String = String.Concat(System.Reflection.Assembly.GetExecutingAssembly.Location, ".config")
If (My.Computer.FileSystem.FileExists(AppConfigFilename)) Then
Dim AppSettingXPath As String = String.Concat("/configuration/applicationSettings/", My.Application.Info.AssemblyName, ".My.MySettings/setting[#name='", SettingName, "']/value")
Dim AppConfigXML As New System.Xml.XmlDataDocument
With AppConfigXML
.Load(AppConfigFilename)
Dim DataNode As System.Xml.XmlNode = .SelectSingleNode(AppSettingXPath)
If (DataNode Is Nothing) Then
Throw New Xml.XmlException(String.Format("Application setting not found ({0})!", AppSettingXPath))
Else
DataNode.InnerText = value.ToString
End If
.Save(AppConfigFilename)
End With
Else
Throw New IO.FileNotFoundException("App.Config file not found!", AppConfigFilename)
End If
End Set
End Property
Create custom dialogs for use in your Visual Studio Setup projects:
http://www.codeproject.com/Articles/18834/Create-custom-dialogs-for-use-in-your-Visual-Studi