/// <summary> /// Agrega todas las holidays a una idOrganization /// </summary> /// <param name="LNL_PanelID"></param> /// <param name="holidaysData"></param> public static void addLenelHolidays(string v_idOrganization, string holidaysData) { string[] holidayDef = holidaysData.Split('|'); int idOrganization = int.Parse(v_idOrganization); List<HolidayData> LENELHolidays; if (!ListaHolidays.ContainsKey(idOrganization)) { LENELHolidays = new List<HolidayData>(); ListaHolidays.Add(idOrganization, LENELHolidays); } LENELHolidays = ListaHolidays[idOrganization]; // Obtiene las holidays de la organizacion LENELHolidays.Clear(); foreach (string holiday in holidayDef) { if (holiday.Trim().Length > 0) { HolidayData holy = new HolidayData(holiday); LENELHolidays.Add(holy); } } // Alta en la BD mainApp.DataManager.addLenelHoliday(idOrganization, LENELHolidays); }
// Carga todas las listas de Holidays de todas las organizaciones. public Dictionary<int, List<HolidayData>> LoadListaHolidays() { Dictionary<int, List<HolidayData>> listaResultado = new Dictionary<int, List<HolidayData>>(); SqlConnection cnn = new SqlConnection(conexion); try { cnn.Open(); SqlCommand cmd = cnn.CreateCommand(); cmd.CommandText = "select * from Holidays"; cmd.CommandType = CommandType.Text; SqlDataReader lector = cmd.ExecuteReader(); while (lector.Read()) { int idOrg = int.Parse(lector["idOrganizacion"].ToString()); if (!listaResultado.ContainsKey(idOrg)) { List<HolidayData> nuevaLista = new List<HolidayData>(); listaResultado.Add(idOrg, nuevaLista); } List<HolidayData> listaHoli = listaResultado[idOrg]; string fechaIni = lector["FechaIni"].ToString(); int cantDias = int.Parse(lector["CantDias"].ToString()); int tipo = int.Parse(lector["Tipo"].ToString()); string holidayDef = fechaIni.Replace('-',',') + ","+tipo.ToString() + "," + cantDias.ToString(); HolidayData nuevaHoli = new HolidayData(holidayDef); listaHoli.Add(nuevaHoli); } lector.Close(); } catch (Exception ex) { loguearString("Excepcion en LoadListaHolidays: " + ex.Message, TiposLOG.HH); } finally { cnn.Close(); } return listaResultado; }