예제 #1
0
        public IEnumerable <string> ProcessTransmissions(IEnumerable <ArgosTransmission> transmissions, ArgosFile file)
        {
            string text = file.Header ?? "";

            text += String.Join(Environment.NewLine, transmissions.Select(t => t.ToString()));
            return(ProcessFile(text));
        }
예제 #2
0
 private static void ProcessTransmissions(CollarFile file, ArgosFile argos,
                                          IGrouping<string, ArgosTransmission> group)
 {
     LogGeneralMessage(String.Format("  Start processing transmissions for Argos Id {0}", group.Key));
     var platformId = group.Key;
     var transmissions = group.ToList();
     var first = transmissions.Min(t => t.DateTime);
     var last = transmissions.Max(t => t.DateTime);
     var databaseViews = new AnimalMovementViews();
     var parameterSets =
         databaseViews.GetTelonicsParametersForArgosDates(platformId, first, last)
                      .OrderBy(c => c.StartDate)
                      .ToList();
     if (parameterSets.Count == 0)
     {
         var msg = String.Format("No Collar for ArgosId {0} from {1:g} to {2:g}",
                                 platformId, first, last);
         LogIssueForFile(file.FileId, msg, platformId, null, null, first, last);
         return;
     }
     if (parameterSets[0].StartDate != null && first < parameterSets[0].StartDate)
     {
         var msg = String.Format("No Collar for ArgosId {0} from {1:g} to {2:g}",
                                 platformId, first, parameterSets[0].StartDate);
         LogIssueForFile(file.FileId, msg, platformId, null, null, first, parameterSets[0].StartDate);
     }
     int lastIndex = parameterSets.Count - 1;
     if (parameterSets[lastIndex].EndDate != null && parameterSets[lastIndex].EndDate < last)
     {
         var msg = String.Format("No Collar for ArgosId {0} from {1:g} to {2:g}",
                                 platformId, parameterSets[lastIndex].EndDate, last);
         LogIssueForFile(file.FileId, msg, platformId, null, null, parameterSets[lastIndex].EndDate, last);
     }
     foreach (var parameterSet in parameterSets)
     {
         if (parameterSet.ParameterId == null ||
             (parameterSet.CollarModel == "Gen3" && parameterSet.Gen3Period == null) ||
             (parameterSet.CollarModel == "Gen4" && parameterSet.Format == null))
         {
             var start = parameterSet.StartDate ?? first;
             var end = parameterSet.EndDate ?? last;
             var msg = String.Format("No Telonics Parameters for Collar {0}/{3} from {1:g} to {2:g}",
                                     parameterSet.CollarManufacturer, start, end, parameterSet.CollarId);
             LogIssueForFile(file.FileId, msg, platformId, parameterSet.CollarManufacturer, parameterSet.CollarId, start, end);
             continue;
         }
         try
         {
             ProcessParameterSet(file, argos, first, last, transmissions, parameterSet);
         }
         catch (Exception ex)
         {
             var message = String.Format(
                 "ERROR {0} adding Argos {1} transmissions from {2:g} to {3:g} to Collar {4}/{5}",
                 ex.Message, parameterSet.PlatformId, first, last,
                 parameterSet.CollarManufacturer, parameterSet.CollarId);
             LogIssueForFile(file.FileId, message, parameterSet.PlatformId, parameterSet.CollarManufacturer,
                             parameterSet.CollarId, first, last);
         }
     }
     LogGeneralMessage("  Finished processing transmissions");
 }
예제 #3
0
        public IEnumerable <string> ProcessTransmissions(IEnumerable <ArgosTransmission> transmissions, ArgosFile file)
        {
            string newHeader = "PlatformId" + file.Header.Substring(8); //case insensitive replace of "CollarId"

            yield return(newHeader);

            foreach (var transmission in transmissions)
            {
                yield return(transmission.ToString());
            }
        }
예제 #4
0
 private static void ProcessParameterSet(CollarFile file, ArgosFile argos, DateTime first, DateTime last,
                                         IEnumerable<ArgosTransmission> transmissions,
                                         GetTelonicsParametersForArgosDatesResult parameters)
 {
     LogGeneralMessage(String.Format("    Start processing collar {0}/{1}", parameters.CollarManufacturer,
                                     parameters.CollarId));
     var start = parameters.StartDate ?? DateTime.MinValue;
     if (start < first)
         start = first;
     var end = parameters.EndDate ?? DateTime.MaxValue;
     if (last < end)
         end = last;
     var processor = GetProcessor(file, parameters);
     var transmissionSubset = transmissions.Where(t => start <= t.DateTime && t.DateTime <= end);
     var lines = processor.ProcessTransmissions(transmissionSubset, argos);
     var data = Encoding.UTF8.GetBytes(String.Join(Environment.NewLine, lines) + Environment.NewLine);
     var filename = Path.GetFileNameWithoutExtension(file.FileName) + "_" + parameters.CollarId + ".csv";
     var fileLoader = new FileLoader(filename, data)
         {
             Project = file.Project,
             Owner = file.ProjectInvestigator,
             Collar = new Collar {CollarManufacturer = parameters.CollarManufacturer,
                                  CollarId = parameters.CollarId},
             Status = file.Status,
             ParentFileId = file.FileId,
             ArgosDeploymentId = parameters.DeploymentId,
             CollarParameterId = parameters.ParameterId,
             AllowDuplicates = true
         };
     fileLoader.Load();
     var message =
         String.Format(
             "    Successfully added Argos {0} transmissions from {1:g} to {2:g} to Collar {3}/{4}",
             parameters.PlatformId, start, end,
             parameters.CollarManufacturer, parameters.CollarId);
     LogGeneralMessage(message);
 }
예제 #5
0
        private static void ProcessFile(CollarFile file, ArgosFile argos, ArgosPlatform platform)
        {
            LogGeneralMessage(String.Format("Start local processing of file {0}", file.FileId));
            var databaseFunctions = new AnimalMovementFunctions();
            if (platform == null)
            {
                databaseFunctions.ArgosFile_ClearProcessingResults(file.FileId);
                if (IsArgosAwsFileIncomplete(argos as ArgosAwsFile) ?? false)
                    LogIssueForFile(file.FileId,
                                    "The Argos server could not return all the data requested and this file is incomplete.");
            }
            else
            {
                databaseFunctions.ArgosFile_UnProcessPlatform(file.FileId, platform.PlatformId);
            }

            var transmissionsByPlatform = from transmission in argos.GetTransmissions()
                                          group transmission by transmission.PlatformId
                                          into transmissions
                                          where platform == null || transmissions.Key == platform.PlatformId
                                          select transmissions;

            foreach (var transmissionSet in transmissionsByPlatform)
                try
                {
                    ProcessTransmissions(file, argos, transmissionSet);
                }
                catch (Exception ex)
                {
                    var message = String.Format("ERROR {0} adding Argos {1} transmissions",
                                                ex.Message, transmissionSet.Key);
                    LogIssueForFile(file.FileId, message, transmissionSet.Key);
                }
            LogGeneralMessage("Finished local processing of file");
        }
예제 #6
0
 public IEnumerable<string> ProcessTransmissions(IEnumerable<ArgosTransmission> transmissions, ArgosFile file)
 {
     return transmissions.SelectMany(transmission => GetMessage(transmission).FixesAsCsv());
 }
예제 #7
0
 public IEnumerable <string> ProcessTransmissions(IEnumerable <ArgosTransmission> transmissions, ArgosFile file)
 {
     return(transmissions.SelectMany(transmission => GetMessage(transmission).FixesAsCsv()));
 }
예제 #8
0
 public IEnumerable<string> ProcessTransmissions(IEnumerable<ArgosTransmission> transmissions, ArgosFile file)
 {
     string text = file.Header ?? "";
     text += String.Join(Environment.NewLine, transmissions.Select(t => t.ToString()));
     return ProcessFile(text);
 }