private IO.Tasks.ImportTable CreateImporterSimple() { string filename, extension; DataFileCompression compression; // Determine file format var format = FileFormatFactory.GetFileFormatDescription( GetUploadedFileUri(), out filename, out extension, out compression); var source = FileFormatFactory.CreateFile(format); source.BaseStream = ImportedFile.PostedFile.InputStream; //source.Open(ImportedFile.PostedFile.InputStream, DataFileMode.Read); var destination = CreateDestination("dbo", filename.Replace(".", "_")); // TODO: get 'dbo' from dataset description return(new IO.Tasks.ImportTable() { Source = source, Destination = destination }); }
public async Task LoadGame(string filename, string instructions) { var ms = new MemoryStream(); var handler = FileFormatFactory.GetSnapShotHandler(filename); var stream = await httpClient.GetStreamAsync("/Roms/" + filename + ".json"); await stream.CopyToAsync(ms); var bytes = ms.ToArray(); handler.LoadSnapshot(bytes, speccy); Instructions = instructions; }
public async Task HandleFileSelected(IFileListEntry[] files) { var file = files.First(); var ms = new MemoryStream(); await file.Data.CopyToAsync(ms); var handler = FileFormatFactory.GetSnapShotHandler(file.Name); var bytes = ms.ToArray(); handler.LoadSnapshot(bytes, speccy); }
private void RefreshFileFormatList() { var dfs = FileFormatFactory.GetFileFormatDescriptions(); foreach (var df in dfs) { if (df.Value.CanWrite) { var li = new ListItem(df.Value.DisplayName, df.Key); FileFormat.Items.Add(li); } } }
protected void RefreshForm() { var format = FileFormatFactory.GetFileFormatDescription(FileFormat.SelectedValue); DetectColumnNamesRow.Visible = format.CanDetectColumnNames; CompressedRow.Visible = !format.IsCompressed; if (DetailsTable.Visible) { ToggleDetails.Text = "simple mode"; } else { ToggleDetails.Text = "advanced mode"; } }
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); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var dfs = FileFormatFactory.GetFileFormatDescriptions(); foreach (var df in dfs) { if (df.Value.CanRead) { var li = new ListItem(df.Value.DisplayName, df.Key); FileFormat.Items.Add(li); } } RefreshForm(); } }
private void ScheduleExportTableJob() { var table = (Jhu.Graywulf.Schema.Table)SchemaManager.GetDatabaseObjectByKey(TableName.SelectedValue); var format = FileFormatFactory.GetFileFormatDescription(FileFormat.SelectedValue); // Make sure it's in MYDB if (StringComparer.InvariantCultureIgnoreCase.Compare(table.DatasetName, MyDBDatabaseDefinition.Name) != 0) { throw new InvalidOperationException(); // *** TODO } var queue = EntityFactory.CombineName(EntityType.QueueInstance, Federation.ControllerMachine.GetFullyQualifiedName(), Jhu.Graywulf.Registry.Constants.LongQueueName); var f = new Jhu.Graywulf.Jobs.ExportTables.ExportTablesFactory(RegistryContext); // TODO: maybe add comments? var job = f.ScheduleAsJob(Federation, new[] { table }, null, format, queue, ""); job.Save(); }
protected Guid ScheduleExportTableJob(string schemaName, string tableName, string path, QueueType queueType) { var queue = String.Format("QueueInstance:Graywulf.Controller.Controller.{0}", queueType.ToString()); using (var context = ContextManager.Instance.CreateContext(ConnectionMode.AutoOpen, TransactionMode.AutoCommit)) { var user = SignInTestUser(context); var ef = new EntityFactory(context); var federation = ef.LoadEntity <Federation>(Registry.AppSettings.FederationName); var format = FileFormatFactory.Create(federation.FileFormatFactory).GetFileFormatDescription(typeof(Jhu.Graywulf.Format.DelimitedTextDataFile).FullName); var mydbds = federation.MyDBDatabaseVersion.GetUserDatabaseInstance(user).GetDataset(); var source = new Jhu.Graywulf.Schema.Table() { Dataset = mydbds, // TODO: fix this DatabaseName = mydbds.DatabaseName, SchemaName = schemaName, TableName = tableName }; var etf = new ExportTablesFactory(context); var ji = etf.ScheduleAsJob( federation, new TableOrView[] { source }, path, format, queue, ""); ji.Save(); return(ji.Guid); } }
protected FileFormatFactory GetFileFormatFactory() { return(FileFormatFactory.Create(fileFormatFactoryType)); }