PDF in .NET

PDF in .NET

A newer and a good utility assembly, which I found, which could manage and generate PDF documents on the fly with simple code in C# and .NET. Check out http://itextsharp.sourceforge.net/ . It just contains a simple DLL that need to referenced from your solution, which does all the magic.

with 0 Comments

ConnectionString Manager

ConnectionString Manager

Most of us, who are using multiple SQLServer connections from our applications need to remember the connectionstring to be replaced in web.config to test the application with the different SQLServers. Either each and every time, we need to type the connectionstring parts. I just thought, I could start out writing a simple web application which could create the connectionstring from the Microsoft-provided DataLinks tool and then it can save the connectiongstring to a text file with a specific extension like .scn (Saved Connection Strings). Currently it saves one connectionstring per file, since I felt that would be easy. The other flexible options could be save all bunch in an XML file or as an Registry Entry.

Currently I have included the following basic options in the utility:

  1. Creates a new connection string, sets the item in the system clipboard and prompts to save it to a location.
  2. Edits an existing connection string , sets the item in the system clipboard and prompts to save it to a location.
  3. Double-clicking the .SCN file automatically launches the Edit action for the connectionstring and then the control flow resumes normally.

TODO:

  1. Optionally, keep all connectionstrings in Registry.
  2. As an addon, encrypt the connectionstring and save it, to enable secure saving of confidential database login credentials.

I would try to upload the utility tonight to my Daffodilnet workspace and then update the URL here.

with 0 Comments

Automating Remote Desktop Web Connection

Automating Remote Desktop Web Connection

Remote Desktop (Terminal Services) is a very useful tool that ships with Windows XP. Actually it is also available, AFAIK, in Windows 2000 also but I think there it needs to be downloaded, configured and managed separately and I think there is a separate interface called 'Terminal Services Manager' over there. It also incurs a separate license. The Remote Desktop Client which gets shipped in Windows XP also has the capabilities of saving the connection details in a separate file in desktop or wherever and when you double click it, it would automatically launch the session for you.

For Windows 2000 Workstations, which do not have this Client, we can download Remote Desktop Web Connection from Microsoft. The installer would automatically configure a virtual directory and the default one http://localhost/tsweb/ would open up a page with an RDPClient ActiveX Control which emulates the behavior of the Client Application.

Now comes the catch. This one being on the webpage, does not have the abilities of saving details onto some desktop or somewhere. Is'nt it? I was having this issue and figured out an easy way. To write a small URL page redirecting to default.htm with all necessary information as URL QueryStrings. I then added a simple window.onLoad JavaScript to default.htm to parse the QueryStrings and launch the connection automatically. The only limitation is that you need to enter the password alone in the window that opens. At the moment, this solution is not able to attack passwords nor do I want to pass passwords in plain querystrings and store them unencrypted in desktop Internet Shortcut files.

The following steps can get you ready with this Remote Desktop Web Connection extension with JavaScript.

  1. Create a URL shortcut file with the URL having the following value: http://localhost/tsweb/Default.htm?srv=deepak&res=0&ac=Y&uN=lavanyadeepak&dN=deepaknetwork
    1. srv -> ServerName to connect
    2. res -> Default Resolution [0 FullScreen]
    3. ac ->  Autoconnect (Y)
    4. uN -> userName
    5. dN -> domainName
  2. Now open tsWeb/default.htm in your notepad and append the following script at the end of the page, preferably before the closing body tag:

<script language="JavaScript">
   function AutoStart()
   {
      if (self.location.href.indexOf("?") > -1)
      {
          var strQueryString = self.location.href.substring(self.location.href.indexOf("?")+1);
   
         var arrQueryStringsParts = strQueryString.split("&");
         for (var intCount=0;intCount < arrQueryStringsParts.length;intCount++)
         {
             var qryPart = arrQueryStringsParts[intCount].split("=");
             switch (qryPart[0])
             {
                case "srv":
                          document.getElementById("editServer").value = qryPart[1];
                          break;
                case "res":
                          for (var intOptCount=0;intOptCount<document.getElementById("comboRes").options.length;intOptCount++)
                          {
                             if (document.getElementById("comboRes").options[intOptCount].value == qryPart[1])
                             {
                                document.getElementById("comboRes").options.selectedIndex = intOptCount;
                                break;
                             }
                          }
                          if (document.getElementById("comboRes").options.selectedIndex < 0)
                            document.getElementById("comboRes").options.selectedIndex = 0;
                          break;
                case "ac":
                          document.getElementById("Check1").checked = (qryPart[1]=="Y");
                          if (document.getElementById("Check1").checked)
                          {
                             document.getElementById("tableLogonInfo").style.display = "block";
                          }
                          break;
                case "uN":
                          document.getElementById("editUserName").value = qryPart[1];
                          break;
                case "dN":
                          document.getElementById("editDomain").value = qryPart[1];
                          break;
             }        
         }
        
         //If valid entries found, then connect...
         if (document.getElementById("editServer").value != "")
            {
               document.getElementById("connectbutton").click();
            }
      }
   }
  
   window.onload = AutoStart;  
</script>

That configures your RemoteDeskop Web Connection page to relatively extend its features further.

with 0 Comments

Dr. IIS -- Clear Cache, Restart IIS Processes etc.

Dr. IIS

Any developer using ASP.NET and VS.NET IDE would have experienced issues with Cache Folder of ASP.NET, VSWebCache having mismatched versions and hence breakpoint not getting hit. We normally use tricks like clearing it manually

This weekend, I was relatively free and thought I would get some practice on Windows Forms in .NET. I made a small application in Windows Forms and nicknamed it Dr. IIS.

I have tried addressing the following issues:

  • Recycle ASPNET Worker Process (currently it detects aspnet_wp as processname. We need to generalize it to w3wp for Windows 2003)
  • Restart W3SVC Service
  • Purges IDE Cache (VsWebCache)
    • Detects first any Visual Studio .NET instances are running. If yes, this option is disabled and a button appears to close existing Visual Studio Instances and then the checkbox gets enabled.
  • Purges Temporary ASP.NET Files from the default version of .NET Framework
  • Pause Indexing Service
  • Also checks whether the logged on user is Administrator. If the user does not have administrator privileges, then the application exits.

I understand that there are lot of scope of improvements to this. Perhaps my next TODO in this would be:

  • Generalize Detection of Worker Process (ASPNET for IIS 5.1 or lower and W3WP for IIS 6)
  • Threaded Application Model
  • CommandLine or Silent Mode
  • Detect and Customize the application to the configured .NET Framework (in case multiple versions exist)
  • Selectively add the required folders to Indexing Service Catalog for exclusion from Indexing.

I would keep updating it in my personal workspace and would publish the URL here. Please do send me your suggestions and improvements for the same.

The current download URL is http://www45.brinkster.com/daffodilnet/tools/driis.aspx 

with 3 Comments

Automated EventLog Clearing and Backup Tool

Automated EventLog Clearing and Backup Tool

Developers writing Windows Services would normally heavily use Windows EventsLog to log messages from the application to System,Application, Security etc builtin logs or to custom log sources too. During development the amount of messages getting logged would be enormous and sometimes during development and testing, we normally and frequently right click clear individual logs before re-running the service again.

I just thought instead of repeatedly doing this, let us put a small Windows Application, enumerate all the available System Logs. The user has to simply run the application, select the logs he wants to clear, and hit clear button.

Out of my own interest, I wanted to get some feel of GUI tricks in Windows Forms like ProgressBar and have used some tricks like ThreadPool to update the parent thread to update it.  Tonight I would try to upload to DaffodilNet page at

http://www45.brinkster.com/daffodilnet/eventlogmanager.aspx

TODO:

There are lot of scope of improvement of this tool. Perhaps significant points to improve upon are:

  1. Backup target to EVT (EventLog Native File). I am trying to explore the feasibility with WMI Api in .NET like the ones in System.Management namespace.
  2. Security Checks. If a non-administrative user loads, then instead of attempting the thread and crashing it can proactively say 'Not all sections of the application are executable by the logged on user, since it needs additional administrative privileges'. Remember, when you run Disk Administrator in Control Panel -> Administrative Tools -> Computer Manager, you see this alert.
  3. Perhaps if you have some suggestion, do send me. I would try to incorporate it.
with 0 Comments

Dependency Walker

Dependency Walker

I was trying to figure out what are the dependencies for a OCX file which I was trying to package. Since I had only Visual Studio .NET in my system, I did'nt have a Dependency Walker (depends.exe).

A brief search in Google revealed this website http://www.dependencywalker.com/ which is the same tool that gets shipped with Visual Studio 6.0. I wanted to share this with my readers of the blog too for their use and reference.

with 1 Comments

QueryExpress -- Generic Tool to Database Updates

QueryExpress -- Tool for Database Updates

A little neat tool from http://www.albahari.com/ which facilitates you to connect to SQLServer, Oracle or any OLEDB Compliant databases. Furthermore, it comes with its source code availability. Its salient features being Threading and Async QueryExecution, plain vanilla XML serializing of connection details and introducing developers to use TypedDataSet.

It was an interesting coincidence that I got to know of QueryExpress sometime about 3 years ago, when we were in  a small organization in Chennai executing a portfolio management project for a client based in California. The database was IBM DB2 and there were no friendly database connector tools and the then ignorance of us in DB2 made us very desparate and discouraging.

A brief search in Google revealed this nice tool. This has enthralled me so much. Even me, nowadays try to update the source, to keep it as a supreme product.

Here are the links to QueryExpress:

  1. QueryExpress home on http://www.albahari.com/ : http://www.albahari.com/query express.html
  2. QueryExpress with ODBC Support: http://www45.brinkster.com/daffodilnet/queryexpress.aspx

Do send us suggestions on what you would like to see in QueryExpress...

with 0 Comments

Elegant Classification of Dropdown Boxes

Elegant Classification in Dropdown Boxes

Dropdown boxes are part of any common webpage. When there are more number of values, then it would be harder to read and would be very unfriendly to the user at large.

One of my friend was asking some trick to workaround this issue and I was suggesting him some XmlHttpRequest and other trick to load it in piecemeal fashion. And accidentally, I discovered a nice trick in HTML called OPTGROUP.

India Pakistan Turkey Australia New Zealand

The elegance of this structure is that the Label Captions are skipped by the web browser automatically and you can apply different coloring for the group.

with 0 Comments

Free Online Digital Certificates

Free Digital Certificates

When we test SSL or Cab Files, if we have a digital certificate, then it would be a full-length testing. Check out the following websites that give free certificates:

  1. http://www.ascertia.com/
  2. http://www.cacert.org/

Just wanted to update. There is a tool called SSLDiagnostics from Microsoft Website. Here is a brief description from MSDN on this tool:

SSL Diagnostics Version 1.0 helps you identify configuration problems in the IIS metabase, certificates, or certificate stores when running Web sites that use SSL. This tool allows you to review SSL configuration information, simulate the SSL handshake to locate errors, or "hot swap" certificates for testing purposes -- http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/f2c980d6-a802-419f-9227-ab46f570c223.mspx

Here is the download URL for SSL Diagnostics:

I hope this would be very useful for developers of web applications whilst testing SSL-enabled applications.

with 0 Comments

SC.EXE

Windows Services -- Breeze to develop in C#

Developing Windows Services is no longer a nightmare, thanks to friendly .NET BCLs, beloved VS.NET Intellisense. But during development, due to errors, we might need to manage the SCM database directly like deleting the Windows Service and that too, without having the assembly on hand, which is impossible using InstallUtil.exe.

I have developing a Scheduler Service for our application and this was a hurdle for me. Fortunately, I came across this tool called SC.EXE available from Microsoft itself.

It comes with nice documentation at: http://msdn.microsoft.com/library/en-us/dndllpro/html/msdn_scmslite.asp?frame=true

Somewhere else, I got a nice downloadable Word document also. I would search again and try to update the same too here.

with 0 Comments

A Cool Experience with SQLServer UDFs

SQLServer and UDFs

UDFs are a cute little things in any database. Just use them in a query and you can loop through the tables and find out without the application bothering about requerying etc.
But in SQLServer, I experienced this glitch. When we created the UDF, it has to be called as owner.functionName unless it is a system defined function.
In our application, we had a generic data access component targetting multiple databases namely three as of now. So this was presenting a piquant situation.
After a deal of small R&D, I found out some of the following workarounds for this:
  • Have the application discover the owner and prefix the same. This being similar to a metadata query, will need a roundtrip to the database. May be as an optimization, we can have a Caching other than for the first request.
  • After the initial seed data has been run for the database, by the setup scripts, make sure that you also reset all owners to the negotiated user login. You can use the system defined stored procedure
    sp_changeobjectowner @objName='GetAppPath', @newowner='lavanya'

It was quite an interesting experience with SQLServer UDFs. But of late, I also came across this URL of having the function behave like System functions:

http://www.winnetmag.com/SQLServer/Articles/ArticleID/15544/pg/2/2.html
with 0 Comments

Cool JavaScript Calendar

DateTime in JavaSCript

Any Webapplication will have a DateTime field.  To have the user enter a datetime in specified format and to validate the same is a nightmare. The best way is to give a friendlier UI where the user can pick the Date and Time.

Check out these URLs:

http://www.softcomplex.com/ (Pop Calendar)
http://www.dynarch.com/projects/calendar/ (Inline DHTML Calender)

 

with 0 Comments

Date Comparisons in JavaScript

Date Comparisons in JavaScript

Almost any developer in the worldwide now uses JavaScript widely for its rich clientside validations. And having a datetime field is a common one in any enterprise web application.

Validating a datetime field is again a tricky task for any webdeveloper.

I was searching for some info on DateTime validations and came across the following simple URL:

Check it out: http://www.flws.com.au/showusyourcode/codeLib/code/js_DateDiff.asp?catID=2

It gives the differences in days, hours, minutes and seconds.

with 0 Comments

Encryption Wrapper in .NET

Rich Encryption Wrapper for .NET

.NET provides rich support for Encryption in its System.Security.Cryptography namespace.

Of late, I was searching for some info when I came across this XCrypt Component for Encryption in .NET.

Check it out @ http://www.codeproject.com/csharp/XCrypt.asp 

It supports almost all Encryption types in .NET and provides an elegant wrapper for the same. It supports both hashing and non-hashing algorithms within it.

with 0 Comments

Cool Assembly Viewer for .NET

Cool Assembly Viewer for .NET

Just browsing for some info and I came across this nice tool. Check out:

http://www.jbrowse.com/products/asmex/

It is quite similar to ILDASM tool that ships with .NET. It also comes with sourcecode. The animation in Help About is also really nice.

For beginners in .NET, the source can be very much useful for learning GDI+ in .NET.

with 0 Comments

A Cool Web-based Interface to Microsoft Access in ASP

Web-based Interface to Microsoft Access

Even now, there are plenty of websites and applications that run on Microsoft Access.  And managing the live databases that are hosted on a website is in fact to be taken with more care. As time passes, the database grows in size after which downloading to the local system, making changes and reuploading would become a nightmare.

I was searching for some web-based IDE for Microsoft Access to manage one of my .MDB files on the web and I came across the following nice tool, which is a freeware available along with sourcecode (in ASP)

http://www.stpworks.com/DesktopDefault.aspx?tabindex=1&tabid=3&articleid=3

Check it out...

with 0 Comments

An IDE that you can customize to your needs...

Visual Studio .NET Extensibility API

Just I was searching for some Runtime.InteropServices examples and I came across some Visual Studio .NET automation examples. Perhaps sometime back, I have been discussing with you through my other weblog at http://deepak.blogdrive.com/ regarding a automated build tool called BuildIt.

Perhaps the following URL would throw more light and give more examples on Visual Studio .NET Extensibility API:

http://www.microsoft.com/downloads/details.aspx?familyid=3ff9c915-30e5-430e-95b3-621dccd25150&displaylang=en

with 0 Comments

Starting to blog...

Warming up...

A new blog and a new window opening up with more tips, articles and other information sharing weblog. Perhaps, my other open source project is getting us more to discover and share, which we would categorize and share with other readers in ADO.NET, Remoting etc.

Just starting up blog here...

More coming up...

Stay Tuned...

with 0 Comments