public JobInstance ScheduleAsJob(Federation federation, TableOrView[] sources, string path, FileFormatDescription format, string queueName, string comments)
        {
            var job = GetInitializedJobInstance(queueName, comments);

            var settings = new ExportTablesJobSettings(job.JobDefinition.Settings);

            path = path ?? settings.OutputDirectory;
            path = Path.Combine(path, String.Format("{0}_{1}{2}", Context.UserName, job.JobID, Jhu.Graywulf.IO.Constants.FileExtensionZip));

            var destinations = new DataFileBase[sources.Length];

            for (int i = 0; i < sources.Length; i++)
            {
                var ff = FileFormatFactory.Create(federation.FileFormatFactory);

                var destination = ff.CreateFile(format);
                destination.Uri = Util.UriConverter.FromFilePath(String.Format("{0}{1}", sources[i].ObjectName, format.DefaultExtension));

                // special initialization in case of a text file
                // TODO: move this somewhere else, maybe web?
                if (destination is TextDataFileBase)
                {
                    var tf = (TextDataFileBase)destination;
                    tf.Encoding = Encoding.ASCII;
                    tf.Culture  = System.Globalization.CultureInfo.InvariantCulture;
                    tf.GenerateIdentityColumn = false;
                    tf.ColumnNamesInFirstLine = true;
                }

                destinations[i] = destination;
            }

            var et = new ExportTables()
            {
                Sources               = sources,
                Destinations          = destinations,
                Archival              = DataFileArchival.Zip,
                Uri                   = Util.UriConverter.FromFilePath(path),
                FileFormatFactoryType = federation.FileFormatFactory,
                StreamFactoryType     = federation.StreamFactory,
            };

            job.Parameters["Parameters"].Value = et;

            return(job);
        }
Example #2
0
        private void OnAsyncExecute(Guid workflowInstanceGuid, string activityInstanceId, ExportTables exportTable)
        {
            // Create table exporter
            var exporter = exportTable.GetInitializedTableExportTask();

            RegisterCancelable(workflowInstanceGuid, activityInstanceId, exporter);

            try
            {
                exporter.Open();
                exporter.Execute();
            }
            finally
            {
                exporter.Close();
            }

            UnregisterCancelable(workflowInstanceGuid, activityInstanceId, exporter);
        }
Example #3
0
        public JobInstance ScheduleAsJob(Federation federation, TableOrView[] sources, string path, FileFormatDescription format, string queueName, string comments)
        {
            var job = GetInitializedJobInstance(queueName, comments);

            var settings = new ExportTablesJobSettings(job.JobDefinition.Settings);

            path = path ?? settings.OutputDirectory;
            path = Path.Combine(path, String.Format("{0}_{1}{2}", Context.UserName, job.JobID, Jhu.Graywulf.IO.Constants.FileExtensionZip));

            var destinations = new DataFileBase[sources.Length];
            for (int i = 0; i < sources.Length; i++)
            {
                var ff = FileFormatFactory.Create(federation.FileFormatFactory);

                var destination = ff.CreateFile(format);
                destination.Uri = Util.UriConverter.FromFilePath(String.Format("{0}{1}", sources[i].ObjectName, format.DefaultExtension));

                // special initialization in case of a text file
                // TODO: move this somewhere else, maybe web?
                if (destination is TextDataFileBase)
                {
                    var tf = (TextDataFileBase)destination;
                    tf.Encoding = Encoding.ASCII;
                    tf.Culture = System.Globalization.CultureInfo.InvariantCulture;
                    tf.GenerateIdentityColumn = false;
                    tf.ColumnNamesInFirstLine = true;
                }

                destinations[i] = destination;
            }

            var et = new ExportTables()
            {
                Sources = sources,
                Destinations = destinations,
                Archival = DataFileArchival.Zip,
                Uri = Util.UriConverter.FromFilePath(path),
                FileFormatFactoryType = federation.FileFormatFactory,
                StreamFactoryType = federation.StreamFactory,
            };

            job.Parameters["Parameters"].Value = et;

            return job;
        }
Example #4
0
        private void OnAsyncExecute(Guid workflowInstanceGuid, string activityInstanceId, ExportTables exportTable)
        {
            // Create table exporter
            var exporter = exportTable.GetInitializedTableExportTask();

            RegisterCancelable(workflowInstanceGuid, activityInstanceId, exporter);

            try
            {
                exporter.Open();
                exporter.Execute();
            }
            finally
            {
                exporter.Close();
            }

            UnregisterCancelable(workflowInstanceGuid, activityInstanceId, exporter);
        }