Beispiel #1
0
        private string ExportItems(List <IDataRecord> items, IRepository graph, uFrameExport export)
        {
            var repo = graph as TypeDatabase;

            if (repo == null)
            {
                throw new Exception("Couldn't export, must be TypeDatabase");
            }
            var actualItems = items;

            var ids = items.Select(p => p.Identifier).ToArray();

            foreach (var record in graph.AllOf <IDataRecord>())
            {
                if (record is Workspace)
                {
                    continue;
                }
                if (!record.ForeignKeys.Any())
                {
                    continue;
                }
                if (record.ForeignKeys.All(x => ids.Any(p => p != null && x != null && (p == x || p.StartsWith(x)))))
                {
                    if (!actualItems.Contains(record))
                    {
                        actualItems.Add(record);
                    }
                }
            }
            actualItems.RemoveAll(p => p.Identifier.Contains(":"));

            export.Repositories = actualItems.GroupBy(p => p.GetType()).Select(p => new ExportedRepository()
            {
                Records = p.Select(x => new ExportedRecord()
                {
                    Data       = InvertJsonExtensions.SerializeObject(x).ToString(true),
                    Identifier = x.Identifier
                }).ToList(),
                Type = p.Key.FullName
            }).ToList();
            var config     = Container.Resolve <IGraphConfiguration>();
            var generators = InvertGraphEditor.GetAllFileGenerators(config,
                                                                    actualItems.ToArray(), true);

            export.CodeFiles = generators.Where(p => File.Exists(p.SystemPath)).Select(p => new ExportedCode()
            {
                Code         = File.ReadAllText(p.SystemPath),
                RelativePath = p.AssetPath.Replace(config.CodeOutputPath, "")
            }).ToList();

            var contents = InvertJsonExtensions.SerializeObject(export).ToString(true);

            return(contents);
        }
Beispiel #2
0
        public void Execute(ExportDatabaseCommand command)
        {
            var export = new uFrameExport();
            var items  = command.Database.Repository.AllOf <IDataRecord>().Where(p => !(p is uFrameDatabaseConfig)).ToList();

            var contents = ExportItems(items, command.Database.Repository, export);
            var fileSave = new ShowSaveFileDialog()
            {
                Extension   = "ufdata",
                DefaultName = command.Database.Title
            };

            Execute(fileSave);
            if (fileSave.Result != null)
            {
                File.WriteAllText(fileSave.Result, contents);
            }
        }
Beispiel #3
0
        public void Execute(ExportWorkspaceCommand command)
        {
            var export = new uFrameExport();
            var items  = new List <IDataRecord>();

            Traverse(command.Workspace, items);
            var contents = ExportItems(items, command.Workspace.Repository, export);
            var fileSave = new ShowSaveFileDialog()
            {
                Extension   = "ufdata",
                DefaultName = command.Workspace.Name
            };

            Execute(fileSave);
            if (fileSave.Result != null)
            {
                File.WriteAllText(fileSave.Result, contents);
            }
        }