Пример #1
0
        /// <summary>
        /// Event delegate method fired when the <see cref="DeleteButton"/> button is clicked.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Event arguments.</param>
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            switch (_selectedItem)
            {
            case null:
                return;

            case MySqlService selectedService:
            {
                var machine = MachinesList.GetMachineById(selectedService.Host.MachineId);
                machine.ChangeService(selectedService, ListChangeType.RemoveByUser);
                MonitoredServicesListView.Items.RemoveAt(MonitoredServicesListView.SelectedIndices[0]);
                break;
            }

            case MySqlInstance selectedInstance:
            {
                if (InstancesList.Remove(selectedInstance))
                {
                    MonitoredInstancesListView.Items.RemoveAt(MonitoredInstancesListView.SelectedIndices[0]);
                }

                break;
            }
            }
        }
Пример #2
0
        public void Test_ReadWriteBinary()
        {
            var l  = new MachinesList();
            var m  = l.CreateNew("Machine1", "HardwareID1", MachineType.Dozer, DeviceTypeEnum.SNM940, false, Guid.NewGuid());
            var m2 = l.CreateNew("Machine2", "HardwareID2", MachineType.Dozer, DeviceTypeEnum.SNM940, true, Guid.Empty);

            TestBinary_ReaderWriterHelper.RoundTripSerialise(l);
        }
Пример #3
0
        public void Add_FailWithNull()
        {
            var l = new MachinesList();

            Action act = () => l.Add(null);

            act.Should().Throw <ArgumentException>().WithMessage("*Machine reference cannot be null*");
        }
Пример #4
0
        public void MapMachineToMachineStatus()
        {
            var machineUid1 = Guid.NewGuid();
            var machineUid2 = Guid.NewGuid();
            var machineUid3 = Guid.Empty;
            var machines    = new MachinesList {
                DataModelID = Guid.NewGuid()
            };

            machines.CreateNew("MachineName1", "hardwareID444", MachineType.ConcretePaver, DeviceTypeEnum.SNM940, false,
                               machineUid1);
            machines[0].InternalSiteModelMachineIndex = 0;
            machines[0].LastKnownX = 34.34;
            machines[0].LastKnownY = 77.77;
            machines[0].LastKnownPositionTimeStamp = DateTime.UtcNow.AddMonths(-2);
            machines[0].LastKnownDesignName        = "design1";
            machines[0].LastKnownLayerId           = 11;

            machines.CreateNew("MachineName2", "hardwareID555", MachineType.AsphaltCompactor, DeviceTypeEnum.SNM940, false,
                               machineUid2);
            machines.CreateNew("MachineName3", "hardwareID666", MachineType.Generic, DeviceTypeEnum.MANUALDEVICE, true,
                               machineUid3);

            var machineStatuses = machines.Select(machine =>
                                                  AutoMapperUtility.Automapper.Map <MachineStatus>(machine)).ToArray();

            machineStatuses.Length.Equals(3);
            machineStatuses[0].AssetUid.HasValue.Equals(true);
            machineStatuses[0].AssetUid?.Equals(machines[0].ID);
            machineStatuses[0].AssetId.Equals(-1);
            machineStatuses[0].MachineName.IsNullOrEmpty().Equals(false);
            machineStatuses[0].MachineName.Equals(machines[0].Name);
            machineStatuses[0].IsJohnDoe.Equals(machines[0].IsJohnDoeMachine);
            machineStatuses[0].lastKnownDesignName.IsNullOrEmpty().Equals(false);
            machineStatuses[0].lastKnownDesignName.Equals(machines[0].LastKnownDesignName);
            machineStatuses[0].lastKnownLayerId.HasValue.Equals(true);
            machineStatuses[0].lastKnownLayerId?.Equals(machines[0].LastKnownLayerId);
            machineStatuses[0].lastKnownTimeStamp.HasValue.Equals(true);
            machineStatuses[0].lastKnownTimeStamp?.Equals(machines[0].LastKnownPositionTimeStamp);
            machineStatuses[0].lastKnownLatitude.HasValue.Equals(true);
            machineStatuses[0].lastKnownLatitude?.Equals(Double.MaxValue);
            machineStatuses[0].lastKnownLongitude.HasValue.Equals(true);
            machineStatuses[0].lastKnownLongitude?.Equals(Double.MaxValue);
            machineStatuses[0].lastKnownX.HasValue.Equals(true);
            machineStatuses[0].lastKnownX?.Equals(machines[0].LastKnownX);
            machineStatuses[0].lastKnownY.HasValue.Equals(true);
            machineStatuses[0].lastKnownY?.Equals(machines[0].LastKnownY);

            machineStatuses[1].AssetUid.HasValue.Equals(true);
            machineStatuses[1].AssetUid?.Equals(machineUid2);
            machineStatuses[1].lastKnownX.HasValue.Equals(false);
            machineStatuses[1].lastKnownY.HasValue.Equals(false);

            machineStatuses[2].AssetUid.HasValue.Equals(true);
            machineStatuses[2].AssetUid?.Equals(machineUid3);
        }
Пример #5
0
        public void LocateByMachineHardwareID()
        {
            var l  = new MachinesList();
            var m  = l.CreateNew("Machine1", "HardwareID1", MachineType.Dozer, DeviceTypeEnum.SNM940, false, Guid.NewGuid());
            var m2 = l.CreateNew("Machine2", "HardwareID2", MachineType.Dozer, DeviceTypeEnum.SNM940, false, Guid.NewGuid());

            l.LocateByMachineHardwareID("HardwareID1").Should().BeSameAs(m);
            l.LocateByMachineHardwareID("HardwareID2").Should().BeSameAs(m2);
            l.LocateByMachineHardwareID("HardwareID3").Should().BeNull();
        }
Пример #6
0
        public void Add()
        {
            var l = new MachinesList();
            var m = new Machine();

            l.Add(m);

            l.Count.Should().Be(1);
            l.Locate(m.ID).Should().BeSameAs(m);
        }
Пример #7
0
        public AddServiceDialog(MachinesList machineslist)
        {
            _sortColumn  = -1;
            MachinesList = machineslist;
            HasChanges   = false;

            InitializeComponent();
            ServicesListView.ColumnClick += ServicesListView_ColumnClick;
            InsertMachinesIntoComboBox();
            MachineSelectionComboBox.SelectedIndex = 0;
        }
Пример #8
0
        public void CreateNew_Duplicate()
        {
            var newGuid = Guid.NewGuid();
            var l       = new MachinesList();
            var m       = l.CreateNew("Machine", "HardwareID", MachineType.Dozer, DeviceTypeEnum.SNM940, false, newGuid);

            // Create an identical machine - should return the first machine created
            var m2 = l.CreateNew("Machine", "HardwareID", MachineType.Dozer, DeviceTypeEnum.SNM940, false, newGuid);

            m.Should().BeSameAs(m2);
        }
Пример #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MonitorMySqlServerInstancesDialog"/> class.
        /// </summary>
        /// <param name="machinesList">List of <see cref="MySqlService"/> objects monitored by the Notifier.</param>
        /// <param name="instancesList">List of names of MySQL instance monitored by the Notifier.</param>
        public MonitorMySqlServerInstancesDialog(MachinesList machinesList, MySqlInstancesList instancesList)
        {
            InitializeComponent();

            _lastServicesNameFilter    = FilterTextBox.Text;
            _lastShowMonitoredServices = ShowMonitoredInstancesCheckBox.Checked;
            MachinesList         = machinesList;
            MySqlInstancesList   = instancesList ?? new MySqlInstancesList();
            InstancesListChanged = false;
            ResetChangeCursorDelegate(true);
        }
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ManageItemsDialog"/> class.
 /// </summary>
 /// <param name="instancesList">List of <see cref="MySqlInstance"/> objects.</param>
 /// <param name="machineslist">List of <see cref="Machine"/> objects.</param>
 public ManageItemsDialog(MySqlInstancesList instancesList, MachinesList machineslist)
 {
     _selectedItem         = null;
     _instancesHaveChanges = false;
     _servicesHaveChanges  = false;
     InitializeComponent();
     InstancesList        = instancesList;
     InstancesListChanged = false;
     MachinesList         = machineslist;
     RefreshServicesAndInstancesListViews();
     SetDialogControlsAvailability();
 }
Пример #11
0
        public void Locate_NameAndJohnDoe()
        {
            var newGuid1 = Guid.NewGuid();
            var l        = new MachinesList();
            var m        = l.CreateNew("Machine", "HardwareID", MachineType.Dozer, DeviceTypeEnum.SNM940, false, newGuid1);

            l.Locate("Machine", false).Should().BeSameAs(m);

            var m2 = l.CreateNew("Machine2", "HardwareID2", MachineType.Dozer, DeviceTypeEnum.SNM940, true, Guid.Empty); // John Doe machines don;t have known guids at this point

            l.Locate("Machine2", true).Should().BeSameAs(m2);
        }
Пример #12
0
        private Machine TestMachine()
        {
            var  l       = new MachinesList();
            Guid newGuid = Guid.NewGuid();

            var m = new Machine("Machine", "HardwareID", MachineType.AsphaltPaver, DeviceTypeEnum.SNM940, newGuid, 12, true);

            m.LastKnownLayerId           = 10;
            m.LastKnownDesignName        = "layer";
            m.LastKnownPositionTimeStamp = DateTime.UtcNow;
            m.LastKnownX = 11;
            m.LastKnownY = 12;

            return(m);
        }
Пример #13
0
        public void CreateNew()
        {
            var newGuid = Guid.NewGuid();
            var l       = new MachinesList();
            var m       = l.CreateNew("Machine", "HardwareID", MachineType.Dozer, DeviceTypeEnum.SNM940, false, newGuid);

            m.Should().NotBeNull();
            m.ID.Should().Be(newGuid);
            m.Name.Should().Be("Machine");
            m.MachineHardwareID.Should().Be("HardwareID");
            m.MachineType.Should().Be(MachineType.Dozer);
            m.DeviceType.Should().Be((int)DeviceTypeEnum.SNM940);
            m.InternalSiteModelMachineIndex.Should().Be(0);
            m.IsJohnDoeMachine.Should().BeFalse();
        }
Пример #14
0
        public void Creation3()
        {
            Guid newGuid = Guid.NewGuid();

            var l = new MachinesList();
            var m = new Machine("Machine", "HardwareID", MachineType.AsphaltPaver, DeviceTypeEnum.SNM940, newGuid, 12, true);

            m.ID.Should().Be(newGuid);
            m.Name.Should().Be("Machine");
            m.MachineHardwareID.Should().Be("HardwareID");
            m.MachineType.Should().Be(MachineType.AsphaltPaver);
            m.DeviceType.Should().Be((int)DeviceTypeEnum.SNM940);
            m.InternalSiteModelMachineIndex.Should().Be(12);
            m.IsJohnDoeMachine.Should().BeTrue();
        }
Пример #15
0
        public void Test_AggregatedDataIntegrator_AddTaskToProcessList()
        {
            var integrator = new AggregatedDataIntegrator();

            SiteModel     siteModel = new SiteModel(/*"TestName", "TestDesc", */ Guid.NewGuid(), StorageMutability.Immutable, 1.0);
            IMachinesList machines  = new MachinesList();

            machines.Add(new Machine("TestName", "TestHardwareID", 0, 0, Guid.NewGuid(), 0, false));
            ServerSubGridTree            tree   = new ServerSubGridTree(siteModel.ID, StorageMutability.Mutable);
            MachinesProductionEventLists events = new MachinesProductionEventLists(siteModel, 1);

            integrator.AddTaskToProcessList(siteModel, siteModel.ID, machines, tree, 0, events);

            Assert.Equal(1, integrator.CountOfTasksToProcess);
            Assert.True(integrator.CanAcceptMoreAggregatedCellPasses, "CanAcceptMoreAggregatedCellPasses is false");
        }
Пример #16
0
        public void ReadWritePersistentStore()
        {
            var l  = new MachinesList();
            var m  = l.CreateNew("Machine1", "HardwareID1", MachineType.Dozer, DeviceTypeEnum.SNM940, false, Guid.NewGuid());
            var m2 = l.CreateNew("Machine2", "HardwareID2", MachineType.Dozer, DeviceTypeEnum.SNM940, true, Guid.Empty);

            // Save it then read it back
            l.SaveToPersistentStore(DIContext.Obtain <ISiteModels>().PrimaryMutableStorageProxy);

            // read it back
            var l2 = new MachinesList();

            l2.LoadFromPersistentStore(DIContext.Obtain <ISiteModels>().PrimaryMutableStorageProxy);

            l.Should().BeEquivalentTo(l2);
        }
Пример #17
0
        /// <summary>
        /// Event delegate method fired when the <see cref="ManageItemsDialog"/> button is closed.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Event arguments.</param>
        private void ManageItemsDialog_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (DialogResult != DialogResult.OK)
            {
                return;
            }

            if (_instancesHaveChanges)
            {
                InstancesList.SaveToFile();
            }

            if (_servicesHaveChanges)
            {
                MachinesList.SavetoFile();
            }
        }
Пример #18
0
        private void Initialise()
        {
            ProcessedEpochCount    = 0;
            ProcessedCellPassCount = 0;

            // Note: Intermediary TAG file processing contexts don't store their data to any persistence context
            // so the SiteModel constructed to contain the data processed from a TAG file does not need a
            // storage proxy assigned to it
            SiteModel = DIContext.Obtain <ISiteModelFactory>().NewSiteModel(StorageMutability.Mutable);

            SiteModelGridAggregator = new ServerSubGridTree(SiteModel.ID, StorageMutability.Mutable)
            {
                CellSize = SiteModel.CellSize
            };

            MachinesTargetValueChangesAggregator = new MachinesProductionEventLists(SiteModel, 0);

            Machines = new MachinesList();
        }
Пример #19
0
        /// <summary>
        /// Validates user entries seem valid credentials on the textboxes  to perform a connection test.
        /// </summary>
        private void ValidateEntries()
        {
            // Validate Host name
            if (!string.IsNullOrEmpty(HostTextBox.Text))
            {
                bool   validName;
                string hostname = HostTextBox.Text.Trim();
                if (hostname.ToLowerInvariant() == MySqlWorkbenchConnection.DEFAULT_HOSTNAME || hostname == MySqlWorkbenchConnection.LOCAL_IP || hostname == ".")
                {
                    // Since we are attempting to add a remote computer, we deem the Host name as invalid if it resolves to a local machine.
                    validName = false;
                    InfoDialog.ShowDialog(InfoDialogProperties.GetErrorDialogProperties(Resources.CannotAddLocalhostTitle, Resources.CannotAddLocalhostMessage));
                }
                else if (!EditMode && MachinesList.HasMachineWithName(hostname))
                {
                    // Host name already exists on the list of added remote machines.
                    validName = false;
                    InfoDialog.ShowDialog(InfoDialogProperties.GetErrorDialogProperties(Resources.MachineAlreadyExistTitle, Resources.MachineAlreadyExistMessage));
                }
                else
                {
                    // Host name is also invalid if has non allowed characters or if is not a proper formated IP address.
                    validName = Regex.IsMatch(hostname, VALID_HOSTNAME_REGEX) || Regex.IsMatch(hostname, VALID_IP_REGEX);
                }

                hostErrorSign.Visible = !validName;
            }

            // Username is invalid if if has non allowed characters.
            var userName = UserTextBox.Text;

            userErrorSign.Visible = !string.IsNullOrEmpty(userName) &&
                                    !Regex.IsMatch(userName, VALID_DOWN_LEVEL_LOGON_NAME_REGEX) &&
                                    !Regex.IsMatch(userName, VALID_USER_PRINCIPAL_NAME_REGEX);

            // Enable or dissable buttons if entries seem valid.
            TestConnectionButton.Enabled = EntriesAreValid;
            if (!EntriesAreValid)
            {
                DialogOKButton.Enabled = false;
            }
        }
Пример #20
0
        /// <summary>
        /// Event delegate method fired when the <see cref="EditButton"/> is clicked.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Event arguments.</param>
        private void EditButton_Click(object sender, EventArgs e)
        {
            string oldUser     = NewMachine.User;
            string oldPassword = NewMachine.Password;

            using (var windowsConnectionDialog = new WindowsConnectionDialog(MachinesList, NewMachine))
            {
                if (windowsConnectionDialog.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }

                HasChanges = true;
                NewMachine.CopyMachineData(windowsConnectionDialog.NewMachine,
                                           oldUser != windowsConnectionDialog.NewMachine.User ||
                                           MySqlSecurity.DecryptPassword(oldPassword) != windowsConnectionDialog.NewMachine.UnprotectedPassword);
                MachinesList.ChangeMachine(NewMachine, ListChangeType.Updated);
                RefreshList();
            }
        }
Пример #21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WindowsConnectionDialog"/> class.
        /// </summary>
        /// <param name="machineslist">List of the machines already being added to monitor services.</param>
        /// <param name="currentMachine">Current machine for editing purposes.</param>
        public WindowsConnectionDialog(MachinesList machineslist, Machine currentMachine)
            : this()
        {
            Text = currentMachine == null ? Text : Resources.EditMachineText;
            errorToolTip.SetToolTip(hostErrorSign, Resources.HostToolTipText);
            errorToolTip.SetToolTip(userErrorSign, Resources.UserToolTipText);

            if (currentMachine != null)
            {
                NewMachine           = currentMachine;
                HostTextBox.Text     = currentMachine.Name;
                UserTextBox.Text     = currentMachine.User;
                PasswordTextBox.Text = currentMachine.UnprotectedPassword;
                MachineAutoTestConnectionLabel.Visible = true;
                MachineAutoTestConnectionIntervalNumericUpDown.Visible     = true;
                MachineAutoTestConnectionIntervalNumericUpDown.Value       = NewMachine.AutoTestConnectionInterval;
                MachineAutoTestConnectionIntervalUOMComboBox.Visible       = true;
                MachineAutoTestConnectionIntervalUOMComboBox.SelectedIndex = (int)NewMachine.AutoTestConnectionIntervalUnitOfMeasure;
                Height   = 265;
                EditMode = true;
            }
            else
            {
                NewMachine = new Machine();
                MachineAutoTestConnectionLabel.Visible = false;
                MachineAutoTestConnectionIntervalNumericUpDown.Visible = false;
                MachineAutoTestConnectionIntervalUOMComboBox.Visible   = false;
                Height   = 235;
                EditMode = false;
            }

            if (machineslist == null)
            {
                return;
            }

            if (machineslist.Machines != null)
            {
                MachinesList = machineslist;
            }
        }
Пример #22
0
        /// <summary>
        /// Event delegate method fired when the <see cref="DeleteButton"/> button is clicked.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Event arguments.</param>
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            if (_selectedItem == null)
            {
                return;
            }

            if (_selectedItem is MySqlService)
            {
                var     selectedService = (MySqlService)_selectedItem;
                Machine machine         = MachinesList.GetMachineById(selectedService.Host.MachineId);
                machine.ChangeService(selectedService, ListChangeType.RemoveByUser);
                MonitoredServicesListView.Items.RemoveAt(MonitoredServicesListView.SelectedIndices[0]);
            }
            else if (_selectedItem is MySqlInstance)
            {
                var selectedInstance = (MySqlInstance)_selectedItem;
                if (InstancesList.Remove(selectedInstance))
                {
                    MonitoredInstancesListView.Items.RemoveAt(MonitoredInstancesListView.SelectedIndices[0]);
                }
            }
        }
Пример #23
0
        /// <summary>
        /// Event delegate method fired when the <see cref="DeleteButton"/> is clicked.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Event arguments.</param>
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            var infoProperties = InfoDialogProperties.GetYesNoDialogProperties(
                InfoDialog.InfoType.Warning,
                Resources.DeleteMachineConfirmationTitle,
                Resources.DeleteMachineConfirmationText);

            infoProperties.CommandAreaProperties.DefaultButton        = InfoDialog.DefaultButtonType.Button2;
            infoProperties.CommandAreaProperties.DefaultButtonTimeout = 30;
            var infoResult = InfoDialog.ShowDialog(infoProperties);

            if (infoResult.DialogResult != DialogResult.Yes)
            {
                return;
            }

            HasChanges = true;
            MachinesList.ChangeMachine(NewMachine, ListChangeType.RemoveByUser);
            int removedMachineIndex = MachineSelectionComboBox.SelectedIndex;

            MachineSelectionComboBox.SelectedIndex = 0;
            MachineSelectionComboBox.Items.RemoveAt(removedMachineIndex);
        }
Пример #24
0
        /// <summary>
        /// Event delegate method fired when the <see cref="ServiceToolStripMenuItem"/> context menu item is clicked.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Event arguments.</param>
        private void ServiceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var dialog = new AddServiceDialog(MachinesList))
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    if (dialog.NewMachine != null && dialog.ServicesToAdd != null && dialog.ServicesToAdd.Count > 0)
                    {
                        NewMachine = MachinesList.GetMachineById(dialog.NewMachine.MachineId);
                        if (NewMachine == null)
                        {
                            MachinesList.ChangeMachine(dialog.NewMachine, ListChangeType.AddByUser);
                            NewMachine = dialog.NewMachine;
                        }

                        foreach (MySqlService service in dialog.ServicesToAdd)
                        {
                            if (NewMachine.ContainsService(service))
                            {
                                InfoDialog.ShowDialog(InfoDialogProperties.GetWarningDialogProperties(Resources.WarningText, Resources.ServiceAlreadyInListWarningText));
                            }
                            else
                            {
                                NewMachine.ChangeService(service, ListChangeType.AddByUser);
                                AddService(service, NewMachine, true);
                            }
                        }
                    }
                }

                if (dialog.HasChanges)
                {
                    RefreshServicesAndInstancesListViews();
                }
            }
        }
Пример #25
0
        /// <summary>
        /// Executor that implements deletion of the project
        /// </summary>
        public async Task <bool> ExecuteAsync()
        {
            _log.LogInformation($"Performing Execute for DataModel:{_deleteSiteModelRequestArgument?.ProjectID}, with selectivity {_deleteSiteModelRequestArgument.Selectivity}");

            if (Response.Result != DeleteSiteModelResult.OK)
            {
                _log.LogInformation($"Deleting site model {_deleteSiteModelRequestArgument?.ProjectID}: Initial execution response state not OK ({Response.Result}) - aborting request");
                return(Response.Result == DeleteSiteModelResult.UnableToLocateSiteModel);
            }

            _log.LogInformation($"Deleting site model {_deleteSiteModelRequestArgument?.ProjectID}: Initiating");

            if (!_siteModel.IsMarkedForDeletion)
            {
                // Instruct the site model to mark itself for deletion. Once completed, the site model will no longer be returned
                // by requests to SiteModels.GetSiteModel()
                _siteModel.MarkForDeletion();
            }

            // Obtain a private storage proxy to perform deletion operations in
            var storageProxy = DIContext.Obtain <IStorageProxyFactory>().MutableGridStorage();

            // Begin executing the deletion process. The aspects to be deleted are, in order:
            // All sub grids containing processed cell data
            // Event lists for all machines in the site model
            // All machines for the site model
            // All proofing runs for the site model
            // Site model machine designs index for the site model
            // Site model machine designs list for the site model
            // The designs store for the site model
            // The surveyed surfaces store for the site model
            // The alignments store for the site model
            // The coordinate system for the site model
            // The existence map for the spatial sub grids [this is done late to aid fault recovery]
            // The base metadata for the site model
            // The persistent store for the site model itself

            //***************************************************
            // Begin removal of data elements from the site model
            //***************************************************

            if (_deleteSiteModelRequestArgument.Selectivity.HasFlag(DeleteSiteModelSelectivity.TagFileDerivedData))
            {
                // Remove all spatial data
                if (!RemoveAllSpatialCellPassData(storageProxy))
                {
                    Response.Result = DeleteSiteModelResult.FailedToRemoveSubGrids;
                    return(false);
                }

                // Remove all event data
                RemovalAllMachineEvents(storageProxy, _deleteSiteModelRequestArgument.Selectivity != DeleteSiteModelSelectivity.All);

                // Remove the machines list for the site model. If the override events are being maintained, then
                // recreate machines with jsut basic information
                if (_deleteSiteModelRequestArgument.Selectivity == DeleteSiteModelSelectivity.All)
                {
                    MachinesList.RemoveFromPersistentStore(_siteModel.ID, storageProxy);
                }
                else
                {
                    _siteModel.Machines.ClearTAGFileStateData(storageProxy);
                }

                // Remove the site model machine designs list for the site model
                SiteModelMachineDesignList.RemoveFromPersistentStore(_siteModel.ID, storageProxy);

                // Remove the proofing run list for the site model
                SiteProofingRunList.RemoveFromPersistentStore(_siteModel.ID, storageProxy);

                // Remove the site model production designs list from the site model
                SiteModelDesignList.RemoveFromPersistentStoreStatic(_siteModel.ID, storageProxy);
            }

            if (_deleteSiteModelRequestArgument.Selectivity.HasFlag(DeleteSiteModelSelectivity.Designs))
            {
                // **********************************************
                // Remove the list of designs from the site model
                // **********************************************
                if (!DIContext.Obtain <IDesignManager>().Remove(_siteModel.ID, storageProxy))
                {
                    _log.LogInformation($"Deleting site model {_siteModel.ID}: Failed to remove site designs");
                    Response.Result = DeleteSiteModelResult.FailedToRemoveSiteDesigns;
                    return(false);
                }
            }

            if (_deleteSiteModelRequestArgument.Selectivity.HasFlag(DeleteSiteModelSelectivity.SurveyedSurfaces))
            {
                // ********************************************************
                // Remove the list of surveyed surfaces from the site model
                // ********************************************************

                if (!DIContext.Obtain <ISurveyedSurfaceManager>().Remove(_siteModel.ID, storageProxy))
                {
                    _log.LogInformation($"Deleting site model {_siteModel.ID}: Failed to remove surveyed surfaces");
                    Response.Result = DeleteSiteModelResult.FailedToRemoveSurveyedSurfaces;
                    return(false);
                }
            }

            if (_deleteSiteModelRequestArgument.Selectivity.HasFlag(DeleteSiteModelSelectivity.Alignments))
            {
                // *************************************************
                // Remove the list of alignments from the site model
                // *************************************************

                if (!DIContext.Obtain <IAlignmentManager>().Remove(_siteModel.ID, storageProxy))
                {
                    _log.LogInformation($"Deleting site model {_siteModel.ID}: Failed to remove alignments");
                    Response.Result = DeleteSiteModelResult.FailedToRemoveAlignments;
                    return(false);
                }
            }

            if (_deleteSiteModelRequestArgument.Selectivity.HasFlag(DeleteSiteModelSelectivity.CoordinateSystem))
            {
                // ************************************************
                // Remove the coordinate system from the site model
                // ************************************************

                // TODO: CSIB add/remove/read support could be wrapped into a more central location as a manager (currently controlled here, Add CSIB activity and SiteModel class)
                if (storageProxy.RemoveStreamFromPersistentStore(_siteModel.ID, FileSystemStreamType.CoordinateSystemCSIB, CoordinateSystemConsts.CoordinateSystemCSIBStorageKeyName) != FileSystemErrorStatus.OK)
                {
                    _log.LogInformation($"Deleting site model {_siteModel.ID}: Failed to remove CSIB");
                    Response.Result = DeleteSiteModelResult.FailedToRemoveCSIB;
                    return(false);
                }
            }

            // ****************************************************************************************************************
            // Commit all assembled deletion stages before removing existence map and metadata. This helps recovery from errors
            // in the commit process resulting in partial deletion.
            // ****************************************************************************************************************

            if (!storageProxy.Commit(out var numDeleted, out _, out _))
            {
                Response.Result = DeleteSiteModelResult.FailedToCommitPrimaryElementRemoval;
                _log.LogInformation($"Deleting site model {_siteModel.ID}: Failed to commit primary element removal");
                return(false);
            }

            Response.NumRemovedElements = numDeleted;

            _log.LogInformation($"Deleting site model {_siteModel.ID}: Primary commit removed {numDeleted} elements");

            if (_deleteSiteModelRequestArgument.Selectivity.HasFlag(DeleteSiteModelSelectivity.SiteModelMetadata))
            {
                // Remove the site model meta data entry for the site model
                // TODO: This is a non transacted operation and could be facaded with the storage proxy cache pattern as an internal implementation concern (this is only a mutable grid activity)
                DIContext.Obtain <ISiteModelMetadataManager>().Remove(_siteModel.ID);
                Response.NumRemovedElements++;
            }

            if (_deleteSiteModelRequestArgument.Selectivity.HasFlag(DeleteSiteModelSelectivity.TagFileDerivedData))
            {
                //*************************
                // Remove the existence map
                //*************************
                _siteModel.RemoveProductionDataExistenceMapFromStorage(storageProxy);

                if (!storageProxy.Commit())
                {
                    Response.Result = DeleteSiteModelResult.FailedToCommitExistenceMapRemoval;
                    _log.LogInformation($"Deleting site model {_siteModel.ID}: Failed to commit existence map removal");
                    return(false);
                }

                Response.NumRemovedElements++;
            }

            if (_deleteSiteModelRequestArgument.Selectivity.HasFlag(DeleteSiteModelSelectivity.SiteModel))
            {
                //************************************************************
                // Remove the site model persistent storage for the site model
                //************************************************************
                var productionDataXmlResult = _siteModel.RemoveMetadataFromPersistentStore(storageProxy);
                if (!productionDataXmlResult)
                {
                    Response.Result = DeleteSiteModelResult.FailedToRemoveProjectMetadata;
                    _log.LogError($"Deleting site model {_siteModel.ID}: Unable to remove site model persistent store");
                    return(false);
                }

                if (!storageProxy.Commit(out _, out _, out _))
                {
                    _log.LogInformation($"Deleting site model {_siteModel.ID}: Failed to commit site model metadata removal");
                    return(false);
                }
            }

            // If the delete operation had partial selectivity enabled, then remove the delete flag from the site model
            if (_deleteSiteModelRequestArgument.Selectivity != DeleteSiteModelSelectivity.All)
            {
                // Instruct the site model to remove the deletion mark against it to allow operations to continue as normal
                _siteModel.RemovedMarkForDeletion();
            }

            Response.NumRemovedElements++;

            _log.LogInformation($"Deleting site model {_siteModel.ID} with selectivity = {_deleteSiteModelRequestArgument.Selectivity}: Complete");

            Response.Result = DeleteSiteModelResult.OK;
            return(true);
        }
Пример #26
0
 /// <summary>
 /// Checks if a Workbench connection is being monitored already.
 /// </summary>
 /// <param name="connection">A Workbench connection to check for.</param>
 /// <returns><c>true</c> if the connection is already being monitored, <c>false</c> otherwise.</returns>
 private bool IsWorkbenchConnectionAlreadyMonitored(MySqlWorkbenchConnection connection)
 {
     return(MachinesList.IsWorkbenchConnectionAlreadyMonitored(connection) ||
            MySqlInstancesList.IsWorkbenchConnectionAlreadyMonitored(connection));
 }
Пример #27
0
        public void Creation()
        {
            var l = new MachinesList();

            l.DataModelID.Should().Be(Guid.Empty);
        }