private string ImportTBB(ImportItem importItem) { importItem.FixPublicationContext(Configuration.DyndleFolder); var templateBuildingBlockData = GetOrCreateNew <TemplateBuildingBlockData>(importItem); templateBuildingBlockData.Title = importItem.Name; templateBuildingBlockData.TemplateType = importItem.TemplateType; if (importItem.IsDyndleMergedDll) { // read the merged dll embedded resource and store it in the workfolder ResourceUtils.StoreResourceOnDisk(ResourceRootPath + "." + DyndleTemplateResourceName, Configuration.WorkFolder, DyndleTemplateResourceName); // get an access token (which is simply the current user var accessToken = Client.GetCurrentUser(); // first, upload the merged DLL with the upload client string pathOnServer = null; using (var uploadClient = CoreserviceClientFactory.GetUploadClient()) { using (FileStream stream = new FileStream(Path.Combine(Configuration.WorkFolder.FullName, DyndleTemplateResourceName), FileMode.Open)) { pathOnServer = uploadClient.UploadBinaryContent(accessToken, stream); } } // if all went well, we now have the path of the DLL on the server if (pathOnServer == null) { throw new Exception("unable to upload file"); } templateBuildingBlockData.BinaryContent = new BinaryContentData(); templateBuildingBlockData.BinaryContent.Filename = DyndleTemplateResourceName; templateBuildingBlockData.BinaryContent.UploadFromFile = pathOnServer; } else { templateBuildingBlockData.Content = importItem.Content; } if (!string.IsNullOrEmpty(importItem.ParameterSchemaId)) { templateBuildingBlockData.ParameterSchema = new LinkToSchemaData() { IdRef = importItem.ParameterSchemaId }; } templateBuildingBlockData = (TemplateBuildingBlockData)Client.Save(templateBuildingBlockData, new ReadOptions()); templateBuildingBlockData = (TemplateBuildingBlockData)Client.CheckIn(templateBuildingBlockData.Id, true, "Dyndle installer", new ReadOptions()); return(templateBuildingBlockData.Id); }
private string ImportComponentTemplate(ImportItem importItem) { importItem.FixPublicationContext(Configuration.DyndleFolder); var componentTemplateData = GetOrCreateNew <ComponentTemplateData>(importItem); componentTemplateData.Title = importItem.Name; componentTemplateData.Content = importItem.Content; componentTemplateData.TemplateType = importItem.TemplateType; componentTemplateData = (ComponentTemplateData)Client.Save(componentTemplateData, new ReadOptions()); componentTemplateData = (ComponentTemplateData)Client.CheckIn(componentTemplateData.Id, true, "Dyndle installer", new ReadOptions()); return(componentTemplateData.Id); }
private string ImportPageTemplate(ImportItem importItem) { importItem.FixPublicationContext(Configuration.DyndleFolder); var pageTemplateData = GetOrCreateNew <PageTemplateData>(importItem); pageTemplateData.Title = importItem.Name; pageTemplateData.Content = importItem.Content; pageTemplateData.FileExtension = importItem.FileExtension; pageTemplateData.TemplateType = importItem.TemplateType; pageTemplateData = (PageTemplateData)Client.Save(pageTemplateData, new ReadOptions()); pageTemplateData = (PageTemplateData)Client.CheckIn(pageTemplateData.Id, true, "Dyndle installer", new ReadOptions()); return(pageTemplateData.Id); }
private string ImportSchema(ImportItem importItem) { importItem.FixPublicationContext(Configuration.DyndleFolder); var schemaData = GetOrCreateNew <SchemaData>(importItem); schemaData.Title = importItem.Name; schemaData.NamespaceUri = importItem.Namespace; schemaData.RootElementName = importItem.RootElementName; schemaData.Xsd = importItem.Content; schemaData.Purpose = importItem.SchemaPurpose; schemaData.Description = importItem.Name; schemaData = (SchemaData)Client.Save(schemaData, new ReadOptions()); schemaData = (SchemaData)Client.CheckIn(schemaData.Id, true, "Dyndle installer", new ReadOptions()); return(schemaData.Id); }
private string ImportPage(ImportItem importItem) { importItem.FixPublicationContext(Configuration.DyndleStructureGroup); var pageData = GetOrCreateNew <PageData>(importItem); pageData.Title = importItem.Name; pageData.ComponentPresentations = JsonConvert.DeserializeObject <ComponentPresentationData[]>(importItem.Content); pageData.PageTemplate = new LinkToPageTemplateData() { IdRef = importItem.PageTemplateId }; pageData.FileName = importItem.Filename; pageData.IsPageTemplateInherited = false; pageData = (PageData)Client.Save(pageData, new ReadOptions()); pageData = (PageData)Client.CheckIn(pageData.Id, true, "Dyndle installer", new ReadOptions()); return(pageData.Id); }