Search This Blog

Friday, December 27, 2013

How to get my iPad to connect to a local hosted site on an internal network

Last two years, I have been transforming from Windows flat client /database centered application developer (VB6, MS access, C#) to being a Microsoft centered web developer using MVC / ASP.net.

There are so many things to understand moving from Windows OS to Web platforms
 - Web server settings, application pools, protocol bindings, Firewalls
 - Understanding basic organization of ASP.NET projects
 - Making sense of javascript, client vs server side script execution
 - Browsers on various plaforms, Windows OS, andriod, iOS
 - Web site design geared to mobile devices
 - Learning tools like Fiddler

Add to this list, how can you get a mobile device like an iPad to access a web site hosted on a local network server.  Something that is essential when you trying to make UI changes for the iPad.

Here is an excellent article from WebEgg site: http://www.webegg.co.uk/local-web-sites-on-ipad-mobile/
Please take time to read through the article.  The solution to the problem is using proxyu settings to setup a reverse proxy allowing specifically configured devices to interact with you local server web site.

Steps:

Like magic, sites configured on localserver/IIS will be accessible on your iPad.

Next task, find the solution the nexus 7.
 Trying the same steps on the nexus 7 did not work. :(


Found a simpler solution:
http://www.mobitechie.com/android-2/how-to-access-localhost-on-android-over-wifi/
Did not install WAMP server. Skip that...
Created Port 80 rule inbound and it worked.








Friday, November 22, 2013

Using BCP utility

Bulk copy program bcp is still supported by SQL 2008 R2 and SQL 2012 Yeah!!!

SQL 2008 R2 http://technet.microsoft.com/en-us/library/ms162802(v=sql.105).aspx
The bcp 10.0 client is installed when you install Microsoft SQL Server 2008 R2 tools. If tools are installed for both SQL Server 2008 R2 and SQL Server 2005, depending on the value of the PATH environment variable, you might be using the earlier bcp client instead of the bcp 10.0 client. This environment variable defines the set of directories used by Windows to search for executable files. To discover which version you are using, run the bcp /v command at the Windows Command Prompt. For information about how to set the command path in the PATH environment variable, see Windows Help.

SQL 2012 http://technet.microsoft.com/en-us/library/ms162802.aspx
The bcp 11.0 client is installed when you install Microsoft SQL Server 2012 tools. If tools are installed for both SQL Server 2012 and an earlier version of SQL Server, depending on the value of the PATH environment variable, you might be using the earlier bcp client instead of the bcp 11.0 client. This environment variable defines the set of directories used by Windows to search for executable files. To discover which version you are using, run the bcp /v command at the Windows Command Prompt. For information about how to set the command path in the PATH environment variable, see Windows Help.

For exporting

bcp [database name].dbo.[table name] out  -n -S -U -P


For Import

bcp [database name].dbo.[table name] out  -n -S -U -P


case is important on arguments.  -n is very important. forces bcp to sql native format.  This is essential of you are exporting and importing data to tables to prevent truncating.

Example

Bcp [New410].dbo.tbCPTDx out tbCPTDx.bcp –n –SRISQA2008R2 –Usa –Psa


Wednesday, November 13, 2013

Creating my first WPF app, the saga continues

In around 60 hrs I have converted a C# winforms application to WPF.

Biggest challenge encountered was the tree control.
In winforms, tree control uses treenodes.  Not the case at all in WPF.

You use HierarchicalDataTemplate


Pretty cool once you get it working.

Next big challenge,  convert sql server data source to SQLite.
Great project on Code Project

Convert SQL Server DB to SQLite DB - CodeProject


But, it converted my Int32 to Int64.

This caused a problem in the class structures I was deserializing the result sets into.

public class LegoPart : INotifyPropertyChanged
    {
        [DataMember, Column]
        public string ItemNo { get; set; }

        [DataMember, Column]
        public string ParentItemNo { get; set; }

        [DataMember, Column]
        public byte[] Image { get; set; }

        [DataMember, Column]
        public string Description { get; set; }

        [DataMember, Column]
        public object Color { get; set; }

        [DataMember, Column]
        public string ImagePath { get; set; }

        public event PropertyChangedEventHandler PropertyChanged;
    }






Next problem, I encountered is apparently SQLite does not support UNION queries
This was simple to eliminate since the resultset is being converted into IList. I simply created two lists and then combined them.

   list1.AddRange(list2);





Friday, October 11, 2013

Loop through SQL values without a cursor.


3rd Time I had to recreate this example so I'm posting it now.


   1:   
   2:  DECLARE @Users TABLE( 
   3:    [RowNumber] Int  PRIMARY KEY,
   4:    [UserId] uniqueidentifier)
   5:   
   6:  DECLARE @iCount Int
   7:   
   8:  INSERT INTO @Users (RowNumber, UserId)
   9:  SELECT rank() Over (order by UserId)
  10:          ,UserId
  11:  FROM Profile
  12:  WHERE PropertyValuesString like '%ReportPending%'
  13:   
  14:   
  15:  SET @iCount=1
  16:  WHILE ((SELECT MAX(RowNumber) FROM @Users) >= @iCount)
  17:  BEGIN
  18:   
  19:          SELECT * FROM @Users WHERE RowNumber = @iCount
  20:          SET @iCount=@iCount+1
  21:  END

Wednesday, October 9, 2013

Working on my first WPF application from scratch

At work, the project I manage (MVC web app has a WPF installer) had a couple of installer related issues.  I've been on this project ~2 years  and up to now I had no reason to modify the WPF installer app.  I need to determine if the project is going to keep the WPF installer or go with a NSIS based installer.  I reviewed the code and came to the conclusion I know very little about WPF.

So last Friday, I started a small WPF project.  I have a little Lego Parts app I have rewritten a couple of times that currently has a WinForms MDI UI.  Obviously my Lego app needs a WPF UI client.

I thought I would capture my thoughts on WPF.

WPF Cons

  • On controls, renamed Text properly to Content.  This is just annoying.
  • Not all controls (example DataGridColumn) have a Name property.
  • XAML - Maybe unfair on day 1 to say this and yes I'm using yesterday;s tech with VS 2010 but it can be so sloooooow.
  • Property windows for WPF controls/Pages etc...  is terrible.  No really good way to getting to the properties I really use often.
  • Unavoidable not annoying differences in names of method and properties differences between a WPF control and its WinForm counterpart.
  • WPF UI is still a bit slower than its WinForms alternative even on a i7 CPU 3.3 Ghz with a middle of the road video card.


WPF Pros

  • XAML - (4 hrs in).  Now I get it.  Once you know a control / page / window property you want to modify just edit the XML.  This is a huge time saver for repetitive tasks.  Plus this compensates for the terrible VS 2010 properties sheet UI.
  • UI elements.  I like page view paradigm.  
    • I really like DataGrid.  Fantastic that the grid keeps its position when itemsource is updated.
  • Extracting InvokeRequired from UI.  This is completely different in WPF but I like the change. It should never have been married to the Control in WinForms.
  • Data Binding approach is streamlined and simple.
  • Basic settings for UI controls moves so far beyond WinForms.  Colored backgrounds, transparency etc...


Bottom line, in under 8 hours, I managed to restructure an existing C# solution to keep the existing WinForms UI project, move common code out of WinForms UI project, and create the basic elements of WPF UI in a new project.

  

Tuesday, October 1, 2013

Snipe Hunt: Finding best way to delete large number of files in Windows 7

Attempting to defrag my hard drive recent and one of the largest fragmented folders was:

C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5

Turns out this folder had over 39 million files taking up 60 GB of drive space.
So it begs the question how do you delete a huge number of files from Windows 7.

Turns out this is the approach I am currently using:

del /f/s/q %1 > nul 
rmdir /s/q %1

from http://www.anushand.com/2012/09/a-faster-way-to-delete-large-folders-in.html

I've estimated it will take ~ 4 days to delete all of these files.

My steps:

1. Rename folder Content.IE5 to (old) Content.IE5
2. Run
                del /f/s/q %1 > nul 
                rmdir /s/q %1

                del /f/s/q "(old) Content.IE5\CAY*.*"

Thursday, September 19, 2013

Creating a Jenkins Build machine


Recently, I had to recreate a Jenkins build server due to a hardware failure.
The process was straightforward but not without issues...


VM started with
WIN2008 R2 server
VS 2010 Pro

Software to be installed:
1) TortoiseSVN 1.7.6, Build 22632 - 64 Bit , 2012/03/08 18:29:39
2) Winrar - wrar420.exe
3) Jenkins 1.531 from  http://jenkins-ci.org/


Steps:
1) Installed TortoiseSVN
2) Pulled local project code in SVN down
3) Install ASP.net/MVC3 (its a MVC3 ASP.NET App)
4) Install IIS 6 Metabase and IIS 6 Configuration Compatibility
         (Needed to for 3 projects in the solution)
        http://technet.microsoft.com/en-us/library/bb397374(v=exchg.80).aspx
5) Install WIF files (Windows Identity Foundation) (used by the project)
a. Windows6.1-KB974405-x64
b. WindowsIdentityFoundation-SDK-4.0
6) Install Jenkins 1.531.
a. Add Text Finder Plugin to Jenkins install.
b. Downgrade SVN plugin to version 1.45
c. Install Active Directory Plugin
d. Give anonymous read access
e. Define other users.
f. Add SVN login as /
g. Manually added subversion.credentials file to 'My Project' task folder  and restarted jenkins
C:\Program Files (x86)\Jenkins\jobs\My Project

7) Turn firewall off.

Issues entered:
1) VS 2012 cannot be used to build 'My Project' .
a. Solution contains is a .net deployment project which is no longer supported by current versions of Visual Studio.  Last supported in VS2010 
b. Had to uninstallVS2012 Pro and install VS2010 Pro
2) After configuring Jenkins and confirming that project code could be fetched from SVN locally on the build server and manually compiled, attempts to set user credentials for SVN resulted in failure: with code SVN E175002
a. Manually added subversion.credentials file to 'My project folder task folder and restarted jenkins

C:\Program Files (x86)\Jenkins\jobs\My Project

Thursday, August 8, 2013

Link servers from SQL 2008 R2 to SQL 2000 (32bit)


Solutiion is from http://sqlblog.com/blogs/roman_rehak/archive/2009/05/10/issue-with-64-bit-sql-server-using-sql-2000-linked-server.aspx


Issue with 64-bit SQL Server using SQL 2000 linked server

Recently we started adding SQL Server 2008 64-bit servers to our production set and we ran into the following issue. When we ran queries on a linked 2000 server, we were getting the following error:
OLE DB provider "SQLNCLI10" for linked server "XXXXXX" returned message "The stored procedure required to complete this operation could not be found on the server. Please contact your system administrator.".
Msg 7311, Level 16, State 2, Line 1
Cannot obtain the schema rowset "DBSCHEMA_TABLES_INFO" for OLE DB provider "SQLNCLI10" for linked server "XXXXXX". The provider supports the interface, but returns a failure code when it is used.

This article from MS website describes the issue pretty well, although it says the issue applies to 2005 but we are using 2008. As suggested, we ran the Instcat.sql file on our development system first, and we ended up getting errrors left and right, so we didn't dare to run it on our main production server. In the end, this workaround worked for us - we needed to create a procedure in the master database on the linked 2000 server. The proc is called sp_tables_info_rowset_64 and it is needed because it is called by 64-bit servers when running remote queries.
 Here is the text of the proc in case you ever need to do the same, create it in the master database:
create procedure sp_tables_info_rowset_64
      @table_name sysname,
      @table_schema     sysname = null,  
      @table_type nvarchar(255) = null
as
  declare @Result int set @Result = 0
  exec @Result = sp_tables_info_rowset @table_name, @table_schema, @table_type
go

Wednesday, June 19, 2013

Checking your outgoing mail server (Is Port 25 blocked?)

Checking your outgoing mail server (Is Port 25 blocked?):

'via Blog this

In a comment Prompt:
telnet example.com 25

or

telnet example.com 587


If unblocked...
220 cl34.gs01.gridserver.com ESMTP Exim 4.63 Tue, 24 Jun 2008 13:45:04 -0700
If blocked...
Trying 64.13.192.208... telnet: connect to address 64.13.192.208: Connection refused telnet: Unable to connect to remote host

Saturday, June 8, 2013

Two questions about the modern Internet?

Why does every browser now hate the Home button?

  - I know why Google hates the home button by why does everyone else follow suit. Too bad, Chrome on many levels is a the best browser out there but Google's business models will eventually render Chrome useless.

   - Mozilla thinks they are smarter than everyone or they are smoking alot of something during UI design sessions.

    - Apple who cares... the moment a major browser release broken basic http authentication I was done.  Apple almost had to produce the iPhone and iPad because no one in their right minds would say I want to develop a web app for Safari.

 - Microsoft - IE9/10 does not suck. But still IE has its challenges, try create ASP.NET/MVC app that shows embedded PDFs also use html dialogs watch the job of staying in focus.  Opposite behavior of everyone else.  

Why can't I find a file sharing site allows me to share a file with URL and then allow the file to be downloaded with a simple WebClient?

  - Skydrive - No.  I tried to use SkyDrive 5 years ago. No Published API at the time, constant UI changes, and file linking schemes.

  - DropBox - You think so...  until some actually uses the link.  DropBox, you're done you just don't know it yet.

  - All of the various sites hosted for nefarious but legal file sharing....
 I just can't do it...  

A thief is always a liar first...Can't trust a user agreement or mission statement for  sites used primarily dumping ground for porn and photos of ex-wives and girl friends.
     Yes includes you Tumblr and Flickr...

Maybe for my next rant, I'll discuss how blogger is now the walking dead....

Wednesday, March 27, 2013

Find open ports in Windows


From http://www.techrepublic.com


Microsoft Windows XP
Microsoft Windows also offers anetstatcommand that can be executed from the command line to get a list of open ports. The standard MS Windows version ofnetstatis slightly more limited than its Unix-like system counterparts, but still suffices to get a listing of listening services:
  netstat -a | find "LISTENING"
The output of this command should look something like this:
TCP    hostname:epmap           hostname:0               LISTENING
TCP    hostname:microsoft-ds    hostname:0               LISTENING
TCP    hostname:10110           hostname:0               LISTENING
TCP    hostname:netbios-ssn     hostname:0               LISTENING
. . . with “hostname” replaced by the system’s hostname, of course.

Saturday, March 16, 2013

Path.Combine() - this is just stupid....

In my DRC project, I found a bug specifically caused by incorrect file path.

My approach was the Base folder path in my app.config / Settings and then use relative paths for all the resources  I need to store in a database.  Seems like a solid plan.   Actually, been using this approach for 10+ years now... what went wrong?

Recently, I've been using Resharper tool to tighten up my code.  During my review of the code, I found where I had some manually concatenated paths using string.Format().  With an eye to porting my application to iOS or Android using Mono, I thought building paths from simple strings simply won't do.  Better to use System.IO.Path.Combine() right?

Wrong!  After converting this code to use Path.Combine() errors occurred.  Impossible I thought, the paths are correct.  I found this issue on StackOverflow:


Why Does Path.Combine not properly concatenate filenames that start with Path.DirectorySeparatorChar

In my testing I found this:

Path path + subfolder + file name

System.IO.Path.Combine(@"C:\DRC_Data","USA","48cnty.dbf")
"C:\\DRC_Data\\USA\\48cnty.dbf"   - PASS


System.IO.Path.Combine(@"C:\DRC_Data\","USA","48cnty.dbf")
"C:\\DRC_Data\\USA\\48cnty.dbf" + PASS


System.IO.Path.Combine(@"C:\DRC_Data",@"USA",@"\48cnty.dbf")
"\\48cnty.dbf" - FAIL



System.IO.Path.Combine(@"C:\DRC_Data\",@"\USA","48cnty.dbf")
"\\USA\\48cnty.dbf" - FAIL


System.IO.Path.Combine(@"C:\DRC_Data\",@"USA",@"\48cnty.dbf")
"\\48cnty.dbf" = FAIL


System.IO.Path.Combine(@"C:\DRC_Data\",@"\USA\",@"48cnty.dbf")
"\\USA\\48cnty.dbf" - FAIL

Now, I'm not going to declare Path.Combine() useless for building paths with relative elements but there needs to a an option set for Path.Combine() does not assume every element that starts with a backslash as a start of a root path.

Path.Combine() works as per spec but it's not what I would have expected either.
Bottom line, it is a helper function that should be more helpful!










 


Wednesday, February 20, 2013

Simple file list from a folder structure

Another thing I can't seem to remember.

Source:  http://smallbusiness.chron.com/copy-list-files-windows-folder-excel-list-40032.html


Step 1

Press "Win-E" to open Windows Explorer and locate the folder for which you need a file list.

Step 2

Hold the "Shift" key, right-click the folder and select "Open Command Window Here."

Step 3

Type "dir /b > dirlist.txt" without quotes and press "Enter." This creates a list containing file names only. To include file sizes and dates, type "dir > dirlist.txt" instead. To also include files in sub-directories, type "dir /b /s > dirlist.txt" to create a list of files with the full directory structure name, such as "C:\folder\subdirectory\file.txt.


Wednesday, February 6, 2013

IIS 7.+ research


IISReset vs recycling App pools

What is the difference between IIS reset and application pool recyle in affecting of cachehttp://stackoverflow.com/questions/8237110/what-is-the-difference-between-iis-reset-and-application-pool-recyle-in-affectin


Restart IIS / Recycle App Pool after X num of errors?
http://stackoverflow.com/questions/1223255/restart-iis-recycle-app-pool-after-x-num-of-errors


Starting, stopping and recycling IIS 7.0 Web sites and application pools

http://mvolo.com/starting-stopping-and-recycling-iis-70-web-sites-and-application-pools


IIS: difference between stop/start & recycle app pool

http://forums.asp.net/t/1670252.aspx/1

Sunday, January 27, 2013

Setting up Plex

Last December, I setup on Plex media server to create a NextFlix like interface for my mine DVD collection.

Plex lets your stream MP4s to multiple clients at once. In my household, typically there are 2-3 plex clients running at once.  Best part is Plex Media Server is free.

First things is to download Plex Media Center. http://www.plexapp.com/getplex/.

Its available for Windows, OS X, Linux, and some NAS applianaces.

Plex clients are available for computer and mobile devices.  The mobile device clients are not free neither is the Windows 8 client. http://www.plexapp.com/.

Here is my Plex Media server configuration

  • Hosted Plex Media server on a Windows 8 machine Intel 2-CPU single core Xeon 2.5 Ghz, 4GB RAM , 32bit.
  • Using ZyXel NAS325 ARM processor with 4 TB of disk space to host my media files.
  • Mapped shared folder on NAS325 to a drive letter on the Windows 8 machine.
  • Windows 8 machine is connected to my 60in flat screen TV.
  • Also use Plex Media Center as the client on the Windows 8 machine. http://www.plexapp.com/download/plex-media-center.php.
Note: I purchased the Plex client from the Windows 8 store.  It was ~$3.00.  The playback was too slow and choppy.  I downloaded Plex media center and its performance was very nice.

Another cool feature is with a little port forwarding, you can allow access to the personal Plex server over the internet.  I have the paid version of  Plex client for Android $4.99 on my Nexus 7 and Kindle Fire tablets.

Now to complete my TV watching experience on flat screen TV, I installed http://www.unifiedremote.com/ which comprises of a service that is installed on a Windows machine and then a client that is installed on my Nexus 7 tablet.  Now, I have a free convenient mouse /keyboard remote control for Windows!

I also installed Plex Remote which is by far the easiest Plex remote to use.  Allows me to control the Plex media center installed on any of my Windows machines.


I converted my DVDs with

Note: I rip my DVDs on Intel i7 8 core processor 3 GHZ with 8 RAM.  


Total cost for this project is~$400.00.

  • $40.00 for Windows 8 license for old converted PC.
  • $150.00 for Zyxel NAS unit without drives
  • ~$130.00 for 2 - 2TB SATA hard drives - special deal on newegg.
  • $13.00 on Plex clients for Windows 8 and 2 android tablets.
  • ~$40.00 for AnyDVD license.
Great way to recycle an old PC with a decent video card.


Monday, January 21, 2013

No more Crystal Reports

More RDLC Basics

The final piece of the puzzle to solve is how to use multiple report data sets in a report.  

Things to know:
  • You do not need to use sub reports to use more than one data set in  report.
  • Report data set != .net C# Data set.  (This is possibly the dumbest thing about RDLC reports).
  • Report data set  is approximately equivalent to .net data table.
  • Setting up multiple report data sets for a single report is easier than most examples so.
Here is the end point I want:  A report where most of the information comes from one query or view where there is a 1=1 relationship between the various data tables.  The next data set is 1 to many relationship listing multiple items associated a data record.  

My working example: Mine Summary report:
Mine Name, location description, map coordinates, and mineral deposit description comes from one data set.  Minerals found at the mine will come from another data set.

End result will be:


First, I used the Report designer in VS 2010:

Defined the data sets:
From December 1, 2012

And the created the report:
From December 1, 2012

You can add report controls Grids, lists, or text boxes and then assign the values to each.
As you assign the value for each control, you can specify the name of the data set the value is from.
From December 1, 2012

The report data sets map to table adapters I have set up in my DataSet in the project.
From December 1, 2012

I can this approach because I want to have the report be as close to a dumb view as possible.  Any data processing or business logic will be performed in C#. So I create a reference dataset(s) that I can design the report with and stored in the project as reference.

Now, all I have to do is create a couple data tables that match the data sets defined in the report.

Here is the code I use to fetch the data:  1st data table is the 1=1 data of mine name, location and map coordinates.  2nd table is list of mineral occurrences.  A 3rd table is used to concatenate the mineral occurrences to a single text column using a Linq aggregate function.


public static DataSet GetReportDataSet(string reportName, string MDBfile, object rowID)
        {

            try
            {
                EnterProc(MethodBase.GetCurrentMethod());
                var dataset = new DataSet();
                string[] sql = null;
                string[] tablenames = null;

                switch (reportName)
                {
                    case "MineSummary":
                        #region MineSummary
                        sql = new[]{string.Format("SELECT * FROM vwMineSummaryReport WHERE MineID={0}", rowID)
                                      , string.Format("SELECT * FROM vwMineSummary_MineralOcc WHERE ID={0}", rowID)
                                      };

                        tablenames = new[] {"Mine"
                                           ,"MineralOcc"
                                           };
                        #endregion
                        break;
                }

                if (sql != null && sql.Length > 0)
                {
                    FillDataSetFromMDB(MDBfile, sql, tablenames, dataset);
                }

                if (dataset.Tables["MineralOcc"].Rows.Count > 0)
                {
                    var table = new DataTable("Minerals");
                    var col = new DataColumn { ColumnName = "Minerals", DataType = typeof(string) };
                    table.Columns.Add(col);
                    string sMinerals = dataset.Tables["MineralOcc"].Rows.Cast<DataRow>().Aggregate("", (current, row) => current.Length > 0 ? current + string.Format(" , {0} ", row[0]) : string.Format(" {0} ", row[0]));
                    table.Rows.Add(sMinerals.Trim());
                    dataset.Tables.Add((table));
                }


                ExitProc(MethodBase.GetCurrentMethod());
                return dataset;

            }
            catch (Exception ex)
            {
                ErrorLog(ex);
                return null;
            }
        }


The next code block is used to assign the data to report data sets.
(A point a claification:  In my application, the user clicks on a button to print/view/or export a report to PDF, and I use events and arguments to pass the data and the report name from a user control hosting all of the functionality to the parent form which catches the event and calls a method to print / preview or export the report.)

In the code, a report event argument is passed to a method that creates a localreport and assigns multiple report data sets (one per data table in the dataset passed in using the argument.)


static LocalReport PrepareRDLCReport(ReportEventArgs args)
        {
            var rds = args.ReportData != null ? new ReportDataSource("DataSet1", args.ReportData)
                                            : new ReportDataSource("DataSet1", args.ReportDataSet.Tables[0]);
            var report = new LocalReport
            {
                ReportEmbeddedResource = string.Format("DRC.RDLC.{0}.rdlc", args.ReportName)
            };

            report.DataSources.Add(rds);
            if (args.ReportName == "MineSummary")
            {
                report.DataSources.Add(new ReportDataSource("DataSet2", args.ReportDataSet.Tables[1]));
                report.DataSources.Add(new ReportDataSource("DataSet3", args.ReportDataSet.Tables[2]));
            }
            return report;

        }

The final block of code is common code used to print a report.


public static void PrintReport(ReportEventArgs args, Form mdiParent)
        {
            try
            {
                if (mdiParent != null)
                     mdiParent.Cursor = Cursors.WaitCursor;

                DateTime startTime = DateTime.Now;
                switch (args.ReportType)
                {
                    case "CrystalReport":
                        ReportDocument reportobj = PrepareReport(args);
                        if (reportobj != null)            
                                reportobj.PrintToPrinter(1, false, 0, 0);
                        break;
                    case "RDLC":
                        var report = PrepareRDLCReport(args);
                        var reportPrintDoc = new ReportPrintDocument(report)
                            {
                                PrinterSettings = {PrinterName = Properties.Settings.Default.DRC_Printer}
                            };

                        reportPrintDoc.Print();
                        break;
                }
                TimeSpan duration = DateTime.Now - startTime;
                DisplayDuration(mdiParent, duration, string.Format("Print report - {0}", args.ReportName));
            }
            catch (Exception ex)
            {
                DRCCommon.Common.ErrorLog(ex);
            }
        }