public static IEnumerable SummarizeTpfFile(SqlInt32 fileId)
 {
     Byte[] bytes = GetFileContents("CollarParameterFiles", fileId, 'A');
     var tpf = new TpfFile(bytes);
     var resultCollection = new ArrayList();
     foreach (var tpfCollar in tpf.GetCollars())
         resultCollection.Add(new Row(fileId, tpfCollar));
     return resultCollection;
 }
Example #2
0
        public static IEnumerable SummarizeTpfFile(SqlInt32 fileId)
        {
            Byte[] bytes            = GetFileContents("CollarParameterFiles", fileId, 'A');
            var    tpf              = new TpfFile(bytes);
            var    resultCollection = new ArrayList();

            foreach (var tpfCollar in tpf.GetCollars())
            {
                resultCollection.Add(new Row(fileId, tpfCollar));
            }
            return(resultCollection);
        }
        private void CreateParameters(ProjectInvestigator owner, CollarParameterFile paramFile)
        {
            var tpfFile = new TpfFile(_fileContents);

            foreach (TpfCollar tpfCollar in tpfFile.GetCollars())
            {
                if (IgnoreSuffixCheckBox.Checked && tpfCollar.Ctn.Length > 6)
                {
                    tpfCollar.Ctn = tpfCollar.Ctn.Substring(0, 6);
                }
                //Does this collar exist?
                var collar = Database.Collars.FirstOrDefault(c => c.CollarManufacturer == "Telonics" &&
                                                             c.CollarId == tpfCollar.Ctn);
                if (collar == null && !CreateCollarsCheckBox.Checked)
                {
                    continue;
                }
                if (collar == null)
                {
                    collar = CreateTpfCollar(owner, tpfCollar.Ctn, tpfCollar.Frequency);
                    if (collar == null)
                    {
                        continue;
                    }
                }
                //Does this Argos platform exist?
                var fileHasArgos = !String.IsNullOrEmpty(tpfCollar.PlatformId) && tpfCollar.Platform == "Argos" &&
                                   !tpfCollar.PlatformId.Trim().Normalize().Equals("?", StringComparison.OrdinalIgnoreCase);
                if (fileHasArgos)
                {
                    var platform = Database.ArgosPlatforms.FirstOrDefault(p => p.PlatformId == tpfCollar.PlatformId && tpfCollar.Platform == "Argos");
                    if (platform == null && CreateCollarsCheckBox.Checked)
                    {
                        platform = CreatePlatform(tpfCollar.PlatformId);
                    }
                    if (platform != null)
                    {
                        //If not paired, then try to parit the collar and platform.  If it fails, or the the dates are wrong, they can correct that later
                        if (!Database.ArgosDeployments.Any(d => d.Collar == collar && d.ArgosPlatform == platform))
                        {
                            CreateDeployment(collar, platform, tpfCollar.TimeStamp);
                        }
                    }
                }
                CreateParameter(collar, paramFile, tpfCollar.TimeStamp);
            }
        }