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); } }
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 exportthread() { BackupSettingsExportImport newexport = new BackupSettingsExportImport(); if (newexport != null) { newexport.ExportImportInit(ref progressBar, false); newexport.newmessage += new textexportmessage(textoutput); newexport.MyLoadSettings(); newexport.getallversionnumbers("", false); //get only program version numbers after loadsettings bool ok = newexport.createbackup(filenametextBox.Text); if (ok) MessageBox.Show(this, "Export completed successfully"); else { if (PB_th != null) { newexport.ProgressbarCancel(); } MessageBox.Show(this, "Export not successful - Check the status and the log file"); } newexport.MySaveSettings(); newexport.newmessage -= new textexportmessage(textoutput); } textoutput("\n"); //create new paragraph after completed export BUSY = false; //job completed }