public static AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownContents2(string knownCategoryValues, string category) { alexiaEntities contexto = new alexiaEntities(); StringDictionary detalles = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues); int cadena = Convert.ToInt32(detalles["padreCicle"]); List <cursos> cursos = (from c in contexto.cursos where c.id_cicle == cadena select c).ToList(); AjaxControlToolkit.CascadingDropDownNameValue[] resultados = new AjaxControlToolkit.CascadingDropDownNameValue[cursos.Count]; AjaxControlToolkit.CascadingDropDownNameValue curso; int i = 0; foreach (cursos item in cursos) { curso = new AjaxControlToolkit.CascadingDropDownNameValue(); curso.name = item.codi; curso.value = item.id.ToString(); resultados[i] = curso; i++; } return(resultados); }
public static AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownContents(string knownCategoryValues, string category) { aulacepEntities contexto = new aulacepEntities(); List <cicles> ciclos = (from c in contexto.cicles select c).ToList(); AjaxControlToolkit.CascadingDropDownNameValue[] resultados = new AjaxControlToolkit.CascadingDropDownNameValue[ciclos.Count]; int i = 0; foreach (cicles item in ciclos) { AjaxControlToolkit.CascadingDropDownNameValue res = new AjaxControlToolkit.CascadingDropDownNameValue(); res.name = item.codi; res.value = item.id.ToString(); resultados[i] = res; i++; } return(resultados); }
public static AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownContents4(string knownCategoryValues, string category) { alexiaEntities contexto = new alexiaEntities(); StringDictionary detalles = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues); int cadena = Convert.ToInt32(detalles["hijoCurs"]); List <ufs> uf = (from c in contexto.ufs where c.id_modul_prof == cadena select c).ToList(); AjaxControlToolkit.CascadingDropDownNameValue[] resultados = new AjaxControlToolkit.CascadingDropDownNameValue[uf.Count]; AjaxControlToolkit.CascadingDropDownNameValue uf_cascading; int i = 0; foreach (ufs item in uf) { uf_cascading = new AjaxControlToolkit.CascadingDropDownNameValue(); uf_cascading.name = item.nom; uf_cascading.value = item.id.ToString(); resultados[i] = uf_cascading; i++; } return(resultados); }
public static AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownContents5(string knownCategoryValues, string category) { alexiaEntities contexto = new alexiaEntities(); StringDictionary detalles = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues); int cadena = Convert.ToInt32(detalles["hijoModul"]); List <avaluacions> av = (from c in contexto.avaluacions select c).ToList(); AjaxControlToolkit.CascadingDropDownNameValue[] resultados = new AjaxControlToolkit.CascadingDropDownNameValue[av.Count]; AjaxControlToolkit.CascadingDropDownNameValue aval_cascading; int i = 0; foreach (avaluacions item in av) { aval_cascading = new AjaxControlToolkit.CascadingDropDownNameValue(); aval_cascading.name = item.nom; aval_cascading.value = item.id.ToString(); resultados[i] = aval_cascading; i++; } return(resultados); }
public static AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownContents3(string knownCategoryValues, string category) { alexiaEntities contexto = new alexiaEntities(); StringDictionary detalles = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues); int cadena = Convert.ToInt32(detalles["hijoCicle"]); List <moduls_prof> modul_prof = (from c in contexto.moduls_prof where c.id_curs == cadena select c).ToList(); AjaxControlToolkit.CascadingDropDownNameValue[] resultados = new AjaxControlToolkit.CascadingDropDownNameValue[modul_prof.Count]; AjaxControlToolkit.CascadingDropDownNameValue modul; int i = 0; foreach (moduls_prof item in modul_prof) { modul = new AjaxControlToolkit.CascadingDropDownNameValue(); modul.name = item.nom; modul.value = item.id.ToString(); resultados[i] = modul; i++; } return(resultados); }
public static AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownContents(string knownCategoryValues, string category) { alexiaEntities contexto = new alexiaEntities(); StringDictionary kv = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues); List <cicles> ciclos = (from c in contexto.cicles select c).ToList(); AjaxControlToolkit.CascadingDropDownNameValue[] resultados = new AjaxControlToolkit.CascadingDropDownNameValue[ciclos.Count]; AjaxControlToolkit.CascadingDropDownNameValue ciclo; int i = 0; foreach (cicles item in ciclos) { ciclo = new AjaxControlToolkit.CascadingDropDownNameValue(); ciclo.name = item.nom; ciclo.value = item.id.ToString(); resultados[i] = ciclo; i++; } return(resultados); }
public static AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownContents2(string knownCategoryValues, string category) { aulacepEntities contexto = new aulacepEntities(); StringDictionary kv = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues); int id_ciclo = int.Parse(kv["ciclos"]); List <cursos> l_cursos = (from c in contexto.cursos where c.id_cicle == id_ciclo select c).ToList(); AjaxControlToolkit.CascadingDropDownNameValue[] resultados = new AjaxControlToolkit.CascadingDropDownNameValue[l_cursos.Count]; int i = 0; foreach (cursos item in l_cursos) { AjaxControlToolkit.CascadingDropDownNameValue res = new AjaxControlToolkit.CascadingDropDownNameValue(); res.name = item.codi; res.value = item.id.ToString(); resultados[i] = res; i++; } return(resultados); }
public CascadingDropDownNameValue[] GetAmandamentTemplates(string knownCategoryValues, string category, string contextKey) { List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); List<AmandamentTemplateEntity> list = new AmandamentTemplateMapper().ListWithAdvancedFilter("", StatusEnum.Active); foreach (AmandamentTemplateEntity entity in list) { CascadingDropDownNameValue cdnv; cdnv = new CascadingDropDownNameValue(entity.Title, entity.AmandamentTemplateId.ToString()); values.Add(cdnv); } return values.ToArray(); }
public virtual CascadingDropDownNameValue[] GetCountries() { CascadingDropDownNameValue[] values = new CascadingDropDownNameValue[Controller.Offer.Countries.Count]; for (int i = 0; i < Controller.Offer.Countries.Count; i++) values[i] = new CascadingDropDownNameValue (Controller.Offer.Countries[i].Name, Controller.Offer.Countries[i].Code, (i == 0)); //CascadingDropDownNameValue[] values = new CascadingDropDownNameValue[3]; //CascadingDropDownNameValue usa = new CascadingDropDownNameValue("United States", "US", true); //CascadingDropDownNameValue canada = new CascadingDropDownNameValue("Canada", "CA"); //CascadingDropDownNameValue australia = new CascadingDropDownNameValue("Australia", "AU"); //values[0] = usa; //values[1] = canada; //values[2] = australia; return values; }
public CascadingDropDownNameValue[] GetBanks(string knownCategoryValues, string category, string contextKey) { List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); List<BankEntity> list = new BankMapper().ListWithAdvancedFilter("", StatusEnum.Active); foreach (BankEntity ent in list) { CascadingDropDownNameValue cdnv; if (ent.Title == contextKey) { cdnv = new CascadingDropDownNameValue(ent.Title, ent.Id.ToString(), true); } else { cdnv = new CascadingDropDownNameValue(ent.Title, ent.Id.ToString()); } values.Add(cdnv); } return values.ToArray(); }
public CascadingDropDownNameValue[] GetContractTemplatesFromCurrentJobDetails(string knownCategoryValues, string category, string contextKey) { List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); Dictionary<int, string> list = new ContractTemplateMapper().ListTemplateContractsFromCurrentJobDetails(); foreach (KeyValuePair<int, string> kvp in list) { CascadingDropDownNameValue cdnv; cdnv = new CascadingDropDownNameValue(kvp.Value, kvp.Key.ToString()); values.Add(cdnv); } return values.ToArray(); }
public CascadingDropDownNameValue[] GetEducationTrainingLevels(string knownCategoryValues, string category, string contextKey) { List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); string[] organizationalLevelNames = Enum.GetNames(typeof(EducationTrainingLevelEnum)); Array organizationalLevelValues = Enum.GetValues(typeof(EducationTrainingLevelEnum)); CascadingDropDownNameValue cdnv; for (int i = 1; i <= organizationalLevelNames.Length - 1; i++) { if (organizationalLevelNames[i] == contextKey) { cdnv = new CascadingDropDownNameValue(organizationalLevelNames[i], i.ToString(), true); } else { cdnv = new CascadingDropDownNameValue(organizationalLevelNames[i], i.ToString()); } values.Add(cdnv); } return values.ToArray(); }
/// <summary> /// A helper method to provide simple implementation of a method to query a data set and return relevant dropdown content. /// </summary> /// <param name="document">XML document containing the data set</param> /// <param name="documentHierarchy">List of strings representing the hierarchy of the data set</param> /// <param name="knownCategoryValuesDictionary">Known category/value pairs</param> /// <param name="category">Category for which the drop down contents are desired</param> /// <param name="inputValidationRegex">Regular expression used to validate user input to the web service (to prevent XPath injection attacks)</param> /// <returns>Contents of the specified drop down subject to the choices already made</returns> public static CascadingDropDownNameValue[] QuerySimpleCascadingDropDownDocument(XmlDocument document, string[] documentHierarchy, StringDictionary knownCategoryValuesDictionary, string category, Regex inputValidationRegex) { // Validate parameters if(document == null) throw new ArgumentNullException("document"); if(documentHierarchy == null) throw new ArgumentNullException("documentHierarchy"); if(knownCategoryValuesDictionary == null) throw new ArgumentNullException("knownCategoryValuesDictionary"); if(category == null) throw new ArgumentNullException("category"); if(inputValidationRegex == null) throw new ArgumentNullException("inputValidationRegex"); // Validate input foreach(string key in knownCategoryValuesDictionary.Keys) if(!inputValidationRegex.IsMatch(key) || !inputValidationRegex.IsMatch(knownCategoryValuesDictionary[key])) throw new ArgumentException("Invalid characters present.", "category"); if(!inputValidationRegex.IsMatch(category)) throw new ArgumentException("Invalid characters present.", "category"); // Root the XPath query var xpath = "/" + document.DocumentElement.Name; // Build an XPath query into the data set to select the relevant items foreach(var key in documentHierarchy) if(knownCategoryValuesDictionary.ContainsKey(key)) xpath += String.Format(CultureInfo.InvariantCulture, "/{0}[(@name and @value='{1}') or (@name='{1}' and not(@value))]", key, knownCategoryValuesDictionary[key]); xpath += ("/" + category.ToLowerInvariant()); // Perform the XPath query and add the results to the list var result = new List<CascadingDropDownNameValue>(); foreach(XmlNode node in document.SelectNodes(xpath)) { var name = node.Attributes.GetNamedItem("name").Value; var valueNode = node.Attributes.GetNamedItem("value"); var value = ((valueNode != null) ? valueNode.Value : name); var defaultNode = node.Attributes.GetNamedItem("default"); var defaultValue = ((defaultNode != null) ? bool.Parse(defaultNode.Value) : false); var dropDownOptionItem = new CascadingDropDownNameValue(name, value, defaultValue); var optionTitleNode = node.Attributes.GetNamedItem("optionTitle"); var optionTitle = ((optionTitleNode != null) ? optionTitleNode.Value : String.Empty); dropDownOptionItem.optionTitle = optionTitle; result.Add(dropDownOptionItem); } return result.ToArray(); }
public CascadingDropDownNameValue[] GetContractsTemplates(string knownCategoryValues, string category) { List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); List<ContractTemplateEntity> list = new ContractTemplateMapper().ListWithAdvancedFilter("", StatusEnum.Active); foreach (ContractTemplateEntity ent in list) { CascadingDropDownNameValue cdnv = new CascadingDropDownNameValue(ent.Title, ent.Id.ToString()); values.Add(cdnv); } return values.ToArray(); }
public CascadingDropDownNameValue[] GetWorkTypes(string knownCategoryValues, string category, string contextKey) { List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); string[] workTypesNames = Enum.GetNames(typeof(WorkType)); Array workTypesValues = Enum.GetValues(typeof(WorkType)); CascadingDropDownNameValue cdnv; for (int i = 1; i <= workTypesNames.Length - 1; i++) { if (workTypesNames[i] == contextKey) { cdnv = new CascadingDropDownNameValue(workTypesNames[i], i.ToString(), true); } else { cdnv = new CascadingDropDownNameValue(workTypesNames[i], i.ToString()); } values.Add(cdnv); } return values.ToArray(); }
public CascadingDropDownNameValue[] GetJobTitlesByOrganisationalUnit(string knownCategoryValues, string category, string contextKey) { StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues); List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); int organisationalId; if (!kv.ContainsKey("OrganizationalUnit") || !Int32.TryParse(kv["OrganizationalUnit"], out organisationalId)) { List<JobTitleView> list = new JobTitleMapper().ListByOrganisationalUnitId(null, "", StatusEnum.Active); foreach (JobTitleView ent in list) { CascadingDropDownNameValue cdnv; if (ent.Title == contextKey) { cdnv = new CascadingDropDownNameValue(ent.Title, ent.Code, true); values.Add(cdnv); } else { cdnv = new CascadingDropDownNameValue(ent.Title, ent.Code); values.Add(cdnv); } } } else { List<JobTitleView> list = new JobTitleMapper().ListByOrganisationalUnitId(organisationalId, "", StatusEnum.Active); foreach (JobTitleView ent in list) { CascadingDropDownNameValue cdnv; if (ent.Title == contextKey) { cdnv = new CascadingDropDownNameValue(ent.Title, ent.Code, true); values.Add(cdnv); } else { cdnv = new CascadingDropDownNameValue(ent.Title, ent.Code); values.Add(cdnv); } } } return values.ToArray(); }
public CascadingDropDownNameValue[] GetRoles(string knownCategoryValues, string category) { List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); List<RoleEntity> list = new RoleMapper().List(""); foreach (RoleEntity ent in list) { CascadingDropDownNameValue cdnv = new CascadingDropDownNameValue(ent.Title, ent.Id.ToString()); values.Add(cdnv); } return values.ToArray(); }
public CascadingDropDownNameValue[] GetPaymentTypesByLeaveType(string knownCategoryValues, string category) { StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues); int leaveTypelId; if (!kv.ContainsKey("LeaveTypes") || !Int32.TryParse(kv["LeaveTypes"], out leaveTypelId)) { return null; } List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); List<LeaveTypeLevelEntity> list = new LeaveTypeLevelMapper().List(leaveTypelId); foreach (LeaveTypeLevelEntity ent in list) { CascadingDropDownNameValue cdnv = new CascadingDropDownNameValue(ent.LeaveNameType.ToString(), ent.Id.ToString()); values.Add(cdnv); } return values.ToArray(); }
public static CascadingDropDownNameValue[] GetDropDownContentsByCounty(string knownCategoryValues, string category) { IApplicationContext ctx = ContextRegistry.GetContext(); ICommonService commonService = ctx["CommonService"] as ICommonService; IBaseService baseService = ctx["BaseService"] as IBaseService; AjaxControlToolkit.CascadingDropDownNameValue[] dvs = null; IApplicationCacheFoundationDate applicationCacheFoundationDate = ctx["ApplicationCacheFoundationDate"] as IApplicationCacheFoundationDate; System.Collections.ArrayList List = new ArrayList(); if (category == "Country") { List<Country> CountryTable = new List<Country>(); Country country1 = new Country("CANADA"); country1.Code = "CA"; Country country2 = new Country("United States"); country2.Code = "US"; CountryTable.Add(country1); CountryTable.Add(country2); for (int index = 0; index < CountryTable.Count; index++) { if (CountryTable[index] != null) { AjaxControlToolkit.CascadingDropDownNameValue dv = new AjaxControlToolkit.CascadingDropDownNameValue(CountryTable[index].Name, CountryTable[index].Code); List.Add(dv); } } } if (List.Count > 0) { dvs = (AjaxControlToolkit.CascadingDropDownNameValue[])List.ToArray(typeof(AjaxControlToolkit.CascadingDropDownNameValue)); } return dvs; }
public CascadingDropDownNameValue[] GetEmployeesByOrganisationalUnit(string knownCategoryValues, string category) { StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues); List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); int organisationalId; if (!kv.ContainsKey("OrganizationalUnit") || !Int32.TryParse(kv["OrganizationalUnit"], out organisationalId)) { #warning change this code to get ur organisation unit and also do not display yourself //Get my organizational unit int myorganizationUnit = 20; List<EmployeeView> list = new EmployeeMapper().ListWithAdvancedFilter("", "", null, myorganizationUnit, null, StatusEnum.Active); foreach (EmployeeView ent in list) { CascadingDropDownNameValue cdnv = new CascadingDropDownNameValue(ent.ToString(), ent.Id.ToString()); values.Add(cdnv); } } else { List<EmployeeView> list = new EmployeeMapper().ListWithAdvancedFilter("", "", null, organisationalId, null, StatusEnum.Active); foreach (EmployeeView ent in list) { CascadingDropDownNameValue cdnv = new CascadingDropDownNameValue(ent.ToString(), ent.Id.ToString()); values.Add(cdnv); } } return values.ToArray(); }
public CascadingDropDownNameValue[] GetNationalities(string knownCategoryValues, string category, string contextKey) { List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); List<NationalityEntity> list = new NationalityMapper().List(""); foreach (NationalityEntity ent in list) { CascadingDropDownNameValue cdnv; if (ent.Title == contextKey) { cdnv = new CascadingDropDownNameValue(ent.Title, ent.Id.ToString(), true); } else { cdnv = new CascadingDropDownNameValue(ent.Title, ent.Id.ToString()); } values.Add(cdnv); } return values.ToArray(); }
public CascadingDropDownNameValue[] GetLeaveTypes(string knownCategoryValues, string category, string contextKey) { List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); List<LeaveTypeEntity> list = new LeaveTypeMapper().List(""); foreach (LeaveTypeEntity entity in list) { CascadingDropDownNameValue cdnv; cdnv = new CascadingDropDownNameValue(entity.Title, entity.Id.ToString()); values.Add(cdnv); } return values.ToArray(); }
public CascadingDropDownNameValue[] GetStepsByGradeId(string knownCategoryValues, string category) { StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues); string gradeId; if (!kv.ContainsKey("Grade")) { return null; } gradeId = kv["Grade"]; List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); List<StepEntity> list = new StepMapper().ListByGradeId(gradeId); foreach (StepEntity ent in list) { string text = (ent.Id); CascadingDropDownNameValue cdnv = new CascadingDropDownNameValue(text, ent.Id.ToString()); values.Add(cdnv); } return values.ToArray(); }
public static CascadingDropDownNameValue[] GetDropDownContents(string knownCategoryValues, string category) { IApplicationContext ctx = ContextRegistry.GetContext(); ICommonService commonService = ctx["CommonService"] as ICommonService; IBaseService baseService = ctx["BaseService"] as IBaseService; AjaxControlToolkit.CascadingDropDownNameValue[] dvs = null; IApplicationCacheFoundationDate applicationCacheFoundationDate = ctx["ApplicationCacheFoundationDate"] as IApplicationCacheFoundationDate; //List<Airport> airports = applicationCacheFoundationDate.FindAllAirport(); //string strCitys = string.Empty; //for (int index = 0; index < airports.Count; index++) //{ // strCitys += airports[index].Name + " - " + airports[index].Code + " , " + airports[index].City.Name + " , " + airports[index].City.CountryCode + " || "; //} //using (StreamWriter sw = File.CreateText("C:\\AirportCode" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString() + " " + DateTime.Now.Hour.ToString() + ".txt")) //{ // sw.Write(strCitys); //} //List<City> Citys = applicationCacheFoundationDate.FindAllCity(); //string strCitys = string.Empty; //for (int index = 0; index < Citys.Count; index++) //{ // strCitys += Citys[index].Name + " - " + Citys[index].Code + " , " + Citys[index].CountryCode + " || "; //} //using (StreamWriter sw = File.CreateText("C:\\CityCode" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString() + " " + DateTime.Now.Hour.ToString() + ".txt")) //{ // sw.Write(strCitys); //} System.Collections.ArrayList List = new ArrayList(); if (category == "Country") { List<Country> CountryTable = applicationCacheFoundationDate.FindCountry(); for (int index = 0; index < CountryTable.Count; index++) { if (CountryTable[index] != null) { AjaxControlToolkit.CascadingDropDownNameValue dv = new AjaxControlToolkit.CascadingDropDownNameValue(CountryTable[index].Name, CountryTable[index].Code); List.Add(dv); } } } if (category == "City") { string CountryCode = GetCategoryValueString(knownCategoryValues); List<City> temp = applicationCacheFoundationDate.FindCityByCountry(CountryCode); for (int index = 0; index < temp.Count; index++) { if (temp[index] != null) { AjaxControlToolkit.CascadingDropDownNameValue dv = new AjaxControlToolkit.CascadingDropDownNameValue(temp[index].Name, temp[index].Code); List.Add(dv); } } } if (category == "Provinces") { string CountryCode = GetCategoryValueString(knownCategoryValues); List<Province> Provinces = applicationCacheFoundationDate.FindProvinceByCountry(CountryCode); for (int index = 0; index < Provinces.Count; index++) { if (Provinces[index] != null) { AjaxControlToolkit.CascadingDropDownNameValue dv = new AjaxControlToolkit.CascadingDropDownNameValue(Provinces[index].Name, Provinces[index].Name); List.Add(dv); } } } if (category == "TourArea") { List<TERMS.Common.Area> areaTable = applicationCacheFoundationDate.FindTourArea(); for (int index = 0; index < areaTable.Count; index++) { if (areaTable[index] != null) { AjaxControlToolkit.CascadingDropDownNameValue dv = new AjaxControlToolkit.CascadingDropDownNameValue(areaTable[index].Name, areaTable[index].Name); List.Add(dv); } } } if (category == "TourCountry") { string AreaCode = GetCategoryValueString(knownCategoryValues); List<TERMS.Common.Country> CountryTable = applicationCacheFoundationDate.FindTourCountry(AreaCode); for (int index = 0; index < CountryTable.Count; index++) { if (CountryTable[index] != null) { AjaxControlToolkit.CascadingDropDownNameValue dv = new AjaxControlToolkit.CascadingDropDownNameValue(CountryTable[index].Name, CountryTable[index].Code); List.Add(dv); } } } if (category == "TourCity") { string CountryCode = GetCategoryValueString(knownCategoryValues); List<TERMS.Common.City> temp = applicationCacheFoundationDate.FindTourCity(CountryCode); temp.Sort(delegate(TERMS.Common.City c1, TERMS.Common.City c2) { return (c1.Name.CompareTo(c2.Name)); }); for (int index = 0; index < temp.Count; index++) { if (temp[index] != null) { AjaxControlToolkit.CascadingDropDownNameValue dv = new AjaxControlToolkit.CascadingDropDownNameValue(temp[index].Name, temp[index].Code); List.Add(dv); } } } if (List.Count > 0) { dvs = (AjaxControlToolkit.CascadingDropDownNameValue[])List.ToArray(typeof(AjaxControlToolkit.CascadingDropDownNameValue)); } return dvs; }
public CascadingDropDownNameValue[] GetGradesByJobCode(string knownCategoryValues, string category) { StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues); string jobCode; if (!kv.ContainsKey("JobTitle")) { return null; } jobCode = kv["JobTitle"]; List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); List<GradeEntity> list = new GradeMapper().ListByJobeCode(jobCode); foreach (GradeEntity ent in list) { string text = ent.Id; CascadingDropDownNameValue cdnv = new CascadingDropDownNameValue(text, ent.Id.ToString()); values.Add(cdnv); } return values.ToArray(); }
/// <summary> /// A helper method to provide simple implementation of a method to query a data set and return relevant dropdown content. /// </summary> /// <param name="document">XML document containing the data set</param> /// <param name="documentHierarchy">List of strings representing the hierarchy of the data set</param> /// <param name="knownCategoryValuesDictionary">Known category/value pairs</param> /// <param name="category">Category for which the drop down contents are desired</param> /// <param name="inputValidationRegex">Regular expression used to validate user input to the web service (to prevent XPath injection attacks)</param> /// <returns>Contents of the specified drop down subject to the choices already made</returns> public static CascadingDropDownNameValue[] QuerySimpleCascadingDropDownDocument(XmlDocument document, string[] documentHierarchy, StringDictionary knownCategoryValuesDictionary, string category, Regex inputValidationRegex) { // Validate parameters if (document == null) { throw new ArgumentNullException("document"); } if (documentHierarchy == null) { throw new ArgumentNullException("documentHierarchy"); } if (knownCategoryValuesDictionary == null) { throw new ArgumentNullException("knownCategoryValuesDictionary"); } if (category == null) { throw new ArgumentNullException("category"); } if (inputValidationRegex == null) { throw new ArgumentNullException("inputValidationRegex"); } // Validate input foreach (string key in knownCategoryValuesDictionary.Keys) { if (!inputValidationRegex.IsMatch(key) || !inputValidationRegex.IsMatch(knownCategoryValuesDictionary[key])) { throw new ArgumentException("Invalid characters present.", "category"); } } if (!inputValidationRegex.IsMatch(category)) { throw new ArgumentException("Invalid characters present.", "category"); } // Root the XPath query var xpath = "/" + document.DocumentElement.Name; // Build an XPath query into the data set to select the relevant items foreach (var key in documentHierarchy) { if (knownCategoryValuesDictionary.ContainsKey(key)) { xpath += String.Format(CultureInfo.InvariantCulture, "/{0}[(@name and @value='{1}') or (@name='{1}' and not(@value))]", key, knownCategoryValuesDictionary[key]); } } xpath += ("/" + category.ToLowerInvariant()); // Perform the XPath query and add the results to the list var result = new List <CascadingDropDownNameValue>(); foreach (XmlNode node in document.SelectNodes(xpath)) { var name = node.Attributes.GetNamedItem("name").Value; var valueNode = node.Attributes.GetNamedItem("value"); var value = ((valueNode != null) ? valueNode.Value : name); var defaultNode = node.Attributes.GetNamedItem("default"); var defaultValue = ((defaultNode != null) ? bool.Parse(defaultNode.Value) : false); var dropDownOptionItem = new CascadingDropDownNameValue(name, value, defaultValue); var optionTitleNode = node.Attributes.GetNamedItem("optionTitle"); var optionTitle = ((optionTitleNode != null) ? optionTitleNode.Value : String.Empty); dropDownOptionItem.optionTitle = optionTitle; result.Add(dropDownOptionItem); } return(result.ToArray()); }
public CascadingDropDownNameValue[] GetOrganizationalUnits(string knownCategoryValues, string category, string contextKey) { List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); List<OrganizationalUnitView> list = new OrganizationalUnitMapper().List(""); foreach (OrganizationalUnitView ent in list) { CascadingDropDownNameValue cdnv; if (ent.TitleAndOrganizationaUnitGroup == contextKey) { cdnv = new CascadingDropDownNameValue(ent.TitleAndOrganizationaUnitGroup, ent.Id.ToString(), true); } else { cdnv = new CascadingDropDownNameValue(ent.TitleAndOrganizationaUnitGroup, ent.Id.ToString()); } values.Add(cdnv); } return values.ToArray(); }