More in this section

Forums / Developing with Sitefinity / Generic Content Provider with Metafields

Generic Content Provider with Metafields

9 posts, 0 answered
  1. Dave
    Dave avatar
    76 posts
    Registered:
    10 Mar 2008
    19 Mar 2008
    Link to this post
    Hi,

    I have a custom Provider and Manager that I want to take advantage of the Generic Content Metafields.  I've used IEventsProvider and EventsManager as a model to create INotesProvider and NotesManager (as well as a DefaultNotesProvider).  I want my custom content (Notes) to have two Metafields.  I've added the provider into web.config's telerik\cmsEngine\providers, and the Metafields (Notes.Type, Notes.TypeId) into \telerik\cmsEngine\metafields.  When I run the application, I get the error (Missing provider: Notes).  Am I missing something?
  2. Dave
    Dave avatar
    76 posts
    Registered:
    10 Mar 2008
    19 Mar 2008
    Link to this post
    Also, in case it wasn't obvious, the provider I added into \telerik\cmsEngine\providers is named "Notes", which I believe must match the prefix of the Metafields.
  3. Dave
    Dave avatar
    76 posts
    Registered:
    10 Mar 2008
    19 Mar 2008
    Link to this post
    It turns out I hadn't fully implemented the Provider and/or Manager correctly.  I believe the missing piece was a parameterless constructor for the manager to set its provider to a default. 
  4. Nikifor
    Nikifor avatar
    232 posts
    Registered:
    18 May 2013
    20 Mar 2008
    Link to this post
    Hi Dave,

    We are glad that you were able to solve the problem.

    Please, feel free to contact us in case you have any other questions or need help with new implementation. Also, please let us know if there has been any topic about which you have not found the needed information in the manuals or if any information is misleading.

    Sincerely yours,
    Nikifor Hristov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Dave
    Dave avatar
    76 posts
    Registered:
    10 Mar 2008
    21 Mar 2008
    Link to this post
    Thanks Nikifor,

    Actually I am having another problem - getting an exception running the following code:

    MetaSearchInfo objNoteTypeSearchInfo = new MetaSearchInfo(MetaValueTypes.ShortText, "NoteType", strType);
    MetaSearchInfo objNoteTypeIdSearchInfo = new MetaSearchInfo(MetaValueTypes.Guid, "NoteTypeId", gidTypeId);

    return this.GetContent(0, 0, String.Empty, String.Empty, ContentStatus.Published, null, objNoteTypeSearchInfo, objNoteTypeIdSearchInfo);

    It does not happen if I remove the MetaSearchInfo filters or change their keys to MetaFields that do not exist.  It appears the error is happening in DefaultProvider.LoadQuerySlow.

    I did some digging and it might be because the records in the sf_GCMetaData have null CntPrntId values.  I am not sure how this value is supposed to be set, but I am using the DefaultProvider.CreateContent, SetMetaData and SaveContent methods.
  6. Nikifor
    Nikifor avatar
    232 posts
    Registered:
    18 May 2013
    24 Mar 2008
    Link to this post
    Hi Dave,

    Unfortunately, we are not able to reproduce the issue on our side. Could you please provide us with the whole implementation of the code you are using? Additionally, please elaborate on the database which you are running, and the version of Sitefinity, under which the project was created. The stack trace of the exception you are getting can be of help too, so please send the Sitefinity.log file located in the YourWebSite\App_Data folder.

    Thank you for your cooperation.

    Best wishes,
    Nikifor
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  7. Dave
    Dave avatar
    76 posts
    Registered:
    10 Mar 2008
    25 Mar 2008
    Link to this post
    Hi Nikifor,

    I am hesitant to upload all of my code for public download, but maybe you can diagnose from this:

    using System; 
    using System.Collections; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Text; 
    using Telerik.Cms.Engine; 
    using Telerik.Cms.Engine.Data.Providers; 
     
    namespace ClientPortalModule.Data 
        public class DefaultClientPortalNotesProvider : ClientPortalNotesProvider, IClientPortalNotesProvider 
        { 
            #region IClientPortalNotesProvider Members 
     
            IContent IClientPortalNotesProvider.AddNote(string strAuthor, DateTime datPost, string strNoteType, Guid gidNoteTypeId, List<string> lstTags, string strText, bool blnInternal) 
            { 
                IContent objNote = this.CreateContent("text/html", Guid.NewGuid()); 
                objNote.Content = strText; 
     
                objNote.Status = ContentStatus.Published; 
     
                objNote.SetMetaData("Author", strAuthor); 
                objNote.SetMetaData("PostDate", datPost); 
                objNote.SetMetaData("NoteType", strNoteType); 
                objNote.SetMetaData("NoteTypeId", gidNoteTypeId); 
                objNote.SetMetaData("IsInternal", blnInternal); 
     
                if (lstTags != null
                { 
                    if (lstTags.Count > 0) 
                    { 
                        this.TagContent(objNote.ID, lstTags); 
                    } 
                } 
     
                this.SaveContent(objNote); 
     
                return objNote; 
            } 
     
            IList IClientPortalNotesProvider.GetNotes(string strType, Guid gidTypeId, bool blnIncludeInternal) 
            { 
                MetaSearchInfo objNoteTypeSearchInfo = new MetaSearchInfo(MetaValueTypes.ShortText, "NoteType", strType); 
                MetaSearchInfo objNoteTypeIdSearchInfo = new MetaSearchInfo(MetaValueTypes.Guid, "NoteTypeId", gidTypeId); 
                MetaSearchInfo objNoInternalSearchInfo = new MetaSearchInfo(MetaValueTypes.Boolean, "IsInternal"false); 
     
                if (!blnIncludeInternal) 
                { 
                    return this.GetContent(0, 0, String.Empty, String.Empty, ContentStatus.Published, null, objNoteTypeSearchInfo, objNoteTypeIdSearchInfo, objNoInternalSearchInfo); 
                } 
                return this.GetContent(0, 0, String.Empty, String.Empty, ContentStatus.Published, null, objNoteTypeSearchInfo, objNoteTypeIdSearchInfo); 
            } 
     
            string[] IClientPortalNotesProvider.GetUploadPathsByRoles(string[] strRoles) 
            { 
                var arrPaths = from r in DataManager.Instance.Clients where strRoles.Contains<string>(r.Role) select r.UploadPath; 
     
                return arrPaths.ToArray<string>(); 
            } 
            #endregion 
     
            public override string Application 
            { 
                get 
                { 
                    return "/ClientPortal/Notes"
                } 
            } 
        } 
     

    ClientPortalNotesProvider inherits from Telerik.Cms.Engine.Data.Providers.DefaultProvider.

    I've also noticed that the records in sf_GCMetaData have their Status field set to 0, while all the other records in there are set to 1.  I tried changing manually but it didn't seem to matter.  Thanks again.
  8. Nikifor
    Nikifor avatar
    232 posts
    Registered:
    18 May 2013
    27 Mar 2008
    Link to this post
    Hi Dave,

    Unfortunately, this code is insufficient for reproducing the exception you get. Could you please confirm which is the version of Sitefinity you are using, and what database. Also, please send us the exception you get. Actually, in the previous post we omitted to mention you need to open a support ticket and then send the requested files. This way, your code would not be publicly available.

    Looking forward to hearing from you.

    Best wishes,
    Nikifor
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  9. Dave
    Dave avatar
    76 posts
    Registered:
    10 Mar 2008
    27 Mar 2008
    Link to this post
    Thanks Nikifor, I've submitted it under Bug Reports.
Register for webinar
9 posts, 0 answered