Saturday, November 23, 2013

Introduction to Scaleout in SignalR

In general, there are two ways to scale a web application: scale up and scale out.
  • Scale up means using a larger server (or a larger VM) with more RAM, CPUs, etc.
  • Scale out means adding more servers to handle the load.
The problem with scaling up is that you quickly hit a limit on the size of the machine. Beyond that, you need to scale out. However, when you scale out, clients can get routed to different servers. A client that is connected to one server will not receive messages sent from another server.



One solution is to forward messages between servers, using a component called a backplane. With a backplane enabled, each application instance sends messages to the backplane, and the backplane forwards them to the other application instances. (In electronics, a backplane is a group of parallel connectors. By analogy, a SignalR backplane connects multiple servers.)
SignalR currently provides three backplanes:
  • Windows Azure Service Bus. Service Bus is a messaging infrastructure that allows components to send messages in a loosely coupled way.
  • Redis. Redis is an in-memory key-value store. Redis supports a publish/subscribe (“pub/sub”) pattern for sending messages.
  • SQL Server. The SQL Server backplane writes messages to SQL tables. The backplane uses Service Broker for efficient messaging. However, it also works if Service Broker is not enabled.

Implementation

In SignalR, every message is sent through a message bus. A message bus implements the IMessageBus interface, which provides a publish/subscribe abstraction. The backplanes work by replacing the default IMessageBus with a bus designed for that backplane. For example, the message bus for Redis is RedisMessageBus, and it uses the Redis pub/sub mechanism to send and receive messages.
Each server instance connects to the backplane through the bus. When a message is sent, it goes to the backplane, and the backplane sends it to every server. When a server gets a message from the backplane, it puts the message in its local cache. The server then delivers messages to clients from its local cache.
For each client connection, the client’s progress in reading the message stream is tracked using a cursor. (A cursor represents a position in the message stream.) If a client disconnects and then reconnects, it asks the bus for any messages that arrived after the client’s cursor value. The same thing happens when a connection uses long polling. After a long poll request completes, the client opens a new connection and asks for messages that arrived after the cursor.
The cursor mechanism works even if a client is routed to a different server on reconnect. The backplane is aware of all the servers, and it doesn’t matter which server a client connects to.

Limitations

Using a backplane, the maximum message throughput is lower than it is when clients talk directly to a single server node. That's because the backplane forwards every message to every node, so the backplane can become a bottleneck. Whether this limitation is a problem depends on the application. For example, here are some typical SignalR scenarios:
  • Server broadcast (e.g., stock ticker): Backplanes work well for this scenario, because the server controls the rate at which messages are sent.
  • Client-to-client (e.g., chat): In this scenario, the backplane might be a bottleneck if the number of messages scales with the number of clients; that is, if the rate of messages grows proportionally as more clients join.
  • High-frequency realtime (e.g., real-time games): A backplane is not recommended for this scenario.

Enabling Tracing For SignalR Scaleout

To enable tracing for the backplanes, add the following sections to the web.config file, under the rootconfiguration element:

<configuration>
  <system.diagnostics>
    <sources>
      <source name="SignalR.SqlMessageBus">
        <listeners>
          <add name="SignalR-Bus" />
        </listeners>
      </source>
      <source name="SignalR.ServiceBusMessageBus">
        <listeners>
          <add name="SignalR-Bus" />
        </listeners>
      </source>
      <source name="SignalR.ScaleoutMessageBus">
        <listeners>
          <add name="SignalR-Bus" />
        </listeners>
      </source>
    </sources>
    <switches>
      <add name="SignalRSwitch" value="Verbose" />
      <!-- Off, Critical, Error, Warning, Information, Verbose -->
    </switches>
    <sharedListeners>
      <add name="SignalR-Bus" 
          type="System.Diagnostics.TextWriterTraceListener" 
          initializeData="bus.log.txt" />
    </sharedListeners>
    <trace autoflush="true" />
  </system.diagnostics>
  . . .
</configuration>

Friday, September 27, 2013

ASP.NET Themes,Skins,Global Themes,Creating Page Themes,Adding a Skin file to a Page Theme,Applying a Theme to a Web Site


Introduction
Using themes is cool and easy way to create a consistent look and feel across a page or an entire web site. Using themes you can easily customize your server controls with predefined looks that come with the .NET Framework or you can create your own themes for your own look.


Themes
Themes are a way to counter the problems faced when creating a layout for server controls and giving them the same look and feel throughout the entire application, with as little effort as possible. Default or Global themes are contained in a special folder inside the framework and can be declared in the source as well as class files. Custom made themes are saved inside the predefined "App_Themes" folder inside ASP.NET applications, making them easier to manage and use according to your needs. The essential part of themes are skin files with the .skin extension. Besides skin files, a theme can be composed of styles sheets .css files as well as images for added support for the layout of the website.


Skins
A skin file has the file name extension .skin and contains property settings for individual controls such as Button, Label, TextBox, or Calendar controls. Control skin settings are like the control markup itself, but contain only the properties you want to set as part of the theme.
                Code Example
<asp:button runat="server" BackColor="lightblue" ForeColor="black" />

You create .skin files in the Theme folder. A .skin file can contain one or more control skins for one or more control types. You can define skins in a separate file for each control or define all the skins for a theme in a single file.
There are two types of control skins, default skins and named skins:
  • A default skin automatically applies to all controls of the same type when a theme is applied to a page. A control skin is a default skin if it does not have a SkinID attribute. For example, if you create a default skin for a Calendar control, the control skin applies to all Calendar controls on pages that use the theme. (Default skins are matched exactly by control type, so that a Button control skin applies to all Button controls, but not to LinkButton controls or to controls that derive from the Button object.)
A named skin is a control skin with a SkinID property set. Named skins do not automatically apply to controls by type. Instead, you explicitly apply a named skin to a control by setting the control's SkinID property. Creating named skins allows you to set different skins for different instances of the same control in an application.


Global Themes
Built-in default themes are stored under the installation path of the .NET Framework: 
%SystemRoot%\Microsoft.NET\Framework\VX.X.XXXX\ ASP.NETClientFiles\Themes\
The actual name of the subdirectory labeled vX.X.XXXX changes according to the build of ASP.NET. Themes defined in this path are visible to all applications running on the machine. You can also use your create a global theme by saving it in a subfolder of the \Themes\ folder in the above directory.

Creating Page Themes
1.       In the Solution Explorer right-click on web site name and point to Add ASP.NET and click Themes
2.       Visual Studio will create a App_Themes folder automatically
3.       Create a subfolder of the App_Themes folder and name it accordingly
4.       Add Skins, Cascading Style Sheets, and Images as needed


Adding a Skin file to a Page Theme
  1. In the Solution Explorer right-click the name of the theme and click Add New Item
  2. In the Add New Item dialog box click Skin File
  3. Type the name of the .skin in the name box
  4. In the .skin file add control definition using declarative syntax, only include properties you want to set for the theme. The definition must include the runat=”server” attribute and must not include the ID=”” attribute.


Code Example
<asp:Button runat="server"
  BackColor="black"
  ForeColor="green"
  Font-Name="Arial"
  Font-Size="10pt" />

You can create as many or as few .skin files in the theme folder but typically you would only create one per control. You can define only one default Skin per control. If you want more use the SkinID attribute in the skin’s control declaration to create named Skins for the same control.


Code Example
                <asp:Label runat="server" ForeColor="#585880" Font-Size="0.7em" Font-Names="Verdana" SkinID="LabelHeader" />

                <asp:Label runat="server" ForeColor="#585980" Font-Size="0.6em" Font-Names="Arial" SkinID="LabelFooter" />


Adding Cascading Style Sheets to a theme is the same as adding a skin accept in the Add New Item dialog box you select Style Sheet.


Applying a Theme to a Web Site
  1. In the application’s web.config file set the <pages> element to the name of the theme either page or global

Code Example
<configuration>
    <system.web>
        <pages theme="ThemeName" />
    </system.web>
</configuration>

Or

  1. Set as style sheet theme and be subordinate to local control properties set the styleSheetTheme attribute instead

Code Example
<configuration>
    <system.web>
        <pages styleSheetTheme="ThemeName" />
    </system.web>
</configuration>


Applying a Theme to an individual page
Set the Theme or StyleSheetTheme attribute of the @ Page directive to the name of the theme

                Code Example
                                <%@ Page Theme="ThemeName" %>
                <%@ Page StyleSheetTheme="ThemeName" %>


Applying a named skin to a control
Set the control’s SkinID property
               
Code Example
                                <asp:Calendar runat="server" ID="DateSelector" SkinID="LargeCalendar" />

Conclusion

In conclusion I hope this information was helpful to you. Themes are nice way to create a consistent look and feel across Web sites quickly and easily.


Thanks & Regards,
www.galaxywebmind.com

Wednesday, August 28, 2013

http://www.galaxywebmind.com/

What we are awaiting is now come true...

The Galaxy Group of Companies
added new venture on SMS platform galaxywebmind.com





www.galaxywebmind.com

Pure Web/Windows/Mobile/SMS/Marketting/ Solutions

Thank you.

Monday, April 22, 2013

How to convert Amount in Words using Crystal Report?


How to Convert Amount (Currency) in words directly on Crystal Report.

Just Simply copy paste below code in your function.
To Create function follow the steps given below:
i) go to Field Explorer
ii) right click on Formula Fields click on New give specific name
iii) Formula Editor window will open just paste the Code given below
iv) Save & Close...
v) Just drag the Field to your specific required Location that done...

Changes to be made from your side is
i) vwCostTypes.UnitCost : This is a Database Field. Change as per your requirement.
Please note if you have Currency as Datatype in SQL DB than Do use ToNumber() function to convert it to number otherwise it will throw error of Number Required.

Please have the below code:
//#####################

//Created by Anup Shah.
//#####################
numbervar RmVal:=0;
currencyVar Amt:=0;
numbervar pAmt:=0;
stringvar InWords :="Rupees ";
Amt := ({vwCostTypes.UnitCost});

if Amt > 10000000 then RmVal := truncate(ToNumber(Amt)/10000000);
if Amt = 10000000 then RmVal := 1;
if RmVal = 1 then
InWords := InWords + " " + towords(RmVal,0) + " crore"
else
if RmVal > 1 then InWords := InWords + " " + towords(RmVal,0) + " crores";

Amt := Amt - Rmval * 10000000;
if Amt > 100000 then RmVal := truncate(ToNumber(Amt)/100000);
if Amt = 100000 then RmVal := 1;
if RmVal >=1 then
InWords := InWords + " " + towords(RmVal,0) + " lakhs";

Amt := Amt - Rmval * 100000;
if Amt > 0 then InWords := InWords + " " + towords(truncate(Amt),0);
pAmt := (ToNumber(Amt) - truncate(ToNumber(Amt))) * 100;
if pAmt > 0 then
InWords := InWords + " and " + towords(pAmt,0) + " paisa only"
else
InWords := InWords + " only";
UPPERCASE(InWords)
//#####################


Happy Coding...!!! ;)


Saturday, April 20, 2013

How to insert null value into DateTime column?

How to insert null value into DateTime column?

Please have a look at the below code...

Generally for Parameters you will write the commented code below....to insert the value in the respective parameters.

But If there is Date and having null value to pass you have to do bit different otherwise it will give error
of  "Parameter missing..."

to overcome such error for the perticular scenario you have to write down the below written code.



cmdnon.Parameters.Add("@orderedDate", SqlDbType.SmallDateTime);
//cmdnon.Parameters["@orderedDate"].Value = this.orderedDate;
cmdnon.Parameters["@orderedDate"].IsNullable = true;

if (this.orderedDate == null)
      cmdnon.Parameters["@orderedDate"].Value = getNullDate;
else
      cmdnon.Parameters["@orderedDate"].Value = this.orderedDate;


this will remove your Error and successfully insert your expected null value into the Database.

Happy Coding!!!

Thursday, April 18, 2013

Display Check Box on Crystal Report Problem!


Adding a Check Box to a Report.

To Display a checkbox on a report.

i) Create a formula to show checked and unchecked box.
ii) Please note the formula below...

if {MyField}=true then CHR(254) else  CHR(168);



iii) Now Place your Field to Report at your required Location and change the font to Wingdings

iv) That's all....Great Job...;) Please have below symbol to change as per your choice and requirements. you can also have other symbols please check in Word to have the other symbols of the Font Wingdings.



Crystal Reports Error: "Invalid group condition"

Error:
"Invalid group condition."
or
"This group section cannot be printed because its condition field is nonexistent or invalid.  Format the section to choose another condition field."


This Bug arise only if you have bad group sectors like
i) Please do Database-> Verify Database
ii) Please check your Dataset provided to the Report for the actual field exists or not.
iii) Remove unused Group from your report

it will gone permanently...;)

Happy Coding...

Tuesday, April 16, 2013

Anup Shah's invitation is awaiting your response

 
 
 
 
 
Anup Shah would like to connect on LinkedIn. How would you like to respond?
 
 
 
 
Anup Shah
Software Developer at TabsBi
 
 
 
 
You are receiving Reminder emails for pending invitations. Unsubscribe.
© 2013 LinkedIn Corporation. 2029 Stierlin Ct, Mountain View, CA 94043, USA.
 
 

Thursday, April 11, 2013

Invitation to connect on LinkedIn

 
LinkedIn
 
 
 
Anup Shah
 
From Anup Shah
 
Software Developer (Sliverlight & WPF) at TabsFM
Vadodara Area, India
 
 
 
 
 
 
 

I'd like to add you to my professional network on LinkedIn.

- Anup

 
 
 
 
 
 
 
You are receiving Invitation to Connect emails. Unsubscribe
© 2012, LinkedIn Corporation. 2029 Stierlin Ct. Mountain View, CA 94043, USA
 

Thursday, March 14, 2013

Visual Studio 2010 Shortcuts ( 6. Tool Windows) Continue...

Hello Guys!

This is very interesting I am gonna providing to you which helps you to manage as well as saves your time while coding

6. Tool Windows
Ctrl+/ Put cursor in the find/command box in toolbar
Ctrl+k+b Open code snippet manager window
Alt+f11 Open macro IDE window
Ctrl+k+w Open bookmark window
Ctrl+Alt+k Open call hierarchy window
Ctrl+Shift+c Open class view window
Ctrl+Alt+a Open Command window
Ctrl+Shift+o Open Output window
Ctrl+Shift+e Open Resource view window
Ctrl+Alt+s Open Server explorer window
Ctrl+Shift+l Open Solution explorer window
Shift+Esc Close Find & Replace Window

Let me help to get more keys...
Happy Coding!!!