Jan 29 2012

Twitter Weekly Updates for 2012-01-29

Powered by Twitter Tools

Jan 25 2012

New post as http://t.co/q0Q9Y0…

New post as http://t.co/q0Q9Y0TS - : To restore a "plain" postgresql backup ... http://t.co/EZWaiR7B #twittertools

Jan 25 2012

To restore a “plain” postgresql backup …

1.  Drop/Recreate the target database using PGAdmin 2.  Be sure to add logins to all roles that are referenced in the backup script.  This should only be necessary the first time.  The phonesystem db references the following logins... phonesystem, phoneadmin, logsreader. 3.  From a terminal window run the following command sudo psql -d phonesystem -U seths -f "<path-to-backup>" Seth
Jan 19 2012

Comment by Seth Spearman on How do I get .NET WinForms components to use a SET timezone instead of clients time zone?

Thank you very much for your reply. I was not suspecting that I would have to re-engineer our application to support this. What did I miss here?
Jan 19 2012

How do I get .NET WinForms components to use a SET timezone instead of clients time zone?

I was not looking forward to describing this problem until I found another forum web site with the EXACT SAME question I need answered (but with no answer.) So with credit to this guy here is my question...

We have a large Windows .Net application (winform executable) that gets installed on the client's desktop. This application calls web services on a server in a different timezone. Virtually all date oriented components detect the timezone difference and automatically adjust the datetime values (returned in dataSets generated by SQL queries), which is generally desirable in most applications but causing problems with accounting related applications that are "date" not "datetime" oriented. We are only interested in the "date" portion. However, a date of 1/1/2003 GMT-5 is automatically converted to 12/31/2002 11:00 GMT-6 on the client. Rather than going through all of the code and extracting the UniversalTime to get back to 1/1/2003 for visual purposes we would like to simply "fake" the timezone for the client-side executable by making it think it's in the same timezone as the server.

Question: Can we set the TimeZone programmatically for the currently running instance only, rather than the global setting?

I really don't have much to add because it is our EXACT issue. In our case we have ActiveReports that are fetching remote SQL data into a datasets and then binding the report to the dataset. So, for example, birthdays are wrong because we are storing the Date for them and X hours are subtracting for the date in the western time zones? So the birthdates are off by minus 1.

Any thoughts?

Thanks!

Seth

Jan 19 2012

How do I get .NET WinForms components to use a SET timezone instead of clients time zone?

        <p>I was not looking forward to describing this problem until I found another forum web site with the EXACT SAME question I need answered (but with no answer.)  So with credit to <a href="http://www.hightechtalks.com/dotnet-framework-winforms/how-set-timezone-runtime-single-213152.html" rel="nofollow">this guy</a> here is my question...  </p>
We have a large Windows .Net application (winform executable) that gets installed on the client's desktop. This application calls web services on a server in a different timezone. Virtually all date oriented components detect the timezone difference and automatically adjust the datetime values (returned in dataSets generated by SQL queries), which is generally desirable in most applications but causing problems with accounting related applications that are "date" not "datetime" oriented. We are only interested in the "date" portion. However, a date of 1/1/2003 GMT-5 is automatically converted to 12/31/2002 11:00 GMT-6 on the client. Rather than going through all of the code and extracting the UniversalTime to get back to 1/1/2003 for visual purposes we would like to simply "fake" the timezone for the client-side executable by making it think it's in the same timezone as the server. Question: Can we set the TimeZone programmatically for the currently running instance only, rather than the global setting?
I really don't have much to add because it is our EXACT issue. In our case we have ActiveReports that are fetching remote SQL data into a datasets and then binding the report to the dataset. So, for example, birthdays are wrong because we are storing the Date for them and X hours are subtracting for the date in the western time zones? So the birthdates are off by minus 1. Any thoughts? Thanks! Seth
Jan 05 2012

Comment by Seth Spearman on How do I create a global exception handler for winforms app that is making asyncronous WebClient calls

Per the code block I added to the question?
Jan 05 2012

Comment by Seth Spearman on How do I create a global exception handler for winforms app that is making asyncronous WebClient calls

Nicholas...just check for non-null on that property? Or can I just put the whole callback into try catch and then do a throw?
Jan 05 2012

How do I create a global exception handler for winforms app that is making asyncronous WebClient calls

I have a winforms app that is making asyncronous WebClient calls with a callback procedures as follows...

using (var wc = new WebClient())
{
    wc.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadCompleted);
    wc.DownloadProgressChanged+=new DownloadProgressChangedEventHandler(DownloadProgressCallback);
    //other stuff
    wc.DownloadFileAsync(uri, fullLocalPath);
}

I want to create a global exception handler so I have defined an application event for it...

[STAThread]
static void Main()
{
    Application.ThreadException += new ThreadExceptionEventHandler(ApplicationThreadException);
    //other stuff
    Application.Exit();

}

private static void ApplicationThreadException(object sender, ThreadExceptionEventArgs e)
{
    // Do logging or whatever here

    Application.Exit();
}

I believe that I am correct that application errors that are raised by the Callback event will not be caught by the Application.ThreadException? So what is the best way of insuring that the callback exceptions are handled?

I have seen on other SO posts that you can also create a handler for AppDomain.CurrentDomain.UnhandledException. Is that the best way to handle the callback exceptions?

I am just looking for best practices when using asyncronous callbacks in a winforms app.

EDIT

Nicholas...thanks for your answer. So can I put the whole callback into a try catch and then do a throw in the catch. Or do I have to explicitly check the AsyncCompletedEventArgs.error property for a non-null value.

If it IS non-null...can you tell me how to cause the callback error to bubble up to my global exception handler?

I think I would do it like this...

private void DownloadCompleted(object sender, AsyncCompletedEventArgs e)
{

    if (e.Error != null)
    {
        throw e.Error;
    }

    if (DownloadHasCompleted == null) return;
    File.Copy(this.RemoteIniFilePath, this.CurrentIniFilePath, true);
    DownloadHasCompleted(this, e);
}

Seth