0

There is an umbraco form entry process on a website that I am attempting to mimic from within a mobile app. As it stands I have a web service that the app talks to, the web service is hosted in the location of the web site and uses Umbraco.Forms.Storage to programmatically enter a Record.

This all works fine and the entries from the mobile app are added to the form Enties table within Umbraco-Contour.

However, I'd like to check that an entry being made is not going to be a duplicate of something already entered. So I wanted to grab all the records entered that match a specific field entry. I am not doing any of this using XSLT, but instead doing it in C# using the Umbraco libraries.

private List<Record> GetRecordsMatchingEmail(string sEmail)
{
    RecordStorage oRStorage;
    List<Record> oMatchedRecords;
    RecordField oField;
    //
    oRStorage = new RecordStorage();
    oMatchedRecords = new List<Record>();
    foreach (var oRec in oRStorage.GetAllRecords(new Guid(FORM_GUID)))
    {
        oField = oRec.RecordFields[new Guid(EMAIL_FIELD_GUID)];
        //
        if (oField.Values.Count < 1 || !sEmail.Equals(oField.Values[0] as string))
            continue;
        //
        oMatchedRecords.Add(oRec);
    }
    //
    return oMatchedRecords;
}

When I run this method on the web service the connection always times out. When I try to trace what is going on with SQL Profiler I see lot's a hits on the DB going to different tables. I don't understand what is happening when this code runs, as I would expect it to just grab all the records entered for the specified form. Doing something similar from within the /Umbraco/Contour portion of the web site causes a totally different SQL command (as seen in profiler) so why is the code version not performing the same sort of query?

All I am after is a way to extract all the records entered for a particular form. I thought GetAllRecords(Guid) using the forms Guid would do that. Has anyone done something similar to this, using pure C# code?

Thanks for helping.

Louis Sherwood
  • 137
  • 2
  • 14

1 Answers1

0

You can try to use:

oField.GetRecordField["Email"].ValuesAsString()

instead of:

oField.Values[0] as string

But I'm not sure it will help

Dzianis Yafimau
  • 2,034
  • 1
  • 27
  • 38