Example #1
0
 /// <summary>
 /// Writes the <see cref="ReceivedLogRecords"/> of this <see cref="TrackedGpsData"/> to file and then clears the subject data from memory.
 /// </summary>
 public async Task WriteDataToFileAsync()
 {
     try
     {
         if (receivedLogRecords.Count > 0)
         {
             // Ensure log records are sorted chronologiocally.
             List <LogRecord> sortedLogRecords = receivedLogRecords.OrderBy(logRecord => logRecord.DateTime).ToList();
             // Write log records to file.
             using (TextWriter fileWriter = new StreamWriter(OutputFilePath, true))
             {
                 if (outputFileCreated == false)
                 {
                     fileWriter.WriteLine(GpsDataHeader);
                     outputFileCreated = true;
                 }
                 foreach (LogRecord logRecord in sortedLogRecords)
                 {
                     await fileWriter.WriteLineAsync($"{DeviceId.ToString()}|{DeviceSerialNumber}|{DeviceName}|{logRecord.DateTime.ToString()}|{logRecord.Latitude.ToString()}|{logRecord.Longitude.ToString()}|{logRecord.Speed.ToString()}");
                 }
             }
             receivedLogRecords.Clear();
         }
     }
     catch (Exception ex)
     {
         ConsoleUtility.LogError(ex);
         if (ex is IOException)
         {
             // Possiable system out of memory exception or file lock. Sleep for a minute and continue.
             await Task.Delay(TimeSpan.FromMinutes(1));
         }
     }
 }
Example #2
0
        void insteon_DeviceChanged(object sender, DeviceChangedEventArgs args)
        {
            DeviceId        id        = args.State.Device.Address;
            DeviceReference reference = new DeviceReference(id.ToString(), PluginName);
            BasicDevice     device    = callbacks.Devices.FindDevice(reference);

            if (device != null)
            {
                InsteonDeviceData deviceData = (InsteonDeviceData)device.AutomationData;
                if (args.State.Device is DimmingLight)
                {
                    DimmingLight onOffDevice = (DimmingLight)args.State.Device;
                    FroggyPlugin.Devices.PercentLevelDevice basicDevice = (FroggyPlugin.Devices.PercentLevelDevice)callbacks.Devices.FindDevice(reference);

                    // Update the value, this will automatically propogate events everywhere (even back to this plugin).
                    basicDevice.Level = onOffDevice.OnLevel * 100 / 255;
                }
                else if (args.State.Device is OnOffDevice)
                {
                    OnOffDevice onOffDevice = (OnOffDevice)args.State.Device;
                    FroggyPlugin.Devices.OnOffDevice basicDevice = (FroggyPlugin.Devices.OnOffDevice)callbacks.Devices.FindDevice(reference);

                    basicDevice.On = onOffDevice.OnLevel != 0;
                }
            }
        }
        /// <summary>
        /// Creates a <see cref="TrackedVehicle"/> instance, validates existence of the output folder, determines filenames for output GPS, fault data and status data files, creates a new <see cref="Geotab.DataOnlyPlan.API.Examples.FleetMonitor.TrackedGpsData"/> instance, and creates a new list to store <see cref="Geotab.DataOnlyPlan.API.Examples.FleetMonitor.TrackedDiagnostic"/> objects.
        /// </summary>
        /// <param name="device">The <see cref="Geotab.Checkmate.ObjectModel.Device"/> associated with the vehicle to be tracked.</param>
        /// <param name="outputFolder">The path of the folder into which output data files are to be written.</param>
        /// <param name="maximumFileSizeInBytes">The maximum size, in bytes, that an output file can reach before a new output file is created.</param>
        public TrackedVehicle(Device device, string outputFolder, long maximumFileSizeInBytes)
        {
            // Validate outputFolder.
            if (!Directory.Exists(outputFolder))
            {
                throw new ArgumentException($"The specified folder, '{outputFolder}', does not exist.");
            }

            Device   = device;
            DeviceId = Device.Id;

            // Generate names of files to which data associated with the TrackedVehicle will be written.
            DateTime startTime       = DateTime.Now;
            string   gpsDataFilename = $"GPS Data - DeviceID {DeviceId.ToString()} FileID {startTime.ToString(DateFormatStringForOutputFilenames)}.csv";

            GpsDataFilePath = Path.Combine(outputFolder, gpsDataFilename);
            string faultDataFilename = $"Fault Data - DeviceID {DeviceId.ToString()} FileID {startTime.ToString(DateFormatStringForOutputFilenames)}.csv";

            FaultDataFilePath = Path.Combine(outputFolder, faultDataFilename);
            string statusDataFilename = $"Status Data - DeviceID {DeviceId.ToString()} FileID {startTime.ToString(DateFormatStringForOutputFilenames)}.csv";

            StatusDataFilePath = Path.Combine(outputFolder, statusDataFilename);

            MaximumFileSizeInBytes = maximumFileSizeInBytes;
            TrackedDiagnostics     = new List <TrackedDiagnostic>();
            TrackedGpsData         = new TrackedGpsData(Device, GpsDataFilePath, maximumFileSizeInBytes);
        }
Example #4
0
        void insteon_DeviceAdded(object sender, DeviceAddedEventArgs args)
        {
            DeviceId        id        = args.Device.Address;
            DeviceReference reference = new DeviceReference(id.ToString(), PluginName);
            BasicDevice     device    = callbacks.Devices.FindDevice(reference);

            if (device != null)
            {
                InsteonDeviceData deviceData = (InsteonDeviceData)device.AutomationData;
            }
            else
            {
                InsteonDeviceData deviceData = new InsteonDeviceData(args.Device.Category, args.Device.Subcategory);
                if (args.Device is DimmingLight)
                {
                    DimmingLight dimmer = (DimmingLight)args.Device;
                    FroggyPlugin.Devices.PercentLevelDevice basic = new FroggyPlugin.Devices.PercentLevelDevice();
                    basic.Address        = reference;
                    basic.Name           = args.Device.DeviceName;
                    basic.Level          = dimmer.OnLevel * 100 / 255;
                    basic.AutomationData = deviceData;
                    callbacks.Devices.AddDevice(basic);
                }
                else if (args.Device is OnOffDevice)
                {
                    OnOffDevice onOffDevice = (OnOffDevice)args.Device;
                    FroggyPlugin.Devices.OnOffDevice basic = new FroggyPlugin.Devices.OnOffDevice();
                    basic.Address        = reference;
                    basic.Name           = args.Device.DeviceName;
                    basic.On             = onOffDevice.OnLevel != 0;
                    basic.AutomationData = deviceData;
                    callbacks.Devices.AddDevice(basic);
                }
            }
        }
Example #5
0
 public void SaveToXml(XmlTextWriter xmlWriter)
 {
     xmlWriter.WriteStartElement("lcdDevice");
     xmlWriter.WriteAttributeString("interface", Interface.Id);
     xmlWriter.WriteAttributeString("id", Id);
     xmlWriter.WriteAttributeString("description", Description);
     xmlWriter.WriteAttributeString("device", DeviceId.ToString());
     xmlWriter.WriteEndElement();
 }
        public void Save()
        {
            RegistryKey key        = Registry.CurrentUser.CreateSubKey(RegistryKeyPath);
            string      _userName  = RememberLoginDetails ? UserName : "";
            string      _passsword = RememberLoginDetails ? Password : "";

            string configString       = RegistryKeyPath + "." + DeviceId.ToString("N") + "." + _userName + "." + _passsword + "." + DownloadFolder + "." + RememberLoginDetails.ToString() + "." + ShowSysTrayIcon.ToString() + "." + HideWhenMinimized.ToString() + "." + AutomaticLogin.ToString();
            string encryptedConfigStr = EncryptionHelper.Encrypt(configString);

            key.SetValue("config", encryptedConfigStr);
        }
Example #7
0
 public void SaveToXml(XmlTextWriter xmlWriter)
 {
     xmlWriter.WriteStartElement("keysDevice");
     xmlWriter.WriteAttributeString("interface", Interface.Id);
     xmlWriter.WriteAttributeString("id", Id);
     xmlWriter.WriteAttributeString("description", Description);
     xmlWriter.WriteAttributeString("device", DeviceId.ToString());
     xmlWriter.WriteAttributeString("keysCount", KeysCount.ToString());
     xmlWriter.WriteAttributeString("realIndexes", HardwareIndexes.ToString());
     xmlWriter.WriteEndElement();
 }
Example #8
0
 public void SaveToXml(XmlTextWriter xmlWriter)
 {
     xmlWriter.WriteStartElement("ledDevice");
     xmlWriter.WriteAttributeString("interface", Interface.Id);
     xmlWriter.WriteAttributeString("id", Id);
     xmlWriter.WriteAttributeString("description", Description);
     xmlWriter.WriteAttributeString("device", DeviceId.ToString());
     xmlWriter.WriteAttributeString("ledsCount", LEDsCount.ToString());
     xmlWriter.WriteAttributeString("indexReverse", IndexReversed.ToString());
     xmlWriter.WriteEndElement();
 }
Example #9
0
        /// <summary>
        /// Finds the device info off the insteon thingy in the basic system.
        /// </summary>
        /// <param name="id">The device id to lookup</param>
        /// <returns>The category, or null if none known</returns>
        public Tuple <byte, byte> GetDeviceCategory(DeviceId id)
        {
            DeviceReference reference = new DeviceReference(id.ToString(), PluginName);
            BasicDevice     device    = callbacks.Devices.FindDevice(reference);

            if (device != null)
            {
                InsteonDeviceData deviceData = (InsteonDeviceData)device.AutomationData;
                return(Tuple.Create(deviceData.Category, deviceData.SubCategory));
            }
            return(null);
        }
Example #10
0
        protected EventStoreBase(EventId eventId, StreamType streamType, StreamData streamData, DeviceId aggregateId,
                                 DeviceName aggregateName, StreamWhen streamWhen)
        {
            this.Id = eventId.Value;

            this.StreamType    = streamType.Value;
            this.StreamData    = streamData.Value;
            this.AggregateId   = aggregateId.ToString();
            this.AggregateName = aggregateName.Value;
            this.StreamWhen    = streamWhen.Value;

            this.IsDispatched = false;
        }
Example #11
0
 public virtual void SaveToXml(XmlTextWriter xmlWriter)
 {
     xmlWriter.WriteStartElement("servoDevice");
     xmlWriter.WriteAttributeString("interface", Interface.Id);
     xmlWriter.WriteAttributeString("id", Id);
     xmlWriter.WriteAttributeString("description", Description);
     xmlWriter.WriteAttributeString("device", DeviceId.ToString());
     foreach (Servo s in Servos)
     {
         xmlWriter.WriteStartElement("servo");
         s.SaveToXml(xmlWriter);
         xmlWriter.WriteEndElement();
     }
     xmlWriter.WriteEndElement();
 }
        public void Test_Equality()
        {
            var id_123456_1 = new DeviceId(0x12, 0x34, 0x56);
            var id_123456_2 = new DeviceId(0x12, 0x34, 0x56);
            var id_AABBCC   = new DeviceId(0xAA, 0xBB, 0xCC);

            Assert.AreEqual(id_123456_1, id_123456_2);
            Assert.AreNotEqual(id_123456_1, id_AABBCC);
            Assert.AreNotEqual(null, id_AABBCC);
            Assert.AreNotEqual(3.14, id_AABBCC);
            Assert.AreNotEqual(id_123456_1.ToString(), id_AABBCC);
            Assert.IsTrue(id_123456_1 == id_123456_2);
            Assert.IsFalse(id_123456_1 == id_AABBCC);
            Assert.IsFalse(id_123456_1 != id_123456_2);
            Assert.IsTrue(id_123456_1 != id_AABBCC);
        }
Example #13
0
        public DeviceService()
        {
            var keychainHelper = Locator.Current.GetService <IKeyChainHelper>();
            var deviceId       = keychainHelper.GetKey(Const.DeviceIdKey);

            if (string.IsNullOrEmpty(deviceId))
            {
                DeviceId = Guid.NewGuid();
                deviceId = DeviceId.ToString();
                keychainHelper.SetKey(Const.DeviceIdKey, deviceId);
            }
            else
            {
                DeviceId = new Guid(deviceId);
            }
        }
        public void Test_Equality()
        {
            var id_123456_1 = new DeviceId(0x12, 0x34, 0x56);
            var id_123456_2 = new DeviceId(0x12, 0x34, 0x56);
            var id_AABBCC = new DeviceId(0xAA, 0xBB, 0xCC);

            Assert.AreEqual(id_123456_1, id_123456_2);
            Assert.AreNotEqual(id_123456_1, id_AABBCC);
            Assert.AreNotEqual(null, id_AABBCC);
            Assert.AreNotEqual(3.14, id_AABBCC);
            Assert.AreNotEqual(id_123456_1.ToString(), id_AABBCC);
            Assert.IsTrue(id_123456_1 == id_123456_2);
            Assert.IsFalse(id_123456_1 == id_AABBCC);
            Assert.IsFalse(id_123456_1 != id_123456_2);
            Assert.IsTrue(id_123456_1 != id_AABBCC);
        }
        public override void ExecuteCmdlet()
        {
            try
            {
                // Make sure params were supplied appropriately.
                ProcessParameters();

                // Get the current device details.
                var deviceDetails = StorSimpleClient.GetDeviceDetails(DeviceId);

                if (deviceDetails == null)
                {
                    throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenIdInResourceMessage, StorSimpleContext.ResourceName, DeviceId));
                }

                // If the device is being configured for the first time, validate that mandatory params
                // for first setup have been provided
                if (!deviceDetails.DeviceProperties.IsConfigUpdated && !ValidParamsForFirstDeviceConfiguration(StorSimpleNetworkConfig, TimeZone, SecondaryDnsServer))
                {
                    throw new ArgumentException(Resources.MandatoryParamsMissingForInitialDeviceConfiguration);
                }

                // Validate Network configs - this method throws an exception if any validation fails
                ValidateNetworkConfigs(deviceDetails, StorSimpleNetworkConfig);

                WriteVerbose(string.Format(Resources.BeginningDeviceConfiguration, deviceDetails.DeviceProperties.FriendlyName));

                // Update device details objects with the details provided to the cmdlet
                // and make request with updated data
                var taskStatusInfo = StorSimpleClient.UpdateDeviceDetails(deviceDetails, this.NewName, this.TimeZone, this.secondaryDnsServer, this.StorSimpleNetworkConfig);

                HandleSyncTaskResponse(taskStatusInfo, "Setup");
                if (taskStatusInfo.AsyncTaskAggregatedResult == AsyncTaskAggregatedResult.Succeeded)
                {
                    var updatedDetails = StorSimpleClient.GetDeviceDetails(DeviceId.ToString());
                    WriteObject(updatedDetails);
                    WriteVerbose(string.Format(Resources.StorSimpleDeviceUpdatedSuccessfully, updatedDetails.DeviceProperties.FriendlyName, updatedDetails.DeviceProperties.DeviceId));
                }
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }
Example #16
0
        public void Save([NotNull] XmlTextWriter output, bool isCopy)
        {
            Assert.ArgumentNotNull(output, nameof(output));

            output.WriteStartElement(@"d");
            output.WriteAttributeStringNotEmpty(@"id", DeviceId.ToString());
            output.WriteAttributeStringNotEmpty(@"l", LayoutId);

            foreach (var item in Renderings)
            {
                var listItem = item as LayoutDesignerItem;

                if (listItem != null)
                {
                    listItem.Commit();
                    listItem.Write(output, isCopy);
                }
            }

            output.WriteEndElement();
        }
 public virtual void SaveToXml(XmlTextWriter xmlWriter)
 {
     xmlWriter.WriteStartElement("stepperDevice");
     xmlWriter.WriteAttributeString("interface", Interface.Id);
     xmlWriter.WriteAttributeString("id", Id);
     xmlWriter.WriteAttributeString("description", Description);
     xmlWriter.WriteAttributeString("device", DeviceId.ToString());
     xmlWriter.WriteAttributeString("type", Type.ToString());
     if (Motor1 != null)
     {
         xmlWriter.WriteStartElement("motor1");
         Motor1.Save(xmlWriter);
         xmlWriter.WriteEndElement();
     }
     if (Motor2 != null)
     {
         xmlWriter.WriteStartElement("motor2");
         Motor2.Save(xmlWriter);
         xmlWriter.WriteEndElement();
     }
     xmlWriter.WriteEndElement();
 }
        public void Can_create_from_id_string()
        {
            const string ID1       = "12.34.56";
            const string ID2       = "AA.BB.Cc";
            var          id_123456 = new DeviceId(ID1);
            var          id_AABBCC = new DeviceId(ID2);

            Assert.AreEqual(0x12, id_123456.IdHi);
            Assert.AreEqual(0x34, id_123456.IdMiddle);
            Assert.AreEqual(0x56, id_123456.IdLo);
            Assert.AreEqual(ID1.ToUpper(), id_123456.ToString());

            Assert.AreEqual(0xAA, id_AABBCC.IdHi);
            Assert.AreEqual(0xBB, id_AABBCC.IdMiddle);
            Assert.AreEqual(0xCC, id_AABBCC.IdLo);
            Assert.AreEqual(ID2.ToUpper(), id_AABBCC.ToString());

            Assert.Throws <ArgumentNullException>(() => { var id = new DeviceId((string)null); });
            Assert.Throws <ArgumentOutOfRangeException>(() => { var id = new DeviceId("12;34.56"); });
            Assert.Throws <ArgumentOutOfRangeException>(() => { var id = new DeviceId("12.34;56"); });
            Assert.Throws <ArgumentOutOfRangeException>(() => { var id = new DeviceId("12.34.5"); });
            Assert.Throws <ArgumentOutOfRangeException>(() => { var id = new DeviceId("12.34.5G"); });
        }
        public void Can_create_from_id_string()
        {
            const string ID1 = "12.34.56";
            const string ID2 = "AA.BB.Cc";
            var id_123456 = new DeviceId(ID1);
            var id_AABBCC = new DeviceId(ID2);

            Assert.AreEqual(0x12, id_123456.IdHi);
            Assert.AreEqual(0x34, id_123456.IdMiddle);
            Assert.AreEqual(0x56, id_123456.IdLo);
            Assert.AreEqual(ID1.ToUpper(), id_123456.ToString());

            Assert.AreEqual(0xAA, id_AABBCC.IdHi);
            Assert.AreEqual(0xBB, id_AABBCC.IdMiddle);
            Assert.AreEqual(0xCC, id_AABBCC.IdLo);
            Assert.AreEqual(ID2.ToUpper(), id_AABBCC.ToString());

            Assert.Throws<ArgumentNullException>(() => { var id = new DeviceId((string)null); });
            Assert.Throws<ArgumentOutOfRangeException>(() => { var id = new DeviceId("12;34.56"); });
            Assert.Throws<ArgumentOutOfRangeException>(() => { var id = new DeviceId("12.34;56"); });
            Assert.Throws<ArgumentOutOfRangeException>(() => { var id = new DeviceId("12.34.5"); });
            Assert.Throws<ArgumentOutOfRangeException>(() => { var id = new DeviceId("12.34.5G"); });
        }
Example #20
0
 /// <summary>
 /// 将 UID 转为 16 进制字符串
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     // 将 制造商ID 转为 4bti 字符串,设备ID 转为 8bit 字符串
     return(string.Format("{0}:{1}", ManufacturerId.ToString("X4"), DeviceId.ToString("X8")));
 }
 /// <inheritDoc />
 public override String ToString()
 {
     return(Advertisement?.DeviceName?.IsNullOrWhiteSpace() != true
     ? "{0} <{1}>".F(Advertisement?.DeviceName, DeviceId)
     : DeviceId.ToString());
 }
Example #22
0
 public override string ToString()
 {
     return(string.Format("{0}:{1}", ManufacturerId.ToString("X4"), DeviceId.ToString("X8")));
 }
        /// <summary>
        /// Writes the <see cref="ReceivedFaultData"/> or <see cref="ReceivedStatusData"/> of this <see cref="TrackedDiagnostic"/> (depending on its <see cref="DiagnosticCategory"/>) to file and then clears the subject data from memory.
        /// </summary>
        /// <returns></returns>
        public async Task WriteDataToFileAsync()
        {
            try
            {
                switch (DiagnosticCategoryType)
                {
                case DiagnosticCategory.FaultData:
                    if (receivedFaultData.Count > 0)
                    {
                        // Ensure FaultData records are sorted chronologiocally.
                        List <FaultData> sortedFaultData = receivedFaultData.OrderBy(faultData => faultData.DateTime).ToList();
                        // Write FaultData records to file.
                        using (TextWriter fileWriter = new StreamWriter(OutputFilePath, true))
                        {
                            foreach (FaultData faultData in sortedFaultData)
                            {
                                string      failureModeCode       = "";
                                string      failureModeName       = "";
                                string      failureModeSourceName = "";
                                FailureMode failureMode           = faultData.FailureMode;
                                if (failureMode != null)
                                {
                                    failureModeCode = failureMode.Code.ToString();
                                    failureModeName = failureMode.Name;
                                    Source failureModeSource = failureMode.Source;
                                    if (failureModeSource != null)
                                    {
                                        failureModeSourceName = failureModeSource.Name;
                                    }
                                }
                                string dismissUserName = "";
                                string dismissDateTime = "";
                                User   dismissUser     = faultData.DismissUser;
                                if (dismissUser != null)
                                {
                                    dismissUserName = dismissUser.Name;
                                    dismissDateTime = faultData.DismissDateTime.ToString();
                                }
                                await fileWriter.WriteLineAsync($"{DeviceId.ToString()}|{DeviceSerialNumber}|{DeviceName}|{faultData.DateTime.ToString()}|{faultData.Diagnostic.Id.ToString()}|{faultData.Diagnostic.Name}|{failureModeCode}|{failureModeName}|{failureModeSourceName}|{faultData.Controller.Name}|{faultData.Count.ToString()}|{faultData.FaultState.ToString()}|{faultData.MalfunctionLamp.ToString()}|{faultData.RedStopLamp.ToString()}|{faultData.AmberWarningLamp.ToString()}|{faultData.ProtectWarningLamp.ToString()}|{dismissDateTime}|{dismissUserName}");
                            }
                        }
                        receivedFaultData.Clear();
                    }
                    break;

                case DiagnosticCategory.StatusData:
                    if (receivedStatusData.Count > 0)
                    {
                        // Ensure StatusData records are sorted chronologiocally.
                        List <StatusData> sortedStatusData = receivedStatusData.OrderBy(statusData => statusData.DateTime).ToList();
                        // Write StatusData records to file.
                        using (TextWriter fileWriter = new StreamWriter(OutputFilePath, true))
                        {
                            foreach (StatusData statusData in sortedStatusData)
                            {
                                await fileWriter.WriteLineAsync($"{DeviceId.ToString()}|{DeviceSerialNumber}|{DeviceName}|{statusData.DateTime.ToString()}|{statusData.Diagnostic.Id.ToString()}|{statusData.Diagnostic.Name}|{statusData.Diagnostic.Source.Name}|{statusData.Data.ToString()}|{statusData.Diagnostic.UnitOfMeasure.Name}");
                            }
                        }
                        receivedStatusData.Clear();
                    }
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                ConsoleUtility.LogError(ex);
                if (ex is IOException)
                {
                    // Possiable system out of memory exception or file lock. Sleep for a minute and continue.
                    await Task.Delay(TimeSpan.FromMinutes(1));
                }
            }
        }
        /// <summary>
        /// Adds a <see cref="StatusData"/> record to the <see cref="ReceivedStatusData"/> of this <see cref="TrackedDiagnostic"/>.
        /// </summary>
        /// <param name="statusData">The <see cref="StatusData"/> record to be added.</param>
        public void AddData(StatusData statusData)
        {
            // Throw exception if there is an attempt to add StatusData and this TrackedDiagnostic does not represent a Diagnostic of the StatusData category.
            if (DiagnosticCategoryType != DiagnosticCategory.StatusData)
            {
                throw new ArgumentException($"This TrackedDiagnostic represents a Diagnostic of the type '{DiagnosticCategoryType}' and cannot accept StatusData.");
            }

            // Validate to ensure StatusData is for the subject Device and Diagnostic.
            if (statusData.Device.Id != DeviceId)
            {
                throw new ArgumentException($"The supplied StatusData is for a Device with Id '{statusData.Device.Id.ToString()}' and cannot be added to this TrackedDiagnostic which represents the Device with Id '{DeviceId.ToString()}'.");
            }
            if (statusData.Diagnostic.Id != DiagnosticId)
            {
                throw new ArgumentException($"The supplied StatusData is for a Diagnostic with Id '{statusData.Diagnostic.Id.ToString()}' and cannot be added to this TrackedDiagnostic which represents the Diagnostic with Id '{DiagnosticId.ToString()}'.");
            }
            receivedStatusData.Add(statusData);

            // Update DeviceName with that of the statusData in case the device name has changed (the statusData will have the latest version of the Device since it gets updated with the device cache in the FeedProcessor before this AddData() method is called.
            if (DeviceName != statusData.Device.Name)
            {
                DeviceName = statusData.Device.Name;
            }
        }
Example #25
0
        private void MainTree_NodeMouseClick(object sender, RadTreeViewEventArgs e)
        {
            try
            {
                DeviceId     = Convert.ToInt32(((DataRowView)e.Node.Parent.Parent.Parent.DataBoundItem)["DeviceId"].ToString());
                DeviceLineId = Convert.ToInt32(((DataRowView)e.Node.Parent.DataBoundItem)["lineid"].ToString());
                StateId      = Convert.ToInt32(((DataRowView)e.Node.DataBoundItem)["stateid"].ToString());

                DeviceLinePrimaryId = Convert.ToInt32(Bll_DeviceLine.GetDeviceLineById(DeviceId.ToString(), DeviceLineId.ToString()).DefaultView[0]["id"].ToString());
            }
            catch { }
        }
Example #26
0
 public string IdString()
 {
     return(DeviceId.ToString());
 }
Example #27
0
        /// <summary>
        /// Adds a <see cref="LogRecord"/> record to the <see cref="ReceivedLogRecords"/> of this <see cref="TrackedGpsData"/>.
        /// </summary>
        /// <param name="logRecord">The <see cref="LogRecord"/> record to be added.</param>
        public void AddData(LogRecord logRecord)
        {
            // Validate to ensure LogRecord is for the subject Device.
            if (logRecord.Device.Id != DeviceId)
            {
                throw new ArgumentException($"The supplied LogRecord is for a Device with Id '{logRecord.Device.Id.ToString()}' and cannot be added to this TrackedGpsData which represents the Device with Id '{DeviceId.ToString()}'.");
            }

            receivedLogRecords.Add(logRecord);

            // Update DeviceName with that of the logRecord in case the device name has changed (the logRecord will have the latest version of the Device since it gets updated with the device cache in the FeedProcessor before this AddData() method is called.
            if (DeviceName != logRecord.Device.Name)
            {
                DeviceName = logRecord.Device.Name;
            }
        }