Ejemplo n.º 1
0
 private static void SummarizeFile(ArgosFile a)
 {
     Console.WriteLine("Transmissions in File");
     foreach (var t in a.GetTransmissions())
     {
         Console.WriteLine(t.ToFormatedString());
     }
     Console.WriteLine("Programs in File");
     foreach (var p in a.GetPrograms())
     {
         Console.WriteLine("  {0}", p);
     }
     Console.WriteLine("Collars in File");
     foreach (var p in a.GetPlatforms())
     {
         Console.WriteLine("  {0} Start {1} End {2}", p, a.FirstTransmission(p), a.LastTransmission(p));
     }
 }
Ejemplo n.º 2
0
        private static void SummarizeArgosFile(SqlInt32 fileId, ArgosFile file)
        {
            using (var connection = new SqlConnection("context connection=true"))
            {
                connection.Open();

                foreach (var program in file.GetPrograms())
                {
                    foreach (var platform in file.GetPlatforms(program))
                    {
                        var minDate = file.FirstTransmission(platform);
                        var maxDate = file.LastTransmission(platform);
                        const string sql = "INSERT INTO [dbo].[ArgosFilePlatformDates] (FileId, PlatformId, ProgramId, FirstTransmission, LastTransmission)" +
                                           " VALUES (@FileId, @PlatformId, @ProgramId, @FirstTransmission, @LastTransmission)";
                        using (var command = new SqlCommand(sql, connection))
                        {
                            command.Parameters.Add(new SqlParameter("@fileId", SqlDbType.Int) {Value = fileId});
                            command.Parameters.Add(new SqlParameter("@PlatformId", SqlDbType.NVarChar) {Value = platform});
                            command.Parameters.Add(new SqlParameter("@ProgramId", SqlDbType.NVarChar) {Value = program});
                            command.Parameters.Add(new SqlParameter("@FirstTransmission", SqlDbType.DateTime2) {Value = minDate});
                            command.Parameters.Add(new SqlParameter("@LastTransmission", SqlDbType.DateTime2) {Value = maxDate});
                            command.ExecuteNonQuery();
                        }
                    }
                }
            }
        }