private void CreateParameter(Collar collar, CollarParameterFile file, DateTime startDateTime)
        {
            DateTime?endDateTime = null;

            if (collar.CollarParameters.Count > 0)
            {
                if (!FixOtherParameters(collar, file, startDateTime, ref endDateTime))
                {
                    return;
                }
            }
            var param = new CollarParameter
            {
                Collar = collar,
                CollarParameterFile = file,
                StartDate           = startDateTime,
                EndDate             = endDateTime
            };

            Database.CollarParameters.InsertOnSubmit(param);
            //Creating a parameter is optional, so we submit now, so a failure will not stop other transactions.
            if (!SubmitChanges())
            {
                Database.CollarParameters.DeleteOnSubmit(param);
            }
        }
Beispiel #2
0
        private void AddFixParameterButton_Click(object sender, EventArgs e)
        {
            var      index   = TpfDataGridView.SelectedRows[0].Index;
            var      start   = (DateTime)TpfDataGridView.SelectedRows[0].Cells[5].Value;
            var      collar  = _collars[index];
            DateTime?endDate = null;

            if (AddFixParameterButton.Text == "Fix Parameter")
            {
                // If we are here, there is one (possibly though unlikely more) parameter(s) with this collar/file but not this start date.
                // If there is only one parameter on this collar (this one), then no problems, just fix the date.  Otherwise, check/fix the other one(s) first.
                if (collar.CollarParameters.Count > 1)
                {
                    if (collar.CollarParameters.Count(p => p.CollarParameterFile == File) > 1)
                    {
                        MessageBox.Show(
                            "This file is assigned to this collar more than once.  This ambiguity prevents automatic correction.",
                            "Oh No!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    endDate = collar.CollarParameters.First(p => p.CollarParameterFile == File).EndDate;
                    if (!FixOtherParameters(collar, start, ref endDate))
                    {
                        return;
                    }
                }
                var param = collar.CollarParameters.First(p => p.CollarParameterFile == File);
                param.StartDate = start;
                param.EndDate   = endDate;
            }
            else // Add
            {
                // If we are here, then this file is not on this collar, but the collar may have other files.
                // If there are no other parameters, then no problems, otherwise, try to fix the other one(s) first
                if (collar.CollarParameters.Count > 0)
                {
                    if (!FixOtherParameters(collar, start, ref endDate))
                    {
                        return;
                    }
                }
                var param = new CollarParameter
                {
                    Collar = collar,
                    CollarParameterFile = File,
                    StartDate           = start,
                    EndDate             = endDate
                };
                Database.CollarParameters.InsertOnSubmit(param);
            }
            if (SubmitChanges())
            {
                TpfDataChanged();
            }
        }
Beispiel #3
0
 public CollarParametersDetailsForm(CollarParameter collarParameter, bool lockCollar = false,
                                    bool lockFile = false)
 {
     InitializeComponent();
     CollarParameter = collarParameter;
     LockCollar      = lockCollar;
     LockFile        = lockFile;
     CurrentUser     = Environment.UserDomainName + @"\" + Environment.UserName;
     LoadDataContext();
     LoadDefaultFormContents(); //Called before events are triggered
 }
 public CollarParametersDetailsForm(CollarParameter collarParameter, bool lockCollar = false,
                                    bool lockFile = false)
 {
     InitializeComponent();
     CollarParameter = collarParameter;
     LockCollar = lockCollar;
     LockFile = lockFile;
     CurrentUser = Environment.UserDomainName + @"\" + Environment.UserName;
     LoadDataContext();
     LoadDefaultFormContents(); //Called before events are triggered
 }
Beispiel #5
0
        private void CollarAdded(string id)
        {
            var collar = Database.Collars.FirstOrDefault(c => c.CollarManufacturer == "Telonics" && c.CollarId == id);

            if (collar == null)
            {
                return;
            }
            //Add Parameter
            var start = (DateTime)TpfDataGridView.SelectedRows[0].Cells[5].Value;
            //Since this is a new collar, I don't need to worry about any parameter conflicts.
            var param = new CollarParameter
            {
                Collar = collar,
                CollarParameterFile = File,
                StartDate           = start
            };

            Database.CollarParameters.InsertOnSubmit(param);
            if (SubmitChanges())
            {
                TpfDataChanged();
            }

            //Add PlatformDeployment
            var platformType = (string)TpfDataGridView.SelectedRows[0].Cells[2].Value;
            var platformId   = (string)TpfDataGridView.SelectedRows[0].Cells[3].Value;

            if (platformType == "Argos")
            {
                var platform = Database.ArgosPlatforms.FirstOrDefault(a => a.PlatformId == platformId);
                if (platform == null)
                {
                    var form = new AddArgosPlatformForm();
                    form.DatabaseChanged += (o, x) => ArgosAdded(platformId, collar, start);
                    form.SetDefaultPlatform(platformId);
                    form.Show(this);
                }
                else
                {
                    AddArgosDeployment(platformId, collar, start);
                }
            }
            if (platformType == "Iridium")
            {
                //TODO: implement support for Iridium
            }
        }
Beispiel #6
0
        private bool AddParameters()
        {
            int?period = String.IsNullOrEmpty(Gen3PeriodTextBox.Text) || Collar.CollarModel != "Gen3"
                              ? (int?)null
                              : Int32.Parse(Gen3PeriodTextBox.Text) *
                         ((string)Gen3TimeUnitComboBox.SelectedItem == "Hours" ? 60 : 1);
            var param = new CollarParameter
            {
                Collar              = Collar,
                Gen3Period          = period,
                CollarParameterFile = (CollarParameterFile)FileComboBox.SelectedItem,
                StartDate           = StartDateTimePicker.Checked ? StartDateTimePicker.Value.Date.ToUniversalTime() : (DateTime?)null,
                EndDate             = EndDateTimePicker.Checked ? EndDateTimePicker.Value.Date.ToUniversalTime() : (DateTime?)null
            };

            Database.CollarParameters.InsertOnSubmit(param);
            if (SubmitChanges())
            {
                return(true);
            }
            // The collar now thinks it has a parameter, deleteOnSubmit does not clear it
            LoadDataContext();
            return(false);
        }
 private void CreateParameter(Collar collar, CollarParameterFile file, DateTime startDateTime)
 {
     DateTime? endDateTime = null;
     if (collar.CollarParameters.Count > 0)
         if (!FixOtherParameters(collar, file, startDateTime, ref endDateTime))
             return;
     var param = new CollarParameter
     {
         Collar = collar,
         CollarParameterFile = file,
         StartDate = startDateTime,
         EndDate = endDateTime
     };
     Database.CollarParameters.InsertOnSubmit(param);
     //Creating a parameter is optional, so we submit now, so a failure will not stop other transactions.
     if (!SubmitChanges())
         Database.CollarParameters.DeleteOnSubmit(param);
 }
        private void CollarAdded(string id)
        {
            var collar = Database.Collars.FirstOrDefault(c => c.CollarManufacturer == "Telonics" && c.CollarId == id);
            if (collar == null)
                return;
            //Add Parameter
            var start = (DateTime) TpfDataGridView.SelectedRows[0].Cells[5].Value;
            //Since this is a new collar, I don't need to worry about any parameter conflicts.
            var param = new CollarParameter
                {
                    Collar = collar,
                    CollarParameterFile = File,
                    StartDate = start
                };
            Database.CollarParameters.InsertOnSubmit(param);
            if (SubmitChanges())
                TpfDataChanged();

            //Add PlatformDeployment
            var platformType = (string)TpfDataGridView.SelectedRows[0].Cells[2].Value;
            var platformId = (string)TpfDataGridView.SelectedRows[0].Cells[3].Value;
            if (platformType == "Argos")
            {
                var platform = Database.ArgosPlatforms.FirstOrDefault(a => a.PlatformId == platformId);
                if (platform == null)
                {
                    var form = new AddArgosPlatformForm();
                    form.DatabaseChanged += (o, x) => ArgosAdded(platformId, collar, start);
                    form.SetDefaultPlatform(platformId);
                    form.Show(this);
                }
                else
                {
                    AddArgosDeployment(platformId, collar, start);
                }
            }
            if (platformType == "Iridium")
            {
                //TODO: implement support for Iridium
            }
        }
 private void AddFixParameterButton_Click(object sender, EventArgs e)
 {
     var index = TpfDataGridView.SelectedRows[0].Index;
     var start = (DateTime)TpfDataGridView.SelectedRows[0].Cells[5].Value;
     var collar = _collars[index];
     DateTime? endDate = null;
     if (AddFixParameterButton.Text == "Fix Parameter")
     {
         // If we are here, there is one (possibly though unlikely more) parameter(s) with this collar/file but not this start date.
         // If there is only one parameter on this collar (this one), then no problems, just fix the date.  Otherwise, check/fix the other one(s) first.
         if (collar.CollarParameters.Count > 1)
         {
             if (collar.CollarParameters.Count(p => p.CollarParameterFile == File) > 1)
             {
                 MessageBox.Show(
                     "This file is assigned to this collar more than once.  This ambiguity prevents automatic correction.",
                     "Oh No!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
             endDate = collar.CollarParameters.First(p => p.CollarParameterFile == File).EndDate;
             if (!FixOtherParameters(collar, start, ref endDate))
                 return;
         }
         var param = collar.CollarParameters.First(p => p.CollarParameterFile == File);
         param.StartDate = start;
         param.EndDate = endDate;
     }
     else // Add
     {
         // If we are here, then this file is not on this collar, but the collar may have other files.
         // If there are no other parameters, then no problems, otherwise, try to fix the other one(s) first
         if (collar.CollarParameters.Count > 0)
             if (!FixOtherParameters(collar, start, ref endDate))
                 return;
         var param = new CollarParameter
         {
             Collar = collar,
             CollarParameterFile = File,
             StartDate = start,
             EndDate = endDate
         };
         Database.CollarParameters.InsertOnSubmit(param);
     }
     if (SubmitChanges())
         TpfDataChanged();
 }