public ScreenAdderViewModel(WellViewModel well)
 {
     this.well     = well;
     svm           = well.AddScreen();
     NeedToCancel  = true;
     CurrentChange = new ChangeDescriptionViewModel(svm.CVM.ChangeController.NewScreen(svm._screen));
     RaisePropertyChanged("CurrentChange");
     RaisePropertyChanged("Intakes");
 }
 public ScreenAdderViewModel(WellViewModel well)
 {
   this.well = well;
   svm = well.AddScreen();
   NeedToCancel = true;
   CurrentChange = new ChangeDescriptionViewModel(svm.CVM.ChangeController.NewScreen(svm._screen));
   RaisePropertyChanged("CurrentChange");
   RaisePropertyChanged("Intakes");
 }
 public WellsOnPlantViewModel(IEnumerable <WellViewModel> wells, PlantViewModel plant, ChangesViewModel cvm)
 {
     CVM          = cvm;
     AllWells     = wells;
     CurrentPlant = plant;
     BuildWellList();
     CanApply      = false;
     DisplayName   = plant.DisplayName;
     CurrentChange = new ChangeDescriptionViewModel(cvm.ChangeController.GetGenericPlantIntake());
 }
Beispiel #4
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);
      }
    }
Beispiel #5
0
        private void Load()
        {
            Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
            openFileDialog.Filter = "Known file types (*.xml)|*.xml";
            openFileDialog.Title  = "Select an XML file with changes in JupiterPlus format";

            if (openFileDialog.ShowDialog().Value)
            {
                foreach (var c in ChangeController.LoadFromFile(openFileDialog.FileName))
                {
                    var cdv = new ChangeDescriptionViewModel(c);
                    cdv.IsDirty = false;
                    Changes.Add(cdv);
                }
                CheckChanges();
            }
        }
    /// <summary>
    /// Adds a new change
    /// </summary>
    /// <param name="CDVM"></param>
    public void AddChange(ChangeDescriptionViewModel CDVM, bool Notify)
    {

      Changes.Add(CDVM);
      ChangeController.UserName = CDVM.User;
      ChangeController.ProjectName = CDVM.Project;
      CDVM.PropertyChanged += new PropertyChangedEventHandler(CDVM_PropertyChanged);
      if (Notify)
        RaisePropertyChanged("NewChange");

      if (!SelectedProjects.Contains(CDVM.Project))
        SelectedProjects.Add(CDVM.Project);
      if (!SelectedUsers.Contains(CDVM.User))
        SelectedUsers.Add(CDVM.User);

      RaisePropertyChanged("SelectedChanges");
    }
Beispiel #7
0
        /// <summary>
        /// Adds a new change
        /// </summary>
        /// <param name="CDVM"></param>
        public void AddChange(ChangeDescriptionViewModel CDVM, bool Notify)
        {
            Changes.Add(CDVM);
            ChangeController.UserName    = CDVM.User;
            ChangeController.ProjectName = CDVM.Project;
            CDVM.PropertyChanged        += new PropertyChangedEventHandler(CDVM_PropertyChanged);
            if (Notify)
            {
                RaisePropertyChanged("NewChange");
            }

            if (!SelectedProjects.Contains(CDVM.Project))
            {
                SelectedProjects.Add(CDVM.Project);
            }
            if (!SelectedUsers.Contains(CDVM.User))
            {
                SelectedUsers.Add(CDVM.User);
            }

            RaisePropertyChanged("SelectedChanges");
        }
    /// <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);
      }
    }
    private void Load()
    {
      Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
      openFileDialog.Filter = "Known file types (*.xml)|*.xml";
      openFileDialog.Title = "Select an XML file with changes in JupiterPlus format";

      if (openFileDialog.ShowDialog().Value)
      {
        foreach (var c in ChangeController.LoadFromFile(openFileDialog.FileName))
        {
          var cdv = new ChangeDescriptionViewModel(c);
          cdv.IsDirty = false;
          Changes.Add(cdv);
        }
        CheckChanges();
      }
    }
        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;
        }