tag:blogger.com,1999:blog-13387369315656369982024-03-13T19:39:07.623+05:30Tech Bytes - Ask meFollow me on Twitter <a href="https://twitter.com/kannagoldsun">@kannagoldsun</a>Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.comBlogger43125tag:blogger.com,1999:blog-1338736931565636998.post-68360149794457500992018-08-15T14:44:00.000+05:302018-08-15T14:44:57.033+05:30VB.NET Extending the MailMessage to have the ability to save the mail message<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Problem:</b><br />
<br />
The <span style="font-family: "courier new" , "courier" , monospace;">System.Net.Mail.MailMessage</span> is badly missing the option of saving the Message as a file. Though there is a workaournd by using the <span style="font-family: "courier new" , "courier" , monospace;">SpecifiedPickupDirectory</span> option of the <span style="font-family: "courier new" , "courier" , monospace;">SmtpClient</span> to write the mail message ot the specific folder. This option however doesn't have flexibility in naming the files. In a multi-threaded parallel execution environment, it is difficult to identify and rename the specific files post writing to disk. There ought to be a better solution to handle this problem.<br />
<br />
<b>Solution:</b><br />
<br />
You can extend the <span style="font-family: "courier new" , "courier" , monospace;">MailMessage </span>class and add a <span style="font-family: "courier new" , "courier" , monospace;">Save m</span>ethod yourself. The <span style="font-family: "courier new" , "courier" , monospace;">Send m</span>ethod of the <span style="font-family: "courier new" , "courier" , monospace;">SmtpClient </span>creates and uses <span style="font-family: "courier new" , "courier" , monospace;">MailWriter </span>object to write out the mail message and it uses <span style="font-family: "courier new" , "courier" , monospace;">fileMailWriter </span>when the <span style="font-family: "courier new" , "courier" , monospace;">SpecificPickupDirectory </span>is specified as the <span style="font-family: "courier new" , "courier" , monospace;">DeliveryMethod</span>. Create your own <span style="font-family: "courier new" , "courier" , monospace;">MailWriter </span>object using <span style="font-family: "courier new" , "courier" , monospace;">FileStream </span>and invoke the internal <span style="font-family: "courier new" , "courier" , monospace;">Send </span>method, passing your <span style="font-family: "courier new" , "courier" , monospace;">MailWriter </span>object. Check out this <a href="https://www.codeproject.com/Articles/32434/Adding-Save-functionality-to-System-Net-Mail-MailM?fid=1533533&df=90&mpp=25&sort=Position&spc=Relaxed&prof=True&view=Normal&fr=1#xx0xx" target="_blank">Code Project Article</a> for more details. The code samples given there are for the C# language. Just in case you need, given below the same code for the Extension in VB.NET.<br />
<br />
<div style="background-color: #cce0ff;">
<hr />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Imports System</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Imports System.Net.Mail</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Imports System.Collections.Generic</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Imports System.Linq</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Imports System.Text</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Imports System.IO</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Imports System.Reflection</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Imports System.Runtime.CompilerServices</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Module MailMessageExtension</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <Extension()></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> Public Sub Save(ByVal msg As MailMessage, FileName As String)</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> Dim asm As Assembly = New SmtpClient().GetType().Assembly</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> Dim _mailWriterType As Type = asm.GetType("System.Net.Mail.MailWriter")</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> Using _fileStream As FileStream = New FileStream(FileName, FileMode.Create)</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> ' Get reflection info for MailWriter contructor</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> Dim _mailWriterContructor As ConstructorInfo = _mailWriterType.GetConstructor(BindingFlags.Instance Or BindingFlags.NonPublic, Nothing, New Type() {GetType(Stream)}, Nothing)</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> ' Construct MailWriter object with our FileStream</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> Dim _mailWriter As Object = _mailWriterContructor.Invoke(New Object() {_fileStream})</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> ' Get reflection info for Send() method on MailMessage</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> Dim _sendMethod As MethodInfo = New MailMessage().GetType().GetMethod("Send", BindingFlags.Instance Or BindingFlags.NonPublic)</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> ' Call method passing in MailWriter</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> _sendMethod.Invoke(msg, BindingFlags.Instance Or BindingFlags.NonPublic, Nothing, New Object() {_mailWriter, True, True}, Nothing)</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> ' Finally get reflection info for Close() method on our MailWriter</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> Dim _closeMethod As MethodInfo = _mailWriter.GetType().GetMethod("Close", BindingFlags.Instance Or BindingFlags.NonPublic)</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> ' Call close method</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> _closeMethod.Invoke(_mailWriter, BindingFlags.Instance Or BindingFlags.NonPublic, Nothing, New Object() {}, Nothing)</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> End Using</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> End Sub</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">End Module</span><br />
<hr />
</div>
<br />
You may observe that you need to create extensions as a module.</div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-73863370377526805592018-04-07T12:09:00.000+05:302018-04-07T12:09:07.573+05:30Hypothetical Indexes in SQL Server<div dir="ltr" style="text-align: left;" trbidi="on">
<b><span style="font-size: large;">Problem</span>:</b><br /><br /><br />While attempting to rebuild all indexes on a table, I am getting the following error:<br /><br /><span style="font-family: Courier New, Courier, monospace;">Cannot rebuild hypothetical index '_dta_index_table_name_10_992214785__K9' online.</span><br /><br />What is this hypothetical index and I cannot see any such indexes in the object explorer against the specific table. How can I get over this error.<br /><br /><br /><i><b><span style="font-size: x-small;">By: Anonymous</span></b></i><br /><br /><br /><b><span style="font-size: large;">Solution:</span></b><br /><br /><br />You or someone who works on the database should have used Database Tuning Advisor (DTA) to analyze the performance aspect of the tables and indexes. DTA creates hypothetical Indexes when it checks queries & tables for columns to measure the performance gain that such indexes may offer and thus come up with a recommendation. Usually when the DTA completes its analysis, it deletes all the hypothetical indexes if it cleanly finishes but in some cases, these indexes may be left over.<br /><br /><br />For a query or a stored procedure execution, after an initial recompile is triggered, the optimizer uses some of the information from these hypothetical indexes, which is out of date, and hence incorrectly determines that a recompile is needed again. During the ensuing recompiles, the information from the hypothetical indexes is never refreshed, and so the optimizer remains in a recompile loop. Hence, dropping hypothetical indexes is a better choice.<br /><br /><br />Clustered hypothetical indexes can be dropped with DROP INDEX statement. Nonclustered hypothetical indexes can be dropped with DROP STATISTICS statement. <br /><br />You may find out all hypothetical indexes using this query:<br /><br /><br /><span style="font-family: Courier New, Courier, monospace;">WITH [hypo] AS (<br /><br />SELECT QUOTENAME(SCHEMA_NAME(o.[schema_id])) +'.'+ QUOTENAME(OBJECT_NAME(i.[object_id])) AS [Table] , QUOTENAME([i].[name]) AS [Index_or_Statistics], 1 AS [Type]<br />FROM sys.[indexes] AS [i]<br />JOIN sys.[objects] AS [o] ON i.[object_id] = o.[object_id]<br />WHERE 1=1 <br />AND INDEXPROPERTY(i.[object_id], i.[name], 'IsHypothetical') = 1<br />AND OBJECTPROPERTY([o].[object_id], 'IsUserTable') = 1<br /><br />UNION ALL<br /><br />SELECT QUOTENAME(SCHEMA_NAME(o.[schema_id])) +'.'+ QUOTENAME(OBJECT_NAME(o.[object_id])) AS [Table], QUOTENAME([s].[name]) AS [Index_or_Statistics], 2 AS [Type]<br />FROM sys.[stats] AS [s]<br />JOIN sys.[objects] AS [o] ON [o].[object_id] = [s].[object_id]<br />WHERE [s].[user_created] = 0<br />AND [o].[name] LIKE '[_]dta[_]%'<br />AND OBJECTPROPERTY([o].[object_id], 'IsUserTable') = 1<br />)<br /><br />SELECT [hypo].[Table],[hypo].[Index_or_Statistics], </span><div>
<span style="font-family: Courier New, Courier, monospace;">CASE [hypo].[Type] <br />WHEN 1 THEN 'DROP INDEX ' + [hypo].[Index_or_Statistics] + ' ON ' + [hypo].[Table] + ';'<br />WHEN 2 THEN 'DROP STATISTICS ' + [hypo].[Table] + '.' + [hypo].[Index_or_Statistics] + ';'<br />END AS [Drop Stmt]<br />FROM [hypo]</span><br /><br /></div>
<div>
Hope this helps you.<br /></div>
</div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-86061037301352994972017-03-13T12:22:00.001+05:302017-03-13T12:23:26.792+05:30Windows Service - How To Setup Email Notification On Service Failure<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
<b>
Problem:</b></div>
<br />
We have designed a scheduler engine, which runs as a windows service and is used for executing different kinds of scheduled tasks. At times, the service stops and we get to know that only when some users complain of not being able to see the outcome of a scheduled task. Since then we have put this scheduler under the monitoring checklist, so that the windows monitoring team have a check on this service. But it would be even more effective, if this is automated. Wonder if Windows offers an easy way of setting up an alert on service stoppage.<br />
<br />
<div style="text-align: left;">
<b>
Solution:</b></div>
<br />
Windows does offer an option to configure email notification for one or more specific events occuring. If you have built your service application to handle the exceptions and write the exception information into the windows event log, then the easier approach is to leverage the windows event notification. If you have not aready used the Windows event log, in your service application, it is recommended to do so, as windows event log is the best place to look for errors and other events. Check out Stuart Lange's article on Handling <a href="https://www.devopsonwindows.com/handle-windows-service-errors/" target="_blank">Windows Service Errors</a>. It is a series of six articles and you may want to check out all of them. Check out the Technet article <a href="https://technet.microsoft.com/en-us/library/cc732728(v=ws.11).aspx" target="_blank">Configure Notification Options</a> to know more about setting up email notifications using the Windows System Resource Manager.<br />
<br />
Just in case, you don't have the option of leveraging the Windows System Resource Manager as above, then you may make use of the Recovery options under the service properties dialog. You may double click on your service on the services console window and you will see a Tab named Recovery. The Recovery option enables you to specify a recovery action three times. See the figure below:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-iQlJo31EblU/WMY8tSzULBI/AAAAAAAANK4/VYp8kqOFJAc86zdoZ1_rVCSLM2P64GGggCLcB/s1600/Service%2BProperties.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="320" src="https://4.bp.blogspot.com/-iQlJo31EblU/WMY8tSzULBI/AAAAAAAANK4/VYp8kqOFJAc86zdoZ1_rVCSLM2P64GGggCLcB/s320/Service%2BProperties.png" width="305" /></a></div>
<br />
As you may observe, you four options to choose when a service fails: Take No Action, which is the default; Restart the servive; Run a program; and Restart the computer. While Restarting the computer is not a good idea if the computer also serves various applications and services, Though you have option to specify a delay for restart and<br />
to send out messages to other connected computers that the computer is being restarted.<br />
<br />
<br />
But certainly Run a Program option can be leveraged to send out an email notification. You may also notice that you have option to specify different actions for the first, second and subsequent failure. It would be a good idea to to try restarting the service atleast once or twice and then try using a custom program to send out an email notification. The custom program can even be a Power Shell script.<br />
<br />
A simple PowerShell script to send out email notification could be as below:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">$Username = "MyUserName";<br />$Password= "MyPassword";<br />$message = new-object Net.Mail.MailMessage;<br />$message.From = "YourName@gmail.com";<br />$message.To.Add($email);<br />$message.Subject = "subject text here...";<br />$message.Body = "body text here...";<br />$smtp = new-object Net.Mail.SmtpClient("smtp.gmail.com", "587");<br />$smtp.EnableSSL = $true;<br />$smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);<br />$smtp.send($message);</span><br />
<div>
<br />
While there are more ways you can handle this problem, I hope this helps you to </div>
</div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-70356729352815115522017-03-12T12:21:00.000+05:302017-03-12T12:26:51.126+05:30MS Excel - Copy Sum of Selected Cells<div dir="ltr" style="text-align: left;" trbidi="on">
<h3 style="text-align: left;">
Problem:</h3>
<br />
Mirosoft Excel is a wonderful office product and is an essential tool in our work life for most of us. But still many would have not discovered its capabilities to the fullest. Here is a problem that I wanted to solve. Typically, techies don't like to do same thing repeatedly and would look for a possible shortcut for that. I have been working through multiple excel sheets, where in have to find totals for a group of cells, without any specific parameters to determine the qualifying cells. If there is a shortcut to accomplish this it would be of help to many.<br />
<br />
<br />
<h3 style="text-align: left;">
Solution:</h3>
<br />
Given that there are no parameters that determine the qualifying cells, it is difficult to come up with a an algorithm to automate the selection and totalling. But it would be possible to leave the selection to the users and then facilitate the summing part. We can leverage the clipboard to achieve this. Let the users select the desired cells and then invoke the macro using the assigned short cut key combination and the total is copied into the clipboard and available for pasting any where.<br />
<br />
Here is the macro that does the work:<br />
<br />
<blockquote class="tr_bq">
<span style="font-family: "courier new" , "courier" , monospace;"><span style="background-color: white; color: #222222; font-size: 16px;">Sub mySum()</span></span><span style="font-family: "courier new" , "courier" , monospace;"><span style="background-color: white; color: #222222; font-size: 16px;"> </span></span></blockquote>
<blockquote class="tr_bq">
<span style="font-family: "courier new" , "courier" , monospace;"><span style="background-color: white; color: #222222; font-size: 16px;"> Dim MyDataObj As New DataObject</span></span><span style="font-family: "courier new" , "courier" , monospace;"><span style="background-color: white; color: #222222; font-size: 16px;"> MyDataObj.SetText </span><span class="skimlinks-unlinked" style="background-color: white; border: none; color: #222222; font-size: 16px; list-style: none; margin: 0px; outline: none; padding: 0px; vertical-align: baseline;">Application.Sum(Selection</span><span style="background-color: white; color: #222222; font-size: 16px;">)</span></span><span style="font-family: "courier new" , "courier" , monospace;"><span style="background-color: white; color: #222222; font-size: 16px;"> MyDataObj.PutInClipboard</span></span> </blockquote>
<blockquote class="tr_bq">
<span style="background-color: white; color: #222222; font-family: "courier new", courier, monospace; font-size: 16px;">End Sub</span></blockquote>
<div>
<br /></div>
<div>
I am sure every one knows how to create a macro and assign a short cut key for it. You may find a lot of resources on creating a macro in excel.</div>
</div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-82804493769001385502017-02-11T12:50:00.000+05:302017-02-11T12:50:52.346+05:30MS Excel - How to get rid of the GetPivotData function in formulas?<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
<b><u>Problem:</u></b></div>
<br />
Have you tried copying a formula involving cells within a pivot table? You may find that the the value in the target cells don't change. You may also notice that the formula doesn't refrerence the cells in the usual way like A1, C2, etc. Instead, it uses the <span style="font-family: Courier New, Courier, monospace;">GetPivotData</span> function. for example when I tried creating a formula adding J4 and I4 and that both J4 and I4 within a Pivot Table. But the formula you see in the target cell is something like the one below:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">=GETPIVOTDATA("Sum of Dec'16"|$A$3|"Group"|"Administrative Expenses")+GETPIVOTDATA("Sum of Nov'16"|$A$3|"Group"|"Administrative Expenses")</span><br />
<br />
As copying this formula to the adjoining cell does not change the cell reference and as such the value doesn't change. How do we workaround this issue?<br />
<br />
<div style="text-align: left;">
<b><u>Solution:</u></b></div>
<br />
I am sure while creating the formula, you would have used the mouse to select the cells referenced in the formula. Try just typing the cell references in the formula without using the mouse. For instance, just type <span style="font-family: Courier New, Courier, monospace;">'=J4+I4'</span> and there you go, the formula remains as it is and at this instance you don't see the reference to the GetPivotData function. Now you copy this formula to the adjoining cells and it works as usual and no issues. So the issue is when you select the cells referenced in the formula using the mouse / touch pad.<br />
<br />
Now why Excel behaves like this, we don't know. However, if you don't like this behavior and permanently disable this you need to do this. It's simple.<br />
<br />
Bring up the <b>Excel Options</b> by clicking on File --> Options menu. May be, there are different ways of reaching out to the Excel Options in different versions of Excel. Under the Formulas Tab, you will find a check box 'Use GetPivotData functions for Pivot Table References' under Working with formulas section. Given below is a screen shot of Excel 2016.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-r4fz8KTkvXg/WJ64Gk0bheI/AAAAAAAAND4/Dk1MnBpG1R4g1UiO6S6TOswYmFs_JwWoQCLcB/s1600/GetPivotData.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="205" src="https://3.bp.blogspot.com/-r4fz8KTkvXg/WJ64Gk0bheI/AAAAAAAAND4/Dk1MnBpG1R4g1UiO6S6TOswYmFs_JwWoQCLcB/s400/GetPivotData.JPG" width="400" /></a></div>
<br />
<br />
There you go, just uncheck this checkbox and Excel won't use the GetPivotData function any more.<br />
<br />
<br />
<br /></div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-80101110275366042332017-01-21T16:23:00.000+05:302017-01-21T17:17:02.001+05:30Bootstrap Carousel - Different intervals for differnet slides<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
<b>
Problem:</b></div>
<br />
Bootstrap Carousel is an easy and convenient option for implementing a slider on your website. But is there a way to advance the slides with different time intervals. For example, slide 1 will advance after 10 seconds, the second slide after 5 seconds and slide 3 to advance after 3 seconds. I came across a scirpting suggestion using the the carousel method with the 'pause' parameter. i.e. Pausing the slide advancing for amount of time computed as the slide timer as reduced by a the interval. But for some reasons this solution wasn't working for me. But I could have it working with a different approach, which is explained below, so that this will be useful for others as well.<br />
<br />
<div style="text-align: left;">
<b>
Solution:</b></div>
<br />
Instead of using the pause attribute, I tried using a script to advance the slides. i.e. advance the slides manually by calling carousel method the 'next' attribute. This can be accomplished in combination with the setTimeOut function. For e-g, something like this should help in having this working.<br />
<br />
<code>
var t;<br />
var start = $('#myCarousel').find('.active').attr('data-interval');<br />
<br />
t = setTimeout(function () { $('#myCarousel').carousel('next') }, start);<br />
</code>
<br />
The block above will ensure that the first slide advances after the interval set for the first slide. Subsequent slide advances can be hanlded using the slid event as below.<br />
<br />
<code>
$('#myCarousel').on('slid.bs.carousel', function () {<br />
<br />
clearTimeout(t);<br />
var duration = $('#myCarousel').find('.active').attr('data-interval');<br />
<br />
t = setTimeout("$('#myCarousel').carousel('next');", duration);<br />
})<br />
</code>
<br />
<div>
Hope this helps. Please to note that to have this working, use the data-interval attribute and set the desired interval in milli-seconds for each slide. e-g.<br />
<br />
<code>
<div class="item" data-interval="4000"><br />
</code>
<br />
<br />
I have found this working fine with a single Carousel in the same page and have not tested this with multiple Carousels in the same page.<br />
<br /></div>
</div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-68530126648511034492016-09-10T19:04:00.000+05:302016-09-10T19:04:05.497+05:30ASP.NET - Setting HTML Meta tags in content pages<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Problem:</b><br /><br /><br />Though the <span style="font-family: Courier New, Courier, monospace;">@Page</span> directive in a content page allows one to specify the <span style="font-family: Courier New, Courier, monospace;">Description </span>and <span style="font-family: Courier New, Courier, monospace;">Keywords </span>attrubutes, the same is ignored when the page is rendered. Instead the <span style="font-family: Courier New, Courier, monospace;">Description </span>and <span style="font-family: Courier New, Courier, monospace;">Keywords </span>as specified in the master page is what gets rendered as part of the final html output. Is this the intended design and is there a solution to work around this issue?<br /><br /><br /><b>Solution:</b><br /><br /><br />By design, the HTML Meta tags specified in the content page is ignored when the page is rendered. In this context it is important to understand the following:<br /><br /><div>
<ul style="text-align: left;">
<li>The Master page contains the <span style="font-family: Courier New, Courier, monospace;"><head></span> tag of the page and not the content page. As such the meta tags specified in the master page will prevail.</li>
<li>The Content page derives the <span style="font-family: Courier New, Courier, monospace;">System.Web.UI.Page</span> class, which though recognizes the Title attribute provided as part of the <span style="font-family: Courier New, Courier, monospace;">@Page</span> directive, it does not recognize the other meta tags like description and keywords.</li>
<li>The master page and content page are dendered in teh following order:</li>
</ul>
<ul style="text-align: left;"><ul>
<li>Content Page PreInit event</li>
<li>Master Page Init event</li>
<li>Content Page Init event</li>
<li>Content Page Load event</li>
<li>Master Page Load event</li>
</ul>
</ul>
<br />As you may observe, while the Load event of Master page happens after that of the Content Page, the Init event of the Master page happens ahead that of the content page. Given that the Master page loads after the content page, you can manage to use the Title attribute specified in the content page using the script tag within the <span style="font-family: Courier New, Courier, monospace;"><title></span> element, as below:<br /><span style="font-family: Courier New, Courier, monospace;"><br /><title><%: Page.Title %></title></span><br /><br />You cannot however handle the Meta tags in the same way. One solution to handle the Meta tags specified in the Content page is to use a custom Page class, which extends the <span style="font-family: Courier New, Courier, monospace;">System.Web.UI.Page </span>class, wherein add support to handling the <span style="font-family: Courier New, Courier, monospace;">Description </span>and <span style="font-family: Courier New, Courier, monospace;">Keywords </span>as input in the <span style="font-family: Courier New, Courier, monospace;">@Page</span> directive. This can be accomplished by adding appropriately overriding the <span style="font-family: Courier New, Courier, monospace;">OnLoadComplete</span> event of the Page class, wherein the needed Meta tags are constructed using the values specified in the <span style="font-family: Courier New, Courier, monospace;">@Page</span> directive and the same are added to the Page Header.<br /><br />Check out this <a href="http://www.codeproject.com/Articles/17368/Using-Meta-Tags-with-Master-Pages-in-ASP-NET" target="_blank">codepage link</a> for a sample solution.<br /></div>
</div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-15052065676421227442016-07-09T15:03:00.000+05:302016-07-09T15:03:41.545+05:30SSRS - Custom Period Filters<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Problem:</b><br />
<br />
Just wondering if the reports published on SQL Server Reporting Services can be customized to have a predefined period filters like Last Week, Last Month, Last Quarter, etc.<br />
<br />
<span style="font-size: x-small;"><i>By: Anonymous</i></span><br />
<br />
<b>Solution:</b><br />
<br />
You have few options to work around this, which are given below:<br />
<br />
<u>1. Dynamic Parameter</u><br />
<u><br /></u>
Basically, your underlying query or stored procedure needs the values for the From and To paramteres to apply in the where clause of the query. You can do this by first creating a mutli valued Period parameter, with values like, Last Week, Last Month, etc specified as available values. The From and To parameters can then be set up in such a way that it fetches the default value from a query, which takes the value from the Period parameter and then return the corresponding From and To values respectively. In these, the Period Parameter shall be positioned above the From and To parameters. The query can be as simple as<br />
<span style="font-size: x-small;"><br /></span>
<span style="font-size: x-small;">SELECT </span><br />
<span style="font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>CASE </span><br />
<span style="font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>WHEN @Period = 'LW' THEN DATEADD(D,((DATEPART(dw, GETDATE())-1)*-1)-7,GETDATE())</span><br />
<span style="font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>WHEN @PEriod = 'LM' THEN DATEADD(M,-1,DATEADD(D,(DAY(GETDATE())-1)*-1, GETDATE()))</span><br />
<span style="font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>END AS FROM_DATE</span><br />
<br />
for the default values of the From parameter. You may extend this idea and use it different ways to make a parameter dynamically derive a value based on a previous parameter. Note that the order of the parameter is important as the parameters are constructed sequentially and there is nothing like an onChange event that you can think of.<br />
<br />
<u>2. Let the SQL Query / Procedure do the work</u><br />
<br />
The second alternative is to put in a logic similar to the above within the Report Query or Stored Procedure, so that the user just selects the period filter and the SQL Server interprets it appropriately and returns the appropriate results. The only difference with this option is that the From and To Filters need not be designed in the report and the user won't see it on screen.<br />
<br />
<u>3. Wrap the report within an Application</u><br />
<br />
Just in case, you are rendering the reports within an Application, like a ASP.NET application or a Windows Forms Application, then you can have the complete control on the Filters in the presentation layer of your application. For instance in this case, you accept a Period Filter from the user in your front end application and then transform it to an appropriate From and To dates to the ReportViewer component and get the report rendered accordingly.<br />
<br />
<br />
<br />
<br />
<br /></div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-33564295108424108022016-07-03T15:14:00.000+05:302016-07-03T15:16:28.226+05:30Issues in Signing a .NET Assembly using .pfx file<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
<b>Problem:</b></div>
<div style="text-align: justify;">
<i><br /></i></div>
<div style="text-align: justify;">
<i>I have procured a code signing certificate with a view to ensure that one of application that we intend to distribute to external users is signed so that the same can be trusted by the end users. I imported the certificate into the certificate store and used it successfully to sign the Click Once Manifest using the Signing tab in the Projec Properties dialog in Visual Studio 2013. But I could not have the assembly signed. I exported the certificate from the store as a .pfx file and tried using it for signing the assembly, but am getting issues like "Private Key not Found", while the Private key is very much present in the .pfx file.</i></div>
<br />
<i><span style="font-size: x-small;">By: Rajkumar David</span></i><br />
<br />
<b>Solution:</b><br />
<br />
<div style="text-align: justify;">
Visual Studio 2013 has known issues in handling PKCS# 12 certificate files as it cannot handle files with multilpe certificates in the CA certificate chain. Visual studio may not still consider such certificates for signing the assembly because of the KeySpec Parameter, which is usually set as AT_KEYEXCHANGE(1), whereas Visual Studio expects this to be AT_SIGNATURE(2). It is possible that while requesting the certificate, the KeySpec is set as 1 and as such the certificate is generated with the value as 1. You may verify CSR that you have submitted to the CA to check this.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
OK, now what do you with that certificate? You have option to import such certificates with KeySpec set as AT_SIGNATUR. The Windows Servers from 2003 onwards have a commandline certificate import utility - certutil.exe. This command allows you to import the certificate with the right KeySpec parameter. Use the following command to do this:</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<span style="font-family: "courier new" , "courier" , monospace;">certutil -importPFX -user <pfxfilename> AT_SIGNATURE</span></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
After importing the certificate using the above command into the certificate store and then export it back as .pfx file from the store for assembly signing within Visual Studio. This should resolve the given problem.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
More on the CertUtil command can be found <a href="https://blogs.technet.microsoft.com/pki/2007/07/29/marking-private-keys-as-non-exportable-with-certutil-importpfx/" target="_blank">here</a>.</div>
<br /></div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-12339443056964086672015-11-29T12:24:00.000+05:302015-11-29T12:26:30.046+05:30How to Create '|' (Pipe) Delimited Files in Excel<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
<b>
Problem:</b></div>
<br />
<i>Microsoft Excel is a very useful tool for data analysis. It supports import of data from various sources and formats into it for analysis. But, though it supports export of data in various common formats, it does not natively support export of data in a delimited text format with the delimiter other than Comma and Tab characters. This post explains how to get the excel data exported into a "|" (pipe) delimited text file.</i><br />
<br />
<div style="text-align: left;">
<b>
Solution:</b></div>
<br />
Excel does not directly support export or saving the data delimited with a pipe or such other characters. It supports comma delimited files (.csv) or tab delimited files though. The csv file generator however uses the List Separator as set in the windows Regional Settings as the delimiter. With this you can change this value in the regional settings and the csv file option will now produce a delimited file with the delimiter of your choice as set in the regional settings. For those not familiar with the regional settings, here is how to get this accomplished:<br />
<br />
If you are using Windows 8 or 8.1, you will find the Regional Settings option under the "Clock, Language and Region" category.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-6SUs2_PPER8/VlqfUS3pFUI/AAAAAAAAJeE/yN1bHeXclAk/s1600/CP.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="1" height="140" src="http://3.bp.blogspot.com/-6SUs2_PPER8/VlqfUS3pFUI/AAAAAAAAJeE/yN1bHeXclAk/s320/CP.PNG" width="320" /></a></div>
<br />
<br />
Click on the Additional Settings button in the Formats tab of the Regional Settings dialogue box. In the Numbers tab of the resulting dialogue box, you will find the field List Separator (Highlighted in the image. By default, it displays ","(comma). Now set it to a character that you need the files to be delimited with. For instance, if you want export a pipe delimited text file from excel, enter the charcter "|" in this field and apply the change.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-4D3cETYcjNQ/VlqfsR8Cw5I/AAAAAAAAJeU/oQqwAqPF4DA/s1600/Formats.PNG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="1" height="320" src="http://4.bp.blogspot.com/-4D3cETYcjNQ/VlqfsR8Cw5I/AAAAAAAAJeU/oQqwAqPF4DA/s320/Formats.PNG" width="307" /></a><a href="http://3.bp.blogspot.com/-Nk0XFCMaRIU/VlqfrZCAhPI/AAAAAAAAJeM/1bcBjWaER_s/s1600/LS.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="1" height="320" src="http://3.bp.blogspot.com/-Nk0XFCMaRIU/VlqfrZCAhPI/AAAAAAAAJeM/1bcBjWaER_s/s320/LS.PNG" width="275" /></a></div>
<br />
<br />
You are done. Close and re-open Excel with the data that you want to export. Now use the Save As option to save the sheet as a csv file (.csv). This will now produce a text file delimited with the pipe character. Unless you regularly use pipe as the delimiter, you may want to set it back to comma, so that it does not impact any other operations that dependent on the List Separator field.<br />
<br />
<br />
<br /></div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-41664166524249897932015-09-20T19:54:00.000+05:302015-09-20T19:54:07.746+05:30Powershell Script for Cleaning up Old Files<div dir="ltr" style="text-align: left;" trbidi="on">
<h3 style="text-align: left;">
Poblem:</h3>
I am working on a project that creates 100s of files every hour which has led to creation of over few thousand files in a week. Due to the very high number of files, Explorer takes so long to list the files in the folder. As this could fill up the storage pretty fast, I need to delete files older than 7 days. Please suggest me how best to accomplish this, preferably using PowerShell and leveraging the Scheduled Tasks.<br />
<br />
<i>By: Anonymous</i><br />
<br />
<h3 style="text-align: left;">
Solution:</h3>
<br />
Powershell is the way to go for these kind of tasks. For deleting old files, the following script will do the job:<br />
<br /><blockquote class="tr_bq">
Get-ChildItem –Path <Base Folder> –Recurse | Where-Object CreationTime –lt (Get-Date).AddDays(-7) | Remove-Item</blockquote>
<br />Replace the <Base Folder> with the actual base folder that need to be looked up for this task. Simiarly, you may observe the from the above script, this will delete the files based on the time of creation of the file. If you want to use the last modified time, replace the CreationTime with LastWriteTime<br /><br />The above script can be executed from the PowerShell prompt or can be scheduled to run automatically using the Windows Task Scheduler. There are couple of things that you should take care of while scheduling:<div>
<br /></div>
<div>
<ul style="text-align: left;">
<li>By default, the deletion will fail as the execution policy may not permit the deletion. To override this set the parameter ExecutionPolicy to bypass</li>
<li>You may want to add the parameters - noninteractive. to enable to run automatically without needing user action. </li>
<li>Do not place the script itself in the program field, Instead save the script as a .ps1 file and pass the script file with fully qualified path as a parameter in the parameter field.</li>
</ul>
</div>
<div>
<br /></div>
<div>
Typically, the following should be added to the parameter field:</div>
<div>
<br /></div>
<blockquote class="tr_bq">
-noninteractive –nologo -ExecutionPolicy Bypass -command "& 'c:\datafiles\cleanup.ps1'"</blockquote>
<div>
<br /></div>
<div>
<div>
Needless to mention that the progrm / script field shall contain the PowerShell executable with its fully qualified path, which will be like this:</div>
</div>
<div>
<br /></div>
<blockquote class="tr_bq">
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe</blockquote>
<div>
You may also want to have a look at the <a href="https://gallery.technet.microsoft.com/scriptcenter/Delete-files-older-than-x-13b29c09" target="_blank">clean up script </a>on the TechNet site, which has many more capabilities, like crating a log of files deleted and so on.</div>
</div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-66911903181947078842015-06-26T19:16:00.000+05:302015-06-26T19:16:44.816+05:30SSRS Report Builder 3.0 - How to avoid page breaks in Report Viewer<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Problem:</b><br />
<br />
The Report Viewer displays the tabular reports with pagination. This is inconvenient to users as they have to click on the page navigator to browse through the report. Is there a way to have the report viewer display all the rows in one view, so that users will find it convenient to browse through the report by just scrolloing up and down?<br />
<br />
<i><span style="font-size: x-small;">By: Muthu Saravanan</span></i><br />
<br />
<b>Solution:</b><br />
<br />
Use the Interactive Size property of the report to overcome this. This property will not however show up in the Report Properties dialog. This will be available on the Properties Pane, which shows up ususally on the right side of the screen. If it is not showing up, check the options under the View menu. To have all records in single view without pagination, set the Height under Interactive Size to 0 cm.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/--cNozPhh8lk/VY1XKnNqzoI/AAAAAAAAHl0/H-Vflpta3JI/s1600/Report%2BBuilder1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/--cNozPhh8lk/VY1XKnNqzoI/AAAAAAAAHl0/H-Vflpta3JI/s1600/Report%2BBuilder1.JPG" /></a></div>
<br />
<br />
This setting is effective for display in the report viewer only. Page breaks in print and other export formats will be based on the Page Size rather than the Interactive Size property.</div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-21386262833024476202015-03-06T23:01:00.000+05:302015-03-07T10:03:51.053+05:30Whitelisting email or domain in Gmail<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Question:</b><br />
<br />
How to whitelist or blacklist an email domain in gmail?<br />
<br />
<i><span style="font-size: x-small;">By: Radhakrishnan Ravi</span></i><br />
<br />
<br />
<b>Answer:</b><br />
<br />
Google has a might spam handler and does a very decent job. However, if you want to put a rule to either whitelist or blacklist, use the filter options provided under settings menu. It is simple and the following steps will take you through in implementing a filter of your choice.<br />
<br />
Choose the Settings menu from the Settings drop down menu on the top right beneath your profile picture.<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<br />
Select the Filter Tab, which will list the filters and will have a link at the bottom captioned ''Create a New Filter". As you may observe, you have an option to import filters as well using the "Import Filter" link.<br />
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-EpI23qsgltA/VPnjUjW3lUI/AAAAAAAACFM/CTNt-FB7c3Y/s1600/Gmail2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-EpI23qsgltA/VPnjUjW3lUI/AAAAAAAACFM/CTNt-FB7c3Y/s1600/Gmail2.JPG" height="90" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div>
<a href="http://2.bp.blogspot.com/-leH4nNqvzk8/VPnjUlbT0ZI/AAAAAAAACFI/EK06dqKHllA/s1600/Gmail3.JPG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://2.bp.blogspot.com/-leH4nNqvzk8/VPnjUlbT0ZI/AAAAAAAACFI/EK06dqKHllA/s1600/Gmail3.JPG" height="241" width="320" /></a><a href="http://2.bp.blogspot.com/-leH4nNqvzk8/VPnjUlbT0ZI/AAAAAAAACFI/EK06dqKHllA/s1600/Gmail3.JPG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><br /></a><br />
<div>
<br /></div>
<div>
Clicking the create filter will take you to the advanced search window as in the image on the right. Alternatively this search window can be accessed using the tiny drop down icon provided on the right side of the search box within gmail. Basically, you will have to decide on the search criteria to apply the filter for. i.e, if you want to whitelist the domain kannan-subbiah.com, enter the domain name in the From field of the search window. Upon entering a valid search criteria, you will find the link "Create a filter with this search" enabled.</div>
</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-YzCF1MUcDnw/VPnjVTVdbBI/AAAAAAAACFY/4hngwrFh9h0/s1600/Gmail4.JPG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-YzCF1MUcDnw/VPnjVTVdbBI/AAAAAAAACFY/4hngwrFh9h0/s1600/Gmail4.JPG" height="320" width="288" /></a></div>
<div>
<br />
Click on this and you will see a Filter Dialogue window as in the image on the left. The options provided are self explanatory and choose appropriate action you want to apply for the chosen search criteria. For instance, if you want to white list the entered domain, select the option "Never send it to Spam" and then click on the Create Filter button at the bottom. Similarly, if you want to permanently delete emails from a specific sender, you may choose the delete option here.<br />
<br />
The filters so added will appear in under the Filter tab of the settings screen. You will then have the option to remove or modify the filters as well.</div>
</div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-6807642206557026812014-11-09T11:54:00.001+05:302014-11-09T12:08:23.689+05:30Microsoft Expression Encoder<div dir="ltr" style="text-align: left;" trbidi="on">
This post is not in response to a specific problem or question, but could be a response to a potential question from some one.<br />
<br />
I was looking for a cost effective and easy to use tool for capturing screens and produce videos. There are many tools, in the freeware, shareware and commercial category for the purpose. But the one that I find interesting is the one from Microsoft, the Expression Encoder. While Microsoft has stopped supporting the commercial version of the product, the same is available as a free download. I am sure, many of you might know about this, but for those who are not, this post will give a glimpse, so that one can start using it and see its advantages.<br />
<br />
Expression Encoder Pro is a component of the Expression Studio, which is currently not sold as a product. In addition to Expression Encoder Pro, the studio also bundles with it Expression Web, Expression Blend and Expression Design. Expression Web is intended for creation of responsive websites leveraging CSS3 and HTML5. Expression Blend is intended to build interactive UI for windows store applications. Expression Design, combined with Expression Blend and Visual Studio helps building innovative, user-centric, fast and fluid applications. Check out more about the <a href="http://www.microsoft.com/expression/eng/" target="_blank">changes and availability of Expression products on the microsoft site</a>.<br />
<br />
Let us look at what Expression Encoder can offer us. Expression Encoder 4 Screen Capture is also installed along with the Expression Encoder 4. The Screen Capture component offers you to record videos using the camera attached to the device / PC, record audio using the microphone, and to record the selected area of the screen.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-B49bTMKoDOQ/VF8CpSaa5sI/AAAAAAAAB-s/zZInQpqbSNA/s1600/Encoder1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-B49bTMKoDOQ/VF8CpSaa5sI/AAAAAAAAB-s/zZInQpqbSNA/s1600/Encoder1.PNG" height="61" width="320" /></a></div>
<br />
<br />
On clicking the Record button, you will be prompted to select a rectangle area to capture and once done, you can continue with your actions on the screen as the recording continues.Once, done, you stop the recording and the output is produced as a .xesc file, which can be further edited using the Encoder.<br />
<br />
To get your captured video encoded into a video output, you will perform the following using the Expression Encoder<br />
<br />
<ul style="text-align: left;">
<li>Choose your project. </li>
<li>Import your source video. </li>
<li>Modify your video. </li>
<li>Set preview and encoding options. </li>
<li>Choose an output format. </li>
<li>Render your video.</li>
</ul>
<div>
Getting used to was not very difficult and the product comes with a useful help document. The tool allows you to overlay visual still and moving image file, edit the sub titles, captions and descriptions, add audio streams, apart from allowing you to insert and cut parts of the source video. </div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-hKf1OTY3VnM/VF8H0jRgaHI/AAAAAAAAB-8/E4LYtIamcfY/s1600/Encoder2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-hKf1OTY3VnM/VF8H0jRgaHI/AAAAAAAAB-8/E4LYtIamcfY/s1600/Encoder2.PNG" height="223" width="400" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Few of the limitations include, inabitlity to add more than one overlay, the supported output format limited to Windows Media Video (.wmv) and IIS smooth streaming. While the tool has much more capabilities, for the specific purpose of creating product demo or tutorial videos, this suits very well. As you know there are many tools out there to convert .wmv to other video formats, like .mp4.</div>
<div>
<br /></div>
<div>
Try it out and share your feedback here.</div>
</div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-29289289923466518832014-11-06T11:27:00.001+05:302014-11-06T13:54:38.626+05:30Windows Steps Recorder - For Problem Reporting<div dir="ltr" style="text-align: left;" trbidi="on">
Question:<br />
<br />
I work in QA department, where reporting issues and defects with all supporting details to well describe the problem is key. We usually use a screen capture tool to capture the images, but then to assemble them as a problem report, we need to depend upon MS Word or such other tool. I am writing to you to check if there is a better tool that helps to perform this task even better.<br />
<br />
By: Krishnan Sadasivam<br />
<br />
Response:<br />
<br />
If you are asking about a tool for screen capture, Snipping tool, which is part of Windows OS from version 7 onwards is a nice tool to capture parts of the screen. There is another tool which again is part of the Windows OS from version 7 upwards, which is called 'Steps Recorder'. This tool captures your actions and associated screen and produce a descriptive output, which will make it a lot easier for the problem reporter and the problem sover. Here is how it works in Windows 8 or 8.1:<br />
<br />
<br />
<ul style="text-align: left;">
<li>Press Windows Key+Q to bring up the search panel on the right.</li>
<li>Type steps and you will see the "Steps Recorder" tool show up in the search results</li>
<li>Click on it and it will launch the Steps Recorder Tool</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-mLov0ZpQKBc/VFsMduEJFqI/AAAAAAAAB-Q/8DRxxySYfVk/s1600/StepsRecorder.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-mLov0ZpQKBc/VFsMduEJFqI/AAAAAAAAB-Q/8DRxxySYfVk/s1600/StepsRecorder.PNG" height="64" width="320" /></a></div>
<div>
<br /></div>
<ul style="text-align: left;">
<li>Click on the Record button and then start reproducing the problem you want to report. </li>
<li>As the recording is in progress, you have the option of adding comments to certain specific area of screen by highlighting it.</li>
<li>Once done click on stop recording and your actions is compiled as multiple steps and optionally as a slide show.</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-XpipDB4eHAY/VFsMk7vEn-I/AAAAAAAAB-Y/kperpIL9T-U/s1600/StepsRecorder1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-XpipDB4eHAY/VFsMk7vEn-I/AAAAAAAAB-Y/kperpIL9T-U/s1600/StepsRecorder1.PNG" height="141" width="400" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<ul style="text-align: left;">
<li>You have option to save the steps as a compiled html and email it as well.</li>
</ul>
<br />
<br />
This free tool will certainly be handly for reporting computer software problems.</div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-80137093410752245362014-11-02T11:40:00.001+05:302014-11-02T12:03:03.713+05:30Excel Pivot & Shortcut Keys<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
<b><span style="font-size: large;">Question:</span></b></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
I understand Microsoft Excel is a good start for analytics on data. Please direct me as to how to create a basic Pivot Table. You may also share me any tutorial references to learn more on Pivot feature in Excel. Also share Short Cut keys in Excel</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<i><span style="font-size: x-small;">By: Vinay Kumar</span></i></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b><span style="font-size: large;">Response:</span></b></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Learning to create a Pivot is fairly easy but the tough part is to know how you want the data to be presented in the Pivot. For this you need to know a good understanding of the data on hand and what you want out of the data. For this question, I assume that you are already clear about your needs.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Here is how you can quickly get a Pivot of your Excel Data:</div>
<br />
<ul style="text-align: left;">
<li style="text-align: justify;">Select the data range that you want to apply Pivot on and then click on the Pivot button, which is in the Toll bar ribbon under the Insert Menu. You may also use the short cut key Alt + NV</li>
<li style="text-align: justify;">This will open up the Pivot dialog window where you will have option to adjust or change your your data range (as you may observe, you can also use an external data source by choosing the appropriate option) and other options.</li>
<li style="text-align: justify;">Clicking ok on this dialog window will open up the Pivot table in a new work sheet (default option) and will show the Pivot Table Fields task pane on the right side. You can drag and drop the fields into Filters, Columns, Rows and Values. </li>
<ul>
<li style="text-align: justify;"><b>FILTERS</b>: This area contains the fields that enable you to page through the data summaries shown in the pivot table by filtering out sets of data — they act as the filters. For example, if you designate the Year field from a data list as a report filter, you can display data summaries in the pivot table for individual years or for all years represented in the data list.</li>
<li style="text-align: justify;"><b>COLUMNS</b>: This area contains the fields that determine the arrangement of data shown in the columns of the pivot table.</li>
<li style="text-align: justify;"><b>ROWS</b>: This area contains the fields that determine the arrangement of data shown in the rows of the pivot table.</li>
<li style="text-align: justify;"><b>VALUES</b>: This area contains the fields that determine which data are presented in the cells of the pivot table — they are the values that are summarized in its last column (totaled by default).</li>
</ul>
<li style="text-align: justify;">Set these in the way you want and your Pivot table is ready.</li>
</ul>
<br />
<div style="text-align: justify;">
To know more about other complex and advanced features of the Pivot Table, <a href="http://www.dummies.com/how-to/computers-software/ms-office/Excel/Excel-2013/Pivot-Tables.html" target="_blank">check here</a>.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Here is a nice <a href="https://filtered.com/home/pages/excel-shortcuts-cheat-sheet" target="_blank">Cheat Sheet</a> containing all the Short Cut keys for Excel. If you are a key board expert, then you will want to <a href="http://www.veodin.com/keyrocket/excel-2013-shortcuts/" target="_blank">check out this</a> as well.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
</div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-62644825461158135042014-08-29T11:38:00.000+05:302014-08-29T11:38:18.334+05:30Windows 8.1 - Switching to Local Account<div dir="ltr" style="text-align: left;" trbidi="on">
<b><span style="font-size: large;">Problem:</span></b><br />
<br />
Microsoft Windows 8.1 update by default prompts to use a Microsoft live account and without noticing, I just went ahead and got signed in using my Microsoft Account. Now how do I switch to a local account?<br />
<br />
<b><span style="font-size: large;">Solution:</span></b><br />
<br />
Yes, Windows 8.1 by default takes the users to sign in using Microsoft live account. However, if you carefull observe, you have the option to use a local account, but Microsoft ensured that you will miss that. Windows however allows users to switch between live account and local accounts. To switch to a local account, follow these steps:<br />
<br />
<br />
<ul style="text-align: left;">
<li>Goto Your Account Settings screen. You can do this by typing "Your Account" on the Windows Search screen (Windows Key + Q) . </li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-5T89PvHHvq8/VAAYT3__DfI/AAAAAAAABq8/eMWnfxNZLik/s1600/Your%2BAccount.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-5T89PvHHvq8/VAAYT3__DfI/AAAAAAAABq8/eMWnfxNZLik/s1600/Your%2BAccount.PNG" height="239" width="320" /></a></div>
<div>
<br /></div>
<ul style="text-align: left;">
<li>You will see a link "Disconnect" under your user account. You should click on Disconnect, which will take you through setting up your local account.</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-cJOiUuTRBaw/VAAYnCfEaaI/AAAAAAAABrE/SJvVQdYRGNU/s1600/Disconnect.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-cJOiUuTRBaw/VAAYnCfEaaI/AAAAAAAABrE/SJvVQdYRGNU/s1600/Disconnect.PNG" height="114" width="320" /></a></div>
<div>
<br /></div>
<ul style="text-align: left;">
<li>As a next step, Windows will have to authenticate you once again and will prompt for your current password.</li>
<li>The next step will prompt you for inputs to have your local account created. </li>
<li>You will then be prompted for a confirmation and you click on the Singout and Finish button.</li>
</ul>
<br />
<br />
You may want to note that by switching to your local account, you will lose the synchronization with your sky drive.<br />
<br />
<br /></div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-4185366213836994572014-08-24T12:09:00.000+05:302014-08-24T12:09:57.412+05:30Error connecting to SMTP Server<div dir="ltr" style="text-align: left;" trbidi="on">
<b><span style="font-size: large;">Problem:</span></b><br />
<br />
All of you would have faced issues when connecting to a remote server on ceertain ports. The issue will be strange to trouble shoot as the same connection works from a different network or on the server and so on. I came across such a situation when building and testing a mailing component and I experienced that the .NET SmtpClient component was encountering exception. It took considerable time for me to trouble shoot and get it resolved.<br />
<br />
<b><span style="font-size: large;">Solution:</span></b><br />
<br />
My first take was to try whether the credentials that I have used is just fine, by creating an email account in outlook and that worked fine. I just wanted to isolate various probable areas of concern. As such I then tried using an online SMTP server test service, which was showing an error that the client must first check for incoming mails. Telnet to the mailserver on port 25 also gave an error. I then examined our mail server, whether it has any such restrictions, but I could not find any specific restriction that could cause this issue.<br />
<br />
My next step was to examine the details of the exception for any possible clues. The inner exception nested couple of levels deep revealed the error as "An attempt was made to access a socket in a way forbidden by its access permissions"<br />
<br />I then tried looking for solutions online there were many posts and one solution was about to try the following and one of that could solve this issue:<br /><ul style="text-align: left;">
<li>Restart the windows firewall service</li>
<li>Reboot the problematic machine</li>
<li>Restart the “TCP/IP stack”. Run CMD as administrator, type “netsh int ip reset resetlog.txt” to reset TCP/IP.</li>
<li>Try to temporarily disable antivirus.</li>
</ul>
After a bit of analysis, I could find that in my case it was the McAfee Endpoint Protection. I could find that the rule "Prevent mass mailing worms from sending mail" was set to block connections on port 25 with certain exceptions. I added the VWDExpress.exe to the exception list and then it started working fine.</div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-75155158179310896022014-08-02T17:55:00.001+05:302014-08-02T17:55:55.236+05:30Losing Wi-Fi connection after sleep<div dir="ltr" style="text-align: left;" trbidi="on">
<b><span style="font-size: large;">Problem</span></b>:<br />
<br />
I use a HP Probook Laptop at home running Windows 8.1 pro. I usually close the laptop whenever I take a short break so that I can resume my work where I left after the break. But, I find that upon opening the Laptop, the wifi does not connect and that too randomly. That means, it works fine on certain occasions and it doesn't on certain occasions. Some times, a restart helps connecting but not always. What could be the problem and how to get this resolved.<br />
<br />
<i><span style="font-size: x-small;">By: Lalith Venkateswaran</span></i><br />
<br />
<b><span style="font-size: large;">Solution</span></b>:<br />
<br />
This could be due to a combination of multiple issues relating to the configurations in your laptop and as well as on your router.<br />
<br />
Upon closing the lid, the laptop goes to sleep mode and powers down the built in wifi device. Which might cause orphaned IPs at your router end and as you reconnect again and again, you might exhaust the DHCP range that your router is configured with. Check if this issue happens when you are on battery. If yes, then you may configure your power options so that your device does not get powered down, every time you close your laptop. You find this setting in the Power management tab of the wifi-adapter configuration. You may also review the advanced power settings for the wifi adaptor under the power options.<br />
<br />
When your wifi connection fails upon wake up, you may check if you are able to connect to a different wifi network. If you don't have a different wifi network, you simply use the hotspot feature on your smartphone and try if your laptop can connect to it. If yes, then it is not just the wifi device on your laptop, it could be due to issues with your wifi router as well. Some routers may have issues in accepting connections from the same devices with the same mac id, as the previous connection might still be there. Try the following steps, which might solve your problem:<br />
<br />
<br />
<ul style="text-align: left;">
<li>Try setting a shorter DHCP lease time, so that the orphaned connections get released sooner, so that your router has no problem in accepting a fresh connection.</li>
<li>Use the DHCP reservation, so that every time the laptop tries to establish a connection, the router assigns the same IP and thus no need for lease expiry / renewal.</li>
</ul>
<br />
<br />
Post a comment if this does not solve your problem.</div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-77775534441516386342014-06-29T13:41:00.002+05:302014-06-29T13:41:25.050+05:30Administration of Vodafone HG556 Router<div dir="ltr" style="text-align: left;" trbidi="on">
<b><span style="font-size: large;">Question:</span></b><br />
<br />
I have a Vodafone HG556a router, which I was using while I was in Ireland with Vodafone network. This router has a USB port and as well as an ADSL port. So I thought that this router can be used back in India with BSNL or such other ADSL Networks in India. When I login to the router with the given default password, I could only see the basic settings and I could not see menu / options to setup the mac filtering and other advanced security settings. I searched google and figured out that there will be a different credential to get into the advanced settings. I tried with the default admin credientials but it does not work. Any help that you can offer here will be of great use for me.<br />
<br />
By: Sreekumar Rajan<br />
<br />
<br />
<b><span style="font-size: large;">Answer:</span></b><br />
<br />
Luckily, I too have a similar router and so I am sure I can help you here. Basically, these routers are locked with the network service providers and hence for any advanced setup, you may have to reach out to their customer service, who will be able to reconfigure your router remotely. Don't worry, there is a way to get the admin credentials and you do not have to reach out to the customer service team of Vodafone (overseas).<br />
<br />
<br />
<a href="http://4.bp.blogspot.com/-Efnmfrkf5HY/U6_FlGJzdQI/AAAAAAAAA3A/Sdol8dJuaQw/s1600/Capture.PNG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://4.bp.blogspot.com/-Efnmfrkf5HY/U6_FlGJzdQI/AAAAAAAAA3A/Sdol8dJuaQw/s1600/Capture.PNG" height="157" width="200" /></a>I assume that you have your basic user credentials. If not, you may perform a hard reset of the router and then look for the credentials <br />
on the back of the router. Usually, the default basic credentials are mentioned in the router itself, if not you may consult the user guide if any that came with the router. The defualt user name is 'vodafone' and the default password is also the same - 'vodafone'. Refer the image, which is that of my Vodafone router and you can see the defaults printed there in.<br />
<br />
<br />
You connect your router to your laptop or desktop using ethernet cable and login into the web administration of the router using the default IP of 192.168.0.1. Alternatively, you may connect through wifi as well, using the default SSID and the WPA as printed at the back of the router. Type the URL <a href="http://192.168.0.1/en_US/backupsettings.conf">http://192.168.0.1/en_US/backupsettings.conf</a> on the browser after logging in with the basic credentials.<br />
<br />
<br />
<a href="http://4.bp.blogspot.com/-6OoEAqfLfMw/U6_Hmz3Sy1I/AAAAAAAAA3M/Tc44Fw17iAo/s1600/Capture2.PNG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://4.bp.blogspot.com/-6OoEAqfLfMw/U6_Hmz3Sy1I/AAAAAAAAA3M/Tc44Fw17iAo/s1600/Capture2.PNG" height="147" width="320" /></a><br />
This will prompt you to download the settings file and depending on your browser settings, allow the download into a desired location. This settings file is basically in xml format and so, you may open this using notepad or wordpad. Search for the word 'syspassword' and you will see the admin password as in this image. You may observe that the value for the key sysPassword in this case is "VF-456gIr". This is the password for the user 'admin'. Log out of the basic user login and then login again using the admin credentials as retrieved above and you are now on course to perform advanced setup tasks on your router.<br />
<br />
It may be possible that the firmware version of your router may be different and in that case, there is a possibility that this technique might not work for you. If so, share with me more details about your router and I can see if some help is available elsewhere.</div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-90017034522226133492014-05-03T09:40:00.006+05:302014-05-03T10:00:15.071+05:30Glitch in Power Switch on the Desktop<div dir="ltr" style="text-align: left;" trbidi="on">
<b><span style="font-size: large;">Question</span></b>:<br />
<br />
The power switch on my desktop has developed some glitches. On a quick examination, I found that the switch mounted on a small board fixed on to the cabinet and this cabinet is an unbranded one bought in the grey market. I have doubts if the switch can be replaced or if the small board housing the switch will be available at all in the market. Is there a work around for this?<br />
<br />
<i><span style="font-size: x-small;">By: Anonymous</span></i><br />
<br />
<b><span style="font-size: large;">Answer</span></b>:<br />
<br />
There is no straight answer for your question, as the switch, the board housing the switch will greatly vary from the cabinet to cabinet. For example, some cabinets are designed to have the LED cluster integrated in the same board and the physical dimension of such boards vary depending on the position and layout of the cluster. The switch can certainly be replaced, but needs a physical examination. As such, you may get hold of a next door PC repair shop, who does chip level servicing and get this serviced.<br />
<br />
Just in case if your PC is 4 or 5 years older, and depending on your usage, you may consider upgrading your PC and in the process, change the cabinet as well. If you think, you are fine with your PC and it has much life left over to serve you, you may try the following:<br />
<br />
Open your cabinet and locate the front panel connectors and figure out the pins that are connected to your reset switch. Now, pull out your reset switch connector and plug onto the pins marked for power switch. You may also plug the power switch connector onto the reset pins. You may need to consult your mother board manual to do this right or else, things may go wrong and you may even you may brick the mother board or the processor. With this, you may use the reset switch to power on your system and your power switch will act as reset, if to the extent it works. With modern PC mother board designs, and the operating systems, the power off is in fact soft and thus you don't need the switch for powering off. This won't work if your PC is very old and the power switch is mechanical.</div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-25682002969278484502014-04-26T12:01:00.000+05:302014-04-26T12:01:52.880+05:30Start PXE Over IPv4<div dir="ltr" style="text-align: left;" trbidi="on">
<b><span style="font-size: large;">Question:</span></b><br />
<br />
My six months old HP Laptop which was working fine all along, once did not boot and I could see the text "Start PXE over IPv4" in the black MS DOS like screen and was unresponsive to keyboard and mouse. I waited for some time and then used the power button to hard shut down and then powered it again. This time it booted normally without any issues. Though the problem did occur thereafter, I am curious to know what PXE is all about. Can you explain what it is and the reason for it showing up?<br />
<br />
<i>By: Anonymous</i><br />
<br />
<b><span style="font-size: large;">Answer:</span></b><br />
<br />
PXE is the short form for Preboot Execution Environment.It allows PCs or laptops to boot over a network as against booting from the local hard disk. Those who have worked with Novell Netware should be familiar with this network booting, where the Network Interface Cards carry a small add on chip containing the Network Boot Program, which will perform the boot over the network.<br />
<br />To address the large deployment challenges, Microsoft began developing the technology that would allow for network-based installation and PXE was the solution for this. To PXE boot a PC, the BIOS should be setup to boot from network. When set so, the BIOS will first get an IP address for the PC from the PXE Server and thereafter to get the boot image using TFTP on to the RAM and then boot out of that image.<br /><br />Now in your case, as you have described the issue, it just happened, without you changing any BIOS setting. Normally the BIOS have multiple boot options configured with an order of priority. Your BIOS probably had the Network boot as one of the boot options and on that occasion, for some reason, your hard drive would have been unresponsive for a moment at the time of boot, as the next choice, the BIOS would have attempted to boot from network using PXE. As it might not find a PXE server over the IPv4 network it stayed there. <div>
<br /></div>
<div>
You can check the BIOS by pressing F2 when your laptop boots and check if the network boot is configured as an option. You may disable this option, if you are not using the Network booting in your environment. On a different note, you may want to check why your local hard disk was not responsive for the boot on that occasion. That could be an odd occurrence and the disk may be just fine too.</div>
<div>
<br /></div>
<div>
To know more about PXE booting, check the following resources:</div>
<ul style="text-align: left;">
<li><a href="http://technet.microsoft.com/en-us/magazine/2008.07.desktopfiles.aspx" target="_blank">Network-Booting Windows</a></li>
<li><a href="http://www.ccboot.com/pxe-boot-windows.htm" target="_blank">PXE Boot Windows XP, Windows 7 and Vista with CCBoot</a></li>
</ul>
</div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-40724967817187052362014-03-16T22:59:00.000+05:302014-03-16T22:59:36.357+05:30Code Quality - Refactoring<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Question:</b><br /><br />My project team has been asked to improve code quality by performing refactoring. I know that code refactoring is all about reviewing the code and ensuring that it follows the best coding practices. I however seek your guidance as to what are the aspects one should look into while performing code refactoring and also point me to some references, where I can learn more about the same.<br /><br /><i><span style="font-size: x-small;">By: Rajesh Dhawan</span></i><br /><br /><br /><b>Answer:</b><br /><br />Your question has the answer to some extent. Martin Fowler and Kent Beck originally defined refactoring as "a change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior… It is a disciplined way to clean up code that minimizes the chances of introducing bugs". Refactoring can be as minor as an inline change or it could be a massive code rewrite. Though large scale code refactoring can be an architectural redesign, as long as it does not change the business logic and when it is done in steps, it can be called as refactoring as well.<br /><br /><br />This is mostly done to improve the non-functional attributes of the program thus leading to improved code readability and maintainability. The design priorities or constraints for the enterprise applications are usually defined by the Enterprise Architecture teams, considering the vision, mission and goals of the enterprise and in turn the IT organization. Having said that while refactoring is all about making code changes to make it conform to the non functional attributes like maintainability, scalability, performance, etc, the specific design best practice or design pattern to consider would differ case to case.<br /><br /><br />Ideally, refactoring is done in iterations and technically there is no end to refactoring. However, one can say that refactoring ends when the code becomes 'simple', in which case, the definition of simple is subjective. As a programmer, you should be able to smell your code to figure out whether it needs refactoring. Here are some situations when your code smells, inviting you to refactor:<br /><br /><ul style="text-align: left;">
<li><b>Duplicated Code</b> - extract out the common bits into theirown method (extract method) if code is in same class if two classes duplicate code, consider extract class to create a new class to hold the shared functionality.</li>
<li><b>Long Methods</b> - extract method!</li>
<li><b>Large Class</b> - Class trying to do too much often shows up as too many instance variables.</li>
<li><b>Long Parameter List</b> - replace parameter with method (receiver explicitly asks sender for data via sender getter method) Example: day month, year, hour minute second ==> date</li>
<li><b>Divergent Change</b> - If you have a fixed class that does distinctly different things consider separating out the varying code into varying classes (extract class) that either subclassor are contained by the non-varying class.</li>
<li><b>Shotgun Surgery</b> - The smell: a change in one class repeatedly requires little changes in a bunch of other classes. try to move method and move field to get all the bits into one class since they areobviously highly dependent.</li>
<li><b>Feature Envy</b> - Method in one class uses lots of pieces from another class. move method to move it to the other class.</li>
<li><b>Data Clumps</b> - Data that's always hanging with each other (e.g. name street zip). Extract out a class (extract class) for the data. Will help trim argument lists too since name street zip now passed as one address object.</li>
<li><b>Switch (case) statements</b> - Use inheritance and polymorphism instead (exampleof this was in Fowler Chapter 1; this is one of the more difficult refactorings)</li>
<li><b>Lazy Class</b> - Class doesn't seem to be doing anything. Get rid of it!</li>
<li><b>Speculative generality</b> - Class designed to do something in the future but never ends up doing it. Thinking too far ahead or you though you needed this generality but you didn't. like above, collapse hierarchyor inline class</li>
<li><b>Message chains</b> - Say you want to send a message toobject D in class A but you have to go through B to get C and C to get D. use hide delagate to hide C and D in B, and add a method to B that does what A wanted to do with D.</li>
<li><b>Inappropriate Intimacy</b> - Directly getting in and munging with the internals of another class. To fix this, move methods, inline methods, to consolidate the intimate bits.</li>
<li><b>Incomplete Library Class</b> - If method missing from library, and we can't change the library, so either: o make this method in yourobject (introduce foreign method) If there is a lot of stuff you want to change: o make yourown extension/subclass (introduce local extension)</li>
<li><b>Data Class</b> - We have already talked about this extensively: in data-centric design, there are some data classes which are pretty much structs: no interesting methods. first don't letother directly get and set fields (make them private) and don't have setter for things outsiders shouldn't change look who uses the data and how they use it and move someof that code to the data class via a combinationofextract method and move method (see the Fowler chapter 1 example for several examplesof this)</li>
<li><b>Comments</b> - Comments in the middleof methods are deodorant. You should really refactor so each comment block is its own method. Do extract method.</li>
</ul>
<br />Check out the following to know more on the subject:<br /><br /><ul style="text-align: left;">
<li><a href="http://refcardz.dzone.com/refcardz/refactoring-patterns#refcard-download-social-buttons-display">The Essential Refactoring Patterns Cheat Sheet</a> - Requires free registration.</li>
<li><a href="http://lostechies.com/gabrielschenker/2009/02/27/refactoring-legacy-code/">Refactoring legacy code</a></li>
<li><a href="http://www.amazon.com/gp/product/0201485672/sr=8-1/qid=1140945278/ref=pd_bbs_1/002-8488683-3737622?_encoding=UTF8">Refactoring: Improving the Design of Existing Code</a> - Book by Martin Fowler</li>
<li><a href="http://study.5ecloud.net/CourseData/113012/1548/TeachDataDown/_2Refactoring%20to%20Patterns.pdf">Refactoring To Patterns</a> - eBook</li>
<li><a href="http://lostechies.com/wp-content/uploads/2011/03/31DaysRefactoring.pdf">31 Days of Refactoring</a> - Useful refactoring techniques you have to know </li>
</ul>
</div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-68881376367749673182014-02-28T10:02:00.000+05:302014-03-02T10:04:48.575+05:30TIFF image support in HTML5<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Question:</b><br />
<br />
I am working on a requirement to display multi-page tiff image in a web application. We have been exploring the new canvas feature of html5 but find that handling multiple pages in the tiff image using canvas a bit of challenge. Please share some ideas in resolving this which would be a great help. You may direct me to javascript or such other resources that might help addressing this. Thanks in advance.<br />
<br />
<i><span style="font-size: x-small;">By: Nilima Jain</span></i><br />
<br />
<b>Answer: </b><br />
<br />
Though most browsers support the canvas feature of HTML5, the tiff format is not supported by all browsers, though IE supports it. So, first ensure you have an agreement on the supported browsers for which you are building this feature, or else you would need a plugin / control for handling tiff images. If you are taking the plugin or activex or applet route, then you have the liberty to make use of some of the client libraries and expose methods to interact with javascript calls from the browser and you are done.<br />
<br />
Just in case you are fine with the browser support and are looking for using canvas for handling tiff, then try exploring the<a href="https://github.com/seikichi/tiff.js" target="_blank"> tiff.js</a> library. Google also has a code library called<a href="https://code.google.com/p/tiffus/" target="_blank"> tiffus</a>. But I have not personally explored these libaries and you may spend some time trying out these whether these are of any help.<br />
<br />
The other approach could be to try out the following approach:<br />
<br />
Have a server side component with service APIs to be able to split the pages in the tiff image into multiple jpg images of the same resolution. This service API when queried without any specific page number would load the tiff image and have the pages parsed as individual images and would return the binary of the first page as jpg format. Similarly, the API, when queried with a specific page, it would ensure returning the specific page. The challenge with this approach would be that there would be more hits between the client and server. This can however be optimized by handling this process in-memory and thus minimizing the disk i/o on the server. This approach is likely to work with all browsers and the canvas feature can be leveraged as well.<br />
<br />
However, if you have a specific browser to work with, for instance Internet Explorer, the best and easy approach would be to build an ActiveX control and wrapping the tiff image handling within it. In this case, the native windows imaging components might just suffice and no need for a third party library to handle the multi-page tiff image. This ActiveX component should expose necessary APIs, which can be invoked by javascript in response to various events at the client side.<br />
<br />
There are quite a few third party commercial libraries to meet this need too.</div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0tag:blogger.com,1999:blog-1338736931565636998.post-86832090727307882152014-01-26T10:52:00.000+05:302014-01-30T19:51:31.294+05:30Continuous Integration in Agile Software Development<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Question:</b><br />
<br />
I am a fresher and have recently joined an IT firm as a .NET developer. After 15 days of orientation and training I am not part of a project team. I have been hearing a lot about Continuous Integration. Can you help me understand what it is and how does it help the project execution?<br />
<br />
<i><span style="font-size: x-small;">By: Rajesh Narayanan</span></i><br />
<br />
<b>Answer:</b><br />
<br />
One of the important reason behind the software project failure was that the defects or issues discovered in the later phases proving to be too expensive to address and thus adding to the time and cost of the project. The industry has come up with different methodologies to address such issues and thus Agile Methodology has gained much adoption and recognition. As you may be aware, one of the key principles of Agile is to put in processes and techniques, so that the defects or issues are detected early on and thus giving opportunity to address sooner. Practices like SCRUM, Pair Programming, Test Driven Development are all expected to address this issue of catching the defects early on. On the same lines Continuous Integration and Deployment also contributes towards offering an opportunity to discover issues early on by offering the customer a working software product every now and then.<br />
<br />
Traditionally, developers work on building components or modules independently and there will be a phase which will be fairly closer to UAT for integrating these modules together. No wonder, the development teams will discover many inconsistencies leading to the modules not working in tandem as intended. This calls for rework on one or more of the already built modules.<br />
<br />
Continuous Integration addresses this problem by ensuring that every time the developer checks-in the code changes, the code modules are integrated with other related modules and deployed as well. This activity is best achieved by automating the build and deployment process. That means, the developer as he checks in code changes, will see the build and deployment errors and or warnings, which are expected to be resolved then and there, so that every code change that is checkedin does not break the working product. Thus the end customer will be able to see a working product always and able to validate the change as it is implemented.<br />
<br />
The following are some of the key practices that makes the Continuous Integration workable and useful as well:<br />
<br />
<br />
<ul style="text-align: left;">
<li><b>Maintain a Single Code Repository</b> - Continuous Integration won't work if developers maintain isolated code repositories for different component or modules. There are plenty of open source and commercial source code control tools that offers robust conflict resolution techniques and facilitates usage of single code repository.</li>
<li><b>Build Automation</b> - The Continuous build and deployment activity is best accomplished by automating the same. Most of the programming languages support this requirement and tools like CruiseControl are also very useful to accomplish this.</li>
<li><b>Test Automation</b> - The automation process shall also execute the basic tests by itself. this where Test Drivent Development is in use. The developers, as they write code are also expected to create test scripts, so that these will also be executed during the automated build process.</li>
<li><b>Frequent Code Commits</b> - The developers should commit the code more frequently and at the least every day. They should commit the code after every logical completion of a code change, so that the build does not break. This where, the Agile principles revolves around braking the coding tasks into smaller units, so that such tasks typically take 8 or 16 hours to complete.</li>
<li><b>Automated Deployment</b> - Coupled with build automation, the code should also be deployed on to the test environment, so those involved in testing see the latest changes as soon as they are committed into the repository.</li>
</ul>
<br />
<br />
Hope the above explains the purpose and the principles of Continuous Integration. You can look up <a href="http://martinfowler.com/articles/continuousIntegration.html" target="_blank">Martin Fowler's article</a> on the subject to know more.</div>
Kannan Subbiahhttp://www.blogger.com/profile/02737187722305953525noreply@blogger.com0