public static DeviceRecord TryFindDeviceInstance(UsbIdentity[] usbIdentities) { if (usbIdentities == null) { throw new ArgumentNullException("usbIdentities"); } var allDevices = DeviceRecord.FindAllUsbDevices(); if (allDevices == null) { return(null); } foreach (var dev in allDevices) { foreach (var id in usbIdentities) { if (string.Equals(dev.VendorID, id.VID, StringComparison.InvariantCultureIgnoreCase) && string.Equals(dev.ProductID, id.PID, StringComparison.InvariantCultureIgnoreCase)) { if (string.IsNullOrEmpty(id.Interface) || string.Equals(id.Interface, dev.Interface)) { return(dev); } } } } return(null); }
public bool UpdateRecord(DeviceRecord record) { if (record == null) { return(false); } return(_sensors.Update(record)); }
// constructor converts a DeviceRecord to this DeviceRecordCache public DeviceRecordCache(DeviceRecord dr) { m_PixelSize = dr.PixelSize; m_MaxWidth = dr.MaxWidth; m_Widths = new ArrayList(dr.numGlyphs); for (ushort i = 0; i < dr.numGlyphs; i++) { m_Widths.Add(dr.GetWidth(i)); } }
public IActionResult Index() { var injectors = _mongoRepo.GetInjectorRecords(); DeviceRecord myObj = MongoDB.Bson.Serialization.BsonSerializer.Deserialize <DeviceRecord>(injectors); var homeVm = new HomeViewModel { Title = "Medrad Family", Injectors = myObj.models }; return(View(homeVm)); }
public void SetUp() { DeviceRecord mockData = new DeviceRecord(); mockData.CompanyId = 1; mockData.Company = "Test"; Mock <IJsonObjectReader <DeviceRecord> > jsonReader = new Mock <IJsonObjectReader <DeviceRecord> >(); jsonReader.Setup(x => x.GetData(path)).Returns(mockData); dataHandler = new DeviceDataHandler(jsonReader.Object); }
public DeviceRecord GetDeviceRecord(uint i, ushort numGlyphs) { DeviceRecord dr = null; if (i < NumberDeviceRecords) { uint offset = (uint)FieldOffsets.DeviceRecord + i * (uint)SizeofDeviceRecord; dr = new DeviceRecord(offset, m_bufTable, numGlyphs); } return(dr); }
public async Task <CreatedData> CreateRecordAsync(int deviceId, string value, DateTime date) { var record = new DeviceRecord { SmartDeviceId = deviceId, Value = value, Date = date }; _context.DeviceRecords.Add(record); await _context.SaveChangesAsync(); return(new CreatedData(record.DeviceRecordId)); }
public async Task <ActionResult> Put(string id, DeviceRecord model) { var exists = await _dbContext.DeviceRecords.AnyAsync(f => f.Id == id); if (!exists) { return(NotFound()); } _dbContext.DeviceRecords.Update(model); await _dbContext.SaveChangesAsync(); return(Ok()); }
// constructor public hdmx_cache(Table_hdmx OwnerTable) { m_TableVersionNumber = OwnerTable.TableVersionNumber; m_NumberDeviceRecords = OwnerTable.NumberDeviceRecords; m_NumGlyphs = OwnerTable.numGlyphs; // put all of the device records in an ArrayList m_DeviceRecords = new ArrayList(m_NumberDeviceRecords); for (short i = 0; i < m_NumberDeviceRecords; i++) { DeviceRecord dr = OwnerTable.GetDeviceRecord((uint)i, m_NumGlyphs); DeviceRecordCache drc = new DeviceRecordCache(dr); m_DeviceRecords.Add(drc); } }
public int AddRecord(DeviceRecord record) { if (record == null) { return(-1); } try { return(_sensors.Insert(record)); } catch (Exception e) { Console.WriteLine(e); throw; } }
public override void DoEnd() { AppRecord appRecord = (AppRecord)GPerfMonitor.GetInstance().GetSamplerRecord(SamplerMetricType.App); if (appRecord != null) { m_Session.App = new GPerfApp(); m_Session.App.Identifier = appRecord.Identifier; m_Session.App.InstallName = appRecord.InstallName; m_Session.App.ProductName = appRecord.ProductName; m_Session.App.Version = appRecord.Version; m_Session.App.UnityVersion = appRecord.EngineVersion; } DeviceRecord deviceRecord = (DeviceRecord)GPerfMonitor.GetInstance().GetSamplerRecord(SamplerMetricType.Device); if (deviceRecord != null) { m_Session.Device = new GPerfDevice(); m_Session.Device.Name = deviceRecord.Name; m_Session.Device.Model = deviceRecord.Model; m_Session.Device.UniqueIdentifier = deviceRecord.UniqueIdentifier; m_Session.Device.GraphicsName = deviceRecord.GraphicsName; m_Session.Device.GraphicsType = deviceRecord.GraphicsType; m_Session.Device.GraphicsVendor = deviceRecord.GraphicsVendor; m_Session.Device.GraphicsVersion = deviceRecord.GraphicsVersion; m_Session.Device.GraphicsMemoryInMb = deviceRecord.GraphicsMemoryInMB; m_Session.Device.SystemMemoryInMb = deviceRecord.SystemMemorySize; } Dictionary <string, string> customGameInfo = GPerfMonitor.GetInstance().CustomSamplingInfoDic; if (customGameInfo.Count > 0) { m_Session.GameInfo = new GPerfGameInfo(); m_Session.GameInfo.Extensions.Add(customGameInfo); } LogRecord logRecord = (LogRecord)GPerfMonitor.GetInstance().GetSamplerRecord(SamplerMetricType.Log); SendToServer(m_Session, logRecord?.FilePath); }
private void btnDetect_Click(object sender, EventArgs e) { try { string devSpec = null; var rawDevices = DeviceRecord.FindAllUsbDevices(); if (rawDevices != null) { foreach (var dev in rawDevices) { if (dev.VendorID?.ToLower() == "03eb") { switch (dev.ProductID ?? "") { case "2103": devSpec = "-2"; break; case "2107": devSpec = "-g"; break; } } } } if (devSpec == null) { throw new Exception("Cannot find any known USB JTAG/SWD programmers. Please ensure your programmer is connected."); } else { SetComboBoxValue(cbAdapter, devSpec); comboBox3.Text = "usb"; MessageBox.Show("Detected " + cbAdapter.Text + ".", "VisualGDB", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "VisualGDB", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void Read(TTFReader r, int numGlyphs) { r.ReadInt(out this.version); r.ReadInt(out this.numRecords); r.ReadInt(out this.sizeDeviceRecord); this.records = new List <DeviceRecord>(); for (int i = 0; i < this.numRecords; ++i) { DeviceRecord dr = new DeviceRecord(); r.ReadInt(out dr.pixelSize); r.ReadInt(out dr.maxWidth); // dr.widths = new List <byte>(); for (int j = 0; j < numGlyphs; ++j) { dr.widths.Add(r.ReadUInt8()); } this.records.Add(dr); } }
public void SetUp() { DeviceRecord mockDataDevice = new DeviceRecord(); mockDataDevice.CompanyId = 1; mockDataDevice.Company = "Test1"; TrackerRecord mockDataTracker = new TrackerRecord(); mockDataTracker.PartnerId = 2; mockDataTracker.PartnerName = "Test2"; Mock <ITrackerDataHandler> mockTrackerHandler = new Mock <ITrackerDataHandler>(); Mock <IDeviceDataHandler> mockDeviceHandler = new Mock <IDeviceDataHandler>(); mockTrackerHandler.Setup(x => x.GetTrackerRecord(It.IsAny <string>())).Returns(mockDataTracker); mockDeviceHandler.Setup(x => x.GetDeviceRecord(It.IsAny <string>())).Returns(mockDataDevice); handleData = new HandleData(mockDeviceHandler.Object, mockTrackerHandler.Object); }
// constructor converts a DeviceRecord to this DeviceRecordCache public DeviceRecordCache( DeviceRecord dr ) { m_PixelSize = dr.PixelSize; m_MaxWidth = dr.MaxWidth; m_Widths = new ArrayList( dr.numGlyphs ); for( ushort i = 0; i < dr.numGlyphs; i++ ) { m_Widths.Add( dr.GetWidth( i )); } }
public DeviceRecord GetDeviceRecord(uint i, ushort numGlyphs) { DeviceRecord dr = null; if (i < NumberDeviceRecords) { uint offset = (uint)FieldOffsets.DeviceRecord + i*(uint)SizeofDeviceRecord; dr = new DeviceRecord(offset, m_bufTable, numGlyphs); } return dr; }
/************************ * public methods */ public bool Validate(Validator v, OTFontVal fontOwner) { bool bRet = true; ushort numGlyphs = GetNumGlyphs(fontOwner); if (v.PerformTest(T.hdmx_Version)) { if (TableVersionNumber == 0) { v.Pass(T.hdmx_Version, P.hdmx_P_Version, m_tag); } else { v.Error(T.hdmx_Version, E.hdmx_E_Version, m_tag, TableVersionNumber.ToString()); bRet = false; } } bool bNumDeviceRecordsOk = true; if (v.PerformTest(T.hdmx_NumDeviceRecords)) { if (NumberDeviceRecords >= 0) { v.Pass(T.hdmx_NumDeviceRecords, P.hdmx_P_NumDeviceRecords, m_tag, NumberDeviceRecords.ToString()); } else { v.Error(T.hdmx_NumDeviceRecords, E.hdmx_E_NumDeviceRecords_neg, m_tag, NumberDeviceRecords.ToString()); bNumDeviceRecordsOk = false; bRet = false; } } bool bSizeOk = true; if (v.PerformTest(T.hdmx_SizeofDeviceRecord)) { if ((SizeofDeviceRecord & 3) != 0) { v.Error(T.hdmx_SizeofDeviceRecord, E.hdmx_E_SizeofDeviceRecord_alignment, m_tag, SizeofDeviceRecord.ToString()); bSizeOk = false; bRet = false; } uint CalculatedSizeofDeviceRecord = CalculateSizeofDeviceRecord(numGlyphs); if (SizeofDeviceRecord != CalculatedSizeofDeviceRecord) { string s = "actual = " + SizeofDeviceRecord + ", calc = " + CalculatedSizeofDeviceRecord; v.Error(T.hdmx_SizeofDeviceRecord, E.hdmx_E_SizeofDeviceRecord_numGlyphs, m_tag, s); bSizeOk = false; bRet = false; } if (bSizeOk) { v.Pass(T.hdmx_SizeofDeviceRecord, P.hdmx_P_SizeofDeviceRecord, m_tag, SizeofDeviceRecord.ToString()); } } bool bLengthOk = true; if (v.PerformTest(T.hdmx_TableLength)) { if (bNumDeviceRecordsOk) { uint CalculatedTableLength = 8 + (uint)NumberDeviceRecords * CalculateSizeofDeviceRecord(numGlyphs); if (GetLength() == CalculatedTableLength) { v.Pass(T.hdmx_TableLength, P.hdmx_P_TableLength, m_tag); } else { string s = "actual: " + GetLength() + ", calc: " + CalculatedTableLength; v.Error(T.hdmx_TableLength, E.hdmx_E_TableLength, m_tag, s); bLengthOk = false; bRet = false; } } else { v.Warning(T.hdmx_TableLength, W._TEST_W_OtherErrorsInTable, m_tag, "unable to validate table length"); } } if (v.PerformTest(T.hdmx_DeviceRecordPadBytesZero)) { if (bSizeOk && bLengthOk & bNumDeviceRecordsOk) { uint unpaddedLength = (uint)numGlyphs + 2; if ((unpaddedLength & 3) == 0) { v.Pass(T.hdmx_DeviceRecordPadBytesZero, P.hdmx_P_DeviceRecordPadBytes_none, m_tag); } else { bool bPadOk = true; if (NumberDeviceRecords > 1) { for (uint i = 0; i < NumberDeviceRecords; i++) { DeviceRecord dr = GetDeviceRecord(i, numGlyphs); for (uint j = 0; j < dr.GetNumPadBytes(); j++) { if (dr.GetPadByte(j) != 0) { bPadOk = false; break; } } } } if (bPadOk) { v.Pass(T.hdmx_DeviceRecordPadBytesZero, P.hdmx_P_DeviceRecordPadBytes_zero, m_tag); } else { v.Error(T.hdmx_DeviceRecordPadBytesZero, E.hdmx_E_DeviceRecordPadBytes_nonzero, m_tag); bRet = false; } } } else { v.Warning(T.hdmx_DeviceRecordPadBytesZero, W._TEST_W_OtherErrorsInTable, m_tag, "unable to validate that device record padding bytes are zero"); } } if (v.PerformTest(T.hdmx_SortedOrder)) { if (bSizeOk && bLengthOk && bNumDeviceRecordsOk) { bool bSortOk = true; if (NumberDeviceRecords > 1) { DeviceRecord drCurr = GetDeviceRecord(0, numGlyphs); DeviceRecord drNext = null; for (uint i = 1; i < NumberDeviceRecords; i++) { drNext = GetDeviceRecord(i, numGlyphs); if (drCurr.PixelSize >= drNext.PixelSize) { bSortOk = false; break; } drCurr = drNext; } } if (bSortOk) { v.Pass(T.hdmx_SortedOrder, P.hdmx_P_SortedOrder, m_tag); } else { v.Error(T.hdmx_SortedOrder, E.hdmx_E_SortedOrder, m_tag); bRet = false; } } else { v.Warning(T.hdmx_SortedOrder, W._TEST_W_OtherErrorsInTable, m_tag, "unable to validate that device records are in sorted order"); } } if (v.PerformTest(T.hdmx_DuplicateDeviceRecords)) { if (bSizeOk && bLengthOk && bNumDeviceRecordsOk) { bool bNoDup = true; if (NumberDeviceRecords > 1) { for (uint i = 0; i < NumberDeviceRecords - 1; i++) { DeviceRecord dr1 = GetDeviceRecord(i, numGlyphs); for (uint j = i + 1; j < NumberDeviceRecords; j++) { DeviceRecord dr2 = GetDeviceRecord(j, numGlyphs); if (dr1.PixelSize == dr2.PixelSize) { bNoDup = false; break; } } } } if (bNoDup) { v.Pass(T.hdmx_DuplicateDeviceRecords, P.hdmx_P_DuplicateDeviceRecords, m_tag); } else { v.Error(T.hdmx_DuplicateDeviceRecords, E.hdmx_E_DuplicateDeviceRecords, m_tag); bRet = false; } } else { v.Warning(T.hdmx_DuplicateDeviceRecords, W._TEST_W_OtherErrorsInTable, m_tag, "unable to validate that there are no duplicate device records"); } } if (v.PerformTest(T.hdmx_Widths)) { if (bSizeOk && bLengthOk && bNumDeviceRecordsOk) { bool bWidthsOk = true; RasterInterf.DevMetricsData dmd = null; try { dmd = fontOwner.GetCalculatedDevMetrics(); } catch (Exception e) { v.ApplicationError(T.VDMX_CompareToCalcData, E._Table_E_Exception, m_tag, e.Message); bRet = false; } if (dmd != null) { for (uint i = 0; i < NumberDeviceRecords; i++) { DeviceRecord dr = GetDeviceRecord(i, numGlyphs); for (uint iGlyph = 0; iGlyph < numGlyphs; iGlyph++) { if (dr.GetWidth(iGlyph) != dmd.hdmxData.Records[i].Widths[iGlyph]) { String sDetails = "rec " + i + ", PixelSize " + dr.PixelSize + ", glyph# " + iGlyph + ", width = " + dr.GetWidth(iGlyph) + ", calc = " + dmd.hdmxData.Records[i].Widths[iGlyph]; v.Error(T.hdmx_Widths, E.hdmx_E_Widths, m_tag, sDetails); bWidthsOk = false; bRet = false; } } } if (bWidthsOk) { v.Pass(T.hdmx_Widths, P.hdmx_P_Widths, m_tag); } } else { // if user didn't cancel, then check for error message if (!v.CancelFlag) { String sDetails = null; try { sDetails = fontOwner.GetDevMetricsDataError(); } catch (Exception e) { v.ApplicationError(T.VDMX_CompareToCalcData, E._Table_E_Exception, m_tag, e.Message); } Debug.Assert(sDetails != null); v.Error(T.hdmx_Widths, E.hdmx_E_Rasterizer, m_tag, sDetails); bRet = false; } } } else { v.Warning(T.hdmx_Widths, W._TEST_W_OtherErrorsInTable, m_tag, "unable to validate that the widths are correct"); } } return(bRet); }
public async Task Post(DeviceRecord model) { await _dbContext.AddAsync(model); await _dbContext.SaveChangesAsync(); }
private void button1_Click(object sender, EventArgs e) { //transaction using (SqlConnection connection1 = new SqlConnection(aps.GetValue("myconnection", typeof(string)).ToString())) { connection1.Open(); // Start a local transaction. SqlTransaction sqlTran = connection1.BeginTransaction(); // Enlist a command in the current transaction. SqlCommand command = connection1.CreateCommand(); command.Transaction = sqlTran; { try { Connect(); ShowStatusBar(string.Empty, true); ICollection <MachineInfo> machineInfoCollection = manipulator.GetLogData(objZkeeper, int.Parse(tbxMachineNumber.Text.Trim())); List <MachineInfo> lstMachineInfo = machineInfoCollection.ToList(); DataTable dt = bllGetAttendanceData.GetLastAttendanceLogPull(); DateTime LastPulledDateTime; DateTime LastPulledDateOnly; var todaysDateTime = DateTime.Now; if (dt.Rows.Count > 0) { LastPulledDateTime = Convert.ToDateTime(dt.Rows[0]["LastPulledDateTime"]); LastPulledDateOnly = Convert.ToDateTime(Convert.ToDateTime(dt.Rows[0]["LastPulledDateTime"]).ToShortDateString()); } else { LastPulledDateTime = Convert.ToDateTime(lstMachineInfo.Where(x => Convert.ToDateTime(x.DateTimeRecord) < DateTime.Now).OrderBy(x => x.DateTimeRecord).FirstOrDefault().DateTimeRecord); LastPulledDateOnly = Convert.ToDateTime(LastPulledDateTime.ToShortDateString()); } var newAttendanceRecords = lstMachineInfo.Where(x => Convert.ToDateTime(x.DateTimeRecord) >= LastPulledDateTime).ToList(); int daysGap = Convert.ToInt32((todaysDateTime - LastPulledDateTime).TotalDays); DataTable allUsers = bllGetAttendanceData.GetAllUser(); for (int i = 0; i <= daysGap; i++) { var DaywiseAttendanceRecords = newAttendanceRecords.Where(x => Convert.ToDateTime(x.DateOnlyRecord) == LastPulledDateOnly.AddDays(i)); if (DaywiseAttendanceRecords.Count() > 0 && allUsers.Rows.Count > 0) { for (int j = 0; j < allUsers.Rows.Count; j++) { int personId = Convert.ToInt32(allUsers.Rows[j]["PersonID"]); if (i == 0) { DataTable logData = bllGetAttendanceData.GetPersonLogDataByDate(personId, LastPulledDateOnly); if (logData.Rows.Count > 0) { var UserwiseLastAttendancerecords = DaywiseAttendanceRecords.Where(x => x.IndRegID == personId).LastOrDefault(); if (UserwiseLastAttendancerecords != null) { int val = bllGetAttendanceData.UpdateLogData(personId, UserwiseLastAttendancerecords.TimeOnlyRecord.ToShortTimeString()); } } else { //insert var UserwiseFirstAttendancerecords = DaywiseAttendanceRecords.Where(x => x.IndRegID == personId).FirstOrDefault(); var UserwiseLastAttendancerecords = DaywiseAttendanceRecords.Where(x => x.IndRegID == personId).LastOrDefault(); if (UserwiseFirstAttendancerecords != null && UserwiseLastAttendancerecords != null) { DeviceRecord dr = new DeviceRecord(); dr.PersonalId = personId; dr.AttendanceDate = UserwiseFirstAttendancerecords.DateOnlyRecord; dr.AttendanceDateTime = Convert.ToDateTime(UserwiseFirstAttendancerecords.DateTimeRecord); dr.InTime = UserwiseFirstAttendancerecords.TimeOnlyRecord.ToShortTimeString(); dr.OutTime = UserwiseLastAttendancerecords.TimeOnlyRecord.ToShortTimeString(); int a = bllGetAttendanceData.Insert(dr); } } } else { var UserwiseFirstAttendancerecords = DaywiseAttendanceRecords.Where(x => x.IndRegID == personId).FirstOrDefault(); var UserwiseLastAttendancerecords = DaywiseAttendanceRecords.Where(x => x.IndRegID == personId).LastOrDefault(); if (UserwiseFirstAttendancerecords != null && UserwiseLastAttendancerecords != null) { DeviceRecord dr = new DeviceRecord(); dr.PersonalId = personId; dr.AttendanceDate = UserwiseFirstAttendancerecords.DateOnlyRecord; dr.AttendanceDateTime = Convert.ToDateTime(UserwiseFirstAttendancerecords.DateTimeRecord); dr.InTime = UserwiseFirstAttendancerecords.TimeOnlyRecord.ToShortTimeString(); dr.OutTime = UserwiseLastAttendancerecords.TimeOnlyRecord.ToShortTimeString(); int a = bllGetAttendanceData.Insert(dr); } } } } } int b = bllGetAttendanceData.InsertLatestPullRecord(todaysDateTime); sqlTran.Commit(); DisplayListOutput("Attendance pulled sucessfully"); } catch (Exception ex) { sqlTran.Rollback(); DisplayListOutput(ex.Message); } } } }