Ejemplo n.º 1
0
        public void CreatePressArticleWithCustomTaxonomy(string title, string url, string taxonomyName, IEnumerable <string> taxonNames, bool isHierarchicalTaxonomy = false)
        {
            // Set the provider name for the DynamicModuleManager here. All available providers are listed in
            // Administration -> Settings -> Advanced -> DynamicModules -> Providers
            var providerName = string.Empty;

            if (ServerOperations.MultiSite().CheckIsMultisiteMode())
            {
                providerName = "dynamicContentProvider";
            }

            DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(providerName);
            Type pressArticleType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.PressRelease.PressArticle");

            Telerik.Sitefinity.DynamicModules.Model.DynamicContent pressArticleItem = dynamicModuleManager.CreateDataItem(pressArticleType);

            // This is how values for the properties are set
            pressArticleItem.SetValue("Title", title);
            pressArticleItem.SetValue("PublishedBy", "Some PublishedBy");
            pressArticleItem.SetValue("Guid", Guid.NewGuid());

            this.AddCustomTaxonomy(taxonNames, taxonomyName, pressArticleItem, isHierarchicalTaxonomy);

            pressArticleItem.SetString("UrlName", url);
            pressArticleItem.SetValue("Owner", SecurityManager.GetCurrentUserId());
            pressArticleItem.SetValue("PublicationDate", DateTime.Now);
            pressArticleItem.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName, "Published");
            dynamicModuleManager.Lifecycle.Publish(pressArticleItem);

            // You need to call SaveChanges() in order for the items to be actually persisted to data store
            dynamicModuleManager.SaveChanges();
        }
        public void CreateFieldWithTitle(string title, string dynamicurl)
        {
            // Set the provider name for the DynamicModuleManager here. All available providers are listed in
            // Administration -> Settings -> Advanced -> DynamicModules -> Providers
            var providerName = string.Empty;

            if (ServerOperations.MultiSite().CheckIsMultisiteMode())
            {
                providerName = "dynamicContentProvider";
            }

            DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(providerName);
            Type allTypes = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.AllTypesModule.Alltypes");

            Telerik.Sitefinity.DynamicModules.Model.DynamicContent allTypesItem = dynamicModuleManager.CreateDataItem(allTypes);

            // This is how values for the properties are set
            allTypesItem.SetValue("Title", title);

            Address address = new Address();

            allTypesItem.SetValue("Address", address);

            allTypesItem.SetString("UrlName", dynamicurl);
            allTypesItem.SetValue("Owner", SecurityManager.GetCurrentUserId());
            allTypesItem.SetValue("PublicationDate", DateTime.Now);
            allTypesItem.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName, "Published");
            dynamicModuleManager.Lifecycle.Publish(allTypesItem);

            // You need to call SaveChanges() in order for the items to be actually persisted to data store
            dynamicModuleManager.SaveChanges();
        }
Ejemplo n.º 3
0
        public void CreatePressArticle(string title, string url, Guid tag, Guid category, string publishedBy, string providerName)
        {
            if (ServerOperations.MultiSite().CheckIsMultisiteMode() && providerName == null)
            {
                providerName = "dynamicContentProvider";
            }

            DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(providerName);
            Type pressArticleType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.PressRelease.PressArticle");

            Telerik.Sitefinity.DynamicModules.Model.DynamicContent pressArticleItem = dynamicModuleManager.CreateDataItem(pressArticleType);

            // This is how values for the properties are set
            pressArticleItem.SetValue("Title", title);
            pressArticleItem.SetValue("Guid", Guid.NewGuid());

            if (publishedBy.IsNullOrEmpty())
            {
                pressArticleItem.SetValue("PublishedBy", "Some PublishedBy");
            }
            else
            {
                pressArticleItem.SetValue("PublishedBy", publishedBy);
            }

            if (tag != null && tag != Guid.Empty)
            {
                pressArticleItem.Organizer.AddTaxa("Tags", tag);
            }

            if (category != null && category != Guid.Empty)
            {
                pressArticleItem.Organizer.AddTaxa("Category", category);
            }

            pressArticleItem.SetString("UrlName", url);
            pressArticleItem.SetValue("Owner", SecurityManager.GetCurrentUserId());
            pressArticleItem.SetValue("PublicationDate", DateTime.Now);
            pressArticleItem.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName, "Published");
            dynamicModuleManager.Lifecycle.Publish(pressArticleItem);

            // You need to call SaveChanges() in order for the items to be actually persisted to data store
            dynamicModuleManager.SaveChanges();
        }
Ejemplo n.º 4
0
        public DynamicContent CreatePressArticleItem(string title, string url)
        {
            var providerName = string.Empty;

            if (ServerOperations.MultiSite().CheckIsMultisiteMode())
            {
                providerName = "dynamicContentProvider";
            }

            DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(providerName);
            Type pressArticleType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.PressRelease.PressArticle");

            Telerik.Sitefinity.DynamicModules.Model.DynamicContent pressArticleItem = dynamicModuleManager.CreateDataItem(pressArticleType);

            // This is how values for the properties are set
            pressArticleItem.SetValue("Title", title);
            pressArticleItem.SetValue("PublishedBy", "Some PublishedBy");
            pressArticleItem.SetValue("Guid", Guid.NewGuid());

            TaxonomyManager taxonomyManager = TaxonomyManager.GetManager();
            var             tag             = taxonomyManager.GetTaxa <FlatTaxon>().Where(t => t.Taxonomy.Name == "Tags").FirstOrDefault();

            if (tag != null)
            {
                pressArticleItem.Organizer.AddTaxa("Tags", tag.Id);
            }

            pressArticleItem.SetString("UrlName", url);
            pressArticleItem.SetValue("Owner", SecurityManager.GetCurrentUserId());
            pressArticleItem.SetValue("PublicationDate", DateTime.Now);
            pressArticleItem.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName, "Published");
            dynamicModuleManager.Lifecycle.Publish(pressArticleItem);

            dynamicModuleManager.RecompileDataItemsUrls(pressArticleType);

            // You need to call SaveChanges() in order for the items to be actually persisted to data store
            dynamicModuleManager.SaveChanges();

            return(pressArticleItem);
        }