Skip to main content

Posts

Showing posts from January, 2013

Custom configuration in Web.config

Almost all projects have come configuration which is mostly unique and absolutely custom. That configuration allow to customize some application behaviors, settings and switching some parts of implementation. In Microsoft .NET Framework configuration can be stored in two types of files: *.config - XML based file which differ depending on project type. In web application such ASP.NET or WCF we working with Web.config file and in desktop application use App.config . *. setting - deprecated type of file which allow to store custom settings in XML  based, strongly typed file.  In this post I focus on Web.config file and demonstrate how to create custom section for this type of file.  At the beginning  we need some basic configuration file which is easy to get one because after we created new ASP.NET project from a template we already should have one. Simplified version on Web.config looks like as resented below. Code Snippet <? xml version = " 1.0 " ?>

Compression in BAT by using 7z

To compress direcotry or files in batch program all You need to do is  to install 7z opensource and create simple 'task.bat' file with only few line of code: @echo Start processing "C:\Program Files\7-Zip"\7zg.exe a C:\Backup\important_data_%date:~0,4%%date:~5,2%%date:~8,2%.7z C:\inetpub\wwwroot\BestWebsite -t7z -mx9 -m0=LZMA -pMYPassword @echo End PAUSE What we do here is: 1) Run 7zg.exe program 2) Create target file important_data_(current data).7z in C:\Backup\ directory 3) Indicate file or folder to compress in this ex we compress 'BestWebsite' directory 4) Set compression parameter in this example we have-t7z -mx9 -m0=LZMA 5) Optionally set a password to compressed document Thank you

WCF Pagination

In many of my projects  including last one I need to user N-Tier architecture for my application. This is very good approach because you can centralize your business logic and have many type of clients (WWW, mobile devices) thanks WCF and REST technology. The other thing is that most of business solutions displays some data in tabular format knows as grids and grid has always one problem: number of records increasing in time. So we need to ask ourselves do we really need to display all the data together  to user on one page? Of course not! Such approach is incorrect and not against best practices because its extends the time of response and send a much more data to client. To deal with that problem many developers uses pagination mechanism which is part of ASP.NET (ex. asp:Grid) but such approach is not correct when working with N-Tier architecture and its not supported in any mobile devices. In my approach I wish to implement all my business logic and services by using Service Facto