Esempio n. 1
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");
 }
Esempio n. 2
0
        /// <summary>
        /// Register a new oid
        /// </summary>
        public OidData Register(string name, string oid, string desc, string uri)
        {
            var oidData = new OidData()
            {
                Name        = name,
                Oid         = oid,
                Description = desc,
                Ref         = new Uri(uri),
                Mnemonic    = name
            };

            this.Register(oidData);
            return(oidData);
        }
Esempio n. 3
0
        /// <summary>
        /// Register a new oid
        /// </summary>
        public void Register(OidData oidData)
        {
            using (DataContext dataContext = this.m_configuration.Provider.GetWriteConnection())
            {
                try
                {
                    dataContext.Open();
                    using (var tx = dataContext.BeginTransaction())
                    {
                        try
                        {
                            // First attempt to find the oid
                            var dba = new DbAssigningAuthority()
                            {
                                Description = oidData.Description,
                                Name        = oidData.Name,
                                Oid         = oidData.Oid,
                                Url         = oidData.Ref.ToString(),
                                DomainName  = oidData.Mnemonic
                            };

                            // Add attributes
                            var regex   = oidData.Attributes.FirstOrDefault(o => o.Key == "ValidationRegex");
                            var asgnDev = oidData.Attributes.FirstOrDefault(o => o.Key == "AssigningDevice");
                            dba.ValidationRegex = regex.Value;
                            if (!String.IsNullOrEmpty(asgnDev.Value))
                            {
                                var device = ApplicationContext.Current.GetService <ISecurityRepositoryService>().FindDevices(o => o.Name == asgnDev.Value).FirstOrDefault();
                                dba.AssigningDeviceKey = device?.Key;
                            }

                            dataContext.Insert(dba);

                            tx.Commit();
                        }
                        catch
                        {
                            tx.Rollback();
                            throw;
                        }
                    }
                }
                catch (Exception e)
                {
                    this.m_tracer.TraceEvent(TraceEventType.Error, e.HResult, "Error inserting OID {0} : {1}", oidData, e);
                    throw;
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Parse oid data
        /// </summary>
        private OidData ParseOidData(DbAssigningAuthority oid)
        {
            var retVal = new OidData()
            {
                Description = oid.Description,
                Mnemonic    = oid.DomainName,
                Name        = oid.Name,
                Oid         = oid.Oid,
                Ref         = !String.IsNullOrEmpty(oid.Url) ? new Uri(oid.Url) : null
            };

            if (!String.IsNullOrEmpty(oid.ValidationRegex))
            {
                retVal.Attributes.Add(new KeyValuePair <string, string>("ValidationRegex", oid.ValidationRegex));
            }
            return(retVal);
        }
Esempio n. 5
0
        public static bool ReadDeviceOiDs(string ip, string ident, out OidData oidData)
        {
            FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "SnmpClient", "ReadDeviceOiDs");
            var dt = Config.GetInstance().SelectFromOidTable(ident);

            try
            {
                FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "SnmpClient",
                                                 "ReadDeviceOiDs - IP " + ip + " OIDDATA " + GetOidValues(ip, dt));

                oidData = GetOidValues(ip, dt);
                return(true);
            }
            catch (SnmpException)
            {
                FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "SnmpClient",
                                                 "ReadDeviceOiDs - SnmpException");
                oidData = null;
                return(false);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// uses snmp to get the values of an mps
        /// fills an OidData instance
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="oid"></param>
        /// <returns></returns>
        public static OidData GetOidValues(string ip, DataTable oid)
        {
            FnLog.GetInstance().AddToLogList(FnLog.LogType.MinorRuntimeInfo, "SnmpClient", "GetOidValues ip " + ip);
            var data     = new OidData();
            var strDict  = new Dictionary <string, string>();
            var longDict = new Dictionary <string, long>();

            try
            {
                foreach (var pair in ScannedOiDs)
                {
                    if (pair.Value == typeof(string))
                    {
                        strDict.Add(pair.Key, GetOidValue(ip, oid.Rows[0].Field <string>(pair.Key)));
                    }
                    else
                    {
                        var dataStr = GetOidValue(ip, oid.Rows[0].Field <string>(pair.Key));
                        longDict.Add(pair.Key, dataStr.Length > 0 ? long.Parse(dataStr) : 0);
                    }
                }

                data.VendorName               = strDict["VendorName"];
                data.Model                    = strDict["Model"];
                data.SerialNumber             = strDict["SerialNumber"];
                data.MacAddress               = strDict["MacAddress"];
                data.IpAddress                = strDict["IpAddress"];
                data.HostName                 = strDict["HostName"];
                data.DescriptionLocation      = strDict["DescriptionLocation"];
                data.AssetNumber              = strDict["AssetNumber"];
                data.FirmwareVersion          = strDict["FirmwareVersion"];
                data.PowerSleep1              = strDict["PowerSleep1"];
                data.PowerSleep2              = strDict["PowerSleep2"];
                data.ProfileName              = strDict["ProfileName"];
                data.DeviceName               = strDict["DeviceName"];
                data.DeviceType               = strDict["DeviceType"];
                data.Manufacturer             = strDict["Manufacturer"];
                data.TotalPages               = longDict["TotalPages"];
                data.TotalPagesMono           = longDict["TotalPagesMono"];
                data.TotalPagesColor          = longDict["TotalPagesColor"];
                data.TotalPagesDuplex         = longDict["TotalPagesDuplex"];
                data.PrinterPages             = longDict["PrinterPages"];
                data.PrinterPagesMono         = longDict["PrinterPagesMono"];
                data.PrinterPagesColor        = longDict["PrinterPagesColor"];
                data.PrinterPagesFullColor    = longDict["PrinterPagesFullColor"];
                data.PrinterPagesTwoColor     = longDict["PrinterPagesTwoColor"];
                data.CopyPagesMono            = longDict["CopyPagesMono"];
                data.CopyPagesColor           = longDict["CopyPagesColor"];
                data.CopyPagesFullColor       = longDict["CopyPagesFullColor"];
                data.CopyPagesTwoColor        = longDict["CopyPagesTwoColor"];
                data.CopyPagesSingleColor     = longDict["CopyPagesSingleColor"];
                data.FaxesSentFaxesReceived   = longDict["FaxesSentFaxesReceived"];
                data.ScansTotalScansTotalMono = longDict["ScansTotalScansTotalMono"];
                data.ScansTotalColor          = longDict["ScansTotalColor"];
                data.ScansCopyMono            = longDict["ScansCopyMono"];
                data.ScansCopyColor           = longDict["ScansCopyColor"];
                data.ScansEmail               = longDict["ScansEmail"];
                data.ScansEmailMono           = longDict["ScansEmailMono"];
                data.ScansNet                 = longDict["ScansNet"];
                data.ScansNetMono             = longDict["ScansNetMono"];
                data.ScansNetColor            = longDict["ScansNetColor"];
                data.LargePagesMono           = longDict["LargePagesMono"];
                data.LargePagesFullColor      = longDict["LargePagesFullColor"];
                data.CoverageAverageBlack     = longDict["CoverageAverageBlack"];
                data.CoverageAverageCyan      = longDict["CoverageAverageCyan"];
                data.CoverageAverageMagenta   = longDict["CoverageAverageMagenta"];
                data.CoverageAverageYellow    = longDict["CoverageAverageYellow"];
                data.BlackLevelMax            = longDict["BlackLevelMax"];
                data.CyanLevelMax             = longDict["CyanLevelMax"];
                data.MagentaLevelMax          = longDict["MagentaLevelMax"];
                data.YellowLevelMax           = longDict["YellowLevelMax"];
                data.BlackLevel               = longDict["BlackLevel"];
                data.CyanLevel                = longDict["CyanLevel"];
                data.MagentaLevel             = longDict["MagentaLevel"];
                data.YellowLevel              = longDict["YellowLevel"];
            }
            catch (Exception)
            {
                FnLog.GetInstance().AddToLogList(FnLog.LogType.Error, "SnmpClient", "GetOidValues ERROR ip " + ip);

                // ignored
            }

            FnLog.GetInstance().AddToLogList(FnLog.LogType.Error, "SnmpClient", "GetOidValues COMPLETE ip " + ip);
            return(data);
        }
Esempio n. 7
0
 /// <summary>
 /// Remove the specified oid
 /// </summary>
 public void Remove(OidData oidData)
 {
     this.DeleteOid(oidData.Mnemonic);
 }