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 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

Dec 30 2011

What target folder should I install my application to that will never require uac elevation?

I have an app and I am working on the installer for it. Assuming that I want the installation to not require elevation and I want the application itself to never require elevation and I want the updater for the application (which is build in) to never require elevation where should I install the application to?

Caveats:

  1. This application is not signed.
  2. I am okay if each user has to install it separately under their profile.
  3. Can I use the registry in the install and accomplish the same goal?
  4. The only writes it makes are to setttings/configuration files.
  5. .NET 4 app.
Dec 23 2011

How can I get a Microsoft Access combobox to behave like a listbox

Boy is my Access rusty...

With a listbox when you click a letter it takes you to the first match for that letter. When you click that letter again it takes you to the second match for that letter and so on.

Is there a way to get a combo box to behave that way?

Seth

Dec 09 2011

Comment by Seth Spearman on How can I automate the checkout of an excel spreadsheet from a sharepoint document library, edit the spreadsheet, and check it back in?

I just looked at the VBA object model and notice that the workbook object has a Checkout method. And the description is "Copies the workbook from a server to a local computer for editing"...just what I was looking for. If that works I will post the code into my answer. Seth