private void TaskExecuted(DocumentImportTask task)
        {
            if (task.DeleteAfterImport)
            {
                var fname = task.Uri.LocalPath;
                try
                {
                    File.Delete(fname);
                }
                catch (Exception ex)
                {
                    Logger.ErrorFormat(ex, "Delete source failed: {0}", fname);
                }
            }

            if (DeleteTaskFileAfterImport)
            {
                try
                {
                    File.Delete(task.PathToTaskFile);
                }
                catch (Exception ex)
                {
                    Logger.ErrorFormat(ex, "Delete task failed: {0}", task.PathToTaskFile);
                    throw;
                }
            }
        }
Beispiel #2
0
        public static void WriteAllText(string fileName, string textFile)
        {
            if (DsFile.Exists(fileName))
            {
                DsFile.Delete(fileName);
            }

            if (fileName != null && fileName.Length < 240)
            {
                System.IO.File.WriteAllText(fileName, textFile);
            }
            else
            {
                MyFile.WriteAllText(fileName, textFile);
            }
        }
        private static int Main(string[] args)
        {
            var lastErrorFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "_lastError.txt");

            if (File.Exists(lastErrorFileName))
            {
                File.Delete(lastErrorFileName);
            }
            try
            {
                MongoRegistration.RegisterMongoConversions(
                    "NEventStore.Persistence.MongoDB"
                    );

                MongoFlatMapper.EnableFlatMapping(true);

                CommandsExtensions.EnableDiagnostics = true;
                Native.DisableWindowsErrorReporting();
                MongoFlatMapper.EnableFlatMapping(true); //before any chanche that the driver scan any type.
                Int32 executionExitCode;
                if (args.Length == 1 && (args[0] == "install" || args[0] == "uninstall"))
                {
                    executionExitCode = (Int32)StartForInstallOrUninstall();
                }
                else
                {
                    executionExitCode = (Int32)StandardDocumentStoreStart();
                }
                return(executionExitCode);
            }
            catch (Exception ex)
            {
                File.WriteAllText(lastErrorFileName, ex.ToString());
                throw;
            }
        }