Community
Showing results for 
Search instead for 
Do you mean 
Reply

RestoreDatabaseAs()

Accepted Solution Solved
Loyal Listener
Posts: 19
Country: USA
Accepted Solution

RestoreDatabaseAs()

[ Edited ]

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


Accepted Solutions
Solution
Accepted by topic author ebaer08
‎09-25-2015 03:20 AM
Employee
Posts: 1,163
Country: USA

Re: RestoreDatabaseAs()

[ Edited ]

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.

Matthew Wood
Act! SDK Support
Community Moderator

View solution in original post


All Replies
Employee
Posts: 1,163
Country: USA

Re: RestoreDatabaseAs()

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.

Matthew Wood
Act! SDK Support
Community Moderator
Loyal Listener
Posts: 19
Country: USA

Re: RestoreDatabaseAs()

[ Edited ]

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!

Solution
Accepted by topic author ebaer08
‎09-25-2015 03:20 AM
Employee
Posts: 1,163
Country: USA

Re: RestoreDatabaseAs()

[ Edited ]

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.

Matthew Wood
Act! SDK Support
Community Moderator
Loyal Listener
Posts: 19
Country: USA

Re: RestoreDatabaseAs()

With this information I was able to make it work.

 

Thanks for your help!