示例#1
0
        private XmlExporter GenerateExportXml(bool includeContentGroups, bool resetAppGuid)
        {
            // Get Export XML
            var attributeSets = new AppRuntime(_zoneId, _appId).ContentTypes.FromScope(includeAttributeTypes: true);

            attributeSets = attributeSets.Where(a => !((IContentTypeShareable)a).AlwaysShareConfiguration);

            var attributeSetIds = attributeSets.Select(p => p.ContentTypeId.ToString()).ToArray();
            var templateTypeId  = SystemRuntime.GetMetadataType(Settings.TemplateContentType);
            var entities        =
                DataSource.GetInitialDataSource(_zoneId, _appId).Out["Default"].List.Where(
                    e => e.Value.Metadata.TargetType != templateTypeId &&
                    e.Value.Metadata.TargetType != Constants.MetadataForAttribute).ToList();

            if (!includeContentGroups)
            {
                entities = entities.Where(p => p.Value.Type.StaticName != _sexycontentContentgroupName).ToList();
            }

            var entityIds = entities
                            .Select(e => e.Value.EntityId.ToString()).ToArray();

            var xmlExport = Factory.Resolve <XmlExporter>()
                            .Init(_zoneId, _appId, true, attributeSetIds, entityIds);

            // var xmlExport = Factory.Container.Resolve<XmlExporter>(new ParameterOverrides { { "zoneId", _zoneId }, { "appId", _appId}, {"appExport", true}, { "contentTypeIds", attributeSetIds }, {"entityIds", entityIds} });
            // new ToSxcXmlExporter(_zoneId, _appId, true, attributeSetIds, entityIds);

            #region reset App Guid if necessary

            if (resetAppGuid)
            {
                var root    = xmlExport.ExportXDocument; //.Root;
                var appGuid = root.XPathSelectElement("/SexyContent/Header/App").Attribute("Guid");
                appGuid.Value = _blankGuid;
            }
            return(xmlExport);

            #endregion
        }