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:
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 ?
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:
1: First of all, are my new items not published
2: All items get the exception, but is in the content tree
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
Hi Richard.
Iwe mistyped the last property, now i just get the exception:
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 !!!!
think its lucene.dll that makes the errors, can i just update it ?
Quick fix :
Still interesert in a better solution :)
Thx Richard !!!
I think you are using a datareader. And you didn't check if it was past its last record.
Cheers,
Richard
is working on a reply...