1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Import Documents Library Data

Import Documents Library Data

7 posts, 1 answered
  1. xor
    xor avatar
    42 posts
    Registered:
    04 Jan 2010
    13 Apr 2010
    Link to this post

    Hello,

    Sorry if this was answered anywhere.
    We have a client that has his documents library content stored in an excel file and the related documents stored in .pdf format on a disc copy, We need to import the library content to the Sitefinity database. What is the best approach for accomplishing this task? And how can we manage the links to the files knowing that we have the documents names stored along with the documents data?


    Thanks,
    Fadi Raheel

  2. xor
    xor avatar
    42 posts
    Registered:
    04 Jan 2010
    14 Apr 2010
    Link to this post
    Any thoughts, samples....? Please help, it is urgent.

    Thanks

  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    16 Apr 2010
    Link to this post
    Hi Fadi Raheel,

    The items in images and documents module are IContent objects. The IContent object has a property Content. You could create a new content item and set its content property to the related content that you store in excel.

    The content is stored in the database or file system as binary array and generally you do not have access to the actual data. The CMS generates a link that you can use the access the documents that you have created. If you want to manipulate the content of the documents through the CMS you need to create a parser that sets/gets the content of a selected item and open it as a content of RadEditor control.

    If there are any further questions, let me know.
    All the best,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  4. xor
    xor avatar
    42 posts
    Registered:
    04 Jan 2010
    21 Apr 2010
    Link to this post
    Hi Ivan Dimitrov,

    I am getting a problem when I try to run my code. Can you please tell me where i am mistaken?
    Below is my code and the stack trace.


    protected
    void NonAI_Click(object sender, EventArgs e)
    {
        Telerik.Libraries.LibraryManager libraryManager = new Telerik.Libraries.LibraryManager();
        // get library by specified Name
        Telerik.Libraries.ILibrary parentLibrary = libraryManager.GetLibrary("HRE External Resources");
        // create an image content item
        //Telerik.Cms.Engine.IContent newContent = libraryManager.CreateContent(MimeMapper.GetMimeMapping(filename));
        Telerik.Cms.Engine.IContent newContent = libraryManager.CreateContent("text/html");
        // specify parent library the image will belong to
        newContent.ParentID = parentLibrary.ID;
        //Telerik.Cms.Engine.ContentManager contentManager = new Telerik.Cms.Engine.ContentManager();
        //// create an empty content
        //Telerik.Cms.Engine.IContent newContent = contentManager.CreateContent("text/html");
        amnestyDataEntities model = new amnestyDataEntities();
        foreach (NonAILibrary item in model.NonAILibraries)
        {
            // save the initial content properties
            // note that properties such as ID are automatically
            // set by Sitefinity. This however does not mean that you cannot
            // change them
            newContent.Content = "... add some text";
            // set meta keys for the content item
            newContent.SetMetaData("Name", item.Title);
            newContent.SetMetaData("Description", item.Subject);
            newContent.SetMetaData("Author", item.Author);
            newContent.SetMetaData("Publisher", item.Publisher);
            //newContent.SetMetaData("Publication_Place", item.Place_of_Publication);
            newContent.SetMetaData("Publication_Year", item.Year_of_Publication);
            newContent.SetMetaData("Location", item.Location);
            string language = item.Language.ToLower();
            switch (language)
            {
                case "english":
                    newContent.SetMetaData("Language", "en");
                    break;
                case "arabic":
                    newContent.SetMetaData("Language", "ar");
                    break;
                default:
                    newContent.SetMetaData("Language", "en");
                    break;
            }
              
            //save the content
            libraryManager.SaveContent(newContent);
        }                        
    }

     

    Server Error in '/AmnestyLebanon.Web' Application.

    Value for property Url is too long. Maximun length is 256

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: Nolics.ORMapper.Base.LengthException: Value for property Url is too long. Maximun length is 256

    Source Error:

    Line 174:            
    Line 175:            //save the content
    Line 176: libraryManager.SaveContent(newContent);Line 177:        }                        
    Line 178:    }

    Source File: f:\HBPro\Projects\AmnestyLebanon\Main\Source\AmnestyLebanon.Web\Sitefinity\Default.aspx.cs    Line: 176

    and this is my StackTrace:

    Nolics.ORMapper.Base.LengthException was unhandled by user code
      Message=Value for property Url is too long. Maximun length is 256
      Source=Telerik.Cms.Engine.Data
      InvalidPropertyName=Url
      StackTrace:
           at Telerik.Cms.Engine.Data.CmsContentBase.nn_verifyData()
           at Telerik.Cms.Engine.Data.CmsContentBase.Nolics.ORMapper.Base.IOdbClass.BeginCommit()
           at Nolics.ORMapper.Base.Transaction.Commit(Boolean fCleanIfSuccess)
           at Nolics.ORMapper.Base.Transaction.Commit()
           at Telerik.Cms.Engine.Data.Providers.DefaultProvider.SaveContent(IContent content, Boolean fireEvents)
           at Telerik.Cms.Engine.ContentProviderBase.SaveContent(IContent content)
           at Telerik.Cms.Engine.ContentManager.SavedStagedContent(StagedContent staged, ContentStatus status)
           at Telerik.Cms.Engine.ContentManager.PublishContent(StagedContent staged)
           at Telerik.Cms.Engine.ContentManager.SaveContent(IContent content, ContentStatus status)
           at Telerik.Cms.Engine.ContentManager.SaveContent(IContent content)
           at Sitefinity_Default.NonAI_Click(Object sender, EventArgs e) in f:\HBPro\Projects\AmnestyLebanon\Main\Source\AmnestyLebanon.Web\Sitefinity\Default.aspx.cs:line 176
           at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
           at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
           at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
           at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
           at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
           at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
      InnerException: 



    Thanks and regards,

    Fadi
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    21 Apr 2010
    Link to this post
    Hello Fadi Raheel,

    The value of the content item title is too long - Url is too long. Maximun length is 256

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  6. xor
    xor avatar
    42 posts
    Registered:
    04 Jan 2010
    21 Apr 2010
    Link to this post

    I didn't provide a value for Url and even if I set it to null, I get that same issue.

    Fadi.

     

  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    21 Apr 2010
    Link to this post
    Hi Fadi Raheel,

    If you do not set the url this means that your item does not have title. You are setting the url by calling
    newContent.SetMetaData("Name", item.Title); which results as an error. The Url is formed by the providername, libraryname and content item name.

    ~/Libraries/MyDocuments/UserManual_3_7

    You get the error when nolics try to populate [sf_CmsContentBase] table.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
    Answered
Register for webinar
7 posts, 1 answered