public RESTStatus GetWindowsLicData(SQLLib sql, object dummy, NetworkConnectionInfo ni, string id) { if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false) { ni.Error = "Access denied"; ni.ErrorID = ErrorFlags.AccessDenied; return(RESTStatus.Denied); } if (string.IsNullOrWhiteSpace(id) == true) { ni.Error = "Missing Data"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.Fail); } lock (ni.sqllock) { if (Computers.MachineExists(sql, id) == false) { ni.Error = "Invalid MachineID"; ni.ErrorID = ErrorFlags.InvalidValue; return(RESTStatus.Fail); } } lock (ni.sqllock) { SqlDataReader dr = sql.ExecSQLReader("SELECT * FROM WindowsLic WHERE MachineID=@m", new SQLParam("@m", id)); if (dr.HasRows == false) { dr.Close(); ni.Error = "No Data"; ni.ErrorID = ErrorFlags.NoData; return(RESTStatus.Fail); } WindowsLicData = new WindowsLic(); dr.Read(); WindowsLicData.Description = Convert.ToString(dr["Description"]); WindowsLicData.GracePeriodRemaining = Convert.ToInt64(dr["GracePeriodRemaining"]); WindowsLicData.LicenseFamily = Convert.ToString(dr["LicenseFamily"]); WindowsLicData.LicenseStatus = Convert.ToInt64(dr["LicenseStatus"]); WindowsLicData.LicenseStatusText = Convert.ToString(dr["LicenseStatusText"]); WindowsLicData.MachineID = Convert.ToString(dr["MachineID"]); WindowsLicData.Name = Convert.ToString(dr["Name"]); WindowsLicData.PartialProductKey = Convert.ToString(dr["PartialProductKey"]); WindowsLicData.ProductKeyChannel = Convert.ToString(dr["ProductKeyChannel"]); WindowsLicData.ProductKeyID = Convert.ToString(dr["ProductKeyID"]); WindowsLicData.ProductKeyID2 = Convert.ToString(dr["ProductKeyID2"]); WindowsLicData.Reported = SQLLib.GetDTUTC(dr["Reported"]); dr.Close(); } return(RESTStatus.Success); }
public RESTStatus GetStartupItems(SQLLib sql, object dummy, NetworkConnectionInfo ni, string id) { if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false) { ni.Error = "Access denied"; ni.ErrorID = ErrorFlags.AccessDenied; return(RESTStatus.Denied); } StartupsRep = new ListStartupItemReport(); StartupsRep.Items = new List <StartupItemFull>(); lock (ni.sqllock) { SqlDataReader dr; if (string.IsNullOrWhiteSpace(id) == true) { dr = sql.ExecSQLReader("select * from Startups inner join ComputerAccounts on ComputerAccounts.MachineID=Startups.MachineID left outer join UsersList on UsersList.SID=HKCUUser AND UsersList.MachineID=Startups.MachineID order by Location,[Key]"); } else { if (Computers.MachineExists(sql, id) == false) { ni.Error = "Invalid data"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.NotFound); } dr = sql.ExecSQLReader("select * from Startups inner join ComputerAccounts on ComputerAccounts.MachineID=Startups.MachineID left outer join UsersList on UsersList.SID=HKCUUser AND UsersList.MachineID=Startups.MachineID WHERE ComputerAccounts.MachineID=@m order by Location,[Key]", new SQLParam("@m", id)); } while (dr.Read()) { StartupItemFull ar = new StartupItemFull(); ar.Computername = Convert.ToString(dr["Computername"]); ar.DT = SQLLib.GetDTUTC(dr["DT"]); ar.HKCUUser = Convert.ToString(dr["HKCUUser"]); ar.MachineID = Convert.ToString(dr["MachineID"]); ar.Username = Convert.ToString(dr["Username"]); ar.Item = Convert.ToString(dr["Item"]); ar.Key = Convert.ToString(dr["Key"]); ar.Location = Convert.ToString(dr["Location"]); StartupsRep.Items.Add(ar); } dr.Close(); } return(RESTStatus.Success); }
public RESTStatus ListRKData(SQLLib sql, object dummy, NetworkConnectionInfo ni, string id) { if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false) { ni.Error = "Access denied"; ni.ErrorID = ErrorFlags.AccessDenied; return(RESTStatus.Denied); } if (string.IsNullOrWhiteSpace(id) == true) { ni.Error = "Invalid data"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.NotFound); } lock (ni.sqllock) { if (Computers.MachineExists(sql, id) == false) { ni.Error = "Invalid data"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.NotFound); } } LstRKData = new BitlockerRKList(); LstRKData.List = new List <BitlockerRK>(); LstRKData.MachineID = id; lock (ni.sqllock) { SqlDataReader dr = sql.ExecSQLReader("SELECT * FROM BitlockerRK WHERE MachineID=@m", new SQLParam("@m", id)); while (dr.Read()) { BitlockerRK rk = new BitlockerRK(); rk.DeviceID = Convert.ToString(dr["DeviceID"]); rk.DriveLetter = Convert.ToString(dr["DriveLetter"]); rk.Reported = SQLLib.GetDTUTC(dr["Reported"]); rk.Keys = JsonConvert.DeserializeObject <List <BitlockerRKKeyElement> >(Convert.ToString(dr["Keys"])); LstRKData.List.Add(rk); } dr.Close(); } return(RESTStatus.Success); }
public RESTStatus ListDevicesFilters(SQLLib sql, object dummy, NetworkConnectionInfo ni, string id) { if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false) { ni.Error = "Access denied"; ni.ErrorID = ErrorFlags.AccessDenied; return(RESTStatus.Denied); } if (string.IsNullOrWhiteSpace(id) == true) { ni.Error = "Invalid data"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.NotFound); } lock (ni.sqllock) { if (Computers.MachineExists(sql, id) == false) { ni.Error = "Invalid data"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.NotFound); } } LstFltData = new FilterDriverList(); LstFltData.List = new List <FilterDriver>(); LstFltData.MachineID = id; lock (ni.sqllock) { SqlDataReader dr = sql.ExecSQLReader("SELECT * FROM DevicesFilter WHERE MachineID=@mid", new SQLParam("@mid", id)); while (dr.Read()) { FilterDriver n = new FilterDriver(); n.ClassGUID = Convert.ToString(dr["ClassGUID"]); n.ServiceName = Convert.ToString(dr["ServiceName"]); n.Type = Convert.ToInt32(dr["Type"]); LstFltData.List.Add(n); } dr.Close(); } return(RESTStatus.Success); }
public RESTStatus ListSTasks(SQLLib sql, object dummy, NetworkConnectionInfo ni, string id) { if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false) { ni.Error = "Access denied"; ni.ErrorID = ErrorFlags.AccessDenied; return(RESTStatus.Denied); } lock (ni.sqllock) { SqlDataReader dr; if (string.IsNullOrWhiteSpace(id) == false) { if (Computers.MachineExists(sql, id) == false) { ni.Error = "Access denied"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.NotFound); } dr = sql.ExecSQLReader("select SimpleTasks.*,ComputerName from SimpleTasks inner join ComputerAccounts on ComputerAccounts.MachineID=SimpleTasks.MachineID where SimpleTasks.MachineID=@m order by MachineID,Name", new SQLParam("@m", id)); } else { dr = sql.ExecSQLReader("select SimpleTasks.*,ComputerName from SimpleTasks inner join ComputerAccounts on ComputerAccounts.MachineID=SimpleTasks.MachineID order by MachineID,Name"); } SimpleList = new SimpleTaskLiteList(); SimpleList.List = new List <SimpleTaskLite>(); while (dr.Read()) { SimpleTaskLite d = new SimpleTaskLite(); sql.LoadIntoClass(dr, d); SimpleList.List.Add(d); } dr.Close(); } return(RESTStatus.Success); }
public RESTStatus ListDiskData(SQLLib sql, object dummy, NetworkConnectionInfo ni, string id) { if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false) { ni.Error = "Access denied"; ni.ErrorID = ErrorFlags.AccessDenied; return(RESTStatus.Denied); } lock (ni.sqllock) { SqlDataReader dr; if (string.IsNullOrWhiteSpace(id) == false) { if (Computers.MachineExists(sql, id) == false) { ni.Error = "Access denied"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.NotFound); } dr = sql.ExecSQLReader("select DiskData.*,ComputerName from DiskData inner join ComputerAccounts on ComputerAccounts.MachineID=DiskData.MachineID where diskData.MachineID=@m order by MachineID,Caption", new SQLParam("@m", id)); } else { dr = sql.ExecSQLReader("select DiskData.*,ComputerName from DiskData inner join ComputerAccounts on ComputerAccounts.MachineID=DiskData.MachineID order by MachineID,Caption"); } LstDiskData = new ListDiskDataReport(); LstDiskData.Items = new List <DiskDataReport>(); while (dr.Read()) { DiskDataReport d = new DiskDataReport(); sql.LoadIntoClass(dr, d); LstDiskData.Items.Add(d); } dr.Close(); } return(RESTStatus.Success); }
public RESTStatus GetEventLogs(SQLLib sql, EventLogSearch eventlogsearch, NetworkConnectionInfo ni) { if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false) { ni.Error = "Access denied"; ni.ErrorID = ErrorFlags.AccessDenied; return(RESTStatus.Denied); } EventLogs = new EventLogReportFullList(); EventLogs.Data = new List <EventLogReportFull>(); if (eventlogsearch == null) { return(RESTStatus.Success); } if (eventlogsearch.QTY < 1) { eventlogsearch.QTY = 500; } string SQLQuery = "SELECT TOP " + eventlogsearch.QTY + " * FROM EventLog WHERE "; List <SQLParam> SQLQueryArgs = new List <SQLParam>(); if (eventlogsearch.MachineID != null) { if (Computers.MachineExists(sql, eventlogsearch.MachineID) == false) { ni.Error = "Invalid Data"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.NotFound); } SQLQuery += "MachineID=@m AND "; SQLQueryArgs.Add(new SQLParam("@m", eventlogsearch.MachineID)); } if (eventlogsearch.Source != null) { SQLQuery += "Source=@s AND "; SQLQueryArgs.Add(new SQLParam("@s", eventlogsearch.Source)); } if (eventlogsearch.EventLogType != null) { SQLQuery += "EventLogType=@t AND "; SQLQueryArgs.Add(new SQLParam("@t", eventlogsearch.EventLogType)); } if (eventlogsearch.FromDate != null) { SQLQuery += "TimeGenerated>=@tgf AND "; SQLQueryArgs.Add(new SQLParam("@tgf", eventlogsearch.FromDate)); } if (eventlogsearch.ToDate != null) { SQLQuery += "TimeGenerated<=@tgt AND "; SQLQueryArgs.Add(new SQLParam("@tgt", eventlogsearch.ToDate)); } if (eventlogsearch.EventLogBook != null) { SQLQuery += "EventLog=@evtb AND "; SQLQueryArgs.Add(new SQLParam("@evtb", eventlogsearch.EventLogBook)); } if (eventlogsearch.CategoryNumber != null) { SQLQuery += "CategoryNumber=@catnum AND "; SQLQueryArgs.Add(new SQLParam("@catnum", eventlogsearch.CategoryNumber)); } SQLQuery = SQLQuery.Trim(); SQLQuery += " 1=1 "; SQLQuery += " ORDER BY TimeGenerated DESC"; lock (ni.sqllock) { SqlDataReader dr = sql.ExecSQLReader(SQLQuery, SQLQueryArgs.ToArray()); while (dr.Read()) { EventLogReportFull ev = new EventLogReportFull(); ev.Category = Convert.ToString(dr["Category"]); ev.CategoryNumber = Convert.ToInt32(dr["CategoryNumber"]); ev.Data = (byte[])dr["Data"]; ev.EventLog = Convert.ToString(dr["EventLog"]); ev.EventLogType = Convert.ToInt32(dr["EventLogType"]); ev.InstanceID = Convert.ToInt64(dr["InstanceID"]); ev.JSONReplacementStrings = Convert.ToString(dr["JSONReplacementStrings"]); ev.LogID = Convert.ToString(dr["LogID"]); ev.MachineID = Convert.ToString(dr["MachineID"]); ev.Message = Convert.ToString(dr["Message"]); ev.Reported = SQLLib.GetDTUTC(dr["Reported"]); ev.Source = Convert.ToString(dr["Source"]); ev.TimeGenerated = SQLLib.GetDTUTC(dr["TimeGenerated"]); ev.TimeWritten = SQLLib.GetDTUTC(dr["TimeWritten"]); EventLogs.Data.Add(ev); } dr.Close(); } return(RESTStatus.Success); }
public RESTStatus CreatePolicy(SQLLib sql, NewPolicyReq request, NetworkConnectionInfo ni) { if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false) { ni.Error = "Access denied"; ni.ErrorID = ErrorFlags.AccessDenied; return(RESTStatus.Denied); } if (request.Name == null || request.Name.Trim() == "") { ni.Error = "Invalid name"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.Fail); } request.Name = request.Name.Trim(); if (request.Grouping != null && request.MachineID != null) { ni.Error = "Either Grouping OR MachineID should be set"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.Fail); } if (request.Grouping != null) { lock (ni.sqllock) { if (Groups.GroupExsits(sql, request.Grouping.Value) == false) { ni.Error = "Group does not exists"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.Fail); } } } if (request.MachineID != null) { lock (ni.sqllock) { if (Computers.MachineExists(sql, request.MachineID) == false) { ni.Error = "MachineID does not exists"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.Fail); } } } try { JsonConvert.DeserializeObject(request.Data); } catch { ni.Error = "JSON error"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.Fail); } NewPolicyID = new NetInt64(); Int64?res; lock (ni.sqllock) { res = sql.InsertMultiDataID("Policies", new SQLData("Type", request.Type), new SQLData("Name", request.Name), new SQLData("Grouping", request.Grouping), new SQLData("MachineID", request.MachineID), new SQLData("DataBlob", request.Data), new SQLData("DT", DateTime.Now), new SQLData("Version", 1), new SQLData("Enabled", 0)); } if (res == null) { ni.Error = "SQL Error"; ni.ErrorID = ErrorFlags.SQLError; return(RESTStatus.ServerError); } NewPolicyID.Data = res.Value; return(RESTStatus.Created); }
public RESTStatus EditPolicy(SQLLib sql, EditPolicy request, NetworkConnectionInfo ni, Int64 id) { if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false) { ni.Error = "Access denied"; ni.ErrorID = ErrorFlags.AccessDenied; return(RESTStatus.Denied); } lock (ni.sqllock) { if (Policies.PolicyExsits(sql, id) == false) { ni.Error = "Invalid data"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.Fail); } } if (id != request.ID) { ni.Error = "Invalid data"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.Fail); } if (request.DataOnly == false) { if (request.Name == null || request.Name.Trim() == "") { ni.Error = "Invalid name"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.Fail); } request.Name = request.Name.Trim(); if (request.Grouping != null && request.MachineID != null) { ni.Error = "Either Grouping OR MachineID should be set"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.Fail); } if (request.Grouping != null) { lock (ni.sqllock) { if (Groups.GroupExsits(sql, request.Grouping.Value) == false) { ni.Error = "Group does not exists"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.Fail); } } } if (request.MachineID != null) { lock (ni.sqllock) { if (Computers.MachineExists(sql, request.MachineID) == false) { ni.Error = "MachineID does not exists"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.Fail); } } } } try { JsonConvert.DeserializeObject(request.Data); } catch { ni.Error = "JSON error"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.Fail); } try { if (request.DataOnly == false) { lock (ni.sqllock) { sql.ExecSQL("Update Policies SET Name=@n, Grouping=@g, MachineID=@m, DataBlob=@blob, DT=Getutcdate(), Version=Version+1 WHERE ID=@id", new SQLParam("@id", request.ID), new SQLParam("@n", request.Name), new SQLParam("@g", request.Grouping), new SQLParam("@m", request.MachineID), new SQLParam("@blob", request.Data)); } } else { lock (ni.sqllock) { sql.ExecSQL("Update Policies SET DataBlob=@blob, DT=Getutcdate(), Version=Version+1 WHERE ID=@id", new SQLParam("@id", request.ID), new SQLParam("@blob", request.Data)); } } } catch { ni.Error = "SQL Error"; ni.ErrorID = ErrorFlags.SQLError; return(RESTStatus.ServerError); } return(RESTStatus.Success); }
public RESTStatus GetAddRemovePrograms(SQLLib sql, object dummy, NetworkConnectionInfo ni, string id) { if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false) { ni.Error = "Access denied"; ni.ErrorID = ErrorFlags.AccessDenied; return(RESTStatus.Denied); } AddRemoveRep = new ListAddRemoveAppsReport(); AddRemoveRep.Items = new List <AddRemoveAppReport>(); lock (ni.sqllock) { SqlDataReader dr; if (string.IsNullOrWhiteSpace(id) == true) { dr = sql.ExecSQLReader("select * from AddRemovePrograms inner join ComputerAccounts on ComputerAccounts.MachineID=AddRemovePrograms.MachineID left outer join UsersList on UsersList.SID=HKCUUser AND UsersList.MachineID=AddRemovePrograms.MachineID order by Name,VersionMajor,VersionMinor"); } else { if (Computers.MachineExists(sql, id) == false) { ni.Error = "Invalid data"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.NotFound); } dr = sql.ExecSQLReader("select * from AddRemovePrograms inner join ComputerAccounts on ComputerAccounts.MachineID=AddRemovePrograms.MachineID left outer join UsersList on UsersList.SID=HKCUUser AND UsersList.MachineID=AddRemovePrograms.MachineID WHERE ComputerAccounts.MachineID=@m order by Name,VersionMajor,VersionMinor", new SQLParam("@m", id)); } while (dr.Read()) { AddRemoveAppReport ar = new AddRemoveAppReport(); ar.Computername = Convert.ToString(dr["Computername"]); ar.DisplayLanguage = Convert.ToString(dr["DisplayLanguage"]); ar.DisplayVersion = Convert.ToString(dr["DisplayVersion"]); ar.IsMSI = Convert.ToBoolean(dr["IsMSI"]); ar.IsWOWBranch = Convert.ToBoolean(dr["IsWOWBranch"]); ar.IsSystemComponent = Convert.ToBoolean(dr["IsSystemComponent"]); ar.Language = Convert.ToString(dr["Language"]); ar.MachineID = Convert.ToString(dr["MachineID"]); ar.Name = Convert.ToString(dr["Name"]); ar.ProductID = Convert.ToString(dr["ProductID"]); ar.UninstallString = Convert.ToString(dr["UninstallString"]); ar.VersionMajor = Convert.ToInt32(dr["VersionMajor"]); ar.VersionMinor = Convert.ToInt32(dr["VersionMinor"]); ar.DT = SQLLib.GetDTUTC(dr["DT"]); ar.HKCUUser = Convert.ToString(dr["HKCUUser"]); ar.Username = Convert.ToString(dr["Username"]); if (string.IsNullOrWhiteSpace(ar.HKCUUser) == true) { ar.HKCUUser = ""; } AddRemoveRep.Items.Add(ar); } dr.Close(); } return(RESTStatus.Success); }
public RESTStatus SetSTasks(SQLLib sql, SimpleTask NewTask, NetworkConnectionInfo ni) { if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false) { ni.Error = "Access denied"; ni.ErrorID = ErrorFlags.AccessDenied; return(RESTStatus.Denied); } if (NewTask == null) { ni.Error = "Invalid data"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.NotFound); } if (string.IsNullOrWhiteSpace(NewTask.Name) == true || string.IsNullOrWhiteSpace(NewTask.Data) == true || NewTask.Type < 1) { ni.Error = "Invalid data"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.NotFound); } if (NewTask.ExecAfter != null) { if (NewTask.ExecAfter.Value.Year < 2010) { ni.Error = "ExecAfter is invalid"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.NotFound); } } lock (ni.sqllock) { if (Computers.MachineExists(sql, NewTask.MachineID) == false) { ni.Error = "Invalid data"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.NotFound); } Int64?ID = sql.InsertMultiDataID("SimpleTasks", new SQLData("MachineID", NewTask.MachineID), new SQLData("Type", NewTask.Type), new SQLData("Name", NewTask.Name), new SQLData("ExecAfter", NewTask.ExecAfter), new SQLData("Data", NewTask.Data)); if (ID == null) { ni.Error = "Server error"; ni.ErrorID = ErrorFlags.SQLError; return(RESTStatus.ServerError); } NewTaskID = new NetInt64(); NewTaskID.Data = ID.Value; } return(RESTStatus.Success); }
public RESTStatus ListDevicesData(SQLLib sql, object dummy, NetworkConnectionInfo ni, string id) { if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false) { ni.Error = "Access denied"; ni.ErrorID = ErrorFlags.AccessDenied; return(RESTStatus.Denied); } if (string.IsNullOrWhiteSpace(id) == true) { ni.Error = "Invalid data"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.NotFound); } lock (ni.sqllock) { if (Computers.MachineExists(sql, id) == false) { ni.Error = "Invalid data"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.NotFound); } } LstDevData = new PnPDeviceList(); LstDevData.List = new List <PnPDevice>(); LstDevData.MachineID = id; lock (ni.sqllock) { SqlDataReader dr = sql.ExecSQLReader("SELECT * FROM DevicesConfig WHERE MachineID=@mid", new SQLParam("@mid", id)); while (dr.Read()) { PnPDevice n = new PnPDevice(); n.Availability = Convert.ToInt32(dr["Availability"]); n.Caption = Convert.ToString(dr["Caption"]); n.ClassGuid = Convert.ToString(dr["ClassGuid"]); n.ConfigManagerErrorCode = Convert.ToInt32(dr["ConfigManagerErrorCode"]); n.ConfigManagerUserConfig = Convert.ToBoolean(dr["ConfigManagerUserConfig"]); n.CreationClassName = Convert.ToString(dr["CreationClassName"]); n.Description = Convert.ToString(dr["Description"]); n.ErrorCleared = dr["ErrorCleared"] is DBNull ? (bool?)null : Convert.ToBoolean(dr["ErrorCleared"]); n.ErrorDescription = Convert.ToString(dr["ErrorDescription"]); n.Index = Convert.ToInt32(dr["Index"]); n.InstallDate = dr["InstallDate"] is DBNull ? (DateTime?)null : SQLLib.GetDTUTC(dr["InstallDate"]); n.LastErrorCode = dr["LastErrorCode"] is DBNull ? (int?)null : Convert.ToInt32(dr["LastErrorCode"]); n.Manufacturer = Convert.ToString(dr["Manufacturer"]); n.Name = Convert.ToString(dr["Name"]); n.PNPClass = Convert.ToString(dr["PNPClass"]); n.PNPDeviceID = Convert.ToString(dr["PNPDeviceID"]); n.Present = Convert.ToBoolean(dr["Present"]); n.Service = Convert.ToString(dr["Service"]); n.Status = Convert.ToString(dr["Status"]); n.StatusInfo = dr["StatusInfo"] is DBNull ? (int?)null : Convert.ToInt32(dr["StatusInfo"]); n.HardwareID = JsonConvert.DeserializeObject <List <string> >(Convert.ToString(dr["HardwareID"])); n.CompatibleID = JsonConvert.DeserializeObject <List <string> >(Convert.ToString(dr["CompatibleID"])); LstDevData.List.Add(n); } dr.Close(); } return(RESTStatus.Success); }