Integrate Microsoft Communicator in web application

I have recently integrated Microsoft Communicator in one of the web based project. Initially it sounds a bit complicated but here is it :

Add reference to following assembly

using CommunicatorAPI;
using CommunicatorPrivate;
using System.Runtime.InteropServices;
// object initialization  MyCommunicator comm = new MyCommunicator();          Response.Write(string.Format("Your status :{0}",comm.GetCommStatus()));
Options 2
add below Js code in your web page and call functions wherever you want 
function ShowUserName(cntrlname,cntrlvalue) {alert(cntrlname);
}
function togglePannelStatus(content) {     var expand = (content.style.display == "none");     content.style.display = (expand ? "block" : "none");     var chevron = content.parentNode             .firstChild.childNodes[0].childNodes[0];     chevron.src = chevron.src             .split(expand ? "expand.gif" : "collapse.gif")             .join(expand ? "collapse.gif" : "expand.gif");
}

//show communicator status 
var ns4 = (navigator.appName.indexOf("Netscape") >= 0           && parseFloat(navigator.appVersion) >= 4           && parseFloat(navigator.appVersion) < 5) ? true : false;
var ns6 = (parseFloat(navigator.appVersion) >= 5           && navigator.appName.indexOf("Netscape") >= 0) ? true : false;
var ns = (document.layers) ? true : false;
var ie = (document.all) ? true : false;
function getElLeft(el) {     if (ns4) { return el.pageX; }     else {         xPos = el.offsetLeft;         tempEl = el.offsetParent;         while (tempEl != null) {             xPos += tempEl.offsetLeft;             tempEl = tempEl.offsetParent;         }         return xPos;     }
}
function getElTop(el) {     if (ns4) { return el.pageY; }     else {         yPos = el.offsetTop;         tempEl = el.offsetParent;         while (tempEl != null) {             yPos += tempEl.offsetTop;             tempEl = tempEl.offsetParent;         }         return yPos;     }
}
var sipUri //= "emailaddress
var nameCtrl;
function ShowOOUI(sipURI, obj) {     nameCtrl = new ActiveXObject('Name.NameCtrl.1');     if (nameCtrl.PresenceEnabled) {         nameCtrl.OnStatusChange = onStatusChange;         nameCtrl.GetStatus(sipURI, "1");     }     var oouiX = getElLeft(obj); oouiY = getElTop(obj);     nameCtrl.ShowOOUI(sipURI, 0, oouiX, oouiY);
}
function HideOOUI() { nameCtrl.HideOOUI(); }
function onStatusChange(name, status, id) {     // This function is fired when the contacts presence status changes.  
    // In a real world solution, you would want to update an image to reflect the users presence 
    //alert(name + ", " + status + ", " + id); 
}

Clear iframe content

A simple trick to clear Iframe content:

window.frames['tabIframe'].location.replace("about:blank");
Smile
 

Install sun-java6-sdk on Ubuntu

1. Go to command Line  (HOW)

2. Add new repository to Ubuntu  (HOW)

3.Get the updates now and run the Install command as follows

$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk

4. this will install  java sdk

image

5. after successful installation, Configuration screen will be popped up

image

6. Check if everything is ok

image

How to add new repository to Ubuntu

Ubuntu has a great collection for software . To get the required software/application user can connect to the internet and can add/install software directly from this location.

How to do it ?

1. Go to command line –Terminal

If you do not know how to do that than please see my Post :

http://d4dilip.wordpress.com/2012/01/03/where-is-teminal-commandline-in-ubantu/

2.  You must run this command under ROOT

command ‘sudo’ will allow you to run a command under root.

command ‘add-apt-repository’ is to add new repository

Example

sudo add-apt-repository “YOUR REPOSITORY URL”

image

Not you need to supply your password to proceed.

Where is teminal commandline in Ubuntu ?

To start a command line (called Terminal ) follow the below steps :

1. Go to Dashboard

image

2. search for ‘Terminal’ (make sure you search from ‘All’ category)

image    image

3. Click on Terminal and  you are ready to go :

image

I hope this helps to someone.

Running websites in asp.net 2.0 and 4.0 on same IIS

This sounds like a very difficult task but its really now.

Lets take it a scenario to make it happen .

I have a Widows 2008 server with IIS 6.1 installed on it . I have some applications running on it already which are built on .net2.0 framework.

I want to host new application built in .net 3.5 or 4.0 framework .

Steps

  1. Download the new framework from below link

http://www.microsoft.com/download/en/details.aspx?id=17851

2. install it .

3. Restart computer

4.now register the new framework on IIS server

   image

 

5. Now you will get new framework application pool in your IIS

image

6. Assign this application to your application.

 

That’s it!!

Wrong vs Right

Most of the time in our life it happens that we have choose. Funny thing is, we always want options for almost everything and sometime even when we have those we say “OH man .. I wish I would have some option !!”

This is almost obvious that,when we have option we tend to choose the RIGHT one. Now another extremely common thing is  many times our choice really do not come to us the we have thought of and choose it.. than what !!!!!!!

well than we almost all the time say “this choice was WRONG”…I don't know smile

I see a different perspective  (well this post is extremely my personal opinion and do not written to conclude any thing ).

We are the same person and we choose something and after some time later we say my choice was wrong..

one perspective is that we have no idea about it and we really did not CHOOSE from the options.. we have just PICK any one of those …

Another perspective is that we have thought enough before CHOOSING any one of the available option for any particular situation.. Some how it did not work and we blame to our descion. and say it was a WRONG descion!!

I think there is no existence of anything like WRONG ,DARK etc.… these are just another way to say the same thing. This does not mean to create negative energy for us (at lest not from my point of view )

Once upon a time so called “WRONG” descion was  RIGHT when took/choose it .. how this can be WRONG today than..

                            

Things always do not work the way  we want them to .. If we cannot face the failure and do not have any right to get in to the game. A good player must know and learn to agree to defeat/failure .. if this is not the case and someone really always wins.. I do not think he actually is a real winner  Smile

we must observe our available options and situations carefully and choose what we think is best for us AT THAT PERTICULAR TIME

try your best to convert it in success and forget about RIGHT AND WRONG… because there is nothing called WRONG exists.. its just the perspective of seeing thing…

TAKE YOUR DESCIONS AND MAKE THEM RIGHT !!

WordPress Tags: Wrong,Most,life,Funny,options,option,perspective,opinion,person,CHOOSE,PICK,Another,situation,Some,existence,DARK,energy,Once,failure,player,winner,situations,PERTICULAR,TIME,TAKE,DESCIONS,MAKE,descion

Get SQL result rows into one variables

Below is a quick tip to convert rows into variable(comma separated)

declare @tmpEmployee table (EmployeeName nvarchar(200))
declare @commaSeperatedNames nvarchar(max)

insert into @tmpEmployee Values('A')
insert into @tmpEmployee Values('B')
insert into @tmpEmployee Values('C')
insert into @tmpEmployee Values('F')
insert into @tmpEmployee Values('AH')
insert into @tmpEmployee Values('AJJ')
insert into @tmpEmployee Values('AH')
 

select EmployeeName  from @tmpEmployee
 

select EmployeeName +',' from @tmpEmployee FOR XML PATH('')

select @commaSeperatedNames =
STUFF(
		(select EmployeeName +',' from @tmpEmployee FOR XML PATH(''))
     ,1,1,''
   )
    select @commaSeperatedNames 
 
 
Here is the results
image

WordPress Tags: EmployeeName,Values,PATH,STUFF,Here,tmpEmployee,nvarchar,commaSeperatedNames

Make List Pageable

I have doing some work these days on MVC .I needed an functionality to show data on the screen with paging.

In the beginning I thought this could be really difficult to add new method for  IEnumerable list objects. Here I am going to share the concept to achieve this and some code snippet..(some of  from my application and some of them are from internet.)

Steps

1.  First we need an interface which has properties to provide necessary information for paging like Page count, page number etc. My interface looks like this :

 

 

	public interface IPagedList<T> : IList<T>
	{
		int PageCount { get; }
		int TotalItemCount { get; }
		int PageIndex { get; }
		int PageNumber { get; }
		int PageSize { get; }
		bool HasPreviousPage { get; }
		bool HasNextPage { get; }
		bool IsFirstPage { get; }
		bool IsLastPage { get; }
	}
 

2. Next we need to simply implement this interface but with

 
System.Collections.Generic.List
 
which look like this 
(I have reformatted the code to fit in the post )
	public class PagedList<T> : List<T>, IPagedList<T>
	{
public PagedList(IEnumerable<T> source, int index, int pageSize, int? totalCount = null)
	: this(source.AsQueryable(), index, pageSize, totalCount)
{
}

public PagedList(IQueryable<T> source, int index, int pageSize, int? totalCount = null)
{
if (index < 0)
throw new ArgumentOutOfRangeException("index", "Value can not be below 0.");
if (pageSize < 1)
throw new ArgumentOutOfRangeException("pageSize", "Value can not be less than 1.");

if (source == null)
source = new List<T>().AsQueryable();

var realTotalCount = source.Count();

PageSize = pageSize;
PageIndex = index;
TotalItemCount = totalCount.HasValue ? totalCount.Value : realTotalCount;
PageCount = TotalItemCount > 0 ? (int)Math.Ceiling(TotalItemCount / (double)PageSize) : 0;

HasPreviousPage = (PageIndex > 0);
HasNextPage = (PageIndex < (PageCount - 1));
IsFirstPage = (PageIndex <= 0);
IsLastPage = (PageIndex >= (PageCount - 1));

if (TotalItemCount <= 0)
return;

var realTotalPages = (int)Math.Ceiling(realTotalCount / (double)PageSize);

if (realTotalCount < TotalItemCount && realTotalPages <= PageIndex)
AddRange(source.Skip((realTotalPages - 1) * PageSize).Take(PageSize));
else
AddRange(source.Skip(PageIndex * PageSize).Take(PageSize));
}

#region IPagedList Members

public int PageCount { get; private set; }
public int TotalItemCount { get; private set; }
public int PageIndex { get; private set; }
public int PageNumber { get { return PageIndex + 1; } }
public int PageSize { get; private set; }
public bool HasPreviousPage { get; private set; }
public bool HasNextPage { get; private set; }
public bool IsFirstPage { get; private set; }
public bool IsLastPage { get; private set; }

#endregion
}

3..  Than we just need a simple extension

 

 

public static class PagingExtensions
{
#region IEnumerable<T> extensions

public static IPagedList<T> ToPagedList<T>(this IEnumerable<T> source, int pageIndex,
 int pageSize, int? totalCount = null)
{     return new PagedList<T>(source, pageIndex, pageSize, totalCount);
}

#endregion
}

4. and we are ready to go:::::

private static IList<Group_tbl> lstGroups = new List<Group_tbl>();
var pagedList=   lstGroups.ToPagedList(currentPageIndex, pageSize);

 

 

Enjoy..

Get sql server objects list

In PL/SQL we can user ‘User_Objects’ to retrieve list of al the objects.

In SQL Server this can be achieved by using ‘sys.Objects’. This provides a high level view of all the objects which can be used for retrieving various type of information.

Example

SELECT * FROM  sys.objects

 

image

 

Below queries can be used to extract a specific type of object details.
 
 

SELECT * FROM  sys.Procedures

 

 SELECT * FROM  sys.tables

 

 SELECT * FROM  sys.views

Follow

Get every new post delivered to your Inbox.