03-01-2011 10:18 AM - edited 03-01-2011 10:20 AM
I'm trying to restore a database from a backup ZIP and don't know what to use for the ProgressHandler parameter.
Here's what I have so far:
string lcLogonName = "mylogon";
string lcPassword = "mypassword";
string lcZipFile = "D:\\Act Databases\\ACT! My_Database.ZIP";
string lcZipPassword = "";
ActFramework loActFramework = new ActFramework();
string lcDatabaseName = "My_Database";
string lcDatabaseHost = "MyComputerName";
string lcDatabaseType = "SQL";
string lcNewTargetFolder = "D:\\Act Databases";
//loProgressHandler,
bool llShareDatabase = false;
loActFramework.RestoreDatabaseAs(lcDatabaseName, lcDatabaseHost, lcDatabaseType, lcNewTargetFolder, lcLogonName, lcPassword, lcZipFile, lcZipPassword, loProgressHandler, llShareDatabase);
03-02-2011 08:20 AM - edited 03-02-2011 08:22 AM
As I mentioned in the previous post, pgb1 is simply a progress bar component that's used in this application so the user can see the progress of the restore. The error message
"The name 'pgb1' does not exist in the current context".
Is probably accurate as it's likely that your application doesn't contain a progress bar with the same name. Or may not contain one at all. I commented out that portion of my code as well and the application still executed without exception. The only requirement is that the handler method accept a parameter of Act.Framework.SupplementalFiles.ProgressInfoEventsArgs.
In the application in which I'm initializing this I'm creating a backup, not restoring a database, so I plugged in some code similar to yours in basic windows form application, here is the relevant portions:
private void button3_Click(object sender, EventArgs e)
{
RestoreDatabase();
}
private void RestoreDatabase()
{
try
{
string dbName = "TestRestore";
string hostName = "MyPCName";
string dbType = "SQL";
string targetFolder = @"C:\Users\Me\Desktop";
string userName = "Chris Huffman";
string pWord = string.Empty;
string zipFile = @"C:\Users\Me\Desktop\DemoCopy02.zip";
string zipPword = "";
Act.Framework.SupplementalFiles.SupplementalFileManager.ProgressEventHandler Handler =
new Act.Framework.SupplementalFiles.SupplementalFileManager.ProgressEventHandler(RestoreHandler);
bool shareDB = false;
afw.RestoreDatabaseAs(dbName, hostName, dbType, targetFolder, userName, pWord, zipFile, zipPword, Handler, shareDB);
MessageBox.Show("Success");
}
catch (Exception x) { }
}
private void RestoreHandler(Act.Framework.SupplementalFiles.ProgressInfoEventArgs piea)
{
}
The only variable that I don't initialize within this code block is afw, which is simply my ActFramework object.
03-01-2011 10:34 AM
I found this sample of getting a SupplementalFileManager.ProgressEventHandler :
Act.Framework.SupplementalFiles.SupplementalFileManager.ProgressEventHandler peh =
new Act.Framework.SupplementalFiles.SupplementalFileManager.ProgressEventHandler(BackUpProg);
private void BackUpProg(Act.Framework.SupplementalFiles.ProgressInfoEventArgs peia)
{
pgb1.PerformStep();
}
pgb1 is a progress event bar, I imagine that this would still work even if the method were empty.
Hope this helps.
03-01-2011 01:33 PM - edited 03-02-2011 06:45 AM
When using the code you suggest I get:
"The name 'pgb1' does not exist in the current context".
You indicated it should work if the method was empty, so I commented out the line that said:
pgb1.PerformSetup();
Now I get the error:
"An object reference is required for the non-static field, method, or property
'TestConsoleProject.TestConsoleClass.BackUpProg(Act.Framework.SupplementalFiles
.ProgressInfoEventArgs)'"
Can you give me a more specific example of how to properly initialize the Progress Handler parameter?
Thanks!
03-02-2011 08:20 AM - edited 03-02-2011 08:22 AM
As I mentioned in the previous post, pgb1 is simply a progress bar component that's used in this application so the user can see the progress of the restore. The error message
"The name 'pgb1' does not exist in the current context".
Is probably accurate as it's likely that your application doesn't contain a progress bar with the same name. Or may not contain one at all. I commented out that portion of my code as well and the application still executed without exception. The only requirement is that the handler method accept a parameter of Act.Framework.SupplementalFiles.ProgressInfoEventsArgs.
In the application in which I'm initializing this I'm creating a backup, not restoring a database, so I plugged in some code similar to yours in basic windows form application, here is the relevant portions:
private void button3_Click(object sender, EventArgs e)
{
RestoreDatabase();
}
private void RestoreDatabase()
{
try
{
string dbName = "TestRestore";
string hostName = "MyPCName";
string dbType = "SQL";
string targetFolder = @"C:\Users\Me\Desktop";
string userName = "Chris Huffman";
string pWord = string.Empty;
string zipFile = @"C:\Users\Me\Desktop\DemoCopy02.zip";
string zipPword = "";
Act.Framework.SupplementalFiles.SupplementalFileManager.ProgressEventHandler Handler =
new Act.Framework.SupplementalFiles.SupplementalFileManager.ProgressEventHandler(RestoreHandler);
bool shareDB = false;
afw.RestoreDatabaseAs(dbName, hostName, dbType, targetFolder, userName, pWord, zipFile, zipPword, Handler, shareDB);
MessageBox.Show("Success");
}
catch (Exception x) { }
}
private void RestoreHandler(Act.Framework.SupplementalFiles.ProgressInfoEventArgs piea)
{
}
The only variable that I don't initialize within this code block is afw, which is simply my ActFramework object.
03-03-2011 09:50 AM
With this information I was able to make it work.
Thanks for your help!