/// <summary> /// Chercher les reponses pour la question de la base SQL et les ajouter au value set pour item. /// </summary> /// <param name="item">Variable du dictionnaire CSPro</param> public void GetValueSet(DictionaryItem item) { try { if (String.IsNullOrEmpty(queryTemplate)) { return; } string query = queryTemplate.Replace("%item%", item.Label); var cmd = new SqlCommand(query, connection); using (var reader = cmd.ExecuteReader()) { if (reader.HasRows) { var valueSet = item.AddValueSet(); valueSet.Name = item.Name; int maxNameLen = 32; string valuesetPost = "_VS1"; if (valueSet.Name.Length > maxNameLen - valuesetPost.Length) { valueSet.Name = valueSet.Name.Substring(0, maxNameLen - valuesetPost.Length); } valueSet.Name += valuesetPost; valueSet.Label = item.Label; while (reader.Read()) { string codeReponse = reader.GetString(0); string libelleReponse = reader.GetString(1); var value = valueSet.AddValue(); value.Label = libelleReponse; value.AddValuePair(String.Format("{0," + item.Length + "}", codeReponse)); } } } } catch (Exception ex) { throw new Exception("Invalid value set query: " + ex.Message, ex.InnerException); } }