Monday, December 31, 2007

Deploying ASP.NET Web application using web deployment project

Its known from many posts in most of the blogs that use of web deployment project in a solution is a better option than opting for XCOPY or copy project.

This post explains my experience using the web deployment project for one of my web application.

Creating a Web Setup Project: Using Visual Studio .NET InstallerWe will start by adding a new Web Setup Project to our deployusingInstaller ASP.NET Web application solution by selecting File->Add Project-> New Project from the menu. In the New Project dialog box, select Setup and Deployment Projects from the Project Types pane and then select Web Setup Project in the Templates pane.


After creating the project, you then need to add the output of the primary assembly and the content files of the ASP.NET Web application to the setup project. To do this, right click on the deployusingInstaller project in the solution explorer and select Add->Project Output from the context menu. In the Add Project Output Group dialog box, select deployusingInstaller from the Project drop down list and select Primary Output from the list.


After adding the project output, you then need to add the related Content Files (such as .aspx files, Images, and so on) to the project. To do this, again bring up the Add Project Output dialog box and then select Content Files from the list this time.

Configuring Properties through the Properties:
There are a number of properties that you can set through the properties window of the Web Setup project. These properties determine the runtime display and behavior of the Windows installer file. To accomplish this, right click on the deployusingInstaller project from the solution explorer and select Properties from the context menu to bring up its properties window.

Installing the ASP.NET Web Application:
Once you have created the Windows installer file (.msi file), then installing the ASP.NET application in the target servers is very straightforward. All you need to do is to double-click on the .msi file from the Windows explorer. This will initiate the setup wizard, which will walk you through the installation steps.


Clicking on Next, results in the following dialog box, where you can specify the virtual directory that will be used to host this Web application. This is one of the handy features wherein the creation of virtual directory is completely automated obviating the need for manual intervention.

In dialog box, you can also click on the Disk Cost... command button to get an idea of the space required for installing this Web application. Clicking on Next in the above dialog box results in the following dialog box where you are asked to confirm the installation.

When you click on Next in the dialog box, the installation will begin and the application will be installed. The application is successfully installed.

After installing the application, you can see the installed ASP.NET application through the Add/Remove Programs option (that can be accessed through Start->Settings->Control Panel) in your computer. From here, you can run the setup program to uninstall the application any time you want to.

Tuesday, June 26, 2007

code to dynamically generate rows on click on ButtonField in gridview

ofcourse there are many posts available on to generate rows dynamically on button click..

I would like to share the code of scenario where in the clickevent (commandname) of buttonfield in gridview would dynamically generate the rows ....

The buttonfield is binded to gridview whose commandname is accessed in the RowBound event of gridview as shown below...

protected void gvStores_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "myCommandAdd")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow selectedRow = gvStores.Rows[index];
TableCell store = selectedRow.Cells[6];
al.Add(Convert.ToInt16(store.Text));
CreateTextBoxControls1(al);
}

method CreateTextBoxControls1() takes input of various click events of gridview which are stored in a static arraylist.


private void CreateTextBoxControls1(ArrayList al)
{
int rowCount = al.Count;

Table tbl = new Table();
if (tbl.GetType().ToString().Equals("System.Web.UI.WebControls.Table") && Placeholder1.FindControl("tbl") == null)
{
tbl.ID = "tbl";
}
tbl.EnableViewState = true;
for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
{
TableRow tr = new TableRow();
TableCell tc = new TableCell();

Label _lblBookStore = new Label();
Button _btnDelete = new Button();

_lblBookStore.ID = "lblBookStore" + (rowIndex + 1).ToString();
_lblBookStore.Text =""+al[rowIndex];
tc.Controls.Add(_lblBookStore);

_btnDelete.ID = "btnDelete" + (rowIndex + 1).ToString();
_btnDelete.Text = "MyBookstore";
_btnDelete.Click += new EventHandler(_btnDelete_Click);
tc.Controls.Add(_btnDelete);

tr.Cells.Add(tc);
tblHelp.Rows.Add(tr);
}
Placeholder1.Controls.Add(tbl);
}

thus the place holder gets various rows added to the page dynamically and can associate an AJAX effect by binding the place holder and gridview inside an update panel.

code to generate a file based on the number of users logged in specific time

I happened to write a console application to generate a file based on the number of users logged in specific time. I hope this might be useful since its interesting to work with console application after a long time.

.. I hope this makes sense for all whose looking for a starting point for writing such applications..


static void Main(string[] args)
{
String[] commandLineArgs = System.Environment.GetCommandLineArgs();
int duration = System.Convert.ToInt32(commandLineArgs[1]);
int delay = System.Convert.ToInt32(commandLineArgs[2]);
String str = commandLineArgs[3];
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "server=myserver;uid=sa;password=sa;Initial Catalog=AdventureWorks;";
conn.Open();
FileStream fs = File.Create("c:\\ " + str + ".log");
StreamWriter sw = new StreamWriter(fs);
while (duration > 0)
{
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM [AdventureWorks].[dbo].[myTestTable]", conn);
DataSet ds = new DataSet();
StringBuilder stb = new StringBuilder();
da.Fill(ds);
if (ds.Tables.Count > 0)
{
if (ds.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
if (ds.Tables[0].Columns.Count == 2 && i == 0)
{
sw.WriteLine(ds.Tables[0].Columns[0].ColumnName + " " + ds.Tables[0].Columns[1].ColumnName);
sw.WriteLine("=====================================");
}
string info = ds.Tables[0].Rows[i][0].ToString() + " " + ds.Tables[0].Rows[i][1].ToString();
sw.WriteLine(info);
}
sw.WriteLine();
}
}
Thread.Sleep(delay * 1000);
duration = duration - 1;
}
sw.Close();
fs.Close();
}
}

To run the application..
goto commandprompt of visual studio and change the directory to debug of the current application and type

myapplication.exe 10 10 mylog

this refers to run the exe of the application with arguments duration of 1min and delay of 10 sec and name of the file to log the needed information.

Wednesday, May 16, 2007

CRM Customization

This post is about a short term work done on MSCRM. Customizing the reports for CRM.

let me walkthrough various terms I am going to discuss in this post

MSCRM:
set up CRM server with organization name as the name of the server.
it can be accessed by http://organizationname/loader.aspx
The referances to various view can be obtained by chceking the mappings and attributes in CRM->Settings
The drilldown reports to be placed under Hidden reports section of CRM. To acieve this, the selection for the type of reports to be empty.Otherwise the respective classification under which the report appears can be placed like Marketing, Sales, Services reports.
Also the respectives views include needs to be referred during importing the report onto CRM. Example:Account, Campaign Response, Campaigns, service appointment, activities, Meter, Oppurtunities etc.
MSCRM customization:
import customizatons pertaining to the organization. this can be done by settings->import customization->import the referred file. The new changes made is refelected by new_() in database tables and respective fields in tables.
To design the default filter, one need to specify its Aliasing Filter for a particular View (Example:FilteredAccount) while writing the query for the report.
SSRS Reports:
The reports can be activated for drill down by selecting the properties->data tab->Edit (in values section) ->Action->Jump to report.
Reports exported to CRM:
The reports were produced using SSRS. The parameters in the "where" condition of query in SSRS will themself become select clauses at runtime.
Global Variables for CRM:
CRM global level variables are to be declared using "CRM_". Typical examples include
CRM_URL == for drilldown.
CRM_FilterText == for getting the filtered values on to the reports.
CRM_SortField == for sorting
CRM_SortDirection == sort direction (Ascending/Descending)
Defining the sort direction for tabular reports:
The following is code for getting the arrow in the table header and implementing the same for sorting. Report -> Report Properties -> Code

Function GetArrow(SortField As String, SortColumn As String, SortDirection As String)As String
If
SortField = SortColumn
then if
SortDirection ="Ascending"
then
Return "D"
Else
Return "Ñ"
End If
Else
Return ""
End If
End Function
The following is code for table details for get refreshed while sorting
=IIF(IsNothing(Parameters!CRM_URL.Value),Nothing,Parameters!CRM_URL.Value & "?ID={"&Fields!myTabledetailName.Value.ToString()&"}&OTC=4400")

Navigation between Excel Workbook/Worksheet


The other day sekhar was referring to similar issue of organizing his activities during his trip. Then comes the issue of managing his various Excel workbooks and worksheets.

Below is the procedure for Navigation – Excel 2007.

1. In sourcebk1, select cell you want to link to destbk1.
2. Find the "Hyperlink" button in "Insert" ribbon, select the same.
a. Case 1: Navigation between workbooks (sourcebk1, destbk1)
1. Select Existing File or Page in the opened window
2. Select the required destination file.
3. Press Ok button
b. Case 2: Navigation between worksheets in same workbook.
1. Select Place in this referance with the cell to be referred.
2. Select required destination worksheet
3. Click Ok button.
Its as simple as playing with a page and work is done ......

Monday, May 14, 2007

workflow development in sharepoint 2007 using Visual Studio

I happened to attend to Suneetha's issue on workflow. I discovered it as a potential source of information to know more about what I am missing to know about integrating what i learnt differently. Though her issue was related to debugging workflow.. Its truly worth knowing everything about it.

When I was in ERS (Evangelism Rhythmic Services), I used to work on Windows Workflow Foundation with Visual Studio(default) and Sharepoint with integration with Visual Studio for custom webparts.

I feel the following links gives an immense information about the topic.
Workflow Development in Visual Studio 2005: http://msdn2.microsoft.com/en-us/library/ms461324.aspx
Debug Your Windows SharePoint Services Workflow: http://msdn2.microsoft.com/en-us/library/ms455354.aspx

Thanks to Eilene Hao, Program Manager, Microsoft Corporation for such an wonderfull presentation. One can also find the same in link below.
http://msevents.microsoft.com/cui/WebCastEventDetails.aspx?culture=en-US&EventID=1032301596&CountryCode=US

Friday, March 23, 2007

Configuring and installing performancepoint scoreboard

Scenario:
I've got a cube for which I need to use Performance point scorecard to showcase certain reports.

I installed performancepoint server CTP1 and trying to do some hands-on over it... messed up with many questions on configuring my sharepoint server.... datasource not getting connected...

I have been stuck with the database not being shown in my scorecard builder.

Solution: Recheck IIS settings of the website created to NetworkAuthority....

Ah! now I can see my Analysis Services Cube and can now get started....