Exemplo n.º 1
0
        /// <summary>
        /// Identifies the device.
        /// </summary>
        /// <param name="ip">The ip.</param>
        /// <returns></returns>
        public static string IdentDevice(string ip)
        {
            FnLog.GetInstance().AddToLogList(FnLog.LogType.RuntimeInfo, "DeviceTools", "IdentDevice");
            var dt      = Config.GetInstance().SelectFromOidTable();
            var profile = SnmpClient.GetOidValue(ip, "1.3.6.1.2.1.1.2.0");

            if (profile.Length == 0)
            {
                FnLog.GetInstance()
                .AddToLogList(FnLog.LogType.Error, "DeviceTools", "IdentDevice - profile.Length == 0");
                throw new SnmpIdentNotFoundException();
            }

            for (var i = 0; i < dt.Rows.Count; i++)
            {
                Debug.Write("\n\n " + SnmpClient.GetOidValue(ip, "1.3.6.1.2.1.1.2.0"));
                Debug.Write("\n\n " + dt.Rows[i].Field <string>("ProfileName"));
                if (profile.Contains(dt.Rows[i].Field <string>("ProfileName")))
                {
                    return(dt.Rows[i].Field <string>("OidPrivateId"));
                }
                FnLog.GetInstance().AddToLogList(FnLog.LogType.RuntimeInfo, "DeviceTools",
                                                 "IdentDevice - " + dt.Rows[i].Field <string>("OidPrivateId"));
            }

            FnLog.GetInstance().AddToLogList(FnLog.LogType.RuntimeInfo, "DeviceTools", "IdentDevice - GENERIC");
            return("Generic");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retrieves the data of all MPS Systems marked for gathereing information
        /// </summary>
        /// <returns></returns>
        public List <OidData> GainData()
        {
            FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "RetrieveDeviceInformation", "GainData");
            var dt = Config.GetInstance().Query("select * from Devices where active='1' or active='True'");
            // DataTable resultTable = null;
            var data = new List <OidData>();

            for (var i = 0; i < dt.Rows.Count; i++)
            {
                if (DeviceTools.IdentDevice(dt.Rows[i].Field <string>("Ip")).Length > 0)
                {
                    if (FnPing.PingAndCheckSuccess(IPAddress.Parse(dt.Rows[i].Field <string>("Ip"))))
                    {
                        if (SnmpClient.ReadDeviceOiDs(dt.Rows[i].Field <string>("Ip"),
                                                      DeviceTools.IdentDevice(dt.Rows[i].Field <string>("Ip")), out OidData oidData))
                        {
                            if (oidData != null)
                            {
                                data.Add(oidData);
                            }
                        }
                    }
                }
            }

            return(data);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Handles the Load event of the RibbonWindow control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs" /> instance containing the event data.</param>
        public void RibbonWindow_Load(object sender, RoutedEventArgs e)
        {
            //zurueck.IsEnabled = false;
            try
            {
                FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT",
                                                 "RibbonWindow_Load Start");

                LoadUserControls();
                FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT",
                                                 "RibbonWindow_Load LoadUserControls done");

                OpenSearchUserControl();
                FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT",
                                                 "RibbonWindow_Load OpenSearchUserControl done");

                //var a = new openRegistration();
                //a.ShowDialog();
            }
            catch (MPSSQLiteException)
            {
                FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupError, "openMPS Main Window INIT",
                                                 "RibbonWindow_Load Config File Error");

                MessageBox.Show("Fehler!!\nKonfigurationsdatei Fehlerhaft",
                                "!!!Kritischer Fehler!!!\n"
                                , MessageBoxButton.OK, MessageBoxImage.Error);
                Close();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Checks Oif Version
        /// Returns true if Version greater/equal than Server Version
        /// Returns false if Version smaller than Server Version
        /// </summary>
        /// <returns></returns>
        public bool CheckOidVersion(out string oidServerVersion)
        {
            FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient", "CheckOidVersion");
            if (Config.GetInstance().Directory.TryGetValue("OidVersion", out string instVer))
            {
                FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient",
                                                 " CheckOidVersion TryGetValue done");

                var ver = SocketIoClient.RetrieveSingleValue <VersionWrapper>(_url,
                                                                              "OidVersionOffer", "OidVersionRequest", null, timeout: 30000);
                FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient",
                                                 "OidVersionOffer received");

                if (System.Version.TryParse(instVer, out Version instVersion) &&
                    System.Version.TryParse(ver.Version, out Version version))
                {
                    FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient",
                                                     "before assigning out");

                    oidServerVersion = ver.Version;
                    FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient",
                                                     "CheckOidVersion Complete");
                    return(instVersion.CompareTo(version) >= 0);
                }
            }

            FnLog.GetInstance().AddToLogList(FnLog.LogType.CriticalError, "OpenMPSClient",
                                             "Missing Directory OidVersion Value");
            throw new QueryFailedException();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Handles the Click event of the ButtonDeleteEntry control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs" /> instance containing the event data.</param>
        private void ButtonDeleteEntry_Click(object sender, RoutedEventArgs e)
        {
            ButtonDeleteEntry.IsEnabled = false;
            ButtonSaveEntry.IsEnabled   = false;
            var ipAddress =
                TextBoxIpSegmentOne.Text + "." +
                TextBoxIpSegmentTwo.Text + "." +
                TextBoxIpSegmentThree.Text + "." +
                TextBoxIpSegmentFour.Text;

            FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "EditDevices",
                                             "Button Delete click " + ipAddress);

            if (selected)
            {
                try
                {
                    Config.GetInstance().NonQuery("delete from Devices where IP='" + ipAddress + "';");
                    LoadGridData();
                }
                catch (Exception)
                {
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Finds the ip range.
        /// </summary>
        /// <param name="ipMask">The ip mask.</param>
        /// <returns></returns>
        public static IPAddress[] FindIpRange(string[] ipMask)
        {
            FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "ScanIp", "FindIpRange");

            var ip   = IPAddress.Parse(ipMask[0]);
            var bits = NetmaskToBit(ipMask[1]);
            var mask = ~(uint.MaxValue >> bits);
            // Convert the IP address to bytes.
            var ipBytes = ip.GetAddressBytes();
            // BitConverter gives bytes in opposite order to GetAddressBytes().
            var maskBytes    = BitConverter.GetBytes(mask).Reverse().ToArray();
            var startIpBytes = new byte[ipBytes.Length];
            var endIpBytes   = new byte[ipBytes.Length];

            // Calculate the bytes of the start and end IP addresses.
            for (var i = 0; i < ipBytes.Length; i++)
            {
                startIpBytes[i] = (byte)(ipBytes[i] & maskBytes[i]);
                endIpBytes[i]   = (byte)(ipBytes[i] | ~maskBytes[i]);
            }
            FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo,
                                             "ScanIp", "FindIpRange NETMASK FROM " +
                                             new IPAddress(startIpBytes).ToString() +
                                             " TO " + new IPAddress(endIpBytes).ToString());

            // Convert the bytes to IP addresses.
            return(new[] { new IPAddress(startIpBytes), new IPAddress(endIpBytes) });
        }
Exemplo n.º 7
0
        /// <summary>
        /// updates the oid table
        /// </summary>
        public void UpdateOidTable()
        {
            FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient", "UpdateOidTable");
            var thread = new Thread(UpdateOidTableThreaded);

            thread.Start();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Checks for the minimum openMPS server version
        /// </summary>
        /// <returns></returns>
        private bool CheckMinClientVersion()
        {
            try
            {
                FnLog.GetInstance()
                .AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient", "CheckMinClientVersion");
                var ver = SocketIoClient.RetrieveSingleValue <VersionWrapper>(_url,
                                                                              "MPSMinClientVersionOffer", "MPSMinClientVersionRequest", null, timeout: 30000);
                var progVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

                if (System.Version.TryParse(progVersion, out Version programVersion) &&
                    System.Version.TryParse(ver.Version, out Version minversion))
                {
                    FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient",
                                                     "CheckMinClientVersion Complete");
                    return(programVersion.CompareTo(minversion) >= 0);
                }

                FnLog.GetInstance().AddToLogList(FnLog.LogType.Error, "OpenMPSClient",
                                                 "CheckMinClientVersion ResultNullOrNotReceivedException");
                throw new ResultNullOrNotReceivedException();
            }
            catch (Exception e)
            {
                FnLog.GetInstance().AddToLogList(FnLog.LogType.Error, "OpenMPSClient",
                                                 "CheckMinClientVersion" + e.Message);
                MessageBox.Show("Could not reach the openMPS Server");
                throw new ResultNullOrNotReceivedException();
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Inserts the in devices via thread.
        /// </summary>
        /// <param name="param">The parameter.</param>
        private void InsertInDevicesViaThread(object param)
        {
            var obj       = (object[])param;
            var ipAddress = (string)obj[0];
            var aktiv     = (string)obj[1];

            try
            {
                var ident  = DeviceTools.IdentDevice(ipAddress);
                var modell = "";
                var serial = "";
                var asset  = "";
                FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "EditDevices",
                                                 "InsertDevicesViaThread " + ipAddress);

                var ip = IPAddress.Parse(ipAddress);
                ProgressBarProgress.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(adjustProgress));

                if (ident.Length > 0)
                {
                    var dt = Config.GetInstance().GetOidRowByPrivateId(ident);
                    ProgressBarProgress.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                                               new Action(adjustProgress));
                    modell = SnmpClient.GetOidValue(ipAddress, dt.Rows[0].Field <string>("Model"));
                    ProgressBarProgress.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                                               new Action(adjustProgress));
                    serial = SnmpClient.GetOidValue(ipAddress, dt.Rows[0].Field <string>("SerialNumber"));
                    ProgressBarProgress.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                                               new Action(adjustProgress));
                    asset = SnmpClient.GetOidValue(ipAddress, dt.Rows[0].Field <string>("AssetNumber"));
                    ProgressBarProgress.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                                               new Action(adjustProgress));
                }
                else
                {
                    ProgressBarProgress.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                                               new Action(adjustProgress));
                    ProgressBarProgress.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                                               new Action(adjustProgress));
                    ProgressBarProgress.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                                               new Action(adjustProgress));
                    ProgressBarProgress.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                                               new Action(adjustProgress));
                }

                Config.GetInstance().InsertInDeviceTable(
                    aktiv,
                    ip.GetAddressBytes(),
                    modell,
                    serial,
                    asset
                    );
            }
            catch (SnmpIdentNotFoundException)
            {
            }

            DataGridDevices.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(LoadGridData));
        }
Exemplo n.º 10
0
 /// <summary>
 /// Updates the grid.
 /// </summary>
 private void UpdateGrid()
 {
     DataGridItemViewer.ItemsSource = OidData.ToDataTable(_oidData).DefaultView;
     ButtonRetrieveData.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(GetNormalView));
     ButtonSend.IsEnabled = true;
     FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "RetrieveDeviceInformation",
                                      "Button ButtonRetrieveData Complete");
 }
Exemplo n.º 11
0
        /// <summary>
        /// Loads the usercontrols that are not needed to start the program threaded to speed up the program start
        /// </summary>
        private void LoadUserControls()
        {
            FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT", "LoadUserControls");

            _userControls = new Dictionary <Type, UserControl>();
            Dispatcher.Invoke(new ThreadStart(LoadDelayableUserControl));
            Dispatcher.Invoke(new ThreadStart(LoadBackstageUserControls));
        }
Exemplo n.º 12
0
 /// <summary>
 /// Loads the usercontrols for the backstage threaded
 /// </summary>
 public void LoadBackstageUserControls()
 {
     FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT",
                                      "LoadBackstageUserControls");
     _userControls.Add(typeof(InfoPage), new InfoPage());
     _userControls.Add(typeof(Settings), new Settings());
     GridHelp.Children.Add(_userControls[typeof(InfoPage)]);
     GridSettings.Children.Add(_userControls[typeof(Settings)]);
 }
Exemplo n.º 13
0
        /// <summary>
        /// Connects to FnLogServer, OpenMPSServer, ManastoneServer
        /// The license check and the retrieval of the OID Table will happen here
        /// Exits if connection is not possible
        /// </summary>
        private void InitClientConnection()
        {
            try
            {
                Config.GetInstance().Open();
                FnLog.SetInstance(new FnLog.FnLogInitPackage(
                                      "https://app.fearvel.de:9020/",
                                      System.Reflection.Assembly.GetExecutingAssembly().GetName().Name,
                                      Version.Parse(GetFileVersion()),
                                      FnLog.TelemetryType.LogLocalSendAll,
                                      "", ""), Config.GetInstance().GetConnector()
                                  );
                FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT",
                                                 "FnLog INIT Complete");
                OpenMPSClient.SetInstance("https://app.fearvel.de:9040/");
                FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT",
                                                 "OpenMPSClient set");
                ManastoneClient.SetInstance("https://app.fearvel.de:9060/", "5d1ae2a2-6ef3-4abd-86b8-905686dc6567");
                FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT", "Manastone set");
                OpenMPSClient.GetInstance().CheckForCompatibleVersion();
                FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT",
                                                 "Compatible VersionChecked");
                if (!ManastoneClient.GetInstance().CheckActivation())
                {
                    FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT",
                                                     "Activation process Started");
                    ActivateProgram();
                }

                FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT",
                                                 "Activation Update OID Starting");
            }
            catch (Exception e)
            {
                FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupError, "Error on InitClientConnection of openMPS",
                                                 e.Message);
                FnLog.GetInstance().ProcessLogList();
                if (e is ManastoneException || e is ResultNullOrNotReceivedException)
                {
                    MessageBox.Show(
                        "Failed to connect to the Server. Check your internet connection and try again Later!");
                    Environment.Exit(0);
                }
                else if (e is SQLiteException)
                {
                    MessageBox.Show(
                        "SQLite Error\n Falls das Produkt noch nicht Aktiviert wurde löschen sie bitte alle *.db dateien\n" +
                        "Falls es bereits aktiviert wurde wenden Sie sich bitte an den Entwickeler");
                    Environment.Exit(0);
                }
                else
                {
                    MessageBox.Show("Ein unbekannter Fehler ist aufgetreten!!");
                    Environment.Exit(0);
                }
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Handles the Click event of the ButtonHelp control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs" /> instance containing the event data.</param>
        private void ButtonHelp_Click(object sender, RoutedEventArgs e)
        {
            FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "EditDevices", "Button help click");

            MessageBox.Show("Gerät neu anlegen:\n"
                            + "Klicken Sie auf den Button „Gerät neu anlegen“ und erfassen anschließend"
                            + "die IPv4-Adresse oder wahlweise den Hostname des Gerätes in den dafür vorgesehenen Feldern"
                            , "Anleitung", MessageBoxButton.OK, MessageBoxImage.Information);
        }
Exemplo n.º 15
0
        /// <summary>
        /// sends the oid data
        /// </summary>
        /// <param name="data"></param>
        public void SendOidData(List <OidData> data)
        {
            FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient", "SendOidData");
            var dataStr = JsonConvert.SerializeObject(data, Formatting.Indented).Trim()
                          .Replace(System.Environment.NewLine, "");
            var res = SocketIoClient.RetrieveSingleValue <SimpleResult>(_url,
                                                                        "closer", "SendData", dataStr, timeout: 30000);

            FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient", "SendOidData sent");
        }
Exemplo n.º 16
0
        /// <summary>
        /// Handles the Click event of the bt_start control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs" /> instance containing the event data.</param>
        private void ButtonRetrieveData_Click(object sender, RoutedEventArgs e)
        {
            FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "RetrieveDeviceInformation",
                                             "Button ButtonRetrieveData Clicked");

            ProgressBarRetrieveData.Value      = 0;
            ProgressBarRetrieveData.Visibility = Visibility.Visible;
            ThreadPool.QueueUserWorkItem(UpdateDataGrid);
            ThreadPool.QueueUserWorkItem(AdaptProgressLoad);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Loads the usercontrols for the ribbon buttons threaded
        /// </summary>
        private void LoadDelayableUserControl()
        {
            FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT",
                                             "LoadDelayableUserControl");

            _userControls.Add(typeof(SearchForDevices), new SearchForDevices());
            _userControls.Add(typeof(EditDevices), new EditDevices());
            _userControls.Add(typeof(RetrieveDeviceInformation), new RetrieveDeviceInformation());
            FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT",
                                             "LoadDelayableUserControl done");
        }
Exemplo n.º 18
0
        /// <summary>
        ///     Updates the data grid.
        /// </summary>
        /// <param name="state">The state.</param>
        private void UpdateDataGrid(object state)
        {
            FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "RetrieveDeviceInformation",
                                             "UpdateDataGrid");
            var oidData = GainData();

            _oidData = oidData;
            //     dt = Collector.shellDT("Select * from Collector");
            // this.dt = dt;
            DataGridItemViewer.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(UpdateGrid));
        }
Exemplo n.º 19
0
        /// <summary>
        /// Displays the
        /// </summary>
        /// <param name="uc"></param>
        /// <param name="text"></param>
        private void DisplayUserControl(UserControl uc, string text = "")
        {
            FnLog.GetInstance()
            .AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT", "DisplayUserControl");

            MainGrid.Children.Clear();
            MainGrid.Children.Add(uc);
            TextBlockInfo.Text = uc is IRibbonAdvisoryText ? ((IRibbonAdvisoryText)uc).AdvisoryText : text;
            FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT",
                                             "DisplayUserControl done");
            FnLog.GetInstance().ProcessLogList();
        }
Exemplo n.º 20
0
        /// <summary>
        /// Loads the remaining part of the Settings UserControl
        /// </summary>
        private void LoadSettingsUserControl()
        {
            try
            {
                FnLog.GetInstance().ProcessLogList();

                GridSetting.Children.Clear();
                var item = _options[ListBoxSettings.SelectedItem.ToString()];
                GridSetting.Children.Add(item);

                ((IReloadable)item).Reload();  //unclean but works
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Downloads and updates the oid table
        /// </summary>
        /// <param name="oidVersion"></param>
        private void DownloadAndUpdateOidTable(string oidVersion)
        {
            ManastoneClient.GetInstance().CheckToken();

            FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient",
                                             "DownloadAndUpdateOidTable - " + ManastoneClient.GetInstance().Token);
            var oid = SocketIoClient.RetrieveSingleValue <List <Oid> >(_url,
                                                                       "OidOffer", "OidRequest", new OidRequest(ManastoneClient.GetInstance().Token).Serialize(),
                                                                       timeout: 30000);

            FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient",
                                             "DownloadAndUpdateOidTable received" + oid.Count);
            Config.GetInstance().UpdateOids(oidVersion, oid);
            FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient",
                                             "DownloadAndUpdateOidTable Complete");
        }
Exemplo n.º 22
0
        /// <summary>
        /// Handles the Click event of the ButtonCreateEntry control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs" /> instance containing the event data.</param>
        private void ButtonCreateEntry_Click(object sender, RoutedEventArgs e)
        {
            FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "EditDevices", "Button Create click ");

            selected = false;
            ButtonSaveEntry.IsEnabled = true;
            unlockElements();
            DataGridDevices.UnselectAll();
            TextBoxHostName.IsEnabled = true;
            TextBoxIpSegmentOne.Clear();
            TextBoxIpSegmentTwo.Clear();
            TextBoxIpSegmentThree.Clear();
            TextBoxIpSegmentFour.Clear();
            TextBoxHostName.Clear();
            CheckBoxActive.IsChecked = true;
        }
Exemplo n.º 23
0
        /// <summary>
        /// Opens the Activation window
        /// Program will exit if an activation is failed or the activation window is closed
        /// </summary>
        private void ActivateProgram()
        {
            var licCheck = new LicenseDialog();

            licCheck.ShowDialog();
            FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT",
                                             "ActivateProgram Dialog Opened");
            if (!licCheck.Result)
            {
                FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT",
                                                 "ActivateProgram Result false: " + licCheck.Result);
                FnLog.GetInstance().ProcessLogList();
                Environment.Exit(1);
            }

            FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT",
                                             "ActivateProgram Dialog finished successfully");
        }
Exemplo n.º 24
0
        /// <summary>
        /// Netmask to bit.
        /// </summary>
        /// <param name="mask">The mask.</param>
        /// <returns></returns>
        public static int NetmaskToBit(string mask)
        {
            FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "ScanIp", "NetmaskToBit");
            var totalBits = 0;

            foreach (var octet in mask.Split('.'))
            {
                var octetByte = byte.Parse(octet);
                while (octetByte != 0)
                {
                    totalBits  += octetByte & 1; // logical AND on the LSB
                    octetByte >>= 1;             // do a bitwise shift to the right to create a new LSB
                }
            }

            FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "ScanIp", "NetmaskToBit - " + totalBits);
            return(totalBits);
        }
Exemplo n.º 25
0
 /// <summary>
 /// Updates the oid table threaded
 /// </summary>
 public void UpdateOidTableThreaded()
 {
     try
     {
         FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient",
                                          "UpdateOidTableThreaded");
         if (!CheckOidVersion(out string oidServerVersion))
         {
             FnLog.GetInstance().AddToLogList(FnLog.LogType.MajorRuntimeInfo, "OpenMPSClient",
                                              "UpdateOidTableThreaded newer version detected");
             DownloadAndUpdateOidTable(oidServerVersion);
         }
     }
     catch (Exception e)
     {
         FnLog.GetInstance().AddToLogList(FnLog.LogType.Error, "OpenMPSClient",
                                          "UpdateOidTableThreaded " + e.Message);
     }
 }
Exemplo n.º 26
0
        /// <summary>
        /// Loads the grid data.
        /// </summary>
        public void LoadGridData()
        {
            FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "EditDevices", "LoadGridData");

            Config.GetInstance().UpdateDevices();
            DataGridDevices.ItemsSource = Config.GetInstance().Devices.DefaultView;
            if (DataGridDevices.Columns.Count >= 7)
            {
                DataGridDevices.Columns[6].Visibility = Visibility.Hidden;
                DataGridDevices.Columns[0].IsReadOnly = true;
                DataGridDevices.Columns[1].IsReadOnly = true;
                DataGridDevices.Columns[2].IsReadOnly = true;
                DataGridDevices.Columns[3].IsReadOnly = true;
                DataGridDevices.Columns[4].IsReadOnly = true;
                DataGridDevices.Columns[5].IsReadOnly = true;
            }

            FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "EditDevices", "LoadGridData Complete");
        }
Exemplo n.º 27
0
        /// <summary>
        ///     Gets the ip mask.
        /// </summary>
        /// <returns></returns>
        public static string[] GetIpMask()
        {
            FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "ScanIp", "GetIpMask");
            string[] address     = null;
            string[] subnetMask  = null;
            var      networkInfo =
                new ManagementObjectSearcher(
                    "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'");
            var moc = networkInfo.Get();

            foreach (var mo in moc)
            {
                address    = (string[])mo["IPAddress"];
                subnetMask = (string[])mo["IPSubnet"];
            }
            FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "ScanIp",
                                             "GetIpMask - " + address[0] + " - " + subnetMask[0]);

            return(new[] { address[0], subnetMask[0] });
        }
Exemplo n.º 28
0
        /// <summary>
        /// Loads the grid data.
        /// </summary>
        public void LoadGridData()
        {
            Config.GetInstance().UpdateDevices();
            var dt = Config.GetInstance().Devices;

            DataGridDevices.ItemsSource = dt.DefaultView;
            if (DataGridDevices.Columns.Count >= 7)
            {
                DataGridDevices.Columns[6].Visibility = Visibility.Hidden;
                DataGridDevices.Columns[0].IsReadOnly = true;
                DataGridDevices.Columns[1].IsReadOnly = true;
                DataGridDevices.Columns[2].IsReadOnly = true;
                DataGridDevices.Columns[3].IsReadOnly = true;
                DataGridDevices.Columns[4].IsReadOnly = true;
                DataGridDevices.Columns[5].IsReadOnly = true;
            }
            DataGridDevices.IsReadOnly = true;
            FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "SearchForDevices",
                                             "Search Complete Count: " + dt.Rows.Count);
        }
Exemplo n.º 29
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RibbonWindow" /> class.
        /// </summary>
        public MainWindow()
        {
            InitClientConnection();
            FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT", "INIT COMPLETE");
            FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT",
                                             "InitializeComponent Started");

            InitializeComponent();
            FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT",
                                             "InitializeComponent COMPLETE");
            MetroWindowMain.Title +=
                " " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
            FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT", "Title updated");
            Loaded += RibbonWindow_Load;
            FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT",
                                             "RibbonWindow_Load complete");
            FnLog.GetInstance().AddToLogList(FnLog.LogType.StartupLog, "openMPS Main Window INIT", "Program Started");
            FnLog.GetInstance().ProcessLogList();
            OpenMPSClient.GetInstance().UpdateOidTable();
        }
Exemplo n.º 30
0
 /// <summary>
 /// Activate button click event
 /// triggers an activation via ManastoneClient
 /// prompts message-boxes if activation failed
 /// closes the dialog if activation is successful
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButtonActivate_OnClick(object sender, RoutedEventArgs e)
 {
     if (CheckLength())
     {
         if (ManastoneClient.GetInstance().Activate(SpliceSegments()))
         {
             Result = true;
             FnLog.GetInstance().AddToLogList(FnLog.LogType.RuntimeInfo, "LicenseDialog", "true close");
             this.Close();
         }
         else
         {
             MessageBox.Show("Fehlerhafe Seriennummer");
         }
     }
     else
     {
         MessageBox.Show("Bitte geben Sie eine gültige Seriennummer ein!");
     }
 }