Technodrone

there's some good in this world, Mr. Frodo... and it's worth fighting for.

  Home  |   Contact  |   Syndication    |   Login
  11 Posts | 2 Stories | 21 Comments | 0 Trackbacks

News

Twitter










Article Categories

Archives

Post Categories

Image Galleries

Code hacks

LinkedIn Profile

Recommended Products

Wednesday, January 28, 2009 #

I enjoyed this article this morning. I observe and play the chicken game constantly. I always called it the "Is it done yet game".  As the recession worsens we are afraid to say "that enhancement to the web site will say 2 weeks to code and a two weeks to test/fix".  Instead we are told do it all in 40 hours knowing there is no stinkin way that is gonna happen.  If you tell the project manager is going to take longer because of testing and integration you are told. "That is not part of the time estimate.'   If your team uses agile sometimes this game is played on a daily basis at the morning stand up meeting.  One of the most popular strategies is to say we are 95% done.  I will admit I have sometimes fibbed and said I was making progress when instead I was behind schedule.  It buys a little time but only works a time or two. In these cases everyone is playing chicken with everyone else just because the team is unwilling or afraid to be honest about time estimates. I think this kind of behavior worsens as we try to do more with less.  In the long run the project still takes as long as it takes. If people are truly striving to do a good job. The  developer may have originally estimated 40 hours the project manager said no do it in 12 hours. In the long run it still takes 40 hours or possibly more due to lack of communication. Why can't we just communicate more honestly . That is just not in vogue in today's climate of fear of retribution.  We just keep playing this time wasting non-productive game.  Here is a link to the article on Stickyminds.com.

Managing the Chicken Game

Disclaimer: References to the Chicken Game do not reflect upon current or past employers. It is just a half thought out editorial based on lack of sleep. No animals were harmed and I only consumed 2 carbon credits creating this post. I put my redbull can in the recycle bin by the way.

 


Friday, January 02, 2009 #

I came into the office on January 2, 2009 and found out one of my applications was not finding files that have names based on the day of year and month of year.  Here is the problem, my code was looking for a file called  'thepreciousfile200911.txt" instead of "thepreciousfile200901001.  This worked 12/28/2008 but when the day of year changed to a single digit on the new year I could no longer check for file existence because the string I was using for the file name was now wrong. When I retrieved the day of year from the current month I blanked out and did not think it would return as 1 and if it did that was the correct file name anyway. Well it was wrong.  Here is what I did to fix it and it was extremely easy.

 

In this example the 3 is the number of characters I want the resulting string to have and the '0' is the character you want to use for padding if the day of year does not equal 3 characters. 

string dayofyear = Convert.ToString(DateTime.Now.DayOfYear).PadLeft(3, 0);

Friday, December 19, 2008 #

The following code adds an attachment to an email if the attachment file exists. If the file does not exist the the email informs the recipient that the file was not found. The recipients are read in from a text file. This sample sets the priority of the email to high and sets the body of the email to html so you can do some formatting. You will need a "Using" statement for System.IO and System.Configuration since things like email server and path to the list of recipients are stored in a config file.  This particular example is from a console application. "EmailBody" is a string builder that as added to as various processes are checked. Note of caution: be the email can be sent from "valid" looking email address and be beware of getting your "Send" portion of the code in a loop.  I know how embarrasing that can be. Have fun, be careful.

        protected static void EmailNotification(string FileName)

         {

            //name of email server

            string emailserver = ConfigurationSettings.AppSettings["emailserver"];

            //path to file that will be added as an attachment if it exists.

        string gl_daily_transactions = ConfigurationSettings.AppSettings ["gl_daily_transactions"];

        var devemail = new System.Net.Mail.MailMessage();

        var mailClient = new System.Net.Mail.SmtpClient(emailserver);

        devemail.From = new System.Net.Mail.MailAddress("XYZInterfaceMonitor@notarealcompany.com");

        string subjectline;

        if (Success)

        {

            subjectline = "XYZ Interface process completed successfully. ";

        }

        else

        {

            subjectline = "XYZ Interface process did not complete successfully. ";

        }

     

            devemail.Subject = subjectline;

    

        devemail.Priority = System.Net.Mail.MailPriority.High;

        if (File.Exists(gl_daily_transactions))

        {

            System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(gl_daily_transactions);

            devemail.Attachments.Add(attachment);

        }

        else

        {

            //append to string builder object

            emailBody.Append("<hr />The GL Daily Transaction File was not found.");

        }

 

        devemail.IsBodyHtml = true;

        emailBody.Append("<hr/>End of Notification");

        devemail.Body = emailBody.ToString();

      //FileReader returns an array of recipients from a text file

        string[] recipients = FileReader.ReadFile(FileName);

 

        for (int index = 0; index < recipients.Length; index++)

        {

 

            if (recipients.Length > 0)

            {

                devemail.To.Add(recipients[index].Trim());

            }

        }

        mailClient.Send(devemail);

 

    }

 

       

 


Friday, December 12, 2008 #

I have been hacking at this for two days. I could use a little help here. I am rewriting a console application that uses a com object named transaut.tlb.  This object exposes cognos transformer functionality. I used tlbimp.exe and imported it.  When I make reference to this dll and use it in my code, the code compiles but I get the runtime error "CLSID{blah ,blah...} failed due to the following error: 80040154".  I tried making a reference to the orginal com object transaut.tlb I tried registering the imported dll but got the error  "cognostransformer.dll was loaded but the DLL Register Server entry point was not found. This object worked with .net version 1. Any help would be appreciated.   Thanks

Thursday, September 18, 2008 #

I have a copy of the "Principles behind the Agile Manifest stapled to my cube wall (http://www.agilemanifesto.org/principles.html).  One of my favorite principles is :

"Agile processes promote sustainable development. The sponsors, developers, and users should be able to maintain a constant pace indefinitely." 

To me this principle promotes work life balance and leads to less burn out and developer attrition.  As our economy weakens I find myself working weekends and into the wee hours. Is this sustainable development?  I am tired and energy drinks are no longer working. I see this happening not just in software development but in  all types of employment.  I find that if I stay up until 3a.m.  to work on a problem I have a hard time waking up at 5:00 am to start a new day. For those involved in Agile development the whole process starts to fall apart when people are not honest during the estimating phase of the project because they are afraid to say they think something will take 40 hours not the 10 hours management would like to see.  We, including myself are shooting ourselves in the foot when our work load becomes unsustainable.  Problem is I don't know what to do about it.  The country is practically in a depression and our employers are also fighting an upstream battle to stay afloat economically.


Wednesday, August 13, 2008 #

The built in validator controls can remove the tedious code needed to traditionally check user input and I have found that using them in very simple pages is a great time saver but using them on a complex page  where valid input varies depending on any number of factors it is better to verify input programmatically, tell the user if there were any problems, tell them what to do, tell them if there were any database errors , or if they successfully completed their transaction.   Whenever I create UI pages or classes I always pre-plan for  what I call "user messages".   I even program these into interfaces so they are required in any implementing classes.  Example if a "Save" is successful in an object pass a boolean of true if not successful  I will tell the user and also write it an error log.  I have read that validation controls keep you from having to do things like regex functions to see if a string contains a Phone#.  I can write the function to check this and put it in a class and call it when needed rather than having to put the control on each page needing Phone#.   I work in an environment where validation can change monthly or even during a part of the month (close of month) so I don't use the validation controls unless I think the requirements for input are not likely to change. 
I have found it most flexible to create a stringbuilder object and append user/error messages to it.  I can then display the messages in a variety of ways depending on a variety of conditions.  I find this is easier to change if the user decides that a phone# is only required for citizens of Arkansas but not for Missouri and then only in certain area codes.
My co-workers don't agree with me. They strive to make the built-in validators work at all cost, and want me to conform.  I am just not feelin it.


Tuesday, August 05, 2008 #

Business owners wanted a report with a hard coded date range rather than a date range prompt. Customer is always right, especially in an economic downturn.   I could not figure out how to do this and after a couple of days of trial and error I got this to work.  I hope this saves someone some time.

--get past 30 days
[Business View].[Sales Tracking Transaction].[Sale Date]between _add_days(current_date,-30) and current_date

--get past year
[Business View].[Sales Tracking Transaction].[Sale Date]between _add_Years(current_date,-1) and current_date


If detailed error logging is needed you can use the following to get the page name as well as the method name that triggered the error. In my case I log errors to the event log as well as store them in the database using log4net. I like getting back detailed error messages so I can more easily find and fix the related bugs.

using System.Diagnostics;

using System. Reflection:

 catch (Exception ex)

{

//retrieves the name of the page so it does not have to be hardcoded
string currentPageName = System.IO.Path.GetFileName(Request.PhysicalPath);

StackFrame stackFrame = new StackFrame();

//retrieves the name of the current method so it does not have to be hardcoded
MethodBase methodBase = stackFrame.GetMethod();

logger.Error(String.Format("Page Name: {1}: There was an error in the Method: {2}, User ID: {0})",
UserID, currentPageName, methodBase.Name), ex);

}


Thursday, February 14, 2008 #

Very hastily put together but I think it may help someone trying to deal with getting controls to communicate with each other when they are not on a single page example master page, content page,user control, server control....

 

http://geekswithblogs.net/technodrone/archive/2008/02/13/get-embedded-controls-to-communicate-via-events.aspx


Friday, February 08, 2008 #

I would like to pass this exam.  For the past year I have been hacking my way through the use of .net framework 2.0.  I know I am missing out on many features due to lack of awareness.  I don't mind buying books for study but want to know what really works.  This is a goal I would like to complete in the next 3 months.  I see many resources for free on the internet, which of them were most helpful.