Ejemplo n.º 1
0
        private void Import(Importer importer, IImportRecord record)
        {
            try
            {
                if (pnlNewName.Visible)
                {
                    record.RootItem.Name = txtNewName.Text;
                }

                if (chkSkipRoot.Checked)
                {
                    importer.Import(record, Selection.SelectedItem, ImportOption.Children);
                    Refresh(Selection.SelectedItem, ToolbarArea.Both);
                }
                else
                {
                    importer.Import(record, Selection.SelectedItem, ImportOption.All);
                    Refresh(record.RootItem, ToolbarArea.Both);
                }

                ShowErrors(record);
            }
            catch (N2Exception ex)
            {
                cvImport.ErrorMessage = ex.Message;
                cvImport.IsValid = false;
                btnImportUploaded.Enabled = false;
            }
            finally
            {
                if (File.Exists(UploadedFilePath))
                    File.Delete(UploadedFilePath);
            }
        }
Ejemplo n.º 2
0
		public XmlInstallationManager(IHost host, IPersister persister, XmlContentRepository repository, ConnectionMonitor connectionContext, Importer importer, IWebContext webContext, ContentActivator activator)
            : base(connectionContext, importer, webContext, persister, activator)
        {
            this.host = host;
            this.persister = persister;
			this.repository = repository;
        }
Ejemplo n.º 3
0
 public MongoInstallationManager(MongoDatabaseProvider database, IHost host, IPersister persister, ConnectionMonitor connectionContext, Importer importer, IWebContext webContext, ContentActivator activator)
     : base(connectionContext, importer, webContext, persister, activator)
 {
     this.database = database;
     this.host = host;
     this.persister = persister;
 }
Ejemplo n.º 4
0
		public InstallationManager(ConnectionMonitor connectionContext, Importer importer, IWebContext webContext, IPersister persister, ContentActivator activator)
		{
			this.connectionContext = connectionContext;
			this.importer = importer;
			this.webContext = webContext;
			this.persister = persister;
			this.activator = activator;
		}
Ejemplo n.º 5
0
 public ContentVersionRepository(IRepository<ContentVersion> repository, Exporter exporter, Importer importer, IUrlParser parser, IProxyFactory proxyFactory)
 {
     this.Repository = repository;
     this.exporter = exporter;
     this.importer = importer;
     this.parser = parser;
     this.proxyFactory = proxyFactory;
 }
Ejemplo n.º 6
0
 public InstallationManager(IHost host, IDefinitionManager definitions, Importer importer, IPersister persister, ISessionProvider sessionProvider, IConfigurationBuilder configurationBuilder, IWebContext webContext)
 {
     this.host = host;
     this.definitions = definitions;
     this.importer = importer;
     this.persister = persister;
     this.sessionProvider = sessionProvider;
     this.configurationBuilder = configurationBuilder;
     this.webContext = webContext;
 }
Ejemplo n.º 7
0
 public InstallationManager(IHost host, DefinitionMap map, ContentActivator activator, Importer importer, IPersister persister, ISessionProvider sessionProvider, IConfigurationBuilder configurationBuilder, IWebContext webContext)
 {
     this.host = host;
     this.map = map;
     this.activator = activator;
     this.importer = importer;
     this.persister = persister;
     this.sessionProvider = sessionProvider;
     this.configurationBuilder = configurationBuilder;
     this.webContext = webContext;
 }
Ejemplo n.º 8
0
		public InstallationManager(IHost host, DefinitionMap map, ContentActivator activator, Importer importer, IPersister persister, ISessionProvider sessionProvider, IConfigurationBuilder configurationBuilder, IWebContext webContext, ConnectionMonitor connectionContext, DatabaseSection config)
		{
			this.host = host;
			this.map = map;
			this.activator = activator;
			this.importer = importer;
			this.persister = persister;
			this.sessionProvider = sessionProvider;
			this.configurationBuilder = configurationBuilder;
			this.webContext = webContext;
			this.connectionContext = connectionContext;
			this.isDatabaseFileSystemEnbled = config.Files.StorageLocation == FileStoreLocation.Database;
		}
Ejemplo n.º 9
0
        internal static ContentItem Deserialize(Importer importer, IUrlParser parser, string xml)
        {
            if (importer == null)
                throw new ArgumentException("Importer cannot be null.", "importer");
            
            if (parser == null)
                throw new ArgumentException("Parser cannot be null.", "parser");

            if (String.IsNullOrEmpty(xml))
                return null; // nothing to deserialize

            var journal = importer.Read(new StringReader(xml));
            foreach (var link in journal.UnresolvedLinks.Where(ul => ul.IsChild == false))
            {
                var item = importer.Persister.Get(link.ReferencedItemID);
                if (item != null)
                    link.Setter(item);
            }

            if (journal.ReadItems == null)
                throw new Exception("Journal couldn't read items due to journal.ReadItems == null. " + xml);

            try
            {
                foreach (var item in journal.ReadItems)
                    (item as IInjectable<IUrlParser>).Set(parser);
            }
            catch (NullReferenceException nilX)
            {
                throw new Exception("Ran into a null reference while attempting to read items from the journal: " + xml, nilX);
            }

            if (journal.RootItem == null)
                return null;

            if (journal.RootItem.VersionOf.HasValue && journal.RootItem.VersionOf.Value != null)
                journal.RootItem.Parent = journal.RootItem.VersionOf.Parent;

            ReorderBySortOrderRecursive(journal.RootItem);

            return journal.RootItem;
        }
Ejemplo n.º 10
0
		public ContentVersion(Importer importer, Exporter exporter, IUrlParser parser)
		{
			Deserializer = (xml) => Deserialize(importer, parser, xml);
			Serializer = (item) => Serialize(exporter, item);
		}
Ejemplo n.º 11
0
		internal static ContentItem Deserialize(Importer importer, IUrlParser parser, string xml)
		{
			var journal = importer.Read(new StringReader(xml));
			foreach (var link in journal.UnresolvedLinks.Where(ul => ul.IsChild == false))
			{
				var item = importer.Persister.Get(link.ReferencedItemID);
				if (item != null)
					link.Setter(item);
			}
			foreach (var item in journal.ReadItems)
				(item as IInjectable<IUrlParser>).Set(parser);
			return journal.RootItem;
		}
        /* public void WriteFile(string name, string data)
        {
            var path = Path.Combine(_path, name);

            using (var ms = new MemoryStream())
            {
                var bytes = Encoding.UTF8.GetBytes(data);
                ms.Write(bytes, 0, bytes.Length);
                ms.Position = 0;
                _fs.WriteFile(path, ms);
            }
        } */

        public IImportRecord SyncItem(ReplicatedItem item)
        {
            lock (this)
            {
                try
                {
                    var reader = new ItemXmlReader(_definitions, _activator, _persister.Repository);
                    var importer = new Importer(null, reader, null);

                    // TODO download
                    var ins = _fs.OpenFile(item.Path, true);
                    var record = importer.Read(ins, item.Path);
                    if (record.RootItem != null)
                        ContentVersion.ReorderBySortOrderRecursive(record.RootItem);
                    return record;
                }
                catch (Exception ex)
                {
                    _logger.Error(string.Format("IMPORT Error: {0} - {1}", item.ID, ex.Message), ex);
                    throw;
                }
            }
        }
Ejemplo n.º 13
0
		public RavenInstallationManager(IHost host, DefinitionMap map, ContentActivator activator, Importer importer, IPersister persister, ISessionProvider sessionProvider, IConfigurationBuilder configurationBuilder, IWebContext webContext, ConnectionMonitor connectionContext, DatabaseSection config, RavenConnectionProvider cp)
			: base(connectionContext, importer, webContext, persister, activator)
		{
			this.cp = cp;
		}