public JobInstance ScheduleAsJob(TableOrView source, string path, FileFormatDescription format, string queueName, string comments) { var job = GetInitializedJobInstance(queueName, comments); var et = new ExportTable(); et.Source = source; // TODO: change this to support different compression formats path = Path.Combine(path, String.Format("{0}_{1}_{2}{3}.gz", Context.UserName, job.JobID, source.ObjectName, format.DefaultExtension)); var destination = FileFormatFactory.CreateFile(format); destination.Uri = new Uri(String.Format("file:///{0}", path)); destination.FileMode = DataFileMode.Write; destination.Compression = CompressionMethod.GZip; // special initialization in case of a text file if (destination is TextDataFile) { var tf = (TextDataFile)destination; tf.Encoding = Encoding.ASCII; tf.Culture = System.Globalization.CultureInfo.InvariantCulture; tf.GenerateIdentityColumn = false; tf.ColumnNamesInFirstLine = true; } et.Destination = destination; job.Parameters["Parameters"].SetValue(et); return job; }
private void OnAsyncExecute(Guid workflowInstanceGuid, string activityInstanceId, ExportTable exportTable) { // Create table exporter var exporter = exportTable.GetInitializedExporter(); RegisterCancelable(workflowInstanceGuid, activityInstanceId, exporter); exporter.Execute(); UnregisterCancelable(workflowInstanceGuid, activityInstanceId, exporter); }