schedul task with custom table

web dev asked on July 17, 2018 02:01

hello kentico dev i try to execute a schedul task to read csv file and save the data into custom table but i think but nothing created any one have idea but it thanks` string filePath = @"C:\convertcsv.csv";

    // Check if file exists.
    int datacreated = 0;
    int dataupdated = 0;
    int dataerror = 0;
    try {
        if (File.Exists(filePath))

            // Read column headers from file
            CsvReader csv = new CsvReader(File.OpenText(filePath));

            List<string> headers = csv.Context.HeaderRecord.ToList();

            // Prepares the code name (class name) of the custom table to which the data record will be added
            string customTableClassName = "AT.People";

            // Gets the custom table
            DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName);
            if (customTable != null)
                // Creates a new custom table item
                CustomTableItem newCustomTableItem = CustomTableItem.New(customTableClassName);

                // Sets the values for the fields of the custom table (ItemText in this case)

                // Save the new custom table record into the database
                EventLogProvider.LogInformation("No parent", "No parent", "Page can't be created as there is no parent page.");

    catch (Exception ex)
    string result = datacreated + " data are created and " + dataupdated + " data are updated and " + dataerror + " data have errors.";
    return result;`

Recent Answers

Peter Mogilnitski answered on July 17, 2018 04:16

Try to do exactly the same thing but manually: go to admin interface of your custom table and try to add a record with empty email only. See if this works. Most likely you have some constraints on your table.

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on July 17, 2018 12:24

Did you try to debug and see where it stops?

As I currently don't see anything filling the filePath. Is there any result being returned in the tasks module? Or any error?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.