Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sonja 133 posts 621 karma points
    Jun 10, 2019 @ 11:09
    Sonja
    0

    using Umbraco API from another dll

    Hi, I'm developing dll that will do some functionalities in umbraco. The dll execution is in the bin folder of umbraco page. I'm trying to get all document types from the database and do something with it. How do I initialize IContenttypeService?

    Example:

    protected static string umbracoConStr;
    protected static IContentTypeService contentTypeService;
    
        public UmbracoData(string path1)
        {
            var webConfigPath = Path.Combine(path1, "..", "Web.config");
            XDocument xdoc = XDocument.Load(webConfigPath);
            umbracoConStr = xdoc.Element("configuration").Element("connectionStrings").Elements("add").Where(c => c.Attribute("name").Value.Equals("umbracoDbDSN")).FirstOrDefault().Attribute("connectionString").Value;        
           //here I need to initialize contentTypeService somehow. PLEASE HELP
        }
    
    
        public static Dictionary<int,string>GetAllDocumentTypes()
        {
    
            var contentTypes = contentTypeService.GetAllContentTypes();
            var dt = new Dictionary<int, string>();
            foreach (var ct in contentTypes)
                dt.Add(ct.Id, ct.Name);
            return dt;
        }
    
  • Sonja 133 posts 621 karma points
    Jun 14, 2019 @ 05:28
    Sonja
    0

    Anybody? this should be similar like Chauffeur is working just not from command line but from application with interface

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies