Copied to clipboard

Flag this post as spam?

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


  • Jacob Jensen 10 posts 31 karma points
    Mar 27, 2011 @ 08:43
    Jacob Jensen
    0

    Trying to dynamically create multiple nodes, performance and exception question

    Hi experts

    Iam trying to create nodes in the content tree dynamically, in an old version 4.0.3, FW2.0, high performance pc, Its about 300 items, with 15 singletext properties, my code is:

     

           public static string CreateRegister(string id, string vname, string name, string add, string add2, string zip, string city, string phone, string fax, string email, string homepage, string employees, string description, bool member, bool visning)
            {
                try
                {
                    //Get the type you would like to use by its alias 
                    //and the user who should be the creator of the document 
                    DocumentType dt = DocumentType.GetByAlias("Register");
                    User author = User.GetUser(0);
    
                    //create a document with a name, a type, an umbraco user, and the ID of the document's parent page. 
                    //To create a document at the root of umbraco, use the id -1 
    
                    Document doc = Document.MakeNew(vname, dt, author, 38549);
    
                    //after creating the document, prepare it for publishing 
    
                    doc.getProperty("id").Value = id;
                    doc.getProperty("vname").Value = vname;
                    doc.getProperty("name").Value = name;
                    doc.getProperty("add1").Value = add;
                    doc.getProperty("add2").Value = add2;
                    doc.getProperty("zip").Value = zip;
                    doc.getProperty("city").Value = city;
                    doc.getProperty("phone").Value = phone;
                    doc.getProperty("fax").Value = fax;
                    doc.getProperty("email").Value = email;
                    doc.getProperty("homepage").Value = homepage;
                    doc.getProperty("employees").Value = employees;
                    doc.getProperty("description").Value = description;
                    doc.getProperty("member").Value = member ? 1 : 0;
                    doc.getProperty("visning").Value = visning ? 1 : 0;
                    doc.Publish(author);
    
                }
                catch (Exception e)
                {
                    return e.Message;
                    throw;
                }
    
                return "Success";
            }

     

    1: First of all, are my new items not published

    2: All items get the exception, but is in the content tree

    System.NullReferenceException was caught
      Message=Object reference not set to an instance of an object.
      Source=Code
      StackTrace:
           at Code.ErhvervKal.CreateRegister(String id, String vname, String name, String add, String add2, String zip, String city, String phone, String fax, String email, String homepage, String employees, String description, Boolean member, Boolean visning) in C:\Users\Jacob\Documents\ErhvervKalundborg\Code\Code\Class1.cs:line 98
      InnerException: 
    
    3: The process stops after 1000 items, cant find an exception, visual studio just popups and attaching to w3 process and tells me that lucene.dll is locked by another process.
    4: iam am execution the command from an xsltextension:
    <Import type="Virksomhed" id="{@cId}" navn="{@firmanavn}" import="{EK:CreateRegister(@cId, @firmanavn, @cPerson1, @add, @add2, @zip, @city, @phone, @fax, @main, 'homepage', 'employees', @desc, @o1, @o2)}"/>
    Can anyone help me out, just ask for more information.
    Best regards
    /Jacob
  • Richard Soeteman 4045 posts 12898 karma points MVP 2x
    Mar 27, 2011 @ 09:15
    Richard Soeteman
    0

    Hi Jacob,

    To answer your questions:

    1. The you need to call umbraco.library.updateCache(documentId) to update the umbraco.config file also

    2. Think you mistyped a property Name

    3. That is because your timeout is too low

    4. That makes no difference.

    Have you tried CMSImport? This adresses all of these issues and you don't need do program. The current version also works on 4.0.3

    Cheers,

    Richard

     

  • Jacob Jensen 10 posts 31 karma points
    Mar 27, 2011 @ 09:32
    Jacob Jensen
    0

    Hi Richard.

    Iwe mistyped the last property, now i just get the exception:

    read past EOF

    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: System.IO.IOException: read past EOF
    Source Error:

    But i get the same exception when i publish in umbraco admin, but not in the live environment. 

    Iwe counted the Documents to 351, when i juse < 100 it works, < 200 visual studio stops the process, with the lucine.dll errror 

    Its to late to use CMSImport, deadline tomorrow :)

    Are threathing a possibility ? think the lucene.dll cant handle all the publishing ?

    THX !!!!

  • Jacob Jensen 10 posts 31 karma points
    Mar 27, 2011 @ 09:40
    Jacob Jensen
    0

    think its lucene.dll that makes the errors, can i just update it ?

  • Jacob Jensen 10 posts 31 karma points
    Mar 27, 2011 @ 10:03
    Jacob Jensen
    0

    Quick fix :

      <xsl:apply-templates select="msxml:node-set($test)//c[@o2 = 1 and @firmanavn != '' and position() &lt; 200]">
                    <xsl:sort select="@firmanavn" data-type="text" />
                </xsl:apply-templates>
    
                <xsl:apply-templates select="msxml:node-set($test)//c[@o2 = 1 and @firmanavn != '' and position() &gt;= 200]">
                    <xsl:sort select="@firmanavn" data-type="text" />
                </xsl:apply-templates>

    Still interesert in a better solution :)

     

    Thx Richard !!!

  • Richard Soeteman 4045 posts 12898 karma points MVP 2x
    Mar 28, 2011 @ 09:35
    Richard Soeteman
    0

    I think you are using a datareader. And you didn't check if it was past its last record.

    Cheers,

    Richard

Please Sign in or register to post replies

Write your reply to:

Draft