Thursday, December 22, 2011

Adding custom field to Work Item Tracking Template "Task"

1) I would assume that you already have the template open or know how to open it from the server for type "Task" in project "SharePoint.Samples" (follow instruction on top to open the template)
2) We would add a drop-down with options and make this field mandatory
3) Switch to tab "Fields" and click "Add"
4) We are naming the new Field as "Solution Type" in tab "Field Definition" enter the detail as highlighted in the image below (Name : Solution Type | Type : String | RefName : SharePoint.Samples.Task.SolutionType | Reportable : dimension )



5) How do we make it a drop-down? Now change the tab to "Rules"
6) Click on "Add" and new window "Select a rule type" will popup
7) Select "ALLOWEDVALUES" which should be the first in list and click "OK"



8) In window "ALLOWEDVALUES" click on "Add"
9) In window "List Item Edit" add the value "Web Part" in "List Item" on click "OK"


10) Repeat two step above to add the following values "Page Layout", "Master Page", "Content Type", "Custom Lists"
11) When you have added all the value in window "ALLOWEDVALUES" click "OK"


12) Click "OK" in window "Field Definition"


13) Now we need to add this field to the form (UI) so that people can start using it
14) Switch to the tab "Layout" and locate "Group - Classification" underneath this right click on "Column" and click on "New Control"

15) Now edit the properties of control form the properties pane on right side of window
16) Change the property for "FieldName" and select "SharePoint.Samples.Task.Solution.Type" from the drop down (this it the custom field which we just created)

17) Change the property "Label" to "Solution Type"
18) Leave all other property values to default for this control

19) Now we have to make this value as Required (Mandatory) while new Task is created
20) Switch to tab "Workflow"
21) Right click on "Transition" (first blue box) and click on "Open Details"

22) In window "Workflow Transition" switch to tab "Fields" and click on "Add"
23) In window "Field Reference" select value for "RefName:"
24) Select "SharePoint.Samples.Task.SolutionType" from drop down and click "OK"

25) In window "Field Reference" switch to tab "Rules" and click on "Add"
26) In window "Select a rule type" select "REQUIRED" and click on "OK"

27) In window "REQUIRED" click on "OK"

28) In window "Field Reference" press "OK"

29) In window "Workflow Transition" click on "OK"

30)Now save the changes to template by "Ctrl+S"
31) After saving the changes refresh the project from Team Explorer, wait for some time after refresh and try to refresh couple of times and have some wait time between the refresh.
32) Open "Team Explorer" > Right click on the Project "SharePoint.Samples" > "Refresh"

33) To verify the changes now you should create a new task
34) Open "Team Explorer" > Expand the project "SharePoint.Samples" > Right click "Work Items" > "Add Work Item" > "Task"

35) Once the new task form is open, you should see your changes as per the image below, the filed is highlighted in yellow which denotes that this is required in order to create a new task

We are done!!

But what if we want to do this for all existing projects? Simple, we do export and import.
1) From VS Menu click "Team" > "Process Editor" > "Work Item Types" > "Export WIT"

2) Enter your server details and press "Connect"

3) You will now see all the projects in TFS, Select the Project and then expand it to select the work item type you want to export "Task" for this post and click "OK"

4) You will see the "Save As" window, browse to the location where you want to save, name the file and click "Save"

5) If you get popup window "Global List" asking "Would you like to include the Global List Definition?" click on "NO"

6) From VS Menu click "Team" > "Process Editor" > "Work Item Types" > "Import WIT"

7) In window "Import Work Item Type Definition"
8) Click on "Browse..." and locate the file which you saved earlier during "Export WIT"
9) Select the project to which you want to apply this template "CustomerService"
10) Click on "OK"


Its done, now to verify do as we did couple of time before, refresh the project "CustomerService" and then create the new task. You should see your changes applied.


for more information please read the given link read...

How to enable or make editable Delete textbox in task with TFS 2008. How to Customize TFS 2008 work area?

Customizing the Work Item Tracking (WIT) Template

Changing work item templates, when new to team foundation server seems quite daunting - the first things I needed to learn about changing the work item templates were the witimport and witexport commands - these allow the import and export of XML definitions for work items on an existing project via the command line and editing the xml by hand was fiddly to say the least.

As said earlier TFS Power Tools makes this very simple by visually representing the XML for editing. The layout presented for editing the template look like a form layout which is quiet easy to work with.

Recently I had to modify the default Work Item templates for type Task to include a new custom field and also we needed to make the Task Start Date and Task Finish Date to be editable. The fields are editable in Database but are locked only in the UI. So we only have to make changes in the UI.

The reason these filed are read only is to prevent users modifying the dates. Often the tasks are loaded/imported from a MS Project Plan (.mpp) which has the Start Date and Finish Date along with dependencies and milestones. The effect of changing the date might change dates for other dependent task(s). MS Project can handle this, but when the date is modified in TFS Work Item and its synchronized with MS Project Plan the MPP is screw-up as this will not change the dependent tasks.

Now lets get the real action started, first I will show you how to make the Task Start Date and Task Finish date editable.

1. Making Task Start Date and Task Finish Date to be editable
1) Open Visual Studio (if not already open)
2) Open Team Explorer Window (Ctrl+\, Ctrl+M) (if not already open)
3) From VS Menu click "Tools" > "Process Editor" > "Work Item Types" > "Open WIT from Server" (Caution: You will be modifying this directly on the TFS Server so try to do it on Test Server rather than a production server)

4) Enter your server details and press "Connect"

5) You will now see all the projects in TFS, Select the Project and then expand it to select the work item type you want to edit Task for this post and click "OK"

6) You will see the screen similar to the one below, this is where you will be modifying the template. There are three tabs: Fields, Layout and Workflow. Fields Tab handles everything about the data/entity, Layout handles the rendering and view, Workflow defines how the data is transformed. You can also view the XML by clicking on View XML

7) As discussed earlier the fields Task Start Date and Task Finish Date are read-only in UI we will go to the Layout tab in order to make them editable.
8) Click tab "Layout"
9) Scroll down to locate "Control - Start Dat&e:", which is under "TabPage - Details" > "Group" > "Column" > "Group - Schedule"
10) Now in the properties for the control on right side of window select the property "ReadOnly" change the value to "False"
11) Repeat the step above to change property "ReadOnly" to "False" for "Control - &Finish Date:"

12) Now we need to change the type of control so that it will be rendered with standard date time control which we can use to select the date
13) On the properties pane of "Control - Start Dat&e:" select the property "Type" and change value from "FieldControl" to "DateTimeControl"
14) Repeat the step above to change the property "Type" for "Control - &Finish Date:" to "DateTimeControl"
15) Save the changes Ctrl+S or File > "Save __Task.wit"

16) After saving the changes refresh the project from Team Explorer, wait for some time after refresh and try to refresh couple of times and have some wait time between the refresh.
17) Open "Team Explorer" > Right click on the Project "SharePoint.Samples" > "Refresh"

18) To verify the changes now you should create a new task
19) Open "Team Explorer" > Expand the project "SharePoint.Samples" > Right click "Work Items" > "Add Work Item" > "Task"

20) Once the new task form is open, switch to "Details" tab and you should see your changes as per the image below


For More information please read SharemyPoint

Monday, October 3, 2011

User Can't able to view Reports section in TFS Panel

Error:The permissions granted to user 'SQL-PDE\harish.k' are insufficient for performing this operation.

Solution:
some steps are required to resolve this problem-
1)Open your TFS server.



2)You need to set the permissions up via SQL Server Management Studio. Run it
as administrator, click Connect in Object Explorer, select Reporting Services
from the dropdown, then enter server name.



3)Once connected, right click on Home and do Properties



4)then you can add your user and apply the permissions you need.

Wednesday, August 17, 2011

Search a string across all projects under Team Foundation Server.

TFS2008 Tools do not have a find-in-files function. But there is a Windows program with this functionality posted on CodePlex. I just installed and tested this and it works well.
for more information please check CodePlex.

Monday, August 8, 2011

c# Windows Service not appearing in services list after install

Many times user create a windows service and add installer to it, but when user try to install, it will installed successfully but dosn't appear in service list.

use the below mentioned steps to find a best solution:

Add a custom action to the setup project.

1.In Solution Explorer, right-click the setup project, point to View, then choose Custom Actions. The Custom Actions editor appears.

2.In the Custom Actions editor, right-click the Custom Actions node and choose Add Custom Action. The Select Item in Project dialog box appears.

3.Double-click the application folder in the list box to open it, select primary output from MyNewService (Active), and click OK. The primary output is added to all four nodes of the custom actions � Install, Commit, Rollback, and Uninstall.

4.Build the setup project.

Thursday, August 4, 2011

Show server time in client application

Sometime client requirement is to show server time in client application, There are two options to complete this task.
1) Read server Date and Time and do postback with timer.
2) Read Server Date and Time and use Javascript to maintain right date and time.

Expamle:

<script type="text/javascript">
var currenttime = '<%#Session["ServerDateTime"]%>';
var montharray = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
var serverdate = new Date(currenttime)

function padlength(what) {
var output = (what.toString().length == 1) ? "0" + what : what
return output
}

function displaytime() {
serverdate.setSeconds(serverdate.getSeconds() + 1)
var datestring = montharray[serverdate.getMonth()] + " " + padlength(serverdate.getDate()) + ", " + serverdate.getFullYear()
var timestring = padlength(serverdate.getHours()) + ":" + padlength(serverdate.getMinutes()) + ":" + padlength(serverdate.getSeconds())
document.getElementById("servertime").innerHTML = datestring + " " + timestring
}

window.onload = function () {
setInterval("displaytime()", 1000)
}

</script>

Monday, July 4, 2011

Extension Methods in .NET 3.5

Introduction
Extension method is new to C#.Its allow you to add new method to the existing class.
Description
1.Extension method allows you to add new method to the existing class without modifying the code, recompiling or modifying the original code.
2.Extension method are special kind of static method but they are called using instance method syntax. Their first parameter specify which type the method operate on, and the parameter is precede by “this” modifier.
3.Extension method are only in scope when you explicitly import the namespace into your source code with “using” directive.
For Example in string object there is no method call “Reverse()” function .But if you need to extend the string ….
Sample Code
namespace ExtensionMethods
{
public static class ExtensionsClass
{
public static bool IsValidEmailAddress(this String EmailAddress)
{
Regex regex = new Regex(@"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$");
return regex.IsMatch(EmailAddress);
}
}
}

How to Use?
string email = harish@company.com;
if ( email.IsValidEmailAddress() ) {

}
Note how the static method above has a "this" keyword before the first parameter argument of type string. This tells the compiler that this particular Extension Method should be added to objects of type "string".

for more information follow the Link

Wednesday, June 22, 2011

280 लाख करोड़ का सवाल है ..

280 लाख करोड़ का सवाल है ...
भारतीय गरीब है लेकिन भारत देश कभी गरीब नहीं रहा"* ये कहना है स्विस बैंक के
डाइरेक्टर का. स्विस बैंक के डाइरेक्टर ने यह
भी कहा है कि भारत का लगभग 280
लाख करोड़
रुपये उनके स्विस
बैंक में जमा है. ये रकम
इतनी है कि भारत का आने वाले 30 सालों का बजट
बिना टैक्स के
बनाया जा सकता
है.
या यूँ कहें कि 60 करोड़
रोजगार के अवसर
दिए जा सकते है. या यूँ भी कह सकते है
कि भारत के किसी भी गाँव से दिल्ली तक 4
लेन रोड बनाया
जा सकता है. ऐसा भी कह
सकते है कि 500 से ज्यादा सामाजिक प्रोजेक्ट पूर्ण किये जा सकते है. ये
रकम
इतनी ज्यादा है कि अगर हर भारतीय को 2000 रुपये हर महीने भी दिए जाये तो 60
साल तक ख़त्म ना हो. यानी भारत को किसी वर्ल्ड बैंक से लोन लेने कि कोई जरुरत
नहीं है. जरा सोचिये ... हमारे भ्रष्ट राजनेताओं
और नोकरशाहों ने
कैसे देश को

लूटा है और ये लूट का सिलसिला अभी तक 2011 तक जारी है.
इस सिलसिले को
अब रोकना

बहुत ज्यादा जरूरी हो गया है. अंग्रेजो ने हमारे भारत पर करीब 200 सालो तक राज
करके करीब 1 लाख
करोड़ रुपये लूटा. मगर आजादी के केवल 64 सालों में हमारे भ्रस्टाचार ने 280
लाख करोड़ लूटा है. एक तरफ 200 साल में 1 लाख करोड़ है और दूसरी तरफ केवल 64
सालों में 280 लाख करोड़ है. यानि हर साल लगभग 4.37लाख करोड़, या हर महीने
करीब 36 हजार करोड़ भारतीय मुद्रा स्विस बैंक में इन भ्रष्ट
लोगों द्वारा जमा
करवाई गई है. भारत को किसी वर्ल्ड बैंक के लोन की कोई दरकार नहीं है. सोचो की
कितना पैसा हमारे भ्रष्ट राजनेताओं और उच्च अधिकारीयों ने ब्लाक करके
रखा हुआ
है. हमे भ्रस्ट राजनेताओं और भ्रष्ट अधिकारीयों के खिलाफ जाने का पूर्ण अधिकार
है.हाल ही में हुवे घोटालों का
आप सभी को पता ही है - CWG घोटाला, २ जी
स्पेक्ट्रुम घोटाला , आदर्श होउसिंग घोटाला ... और ना जाने कौन कौन
से घोटाले
अभी उजागर होने वाले है ........आप लोग जोक्स फॉरवर्ड करते ही हो. इसे भी इतना
फॉरवर्ड करो की पूरा भारत
इसे पढ़े ... और एक आन्दोलन बन जाये

Thursday, June 2, 2011

How to search any specific string in a procedure, stored procedure and many other information.

If you need to find how many DB objects a person created and what is the created and modified date.

Please use the following sql statement for this:

SELECT *
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%search_string%'
AND ROUTINE_TYPE = 'PROCEDURE'

Friday, May 27, 2011

Hide Console Window in Console Application with C#

1) First write below code above your console main method:
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

2) Put below line of code in starting of main Method
// hide the console window
setConsoleWindowVisibility(false, Console.Title);

3) use below lie of code in your class
public static void setConsoleWindowVisibility(bool visible, string title)
{
//Sometimes System.Windows.Forms.Application.ExecutablePath works for the caption depending on the system you are running under.
IntPtr hWnd = FindWindow(null, title);

if (hWnd != IntPtr.Zero)
{
if (!visible)
//Hide the window
ShowWindow(hWnd, 0); // 0 = SW_HIDE
else
//Show window again
ShowWindow(hWnd, 1); //1 = SW_SHOWNORMA
}
}

Finally you will see your console window hide.

Friday, May 20, 2011

Inserting duplicate records in Primary key field

One time I seen a duplicate entry in table primary key field,
that's strange for me or everyone, who don't know about this. But It's possible.

please follow the instructions:

1) let first us create a table:
create table testTable(
testempno number(9) primary key,
testename varchar2(50)
);

2) Insert some valid records into the table.
insert into testTablevalues(1,'test1');
insert into testTable values(2,'test2');
commit;

TESTEMPNO TESTENAME
1 test1
2 test2

3) Find out the constraint name for the primary key:
SELECT CONSTRAINT_NAME FROM USER_CONSTRAINTS WHERE TABLE_NAME LIKE 'testTable' ;

CONSTRAINT_NAME
SYS_C00111110

4) Disable the constraint:
ALTER TABLE testTable DISABLE CONSTRAINT SYS_C00111110;

5) Check whether the index for the field is enabled or not:
select index_name,index_type from user_indexes where table_name like 'testTable';

It should return no rows returned. If otherwise returned drop the index.

6) Now insert the duplicate record:
INSERT INTO testTable VALUES (1,'testDuplicate');

7) Now create a non-unique index on the field:
CREATE INDEX testTable_INDEX ON testTable(testempno);

8) And at final enable the primary key constraint:
ALTER TABLE testTable ENABLE NOVALIDATE CONSTRAINT SYS_C00111110;

Now give a select * from testTable;

TESTEMPNO TESTENAME
1 test1
2 test2
1 testDuplicate

9)Now you have a enabled primary key constraint with a violated data:
SELECT CONSTRAINT_NAME,STATUS FROM USER_CONSTRAINTS WHERE TABLE_NAME='testTable';

CONSTRAINT_NAME STATUS
SYS_C00111110 ENABLED

For More Info Click Here

Friday, April 29, 2011

Undo changes in Team Foundation Server(TFS) and "Undo Pending Changes..." for users no longer with the company

How do you undo a change for a person who is no longer with the company?

In two steps you can perform this task.

1) Open Command Prompt and select an specified path
C:\Program Files\Microsoft SQL Server\90\NotificationServices\9.0.242\Bin>cd C:\
Program Files\Microsoft Visual Studio 9.0\Common7\IDE


2) Give a proper file path with tf command
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE>tf undo /workspace:WorkSpace Name;tfs User name $/file path /s:http://172.0.1.1:port

finally you will get a successful message as below.

The operation completed successfully.

Wednesday, April 6, 2011

Using INSERT / OUTPUT in a SQL Server Transaction

Frequently I find myself in situations where I need to insert records into a table in a set-based operation wrapped inside of a transaction where secondarily, and within the same transaction, I spawn-off subsequent inserts into related tables where I need to pass-in key values that were the outcome of the initial INSERT command. Thanks to a Transact/SQL enhancement in SQL Server, this just became much easier and can be done in a single statement... WITHOUT A TRIGGER!


Solution
One of the Transact/SQL enhancements in Microsoft SQL Server is the OUTPUT sub-clause of the INSERT statement. You can now capture the records inserted via an INSERT statement (think also being able to capture IDENTITY column values for the new rows) for subsequent use in an additional INSERT statement for a child table to persist referential integrity without the need for an INSERT trigger.

Why not just use a trigger? It's a viable and proven construct of SQL Server, right?

The short answer is "Yes, it is." However, triggers are one of those nasty little secrets that the database keeps. They don't just jump right out at you and say "HERE I AM!" Take for example the troubleshooting process of deadlocks or tuning a poorly-performing query - a trigger sitting in the background performing as it's been asked to may be causing your issues, but you're going to go through many iterations of searching stored procedures, and ad-hoc T/SQL code before you probably even stop to consider there is a trigger firing off data modification language commands (DML) - INSERTS, UPDATES, or DELETES that are adjunct to what you're trying to diagnose. I associate the use of triggers with the use of ad-hoc T/SQL code used in an application's code stack and passed to a SQL Server instance for processing - practices to shy away from.

That is why I like what I see with the INSERT-OUTPUT construct. You get the benefits of being able to capture the inserted values that you can then pass to a secondary command - and you can wrap this all inside a single transaction for atomicity. The syntax for this construct is shown below and differs only slightly from the basic INSERT T/SQL command:

INSERT INTO
(

)
OUTPUT INSERTED. --and other columns from SOME_TABLE if need be
INTO
(

)
SELECT
(

)
FROM
WHERE
The only difference between this and a standard INSERT statement is the inclusion on the OUTPUT...INTO statement. To make this easy think of it as simply a secondary INSERT statement inside of the original INSERT statement that captures the values in the virtualized INSERTED table - the same table that a trigger would use - to process a secondary INSERT to another table. In the example below, and in keeping with the holiday season, let's say you're responsible for doing a bit of hiring at the corporate AdventureWorks offices. A right-jolly old elf is being hired for some in-store promotions and in keeping with corporate policy you always perform a 90 day review for any new hires. We want to have the notfication recorded when the new hire is entered without any additional work on the part of Human Resources. The code below demonstates how we can use INSERT-OUTPUT to do this.

USE AdventureWorks;
GO

---Create Example Tables
/*
Note, this is not fully-normalized. I would have included another table
for Notification Types if this was an actual solution.
I would also use an int NotificationTypeID column in Notifications table
instead of a varchar(xx) NotificationType column.
*/

CREATE SCHEMA [HR] AUTHORIZATION dbo;
GO

CREATE TABLE [HR].[Staff]
(
[StaffID] [int] IDENTITY(1,1) NOT NULL,
[FirstName] VARCHAR(30) NOT NULL,
[LastName] VARCHAR(30) NOT NULL,

CONSTRAINT [PK_StaffID] PRIMARY KEY CLUSTERED
(
[StaffID] ASC
)ON [PRIMARY]
) ON [PRIMARY];

CREATE TABLE [HR].[Notification]
(
[NotificationID] [int] IDENTITY(1,1) NOT NULL,
[StaffID] [int] NOT NULL,
[NotificationDate] DATETIME NOT NULL,
[NotificationType] VARCHAR(30) NOT NULL,

CONSTRAINT [PK_NotificationID] PRIMARY KEY CLUSTERED
(
[NotificationID] ASC
)ON [PRIMARY]
) ON [PRIMARY]; Now that we've built the objects for this little exercise we can look at the INSERT-OUTPUT construct in action...

/*
Demonstrate how you can insert the key values added to Staff.StaffID
into Notifications.StaffID in single transaction
*/

INSERT INTO HR.Staff ( FirstName, LastName )
OUTPUT INSERTED.StaffID, DATEADD(d,90,GETDATE()),'90-Day Review'
INTO HR.Notification
(
StaffID,
NotificationDate,
NotificationType
)
VALUES ( 'Santa','Claus'); Selecting now from both the Staff and Notification tables you'll see that the key values were successfully entered into both tables:

SELECT * FROM HR.Staff;
SELECT * FROM HR.Notification;

Now there is a very important - and quite limiting caveat to using INSERT-OUTPUT. The Output target can't be part of any foreign key relationship. Even if there is no cascading relationship to any other object via that relationship in the database. Let's look at what happens if it is. We'll add a foreign key to Notification on StaffID, referencing the StaffID column in the Staff table and then try to add some additional holiday help:

--Add Foreign Key for StaffID column to Notifications table
ALTER TABLE HR.Notification ADD CONSTRAINT [FK_Notification_Staff]
FOREIGN KEY
(
StaffID
)
REFERENCES HR.Staff
(
StaffID
);

/*
Demonstrate how you can insert the key values added to Staff.StaffID
into Notifications.StaffID in single transaction
*/

INSERT INTO HR.Staff ( FirstName, LastName )
OUTPUT INSERTED.StaffID, DATEADD(d,90,GETDATE()),'90-Day Review'
INTO HR.Notification
(
StaffID,
NotificationDate,
NotificationType
)
VALUES ( 'Frosty','Snowman');

SELECT * FROM HR.Staff;
SELECT * FROM HR.Notification;
The following error message is returned as expected:

Msg 332, LEVEL 16, State 1, Line 17
The target TABLE 'HR.Notification' OF the OUTPUT INTO clause cannot be ON either side OF a (PRIMARY KEY, FOREIGN KEY) relationship. Found reference CONSTRAINT 'FK_Notification_Staff'.


For More Information please visit http://www.mssqltips.com/tip.asp?tip=2183

Wednesday, January 12, 2011

Retrieving or Limiting the First N Records from a SQL Query

In SQL server 2005, SET ROWCOUNT n has the same behavior as SQL server 2000. It’s recommended to use TOP (n) instead of SET ROWCOUNT n.But in SQL server 2008 you are able to use variable at place of n in TOP (n).

Example:
for RowCount
DECLARE @RowsCount INT
SELECT @RowsCount = 0

SET ROWCOUNT @RowsCount
SELECT * FROM MyTable
SET ROWCOUNT 0

for TOP (n)

DECLARE @RowsCount INT
SELECT @RowsCount = 0

SELECT TOP (@RowsCount ) * FROM MyTable

Wednesday, January 5, 2011

Message Queue in .Net

Queue is nothing but FIFO (First In First Out).

Before going to Message Queue concept, why we need Message Queuing?
Answer is that, we require Message Queue mechanism when we want to store insignificant data which is not required to store and we want to do some operations on it.

For example, we want to accept data from multiple users and we have to do some operations on that data, after that we require writing data to some files. Then in this situation we need not require data to store in database, we just want to do some operations on that data and copy that to some files. This requirement will be fulfilled by Message Queue.

If we take another example, where we have two applications in two different systems. One application will send the data and another will need to process the data.

Here I am explaining second example but two applications are in same system.

To run Message Queue concept in .Net, we need Message Queue service to be installed in our system. By default installation of Operating System, it will not install. To install Message Queue service
Start->settings->control panel ->Add/Remove programs-> Click on Add/Remove window components-> Check Message Queuing ->Click Next button

If you unable install, please refer documentation of corresponding Operating System.

After successful installation of Message Queue, you have to write the code to use it.
Here I am explaining Message Queue by using VB.Net.

In this example we need two applications, one is to store data in Message Queue and another is to retrieve data from Queue.

namespace is "System.Messaging"

Step 1: Push Data in Queue

static void PushDatainQueue(string QueueData, string QueueLable)
{
#region Queue
string strQuePath = string.Empty;
MessageQueue objMessageQueue = new MessageQueue();
strQuePath = @".\Private$\syccrm";

if (MessageQueue.Exists(strQuePath))
//creates an instance MessageQueue, which points
//to the already existing MyQueue
objMessageQueue = new System.Messaging.MessageQueue(strQuePath);
else
//creates a new private queue called MyQueue
objMessageQueue = MessageQueue.Create(strQuePath);
#endregion

#region Message
System.Messaging.Message objMessage = new System.Messaging.Message();
objMessage.Priority = MessagePriority.Normal;
objMessage.Body = QueueData;
objMessage.Label = QueueLable;
#endregion

#region Push Message in Queue
objMessageQueue.Send(objMessage);
#endregion
}

Step 2: Receive Data from Queue

static void ReceiveDataFromQueue(string strQuePath)
{
MessageQueue objMessageQueue = new MessageQueue();
if (MessageQueue.Exists(strQuePath))
objMessageQueue = new System.Messaging.MessageQueue(strQuePath);
else
objMessageQueue = MessageQueue.Create(strQuePath);
Message objMessage = new Message();
objMessageQueue = objMessageQueue.Receive();
String strOperation = objMessageQueue.Label.ToString();
string queueData = objMessageQueue.Body.ToString();
}

Note:for private and public queue syntax
// References public queues.
public void SendPublic()
{
MessageQueue myQueue = new MessageQueue(".\\myQueue");
myQueue.Send("Public queue by path name.");

return;
}

// References private queues.
public void SendPrivate()
{
MessageQueue myQueue = new
MessageQueue(".\\Private$\\myQueue");
myQueue.Send("Private queue by path name.");

return;
}

Tuesday, January 4, 2011

Parallel ForEach on DataTable

i would like to use the new Parallel.ForEach function to loop through a datatable and perform actions on each row.

Example:

Normal foreach loop
foreach (DataRow dr in objDS.Tables[0].Rows)
{
if (!objHT.Contains(dr["MessageKey"].ToString()))
objHT.Add(dr["MessageKey"].ToString(), dr["MessageValue"].ToString());
}

Parallel.ForEach loop for above DataTable
Parallel.ForEach(objDS.Tables[0].AsEnumerable(), dr =>
{
if (!objHT.Contains(dr["MessageKey"].ToString()))
objHT.Add(dr["MessageKey"].ToString(), dr["MessageValue"].ToString());
});

Split the String values with a special character in MS Flow to convert this into Array

 Many times we have a requirement to prepare the Mailing address for some of the documents, suppose there are Address Line1, Address Line2, ...