Wednesday, 1 May 2013

SSRS 2008 R2 on Windows 8… Cannot log in

I recently installed SQl Server 2008 R2 with Advanced Services on a Windows 8 Box. However, when I tried to log into the ReportManager of SSRS, I found that it wouldn’t accept my Username and Password Combo.

After some searching, I found this poston Stack Overflow, which explained it nicely;

http://stackoverflow.com/questions/14433068/user-does-not-have-required-permissions-ssrs-2008-on-windows-8

Turns out, that as standard, the Administrator account isn’t active in Windows 8, and needs to be turned on. More annoyingly, this means that SSRS needs to be uninstalled, and reinstalled using the hidden Administrator account.

The steps I took to finally resolve were;

  1. Uninstall SSRS Node COMPLETELY by going to control panel>SQL Server 2008>Remove>Check Reporting Services
  2. Enable default admin account: command prompt>run as administrator>net user administrator, hit enter.
  3. New line: net user administrator /active:yes
  4. Reboot
  5. Logging in as default administrator
  6. Setup a Password of your Choice
  7. Reinstall the SSRS Node
  8. Install SP3 as administrator
  9. Go to IE.exe DIRECTLY in Windows 8: C:\Program Files\Internet Explorer\iexplore.exe>Run as administrator.
  10. Go to http:// (servername)/Reports
  11. You SHOULD now be able to finally see site settings. NOW YOU CAN FOLLOW everyone's directions of adding YOUR USER under site settings. Also go to folder permissions and add the user as a default here as well.
  12. (optional) For safety I would hide the default admin account now by using step 2 but substitute /active:no in.

SSRS 2008 R2 Reports are blank in Chrome

I stumbled across this apparently well documented problem today, where my SSRS 2008R2 Report was showing up fine in IE, but blank in Chrome;

http://stackoverflow.com/questions/5968082/ssrs-2008-r2-reports-are-blank-in-safari-and-chrome

It seems as though the main Div Tag uses IE compatible only Overflow styles, which Chrome doesn’t interpret well.

I found a nice blog post here which explained how to work around this issue;

http://grumpydba.blogspot.co.uk/2012/02/sql-2008-r2-report-doesnt-show-on.html

The Short and curlies of it are;

Connect to your Reporting Services server, and find the relevant ReportingServices.js file - this will probably be somewhere like "C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportManager\js\ReportingServices.js", or on a 64 bit machine, "C:\Program Files (x86)\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportManager\js\ReportingServices.js"


First up, take a copy of this file - let's not be silly here and assume this is a 100% foolproof solution!
Next, edit this file in notepad. Do a quick search for PageLoad, to ensure no-one else has already hacked applied this fix, then jump to the bottom of the existing text.
Simply append the following code:

function pageLoad() 
{
    var element = document.getElementById("ctl31_ctl10");
    if (element)
    {
        element.style.overflow = "visible";
    } 
}


Save the file, and restart Reporting Services - you should now find that Chrome displays your reports again.


You’ll need to find the correct ElementId, by viewing the Source of the report in Chrome. If you search for “VisibleReportContent”, you should find something like “VisibleReportContentctl31_ctl09”. Where the “ctl31_ctl09” is the ElementID you’re looking for!

Tuesday, 26 March 2013

WPF - Programmatically Adding Buttons the MVVM Way

I recently came across a requirement to Programmatically Add Buttons to a WPF View in my MVVM based app. Obviously this is not entirely trivial as each Button must contain the correct Bindings to interact with the underlying ViewModel.

The way I tackled this was to use an ItemsControl, with a Canvas Control in the ItemsPanelTemplate. I then added a DataTemplate to the ItemTemplate, with our Button Template in this.

This Button Template contained the relevant binding to hook up the Command Property to my ViewModel.

For ease of use, I then created a Class which housed the various Properties I wanted to expose to each Button, such as it’s Position, CommandParameter and Content, and allowed me to return a Tickness for the Button Position.

From here I created an ObservableCollection of my new Button Class, and bound this to the ItemsControl.

The code can be seen below;

XAML:

<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <Canvas x:Name="MyCanvas">
        <ItemsControl ItemsSource="{Binding MyButtons}" Height="237" Width="507">
            <ItemsControl.ItemsPanel >
                <ItemsPanelTemplate>
                    <Canvas IsItemsHost="true"></Canvas>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Button Margin="{Binding ControlMargin}" Content="{Binding Content}" Command="{Binding DataContext.ButtonCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" CommandParameter="{Binding ProductId}"></Button>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </Canvas>
</Window>

FluidButton Class:



 

Public Class FluidButton
 
    Public Property Content As String
    Public Property LeftPos As Double
    Public Property TopPos As Double
    Public Property ProductId As Double
 
    ''' <summary>
    ''' Returns the Control Margin, using the Class Properties
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public ReadOnly Property ControlMargin As Thickness
        Get
            Return New Thickness With {.Left = LeftPos, .Top = TopPos}
        End Get
    End Property
    
End Class

Properties:



 

    ''' <summary>
    ''' Our Collection of Buttons or Products
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property MyButtons As ObservableCollection(Of FluidButton)
 
    ''' <summary>
    ''' Used to expose the Button Pressed Execute Commands to the UI for Binding
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks>Newed up in the Form Load Event</remarks>
    Public Property ButtonCommand As DelegateCommand
Adding Buttons:


 

MyButtons = New ObservableCollection(Of FluidButton)
 
MyButtons.Add(New FluidButton With {.Content = "Test1", .LeftPos = 0, .TopPos = 20, .ProductId = 1})
MyButtons.Add(New FluidButton With {.Content = "Test2", .LeftPos = 40, .TopPos = 30, .ProductId = 2})
MyButtons.Add(New FluidButton With {.Content = "Test3", .LeftPos = 80, .TopPos = 40, .ProductId = 3})
MyButtons.Add(New FluidButton With {.Content = "Test4", .LeftPos = 120, .TopPos = 50, .ProductId = 4})
MyButtons.Add(New FluidButton With {.Content = "Test5", .LeftPos = 160, .TopPos = 60, .ProductId = 5})