public void CreateScheduledExport(string folderName)
        {
            try
            {
                Log.Debug("CreateScheduledExport folder=" + folderName);
                BackupSettingsExportImport newexportimport = new BackupSettingsExportImport();
                newexportimport.DEBUG = DEBUG;
                newexportimport.newmessage += new textexportmessage(textoutput); //enable logging from newimportexport class
                newexportimport.MyLoadSettings();
                newexportimport.getallversionnumbers("", false); //get only program version numbers after loadsettings
                STATUS = "";
                ProgressBar progressBar = new System.Windows.Forms.ProgressBar();
                newexportimport.ExportImportInit(ref progressBar, true);
                newexportimport.createbackup(folderName); //perform export
                newexportimport.newmessage -= new textexportmessage(textoutput);

                string fName = TV_USER_FOLDER + @"\" + BACKUPSETTING_TV_DIR + @"\" + STATUS_FILE;
                try
                {
                    StreamWriter fs = File.AppendText(fName);
                    fs.Write(STATUS);
                    fs.Close();
                    if (DEBUG == true)
                        Log.Debug("BackupSetting: " + STATUS_FILE + " file written");
                }
                catch (Exception ee)
                {
                    Log.Debug("BackupSettingsServer: Error in writing file  " + fName);
                    Log.Debug("BackupSettingsServer: Exception message is " + ee.Message);
                }
                Log.Debug("CreateScheduledExport completed");
            }
            catch (Exception exc)
            {
                Log.Error("CreateScheduledExport: Exception=" + exc.Message);
            }
        }
        private void importthread()
        {
            BackupSettingsExportImport newimport = new BackupSettingsExportImport();

            if (newimport != null)
            {
                newimport.ExportImportInit(ref progressBar, false);
                newimport.newmessage += new textexportmessage(textoutput);

                newimport.MyLoadSettings();
                newimport.getallversionnumbers("", false); //get only program version numbers after loadsettings
                newimport.Status = Status;
                bool ok = newimport.restorebackup(filenametextBox.Text);
                if (ok)
                    MessageBox.Show(this, "Import completed successfully");
                else
                {
                    if (PB_th != null)
                    {
                        newimport.ProgressbarCancel();
                    }
                    MessageBox.Show(this, "Import not successful - Check the status and the log file");
                }
                newimport.MySaveSettings();
                newimport.newmessage -= new textexportmessage(textoutput);
            }

            textoutput("\n");  //create new paragraph after completed export
            BUSY = false; //job completed
        }
        public void AutomatedExportProcessing(object sender, FileSystemEventArgs e)
        {
            try
            {
                textoutput("**************************************************************");
                textoutput("Automated Export started at "+DateTime.Now.ToString());
                textoutput("**************************************************************");
                AutomatedExport.EnableRaisingEvents = false; //set watcher inactive
                System.IO.StreamReader sr = new System.IO.StreamReader(TV_USER_FOLDER + @"\" + BACKUPSETTING_TV_DIR + @"\" + AUTO_EXPORT_FILE);
                string foldername = sr.ReadToEnd();

                sr.Close();
                File.Delete(TV_USER_FOLDER + @"\" + BACKUPSETTING_TV_DIR + @"\" + AUTO_EXPORT_FILE); //delete file

                BackupSettingsExportImport newexportimport = new BackupSettingsExportImport();
                newexportimport.DEBUG = DEBUG;
                newexportimport.newmessage += new textexportmessage(textoutput); //enable logging from newimportexport class
                newexportimport.MyLoadSettings();
                newexportimport.getallversionnumbers("", false); //get only program version numbers after loadsettings
                STATUS = "";

                string[] folderarray = foldername.Split('\n');

                if (foldername.ToLower().StartsWith("autocreatefilename"))  //use autocreate or use string as new foldername
                {
                    if (folderarray.Length > 1)
                    {
                        foldername = newexportimport.CreateAutomatedFolderName(folderarray[1], WhoAmI.Tv_Server); //second line in file gives foldername for autocreate
                    }
                    else
                    {
                        foldername = newexportimport.CreateAutomatedFolderName(newexportimport.pathname, WhoAmI.Tv_Server); //now folder defined for auto create - use last stored folder
                    }
                }
                newexportimport.pathname = foldername;

                ProgressBar progressBar = new System.Windows.Forms.ProgressBar();
                newexportimport.ExportImportInit(ref progressBar, true);

                newexportimport.createbackup(foldername); //perform export

                //append status of postprocessing to status file
                // do not use textoutput anymore
                newexportimport.newmessage -= new textexportmessage(textoutput);
                string fName = TV_USER_FOLDER + @"\" + BACKUPSETTING_TV_DIR + @"\" + STATUS_FILE;
                try
                {
                    StreamWriter fs = File.AppendText(fName);
                    fs.Write(STATUS);
                    fs.Close();
                    if (DEBUG == true)
                        Log.Debug("BackupSetting: " + STATUS_FILE + " file written");
                }
                catch (Exception ee)
                {
                    Log.Debug("BackupSettingsServer: Error in writing file  " + fName);
                    Log.Debug("BackupSettingsServer: Exception message is " + ee.Message);
                }
                textoutput("Automated Export finished \n");
                POSTPROCESSING = false; // reset POSTPROCESSING flag
                AutomatedExport.EnableRaisingEvents = true;  //set watcher active
            }
            catch (Exception exc)
            {
                Log.Error("ScheduledExportProcessing: Exception=" + exc.Message);
            }
        }
Example #4
0
        private void importthread()
        {
            BackupSettingsExportImport newimport = new BackupSettingsExportImport();

            if (newimport != null)
            {
                newimport.newmessage += new textexportmessage(textoutput);
                newimport.ExportImport(ref progressBar, CONFIG_FILE);

                newimport.MyLoadSettings();
                newimport.getallversionnumbers("", false); //get only program version numbers after loadsettings
                bool ok = newimport.restorebackup(filenametextBox.Text);
                if (ok)
                    MessageBox.Show(this, "Import completed successfully");
                else
                {
                    if (PB_th != null)
                    {
                        newimport.ProgressbarCancel();
                    }
                    MessageBox.Show(this, "Import not successful - Check the status and the log file");
                }
                newimport.MySaveSettings();
                newimport.newmessage -= new textexportmessage(textoutput);
            }

            textoutput("\n");  //create new paragraph after completed export
            BUSY = false; //job completed

            /*
            bool ok = newexportimport.restorebackup(filenametextBox.Text);
            if (ok)
                MessageBox.Show("Import completed successfully", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            else
            {
                if (PB_th != null)
                {
                    newexportimport.progressbar((int)PB_action.CANCEL, ref PB_Import, PB_action_number);
                }
                MessageBox.Show(this, "Import not successful - Check the status and the log file");
            }

            //MyLoadSettings();  // reload plugin settings after import
            textoutput("\n");  //create new paragraph after completed import
            BUSY = false; //reset processing flag   */
        }