I am writing a webservice to expose data collected in my process to a website.
I am access the data using the GetList method of the particular SmartObject. When I use a SQLDataReader, I am able to retrieve my results, but when I access this in code, I get no results returned, and no errors. If I change it to use the Load method and specify the parameter value, then I get results returned. I have even used the Developers Reference that comes with K2 [blackpearl] to check that the code is correct. Perhaps I'm overlooking something, or doing something wrong. Below is the code, can you see anything wrong?
public Vacancy GetAllVacancies()
{
Vacancy vac = new Vacancy();
string _user = ConfigurationManager.AppSettings["User"];
string _server = ConfigurationManager.AppSettings["Host"];
string _password = ConfigurationManager.AppSettings["Password"];
SourceCode.SmartObjects.Client.SmartObjectClientServer serverName = new SourceCode.SmartObjects.Client.SmartObjectClientServer();
SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder connectionString = new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();
//build the connection string
connectionString.Authenticate = true;
connectionString.Host = _server;
connectionString.Integrated = true;
connectionString.IsPrimaryLogin = true;
connectionString.Port = 5555;
connectionString.UserID = _user;
connectionString.Password = _password;
serverName.CreateConnection();
serverName.Connection.Open(connectionString.ToString());
try
{
SmartObject smoVacancy = serverName.GetSmartObject("Vacancy");
smoVacancy.MethodToExecute ="GetList";
SmartObjectList smoList = serverName.ExecuteList(smoVacancy);
foreach (SmartObject smo in smoList.SmartObjectsList)
{
vac.AdvertID = Convert.ToInt32(smoVacancy.Properties["AdvertID"].Value);
vac.NampeProfile = smoVacancy.Properties["NameProfile"].Value;
}
}
catch (Exception ex)
{
ex.Message.ToString();
}
finally
{
serverName.Connection.Close();
}
return vac;
}