Esempio n. 1
0
        /// <summary>
        /// This method is named 'Horario.guardarProgramacion' and must be synced if needed.
        /// This method returns an int. That in Horario is void.
        /// </summary>
        /// <param name="datosProgramacion">What to save</param>
        private int saveSchedule(DetalleProgramacion datosProgramacion) {
            if (log.IsDebugEnabled) {
                log.Debug("Executing saveSchedule");
            }
            int rslt = 0;
            if (datosProgramacion == null) {
                return -1;
            }
            Pelicula peliculaDao = new Pelicula();
            ProgramacionPeliculaDto programacionDto = null;
            foreach (var itemFechas in datosProgramacion.fs) {
                foreach (var itemFormatos in itemFechas.fms) {
                    programacionDto = new ProgramacionPeliculaDto();
                    programacionDto.idHorarioPelicula = itemFormatos.idh;
                    String[] hhmm = itemFormatos.h.Split(',');
                    List<string> hhmmList = new List<string>();
                    foreach (var shhmm in hhmm) {
                        if (shhmm != "00:00") {
                            hhmmList.Add(shhmm);
                        }
                    }
                    programacionDto.horaMinutoPelicula = hhmmList.ToStringDelimited(",");
                    if (!String.IsNullOrEmpty(programacionDto.horaMinutoPelicula) || programacionDto.idHorarioPelicula != 0) {
                        if (string.IsNullOrEmpty(itemFechas.f)) {
                            continue;
                        }

                        DateTime fecha = itemFechas.f.DDMMYYYYToDateTime();
                        programacionDto.idFormato = itemFormatos.idf;
                        programacionDto.idPelicula = datosProgramacion.id;
                        programacionDto.idTeatro = idTheater;
                        programacionDto.mesHorarioPelicula = fecha.Month;
                        programacionDto.annoHorarioPelicula = fecha.Year;
                        programacionDto.diaHorarioPelicula = fecha.Day;
                        programacionDto.nombreDiaSemanaHorarioPelicula = Utils.getDayNameSpanish(fecha.DayOfWeek.ToString());
                        programacionDto.frecuencia = Utils.getDayNameNumber(fecha.DayOfWeek.ToString());
                        rslt = peliculaDao.createUpdateProgramacionPelicula(programacionDto);
                        if (log.IsDebugEnabled) {
                            log.Debug("createUpdateProgramacionPelicula rslt=["+ rslt + "] with data=[" + programacionDto.ToString() + "]");
                        }
                        programacionDto = null;
                    }
                }
            }
            if (log.IsDebugEnabled) {
                log.Debug("Executing saveSchedule End");
            }
            return rslt;            
        }
Esempio n. 2
0
 /// <summary>
 /// Create or updates a schedule programming.
 /// </summary>
 /// <param name="datosProgramacion">What to update/create</param>
 /// <returns>0: Success, -1: Failure</returns>
 public int createUpdateProgramacionPelicula(ProgramacionPeliculaDto datosProgramacion) {
     if (log.IsDebugEnabled) {
         log.Debug("createUpdateProgramacionPelicula Starts");
     }
     HandleDatabase hdb = null;
     SqlTransaction transaction = null;
     SqlDataReader rdr = null;
     int rslt = 0;
     try {
         hdb = new HandleDatabase(Settings.Connection);
         hdb.Open();
         List<SqlParameter> paramList = new List<SqlParameter>() {
             new SqlParameter() {ParameterName = "@IDHORARIOPELICULA", Value = datosProgramacion.idHorarioPelicula, SqlDbType = SqlDbType.Int},
             new SqlParameter() {ParameterName = "@IDFORMATO", Value = datosProgramacion.idFormato, SqlDbType = SqlDbType.Int},
             new SqlParameter() {ParameterName = "@IDPELICULA", Value = datosProgramacion.idPelicula, SqlDbType = SqlDbType.Int},
             new SqlParameter() {ParameterName = "@IDTEATRO", Value = datosProgramacion.idTeatro, SqlDbType = SqlDbType.Int},
             new SqlParameter() {ParameterName = "@ANNOHORARIO", Value = datosProgramacion.annoHorarioPelicula, SqlDbType = SqlDbType.Int},
             new SqlParameter() {ParameterName = "@MESHORARIO", Value = datosProgramacion.mesHorarioPelicula, SqlDbType = SqlDbType.Int},
             new SqlParameter() {ParameterName = "@DIAHORARIO", Value = datosProgramacion.diaHorarioPelicula, SqlDbType = SqlDbType.Int},
             new SqlParameter() {ParameterName = "@HORAMINUTO", Value = datosProgramacion.horaMinutoPelicula, SqlDbType = SqlDbType.VarChar},
             new SqlParameter() {ParameterName = "@SALA", Value = datosProgramacion.sala, SqlDbType = SqlDbType.VarChar},
             new SqlParameter() {ParameterName = "@NOMBREDIA", Value = datosProgramacion.nombreDiaSemanaHorarioPelicula, SqlDbType = SqlDbType.VarChar},
             new SqlParameter() {ParameterName = "@FRECUENCIA", Value = datosProgramacion.frecuencia, SqlDbType = SqlDbType.Int}
         };
         String sql = "SP_CREARACTUALIZARPROGRAMACIONPELICULA @IDHORARIOPELICULA,@IDFORMATO,@IDPELICULA,@IDTEATRO,@ANNOHORARIO,@MESHORARIO, @DIAHORARIO,@HORAMINUTO,@SALA, @NOMBREDIA,@FRECUENCIA";
         var i = 1;
         if (log.IsDebugEnabled) {
             log.Debug("SQL=[" + sql + "]");
             paramList.ForEach(p => {
                 var paramValues = "ParameterName=[" + p.ParameterName + "], Value=[" + p.Value + "], SqlDbType=[" + p.SqlDbType + "]";
                 log.Debug("Parameter " + i++ + " val=[" + paramValues + "]");
             });
         }
         transaction = hdb.BeginTransaction("crUpdProgramacionPelicula");
         rdr = hdb.ExecSelectSQLStmtAsReader(transaction, sql, paramList.ToArray());
         rslt = 1;
     } catch (Exception ex) {
         if (log.IsFatalEnabled) {
             log.Fatal("Exception occurred " + ex.Message);
             log.Fatal("Exception trace=[" + ex.StackTrace + "]");
             log.Fatal("Return sets to -1");
         }
         rslt = -1;
     } finally {
         try {
             if (rdr != null) { rdr.Close(); }
             if (transaction != null) { transaction.Commit(); }
             if (hdb != null) { hdb.Close(); }
         } catch (Exception e) {
             if (log.IsFatalEnabled) {
                 log.Fatal("Exception occurred " + e.Message);
                 log.Fatal("Exception trace=[" + e.StackTrace + "]");
                 log.Fatal("Return sets to -1");
             }
             rslt = -1;
         }
     }
     if (log.IsDebugEnabled) {
         log.Debug("rslt=[" + rslt + "]");
         log.Debug("createUpdateProgramacionPelicula Ends");
     }
     return rslt;
 }
Esempio n. 3
0
 /// <summary>
 /// Creates an object instance and save only one record.
 /// </summary>
 /// <returns></returns>
 public int executeSaveScheduleSingleTest() {
     if (log.IsDebugEnabled) {
         log.Debug("Executing executeSaveScheduleSingleTest");
     }
     Pelicula peliculaDao = new Pelicula();
     ProgramacionPeliculaDto programacionDto = new ProgramacionPeliculaDto();
     int rslt = 0;
     DateTime fecha = DateTime.Now;
     programacionDto.idHorarioPelicula = 0;
     programacionDto.idFormato = 1;
     programacionDto.idPelicula = 14;
     programacionDto.idTeatro = idTheater;
     programacionDto.mesHorarioPelicula = fecha.Month;
     programacionDto.annoHorarioPelicula = fecha.Year;
     programacionDto.diaHorarioPelicula = fecha.Day;
     programacionDto.nombreDiaSemanaHorarioPelicula = Utils.getDayNameSpanish(fecha.DayOfWeek.ToString());
     programacionDto.frecuencia = Utils.getDayNameNumber(fecha.DayOfWeek.ToString());
     programacionDto.horaMinutoPelicula = "14:40,17:30,20:50";
     programacionDto.sala = 2;
     rslt = peliculaDao.createUpdateProgramacionPelicula(programacionDto);
     if (log.IsDebugEnabled) {
         log.Debug("executeSaveScheduleSingleTest rslt=[" + rslt + "] with data=[" + programacionDto.ToString() + "]");
         log.Debug("Executing executeSaveScheduleSingleTest Ends");
     }
     return rslt;
 }
Esempio n. 4
0
 /// <summary>
 /// Saves all information about the schedule for movie/theater back to disk.
 /// </summary>
 /// <param name="datosProgramacion">An object representing the information to save from JSON format</param>
 private void guardarProgramacion(DetalleProgramacion datosProgramacion) {
     if (log.IsDebugEnabled) {
         log.Debug("guardarProgramacion Starts");
     }
     if (datosProgramacion == null) {
         if (log.IsDebugEnabled) {
             log.Debug("Supplied parameter is not set");
         }
         return;
     }
     Pelicula peliculaDao = new Pelicula();
     ProgramacionPeliculaDto programacionDto = null;            
     foreach (var itemFechas in datosProgramacion.fs) {
         foreach (var itemFormatos in itemFechas.fms) {
             programacionDto = new ProgramacionPeliculaDto();
             programacionDto.idHorarioPelicula = itemFormatos.idh;
             String[] hhmm = itemFormatos.h.Split(',');
             List<string> hhmmList = new List<string>();
             foreach (var shhmm in hhmm) {
                 if (shhmm != "00:00") {
                     hhmmList.Add(shhmm);
                 }
             }
             programacionDto.horaMinutoPelicula = hhmmList.ToStringDelimited(",");
             if (!String.IsNullOrEmpty(programacionDto.horaMinutoPelicula) || programacionDto.idHorarioPelicula != 0) {
                 if (string.IsNullOrEmpty(itemFechas.f)) {
                     continue;
                 }
                 
                 DateTime fecha = itemFechas.f.DDMMYYYYToDateTime();                        
                 programacionDto.idFormato = itemFormatos.idf;
                 programacionDto.idPelicula = datosProgramacion.id;
                 programacionDto.idTeatro = Convert.ToInt32(teatroSeleccionado.Value.ToString());
                 programacionDto.mesHorarioPelicula = fecha.Month;
                 programacionDto.annoHorarioPelicula = fecha.Year;
                 programacionDto.diaHorarioPelicula = fecha.Day;
                 programacionDto.nombreDiaSemanaHorarioPelicula = Utils.getDayNameSpanish(fecha.DayOfWeek.ToString());
                 programacionDto.frecuencia = Utils.getDayNameNumber(fecha.DayOfWeek.ToString());
                 peliculaDao.createUpdateProgramacionPelicula(programacionDto);                                    
                 programacionDto = null;
             }
         }
     }
     if (log.IsDebugEnabled) {
         log.Debug("guardarProgramacion Starts");
     }
 }