Copied to clipboard

Flag this post as spam?

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


  • Fengelz 106 posts 221 karma points
    Oct 15, 2009 @ 12:25
    Fengelz
    0

    ServerTimeout in document creation

    Hi.

    Im currenttly trying to read in some data from a spreadsheet into our umbraco solution.

    It is 213 nodes I need to create, but I keep getting a ServerTimeout Exception every 2. time I try to read in the data.

    Anybody experienced this when trying to create a large amount of documents?

    Heres my code:

    protected void Commit_Spreadsheet(object sender, EventArgs e)
        {
            string excelpath = httpcontext.Server.MapPath("/media/" + Spreadsheet.FileName);
            Base.Print(excelpath);
            Spreadsheet.SaveAs(excelpath);
            DataSet ds = FonqiCode.NET.Change.ExcelToDataSet(excelpath, "Total");
            Base.Print(ds.Tables[0].Rows.Count);
            int counter = 1;
            DocumentType dt = DocumentType.GetByAlias("Contact");
            User u = new User(0);
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                if (!String.IsNullOrEmpty(dr[0].ToString()))
                {
                    Document kontact = Document.MakeNew(dr[0].ToString(), dt, u, contactsFolderNodeId);
                    kontact.getProperty("Name").Value = dr[0];
                    kontact.getProperty("Title").Value = dr[1];
                    kontact.getProperty("Email").Value = dr[2];
                    kontact.Save();
                    //contact.Publish(u);
                    //umbraco.library.UpdateDocumentCache(contact.Id);
                    //Base.Print((counter++) + " " + dr[0] + ", " + dr[1] + ", " + dr[2]);
                }
            }
            //umbraco.library.UpdateDocumentCache(contactsFolderNodeId);
            Base.Print("Done");
        }

    Best regards 

    Sune Fengel

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Oct 15, 2009 @ 12:42
    Douglas Robar
    0

    Not a direct answer to your question, but you might find it quicker to use Richard's excellent umbImport tool, available in the projects section of the site.

    cheers,
    doug.

  • Fengelz 106 posts 221 karma points
    Oct 16, 2009 @ 10:37
    Fengelz
    0

    The umbImport tool looks great, I tried to convert my excel to csv to import it this way but it threw an exception, so I gave up on it. But maybe Ill try to convert the spreadsheet to xml. Only problem is I havn't been able to find out how the xml should be formatted.

    -Best regards 

    Sune Fengel

  • Richard Soeteman 4052 posts 12925 karma points MVP 2x
    Oct 16, 2009 @ 10:47
    Richard Soeteman
    1

    Hi Sune,

    csv  shouldn't be a problem. Check the exported format and apply the csv settings when uploading teh csv in umbImport. You can use xml also. The xml method accepts only elements..

    Cheers,

    Richard

  • Fengelz 106 posts 221 karma points
    Oct 16, 2009 @ 14:52
    Fengelz
    0

    Hi Richard

    Thanks for the great tool.

    I managed to tweak my csv file and save it as utf-8 and successfully imoprted all my data.

    So thanks for the help also.

    - Best regards 

    Sune Fengel

Please Sign in or register to post replies

Write your reply to:

Draft