Beispiel #1
0
        public bool ExecuteNow()
        {
            ClientServer sc = new ClientServer(this.ClientID);
            DataExport   de = new DataExport(sc.GetServer().Connection());

            de.Merge <ExportSettings>(Settings);
            Data.ImportExport im = new Data.ImportExport();
            try
            {
                Status = ImportExportStatus.progress;
                im.UpdateScheduleStatus(this.ClientID, ExportImportID, (int)Status, "");
                string fileName = @"/sqldump-" + Guid.NewGuid().ToString() + ".sql";
                var    path     = FolderPath + fileName;
                de.ExportTo(path);
                Status = ImportExportStatus.completed;
                im.UpdateScheduleStatus(this.ClientID, ExportImportID, (int)Status, "", fileName);
            }
            catch (Exception ex)
            {
                Status = ImportExportStatus.error;
                im.UpdateScheduleStatus(this.ClientID, ExportImportID, (int)Status, ex.Message);
                throw ex;
            }
            finally {
            }
            return(true);
        }
Beispiel #2
0
        public bool ImportNow()
        {
            ClientServer sc = new ClientServer(this.ClientID);
            DataImport   di = new DataImport(sc.GetServer().Connection());

            Data.ImportExport im = new Data.ImportExport();

            try
            {
                string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
                assemblyFolder = assemblyFolder.Replace("\\Debug", "");
                assemblyFolder = assemblyFolder.Replace("\\bin", "");
                assemblyFolder = assemblyFolder.Replace("\\netcoreapp2.1", "");
                assemblyFolder = assemblyFolder.Replace("file:\\", "");
                if (ImportFilePath.StartsWith("~"))
                {
                    ImportFilePath = ImportFilePath.Substring(1);
                }
                string impPath = assemblyFolder + ImportFilePath;
                Status = ImportExportStatus.progress;
                im.UpdateScheduleStatus(this.ClientID, ExportImportID, (int)Status, "");
                string rst = di.ImportFrom(impPath, IgnoreSQLErrors);
                if (rst == "done")
                {
                    Status = ImportExportStatus.completed;
                    im.UpdateScheduleStatus(this.ClientID, ExportImportID, (int)Status, "");
                    return(true);
                }
                else
                {
                    Status = ImportExportStatus.error;
                    im.UpdateScheduleStatus(this.ClientID, ExportImportID, (int)Status, rst);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Status = ImportExportStatus.error;
                im.UpdateScheduleStatus(this.ClientID, ExportImportID, (int)Status, ex.Message);
                throw ex;
            }
            finally
            {
            }
        }