コード例 #1
0
    /// <summary>
    /// Comes here when an entry is deleted from the head observations
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    void Collection_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
    {
      if (e.OldItems.Count > 0)
      {
        TimestampValue tsv = e.OldItems[0] as TimestampValue;

        IIntake intake = HeadObservations.Keys[CurrentIntakeIndex];
        ChangeDescription c = CVM.ChangeController.GetRemoveWatlevel(intake, tsv.Time);
        ChangeDescriptionViewModel cv =new ChangeDescriptionViewModel(c);
        cv.IsDirty = true;
        cv.IsApplied = true;
        CVM.AddChange(cv, true);
      }
    }
コード例 #2
0
        private void Apply()
        {
            if (IntakeAdded != null)
            {
                ChangeDescription cd = CVM.ChangeController.AddIntakeToPlant(IntakeAdded, CurrentPlant.plant);
                CurrentChange.changeDescription.Action       = cd.Action;
                CurrentChange.changeDescription.ChangeValues = cd.ChangeValues;
                CurrentChange.changeDescription.PrimaryKeys  = cd.PrimaryKeys;
            }
            else if (IntakeRemoved != null)
            {
                ChangeDescription cd = CVM.ChangeController.RemoveIntakeFromPlant(IntakeRemoved, CurrentPlant.plant);
                CurrentChange.changeDescription.Action       = cd.Action;
                CurrentChange.changeDescription.ChangeValues = cd.ChangeValues;
                CurrentChange.changeDescription.PrimaryKeys  = cd.PrimaryKeys;
            }
            else //Only the dates have been changed
            {
                if (StartDateChange != null)
                {
                    if (StartDateChange.PrimaryKeys.Values.First() == "") //It is a change of change
                    {
                        ChangeDescription cd = CVM.ChangeController.AddIntakeToPlant(CurrentIntake, CurrentPlant.plant);
                        CurrentChange.changeDescription.Action       = TableAction.EditValue;
                        CurrentChange.changeDescription.ChangeValues = cd.ChangeValues;
                        CurrentChange.changeDescription.PrimaryKeys  = cd.PrimaryKeys;
                    }
                    else
                    {
                        CurrentChange.changeDescription = StartDateChange;
                    }
                    if (EndDateChange != null)
                    {
                        CurrentChange.changeDescription.ChangeValues.Add(EndDateChange.ChangeValues[0]);
                    }
                }
                else if (EndDateChange != null)
                {
                    if (EndDateChange.PrimaryKeys.Values.First() == "") //It is a change of change
                    {
                        ChangeDescription cd = CVM.ChangeController.AddIntakeToPlant(CurrentIntake, CurrentPlant.plant);
                        CurrentChange.changeDescription.Action       = TableAction.EditValue;
                        CurrentChange.changeDescription.ChangeValues = cd.ChangeValues;
                        CurrentChange.changeDescription.PrimaryKeys  = cd.PrimaryKeys;
                    }
                    else
                    {
                        CurrentChange.changeDescription = EndDateChange;
                    }
                }
            }
            //call distribute extraction again.
            CurrentPlant.plant.DistributeExtraction(true);

            CurrentChange.IsDirty   = true;
            CurrentChange.IsApplied = true;
            CVM.AddChange(CurrentChange, false);
            CurrentChange   = new ChangeDescriptionViewModel(CVM.ChangeController.GetGenericPlantIntake());
            IntakeRemoved   = null;
            IntakeAdded     = null;
            EndDateChange   = null;
            StartDateChange = null;
            CanApply        = false;
        }