European Silverlight 4 & Silverlight 5 Hosting BLOG

BLOG about Silverlight 5 Hosting and Its Techologies - Dedicated to European Windows Hosting Customer

European Silverlight Hosting - HostForlIFE.eu :: Storing Files in SQL Server using WCF RIA Services and Silverlight

clock November 24, 2016 05:32 by author Scott

We have worked on several Silverlight Line of Business applications that require storing documents and files in a secure environment. There are several ways to accomplish this but one approach that has been successful for us is to store the documents using FILESTREAM Storage in SQL Server 2008. 

This is the first of three articles which will describe how you can create a Silverlight LOB application that stores and displays documents using FILESTREAM Storage in SQL Server 2008. 

1. Configuring FILESTREAM in your database and WCF RIA Services setup. 
2. Uploading and Saving files to the database from a Silverlight LOB application. 
3. Viewing files stored in the FILESTREAM from a Silverlight LOB application. 

Configuring FILESTREAM in you database

The first thing I would recommend is to read about FILESTREAM. Here is a tutorial which describes FILESTREAM. 

Okay, now that you read the entire white paper we are ready to roll! 

Setting up your database

Your database needs to enable FILESTREAM on the instance of the SQL Server Database Engine. 

Now that the FILESTREAM is enabled for the server you need to configure your database.

The basic steps include: 

1. Create a Filegroup of type Filestream

2. Create a File for the new Filestream Group

Now that your  database can handle FILESTREAM, the next is to create the SQL Tables that will store documents using the FILESTREAM. In this example I will be using three tables:

- File - storage for the document via the FILESTREAM
- Document - metadata about the File
- Folder - Virtual folder for the document

File table script

CREATE TABLE [dbo].[File]( [FileID] [int] IDENTITY(1,1) NOT NULL, [DocumentFileId] [uniqueidentifier] ROWGUIDCOL NOT NULL, [DocumentFile] [varbinary](max) FILESTREAM NULL, CONSTRAINT [File_PK] PRIMARY KEY CLUSTERED ( [FileID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] FILESTREAM_ON [FileStreamGroup1], UNIQUE NONCLUSTERED ( [DocumentFileId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] FILESTREAM_ON [FileStreamGroup1]

One thing we have found is that you only want to access the File table when you are ready to display the document. If you include this table in RIA Service Domain Service it will really slow things down—a lot. That is why we separated the metadata from the FILESTREAM into two tables - File and Document. 

Document table

You can add as many columns for metadata as needed for your project.  

A few things to notice:

1. This table contains a description and some metadata about the file. We use this table to bind a list of documents in a treeview or gridview control.
2. The guid field is used to create a second unique field. More to come on this in part 3.
3. Path will store the actual file name (e.g. MyDocument.pdf). We need this field so we can determine the type of file that is stored in the database (more on this in part 3).
4. FolderID points to a Folder table (see below). We use this table to organize documents in Folders.

Folder table

We use the ParentFolderID to enable nested folders.  

Okay, now our database is configured for FILESTREAM and we have the necessary tables to store documents. We are creating a Silverlight LOB application using WCF RIA Services, so assuming we already have our Silverlight project created our next steps will be:

1. Add/Update Entity Framework Entity Data Model (*.edmx) in the project. Include the File, Document, and Folder tables.
2. Add/Update Domain Service class and metadata for the three tables.

Tip - I like to include two methods when returning a Document. One that includes the File (i.e. Heavy version) and one that does not include the File (i.e. Lightweight version). This gives me flexibility on the client side. 

public Document GetDocumentById(int documentId) { return this.ObjectContext.Documents.Where(d => d.DocumentID == documentId).FirstOrDefault(); } public Document GetDocumentWithFileById(int documentId) { return this.ObjectContext.Documents.Include("File") .Where(d => d.DocumentID == documentId).FirstOrDefault(); }

To get a list of documents for a folder I use the following query. This can be bound to a gridview control. 

public IQueryable GetDocumentsByFolderId(int folderId) { return this.ObjectContext.Folders .Include("Document") .Where(f => f.FolderID == folderId).OrderByDescending(com => com.Document.CreatedDate); } 



European Silverlight 5 Hosting - HostForLIFE.eu :: How to Implement AutoComplete Text in Silverlight

clock October 5, 2016 23:59 by author Scott

Introduction

Silverlight is evolving with a lot of new features in each and every version release. The AutoComplete text feature is one such example. In this article I will demonstrate the implementation of the AutoComplete text feature in a Silverlight application. I will also create a sample Silverlight application to help explain the code. I have used Silverlight 4.0 and Visual Studio 2010 for developing the sample application.

AutoComplete Functionality

AutoComplete text functionality is not only a fancy effect but it's also a pretty useful feature from a user prospective and this feature is available in most of the latest applications. As the user enters text in a text box, a list of values gets populated and are listed in a similar fashion to that of a drop down based on the entered text. So the user is able to see the possible suggestions and can select a value from them or they also have the freedom to enter their own text as the base control is a textbox.

Some popular websites implementing the auto complete functionality are www.google.com,www.youtube.com, etc.,

Silverlight AutoCompleteBox Control

Implementing the autocomplete functionality in a Silverlight application is pretty straight forward because of the availability of the AutoCompleteBox control. This control is available in Silverlight 3.0 and higher versions. The developer only needs to set the ItemSource property of the AutoCompleteBox control with the value collection that is to be listed. The rest will be taken care by the control itself. 

Below are some of the useful settings that can be leveraged from the AutoCompleteBox control.

  1. FilterMode – Specifies the filter mode to display the data (StartsWith, Contains, Equals, etc.,)
  2. MinimumPrefixLength – Minimum prefix length for the auto complete feature to be triggered
  3. MaxDropDownHeight – Maximum height of the dropdown
  4. IsTextCompletionEnabled – If set to true then the first match found during the filtering process will be populated in the TextBox

 

Silverlight AutoCompleteBox Implementation

In this section we will create a sample Silverlight window implementing the autocomplete text feature. In the MainWindow.xaml add an AutoCompleteBox control and set the basic properties. Below is the code:

<UserControl xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  
    x:Class="AutoCompleteBoxSample.MainPage"
    xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
    xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
    xmlns:d=http://schemas.microsoft.com/expression/blend/2008
    xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">
        <Canvas>
            <sdk:Label Content="Enter the city: " Margin="46,76,264,198" />
            <sdk:AutoCompleteBox Height="28" H
orizontalAlignment="Left" Margin="142,77,0,0" FilterMode="StartsWith"
MinimumPrefixLength="1" MaxDropDownHeight="80" Name="autoCompleteBox1" VerticalAlignment="Top" Width="120"
Canvas.Left="-6" Canvas.Top="-5" />
        </Canvas>
    </Grid>
</UserControl>

namespace AutoCompleteBoxSample
{
    public partial class MainPage : UserControl
    {
        List<string> _cities;

        public MainPage()
        {
            InitializeComponent();
            autoCompleteBox1.ItemsSource = PopulateCities();
        }

        private IEnumerable PopulateCities()
        {
            _cities = new List<string>();
            _cities.Add("Boston");
            _cities.Add("Bangalore");
            _cities.Add("Birmingham");
            _cities.Add("Auckland");
            _cities.Add("Amsterdam");
            _cities.Add("Aspen");
            return _cities;
        }
    }
}

Run the application and you will see the figure below:

 

 

Using a DomainDataSource

In the above case we had the data directly in the application and it was hence hard-coded. In case if the data lies in the database, then the WCF RIA service and the DomainDataSource comes into play. Create a WCF RIA service and hook up the service to expose the data in the table through a generated data context method. Use a DomainDataSource to act as an ItemSource for the AutoCompleteBox control.

Below is the XAML code:

<Canvas>
     <riaControls:DomainDataSource AutoLoad="True"
                                      QueryName="GetCities"
                                      x:Name="CityDataSource">
          <riaControls:DomainDataSource.DomainContext>
                    <web:MyDatabaseContext />
          </riaControls:DomainDataSource.DomainContext>
     </riaControls:DomainDataSource>
     <sdk:Label Content="Enter the city: " Margin="46,76,264,198" />
<sdk:AutoCompleteBox Height="28" ItemsSource="{Binding Data, ElementName=CityDataSource}"
HorizontalAlignment="Left" Margin="142,77,0,0" FilterMode="StartsWith" MinimumPrefixLength="1" MaxDropDownHeight="80"
Name="autoCompleteBox1" VerticalAlignment="Top" Width="120" Canvas.Left="-6" Canvas.Top="-5" />
</Canvas>



European Silverlight 5 Hosting - UK :: Style Setters with Silverlight 5

clock November 17, 2014 07:12 by author Scott

One of new Silverlight 5 feature is Style Setter. This great feature was heavily missing from the earlier Silverlight version. The functionality is pretty useful and is extensively used in WPF applications.

Implementing MVVM scenarios with controls inherited from ItemsControls is not an easy way and sometimes may require a lot of work.

Say binding IsSelected on C1TreeView or binding GroupName/HeaderBackground in C1Menu. There are lot of workarounds to these scenarios.

Setting binding in Style Setters is really helpful in these scenarios and it does reduces a lot of work.

Lets see this by an example. Below are the simple classes that we will be using for binding purposes:-

public class Parent
  {
    public string Name{get;set;}
    public List<Child> Childs{get;set;}
    public bool IsSelected { get; set; }
  } 

 public class Child
  {
   public Child(string name)
    {
     this.Name=name;
    }
   public string Name{get;set;}
   public bool IsSelected { get; set; }
  }

Lets populate the collection in our ViewModel:-

public class MyViewModel
  {
   private List<Parent> _collections;
   public MyViewModel()
    {
     _collections = new List<Parent>();
     _collections.Add(new Parent() { Name = "P1", Childs = new List<Child>() { new Child("C11"){IsSelected=true} , new Child("C12"), new Child("C13") } });
     _collections.Add(new Parent() { Name = "P2", IsSelected=true, Childs = new List<Child>() { new Child("C21"), new Child("C22"), new Child("C23") } });
     _collections.Add(new Parent() { Name = "P3", Childs = new List<Child>() { new Child("C31"), new Child("C32"), new Child("C33") } });
     } 

   public List<Parent> Collections
     {
      get
        {
         return _collections;
        }
      }
    }

Next is important xaml that shows the entire binding stuff in xaml:-

<c1:C1TreeView ItemsSource="{Binding Collections}" Grid.Row="1">
 <c1:C1TreeView.ItemTemplate>
 <c1:C1HierarchicalDataTemplate ItemsSource="{Binding Childs}">
 <TextBlock HorizontalAlignment="Stretch" Margin="2" Text="{Binding Name}"/>
 </c1:C1HierarchicalDataTemplate>
 </c1:C1TreeView.ItemTemplate>
<c1:C1TreeView.ItemContainerStyle>
 <Style TargetType="c1:C1TreeViewItem">
 <Setter    Property="IsSelected" Value="{Binding IsSelected}"/>
 </Style>
 </c1:C1TreeView.ItemContainerStyle>
</c1:C1TreeView>

As you can see from the above xaml code, we have used the ItemContainerStyle and bound theIsSelected property on the C1TreeViewItem with the IsSelected property exposed on our class. That was pretty simple. Isnt It?

With earlier versions, you may have to use some helper classes like SetterValueBindingHelper to achieve the same thing.

You can set similar type of styles to most of the controls inherited from ItemsControl like C1Menu,C1Accordion, C1Book etc.  while still obeying the rules of standard MVVM.

The things doesn’t stop here. With this new feature, its pretty easy to bind the C1DataGrid’s row /cell background/foreground/fontweight etc. all in xaml without manually setting the properties in code. See below xaml code which binds the IsAvailable property on the bound item toDataGridRowPresenters Background/Fontweight:-

<Style x:Key="myrowstyle" TargetType="c1:DataGridRowPresenter">
 <Setter  Property="Background" Value="{Binding RelativeSource={RelativeSource Self}, Path=Row.DataItem.IsAvailable, Converter={StaticResource BackgroundConverter}}"/>
 <Setter  Property="FontSize"  Value="{Binding RelativeSource={RelativeSource Self}, Path=Row.DataItem.IsAvailable, Converter={StaticResource FontweightConverter}}"/>
 </Style>

 



European Silverlight 5 Hosting - UK :: What is Linked and Multicolumn Text Silverlight 5?

clock October 27, 2014 08:10 by author Scott

Today, in this article let's concentrate on another SilverLight application, whereby communicating with a WCF Service to perform some operation.

What is Linked and Multicolumn Text?

In simple terms "It enables content to render on browser as per column wise when the text is over flown. So for this we can linkup textbox with other, to make sure it flows into next textbox control when the current textbox is full with the content".

 

Let's get this implemented practically for a better idea of this.

1. The complete code of the IService1.cs looks like this.

Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
Namespace WCF_Linked_Text
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the     interface name "IService1" in both code and config file together.
    [ServiceContract]
    Public Interface IService1
    {
      [OperationContract]
       string text1();
      [OperationContract]
       string text2();
    }
}

2. The complete code of the Service1.svc.cs looks like this.

Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace WCF_Linked_Text
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the classname "Service1" in code, svc and config file together.
    public class Service1 : IService1
    {
        public string text1()
        {
            return "RichTextBox 1 Message via WCF ";
        }
        public string text2()
        {
            return "RichTextBox 2 Message via WCF ";
        }
    }
}

3. The complete code of the Web.Config looks like this.

Code

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing  exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

4. The complete code of the Clientaccesspolicy.xml looks like this (to avoid cross domain problem in SilverLight).

Code

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
    <cross-domain-access>
        <policy>
            <allow-from http-request-headers="SOAPAction">
                <domain uri="*"/>
            </allow-from>
            <grant-to>
                <resource path="/" include-subpaths="true"/>
            </grant-to>
        </policy>
    </cross-domain-access>
</access-policy>

5. The complete code of the MainPage.xaml looks like this.

Code

<UserControl x:Class="Linked_Text_and_Multi_Column_Application.MainPage"\
    xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
    xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
    xmlns:d=http://schemas.microsoft.com/expression/blend/2008
    xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006
    mc:Ignorable="d"
    d:DesignHeight="224" d:DesignWidth="400">
     <Grid x:Name="LayoutRoot" Background="White" Height="253">
         <RichTextBlock x:Name="richTextBlock1"
                       HorizontalAlignment="Left"
                       Margin="0,12,0,134"
                       Width="168"
                       MouseEnter="richTextBlock1_MouseEnter"
                       OverflowContentTarget="{Binding ElementName=richTextBlock2}"
                       FontFamily="Verdana"
                       FontSize="22">
        <Paragraph>jjjjjjjjjjjjjjjjjsssssssssssssssssssssssssssssssssssssssssssssssssjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
                        jjjjjjjjjjjj
</Paragraph>
        </RichTextBlock>
          <RichTextBlockOverflow HorizontalAlignment="Left"
                               Margin="220,13,0,133"
                               Name="richTextBlock2"
                               Width="168" 
                               MouseEnter="richTextBlock2_MouseEnter">
          </RichTextBlockOverflow>
      </Grid>
</UserControl>

6. The complete code of the MainPage.xaml.cs looks like this.

Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Linked_Text_and_Multi_Column_Application.ServiceReference1;
namespace Linked_Text_and_Multi_Column_Application
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
                  }
         private void text1_Call(object sender, text1CompletedEventArgs e)
        {
            MessageBox.Show(e.Result, "Linked Text - MultiColumn", MessageBoxButton.OKCancel);
        }
         private void richTextBlock1_MouseEnter(object sender, MouseEventArgs e)
        {
            objClient.text1Completed +=new EventHandler<text1CompletedEventArgs>(text1_Call);
            objClient.text1Async();
        }
         private void text2_Call(object sender, text2CompletedEventArgs e)
        {
            MessageBox.Show(e.Result, "Linked Text - MultiColumn", MessageBoxButton.OKCancel);
        }
         private void richTextBlock2_MouseEnter(object sender, MouseEventArgs e)
        {
            objClient.text2Completed += new EventHandler<text2CompletedEventArgs>(text2_Call);
            objClient.text2Async();
        }
         #region Instance Variables
        Service1Client objClient = new Service1Client();
        #endregion
     }
}

7. The output of the application looks like this.

8. The output of the RichTextBox1 Hover Application looks like this

9. The output of RichTextBox2 Hover Application looks like this.



European HostForLIFE.eu Proudly Launches ASP.NET 4.5.1 Hosting

clock January 30, 2014 06:11 by author Scott

HostForLIFE.eu proudly launches the support of ASP.NET 4.5.1 on all their newest Windows Server environment. HostForLIFE.eu ASP.NET 4.5.1 Hosting plan starts from just as low as €3.00/month only.

ASP.NET is Microsoft's dynamic website technology, enabling developers to create data-driven websites using the .NET platform and the latest version is 4.5.1 with lots of awesome features.

According to Microsoft officials, much of the functionality in the ASP.NET 4.5.1 release is focused on improving debugging and general diagnostics. The update also builds on top of .NET 4.5 and includes new features such as async-aware debugging, ADO.NET idle connection resiliency, ASP.NET app suspension, and allows developers to enable Edit and Continue for 64-bit.

HostForLIFE.eu is a popular online ASP.NET based hosting service provider catering to those people who face such issues. The company has managed to build a strong client base in a very short period of time. It is known for offering ultra-fast, fully-managed and secured services in the competitive market.

The new ASP.NET 4.5.1 also add support for asynchronous debugging for C#, VB, JavaScript and C++ developers. ASP.NET 4.5.1 also adds performance improvements for apps running on multicore machines. And more C++ standards support, including features like delegating constructors, raw string literals, explicit conversion operators and variadic templates.

Microsoft also is continuing to add features meant to entice more JavaScript and HTML development for those using Visual Studio to build Windows Store. Further information and the full range of features ASP.NET 4.5.1 Hosting can be viewed here http://www.hostforlife.eu/European-ASPNET-451-Hosting.



Press Release - Wordpress 3.8 Hosting with HostForLIFE.eu from Only €3.00/month

clock January 23, 2014 10:41 by author Scott

HostForLIFE.eu proudly launches the support of WordPress 3.8 on all their newest Windows Server environment. HostForLIFE.eu WordPress 3.8 Hosting plan starts from just as low as €3.00/month only.

WordPress is a flexible platform which helps to create your new websites with the CMS (content management system). There are lots of benefits in using the WordPress blogging platform like quick installation, self updating, open source platform, lots of plug-ins on the database and more options for website themes and the latest version is 3.8 with lots of awesome features.

WordPress 3.8 was released in December 2013, which introduces a brand new, completely updated admin design: with a fresh, uncluttered aesthetic that embraces clarity and simplicity; new typography (Open Sans) that’s optimized for both desktop and mobile viewing; and superior contrast that makes the whole dashboard better looking and easier to navigate.

HostForLIFE.eu is a popular online WordPress hosting service provider catering to those people who face such issues. The company has managed to build a strong client base in a very short period of time. It is known for offering ultra-fast, fully-managed and secured services in the competitive market.

Another wonderful feature of WordPress 3.8 is that it uses vector-based icons in the admin dashboard. This eliminates the need for pixel-based icons. With vector-based icons, the admin dashboard loads faster and the icons look sharper. No matter what device you use – whether it’s a smartphone, tablet, or a laptop computer, the icons actually scale to fit your screen.

WordPress 3.8 is a great platform to build your web presence with. HostForLIFE.eu can help customize any web software that company wishes to utilize. Further information and the full range of features WordPress 3.8 Hosting can be viewed here http://www.hostforlife.eu.

 



Press Release - European HostForLIFE.eu Proudly Launches Umbraco 7 Hosting

clock January 15, 2014 11:33 by author Scott

HostForLIFE.eu, a leading Windows web hosting provider with innovative technology solutions and a dedicated professional services team, today announced the supports for Umbraco 7 Hosting plan due to high demand of Umbraco 7 CMS users in Europe. Umbraco 7 features the stable engine of Umbraco 6 powering hundreds of thousands of websites, but now enriched with a completely new, remarkably fast and simple user interface.

Umbraco is fast becoming the leading .NET based, license-free (open-source) content management system. It is an enterprise level CMS with a fantastic user-interface and an incredibly flexible framework which is both scalable and easy to use. Umbraco is used on more than 85,000 websites, including sites for large companies such as Microsoft and Toyota.

HostForLIFE.eu is a popular online Umbraco 7 hosting service provider catering to those people who face such issues. The company has managed to build a strong client base in a very short period of time. It is known for offering ultra-fast, fully-managed and secured services in the competitive market.

Umbraco has given a lot of thought to the user experience of their CMS. The interface uses a navigational flow and editing tools that anybody using Windows Explorer and Microsoft Word will immediately recognise. Your site structure sits in a tree view - just like Windows Explorer. Anybody with experience using Microsoft Word, can use Umbraco's simple rich text editing (RTE) interface.

"Umbraco 7 is easy to install within few clicks, special thanks to HostForLIFE.eu special designed user friendly web hosting control panel systems." - Ivan Carlos, one of the many HostForLIFE.eu satisfying clients.

Further information and the full range of features Umbraco 7 Hosting can be viewed here http://hostforlife.eu/European-Umbraco-7-Hosting.



Press Release - European HostForLIFE.eu Proudly Launches DotNetNuke 7.1 Hosting

clock January 7, 2014 07:20 by author Scott

HostForLIFE.eu proudly launches the support of DotNetNuke 7.1 on all our newest Windows Server 2012 environment. Our European DotNetNuke 7.1 Hosting plan starts from just as low as €3.00/month only and this plan has supported ASP.NET 4.5, ASP.NET MVC 4 and SQL Server 2012.

DotNetNuke (DNN) has evolved to become one of the most recognizable open source Content Management systems. Basically it is based on the Microsoft platform, i.e. ASP.NET, C#, SQL, jQuery etc. As a web development platform, DotNetNuke provides a solid base platform.

HostForLIFE.eu clients are specialized in providing supports for DotNetNuke CMS for many years. We are glad to provide support for European DotNetNuke CMS hosting users with advices and troubleshooting for our clients website when necessary.

DNN 7.1 provides intuitive drag-n-drop design feature, streamlined interface, built in social authentication providers, fully integrated SEO (Search Engine Optimization), membership system, granular access control, and many other features. In fact DNN 7 is all in one web development and content management system. No longer is the site design realm of just technically inclined, DNN 7 delivers advanced features and capabilities that are not matched by other CMS systems. In fact it is most well rounded CMS system available to date.

DotNetNuke 7.1 is a great platform to build your web presence with. HostForLIFE.eu can help customize any web software that company wishes to utilize. Further information and the full range of features DotNetNuke 7.1 Hosting can be viewed here http://hostforlife.eu/European-DotNetNuke-71-Hosting.



European Silverlight 5 Hosting - Amsterdam :: Vector and Bitmap Printing for Reports in Silverlight 5

clock October 17, 2013 07:11 by author Scott

Printing Basics

Just as it was in Silverlight 4, Printing is centered around the PrintDocument class, found in System.Windows.Printing. This class has three primary events: BeginPrint, EndPrint, and PrintPage, which are your hooks into the printing system. You do setup in BeginPrint, teardown in EndPrint, and all the actual page production in PrintPage.

Page Markup

Here's the simple test page XAML I used for this printing example.

<Grid x:Name="LayoutRoot" Background="White">
    <Button Content="Print Bitmap"
            Height="23"
            HorizontalAlignment="Left"
            Margin="141,79,0,0"
            Name="PrintBitmap"
            VerticalAlignment="Top"
            Width="95"
            Click="PrintBitmap_Click" />
    <Button Content="Print Vector"
            Height="23"
            HorizontalAlignment="Left"
            Margin="141,108,0,0"
            Name="PrintVector"
            VerticalAlignment="Top"
            Width="95"
            Click="PrintVector_Click" />
    <Button Content="Force Vector"
            Height="23"
            HorizontalAlignment="Left"
            Margin="141,137,0,0"
            Name="PrintVectorForced
            VerticalAlignment="Top"
            Width="95"
            Click="PrintVectorForced_Click" />
</Grid>

The application UI looks really simple, just three buttons on a page. This is one of my finest designs.

Next, I'll wire up an event handler for each button, and use it to demonstrate the behavior of the three different printing approaches.

Page Code for Basic Vector Printing

Here's the code for a basic vector print of 30 rows.

// Tests basic (not forced) vector printing  
private void PrintVector_Click(object sender, RoutedEventArgs e)
{
    PrintDocument doc = new PrintDocument();

    doc.PrintPage += (s, ea) =>
        {
            StackPanel printPanel = new StackPanel();

            Random rnd = new Random();

            for (int i = 0; i < 30; i++)
            {                  
                TextBlock row = new TextBlock();
                row.Text = "This is row " + i + " of the current page being printed in vector mode.";                      

                printPanel.Children.Add(row);
            }

            ea.PageVisual = printPanel;
            ea.HasMorePages = false;
        };

    PrinterFallbackSettings settings = new PrinterFallbackSettings();

    doc.Print("Silverlight Vector Print");
}

Note that the PageVisual is assigned after the printPanel is populated. If you assign it prior, and do not force a recalculation of layout (in my example, the panel isn't in the visual tree, but layout is calculated with you assign PageVisual), you'll get a StackPanel with 30 items all piled on each other in the same row. The easiest way to fix this is to assign the PageVisual after the visual has all its children populated.

You could also point the PageVisual to an on-screen visual if you desire. If you're going to do that, you'll need to unhook the visual from the tree first, as a single element cannot have two parents.

If you have no more pages to print other than this one, set HasMorePages to false. If you have additional pages after this one, set it to true.

Printer Fallback Settings and Forcing Vector Printing Mode

New in Silverlight 5 is the PrinterFallbackSettings class. This class is used by one of the overloads of PrintDocument.Print to set two options: ForceVector and OpacityThreshold.

In the previous example, if you had any elements that had opacity other than 1.0, perspective transforms, or other things PostScript doesn't understand, Silverlight would silently fall back to bitmap-based printing.

ForceVector forces Silverlight to print in vector mode, assuming you have a PostScript-enabled printer driver, even when postscript-incompatible items exist in the element tree assigned to PageVisual. You use this in tandem with OpacityThreshold. The Opacity threshold sets the value over which Silverlight will treat an element's opacity as 1.0 to support PostScript printing.

// tests trying to force vector printing mode
private void PrintVectorForced_Click(object sender, RoutedEventArgs e)
{
    PrintDocument doc = new PrintDocument();

    doc.PrintPage += (s, ea) =>
    {
        StackPanel printPanel = new StackPanel();

        Random rnd = new Random();

        for (int i = 0; i < 30; i++)
        {
            TextBlock row = new TextBlock();
            row.Opacity = (rnd.Next(3, 10)) / 10.0;
            row.Text = "This is row " + i + " of the current page being printed. Opacity is " + row.Opacity;

            printPanel.Children.Add(row);
        }

        ea.PageVisual = printPanel;
        ea.HasMorePages = false;
    };

    PrinterFallbackSettings settings = new PrinterFallbackSettings();
    settings.ForceVector = true;
    settings.OpacityThreshold = 0.5;

    doc.Print("Silverlight Forced Vector Print", settings);
}

If your content or your printer doesn't support PostScript printing, Silverlight automatically falls back to sending an uncompressed bitmap to the printer. If your printer doesn't support PostScript, you'll see the effect of opacity in the printed results (some items lighter colored than others, for example) as the fallback bitmap mode supports opacity.

Printing in Bitmap Mode

Sometimes you know you want to print in bitmap mode. Rather than let vector mode fall back to bitmap, you can simply force bitmap printing from the start. If you have a PostScript compatible printer and driver, this is quite a bit faster than it was in Silverlight 4, as the bitmap is compressed. If you don't have a PostScript driver, it sends a plain old uncompressed bitmap just like Silverlight 4.

// tests printing in bitmap mode
private void PrintBitmap_Click(object sender, RoutedEventArgs e)
{
    PrintDocument doc = new PrintDocument();

    doc.PrintPage += (s, ea) =>
    {
        StackPanel printPanel = new StackPanel();

        Random rnd = new Random();

        for (int i = 0; i < 30; i++)
        {
            TextBlock row = new TextBlock();
            row.Opacity = (rnd.Next(3, 10)) / 10.0;
            row.Text = "This is row " + i + " of the current page being printed in bitmap mode. Opacity is " + row.Opacity;

            printPanel.Children.Add(row);
        }

        ea.PageVisual = printPanel;
        ea.HasMorePages = false;
    };

    doc.PrintBitmap("Silverlight Bitmap Print");
}

Bitmap mode will preserve the opacity settings, as well as ensure render transforms are printed (assuming you apply them) etc. It's not the best approach for printing a report, but it's the highest-fidelity approach for printing visuals when you want to do the equivalent of a print-screen.

The resolution of the bitmap sent is set to the selected printer resolution, typically 600dpi.

Efficient Printing

So, for the most efficient printing of multi-page reports, you'll want to make sure you do the following:

  • Have a PostScript-compatible printer with an appropriate PostScript driver (typically ends with " PS")
  • Avoid Opacity other than 1.0 in your elements to be printed (or use the appropriate fallback settings)
  • Leave out perspective transforms, 3d, and other things not compatible with PostScript printing.


European WCF 4.5 Hosting - Amsterdam :: Improvement Windows Communication Foundation (WCF) in .NET 4.5

clock October 1, 2013 09:03 by author Scott

New versions of the Windows Workflow Foundation (WF) and Windows Communication Foundation (WCF) are available in the .NET Framework 4.5, which is included with Windows Server 2012 and Windows 8. The upgrades improve the developer experience and the manageability of applications built using the foundations, while adding new capabilities. Some benefits, such as WF performance improvements and WCF configuration simplification can be realized for existing applications without requiring developers to make modifications. However, a majority of the enhancements are most helpful when writing new code.

WF 4.5 Brings Better Designer, Versioning

WF offers a specialized programming environment for business processes, called workflows. WF 4.5 improves on the previous version, WF 4, while providing backward compatibility.

WF Simplifies Business Process Programming

WF consists of programming interfaces, design and debugging tools, and a runtime engine (which is separate from the common language runtime included with the .NET Framework) that enable the implementation and execution of workflow processes, reducing the amount of code a developer must write.

Workflows are specialized programs that automate custom, often long-running, business processes and enforce business rules in applications. Using software to automate workflows can relieve workers from having to perform repetitive and mechanical tasks, ensure that required procedures are consistently followed, and improve the reliability, tracking, and transparency of those procedures. Several Microsoft products, including SharePoint Server, Dynamics CRM, Dynamics AX, and Team Foundation Server employ WF for workflows.

Developers build workflows in WF by assembling groups of activities, which represent the tasks and logic that comprise a business process, using the WF visual designer which generates XAML script, or by writing C# or Visual Basic (VB) code. WF includes a base set of activities that help build the basic structure of workflows, such as control loops and parallel execution paths, and developers can write custom activities that execute code specific to an application's needs. Microsoft applications integrate with WF by offering custom activities that can be used in workflows to deliver product functionality (such as checking an item into a SharePoint document library).

WF 4.5 Improves on WF 4, Maintains Compatibility

WF 4.5 builds on WF 4, which was a major upgrade that wasn't entirely backward compatible with its predecessor, WF 3.5. Microsoft calls WF 4.5 an additive update, implying that it is fully backward compatible with WF 4. WF 4.5 and WF 4 cannot coexist in a Windows installation, since installing .NET 4.5 replaces .NET 4.

Enhancements in WF 4.5 continue on themes addressed in WF 4, such as simplified development and better performance, and include the following:

Contract-first development. WF is often used in combination with WCF to implement workflows that communicate with remote Web services. Contract-first development in WF automatically generates activity objects for existing WCF services, and developers can use these in the WF designer, reducing the work required to create workflows that use Web services.

C# expressions. Code expressions can be included within workflow activities for tasks such as creating output strings. Previously, only VB could be used to write these expressions (even within C# workflow projects), but now C# is supported as well.

More state machine support. A state machine defines a process that exists within one of multiple possible states until an event causes it to move to a different state. States can be revisited indefinitely, or the process can reach a final state. State machines can describe many types of processes, such as order fulfillment for businesses or chemical reactions for scientific research. WF 4.5 adds features for building state machines, including new activities, designer tools that reduce manual steps, and debugging capabilities.

Designer improvements. A graphical designer for building WF workflows is available in Visual Studio (VS), allowing developers to visually create workflows rather than defining them entirely within code (which is also supported). The WF 4.5 designer adds search features (although not replace), an outline view (similar to Word's Navigation pane), and a pan mode, which will help developers work with large workflows. The newest designer also allows annotations to be added to activities to assist search and enable better commenting of intended functionality. Auto-connect simplifies attaching new activities into a workflow, and auto-insert helps when placing an activity between two existing activities in a workflow.

The designer can also be hosted within other applications so that users don't need to run VS to work with workflows targeted for specific solution spaces, and so that users are limited to workflow elements that are relevant to an application domain. However, not all features available in the designer in VS are available when it is hosted elsewhere (for example, C# expressions and some search capabilities are not available).

Workflow versioning. Workflow processes are prone to revisions, but WF has not previously offered versioning support, leaving the task to developers and IT personnel. WF 4.5 introduces workflow identities, which allow the assignment of names and version numbers to workflow definitions. Multiple definitions can be deployed side by side, and running instances of a workflow can be identified by the definition they are using. This allows new workflow definitions to be deployed and used by new instances while old instances run to completion using an older definition. Further, a dynamic update feature allows existing instances to convert to a later workflow definition, provided the developer defines how the conversion should be handled.

Partial trust hosting. Previously, workflow code would have access to all permissions available to the host application, but in WF 4.5, workflows can run in a partially trusted AppDomain, limiting their capabilities to work with the system. Partial trust can reduce the security risk of using workflows obtained from third parties and can make using workflows safer in hosted multitenant deployments.

Better performance. VB expression support has been modified to deliver better runtime performance, which will improve the efficiency of workflows implemented with such expressions by upgrading to WF 4.5 without rewriting code.

WCF 4.5 Eases Configuration, Adds Communications Options

WCF provides developers with a message-oriented API that can be used to communicate over local networks or across the Internet using protocols such as HTTP, TCP, and Microsoft Message Queuing (MSMQ), reducing the amount of code and time required to integrate applications and enabling the implementation of service-oriented architectures.

The power of WCF is its ability to decouple a Web service's internal logic from the protocols used to send and receive messages, allowing either to be modified without affecting the other. The Web service logic is contained in the source code, while the communications protocol information is contained in a separate configuration file. This allows developers to create business logic and IT administrators to determine the best way to access that logic. The model also allows Microsoft to focus development on a single infrastructure and tool set that handles multiple messaging protocols, rather than developing separate solutions for each protocol.

WCF 4.5 aims to reduce configuration complexity and developer effort while improving performance and adding new communications options with enhancements that include the following:

Configuration file simplification. WCF uses XML-based configuration files to separate connection protocol information from code, but these files can be tedious to edit. Properties set to default values can be excluded in WCF 4.5 configuration files, shortening the files and reducing the complexity of working with them. Also, the VS XML editor now provides tooltips when working with a WCF configuration file to help developers understand elements and properties without opening separate documentation.

Asynchronous methods. .NET 4.5 has new elements that simplify the development effort required to write applications that perform tasks in parallel. Methods can be called asynchronously (so they run in a separate thread while the calling code path continues) with much less coding overhead than previously. WCF 4.5 supports methods that take advantage of the new .NET 4.5 asynchronous capabilities, helping developers create better performing WCF applications.

Portable libraries. A portable .NET Framework class library can run on different platforms such as Windows 8, Windows Phone 8, and the Windows Store, eliminating the need to write multiple versions of code for tasks that run the same way on each platform. WCF 4.5 code (with some exceptions) can be used in portable class libraries, so an application's WCF code doesn't have to be rewritten for each platform.

Better message streaming. WCF 4.5 offers improved performance when messages are streamed by using asynchronous streaming, which allows process threads to be closed and reused while waiting on a response (previously, threads would hold system resources while waiting for a response). Also, performance is improved when messages are streamed by a service hosted in IIS, since ASP.NET will now send the message to WCF before the entire message is received (previously, ASP.NET would wait until the full message was received and buffered). This reduces memory usage and enables WCF to respond more quickly.

UDP and WebSocket bindings. WCF uses bindings to define how services communicate. Several binding types, such as HTTP, TCP, and MSMQ are included with WCF, and developers can define custom binding types for other communication mechanisms. WCF 4.5 adds bindings for UDP (which supports message broadcasting to multiple clients without soliciting a response) and WebSocket (which provides two-way TCP communication using HTTP or HTTPS ports with reduced overhead and better performance than HTTP).

 



About HostForLIFE.eu

HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2016 Hosting, ASP.NET Core 2.2.1 Hosting, ASP.NET MVC 6 Hosting and SQL 2017 Hosting.


Tag cloud

Sign in