private BsonDocument buildRxAmplitudeTest(RxAmplitudeTest tcd) { Measurement measurement = null; // Initialize object that will be stored under 'device' in mongo document BsonDocument nestedDevice = null; if (tcd.RxTest != null) { try { measurement = tcd.RxTest.Measurement; } catch (Exception exc) { Program.log("ERROR RXAMPLITUDE: " + tcd.Id + " - " + exc.Message); } finally { nestedDevice = SyncManager.Instance.getNestedDevice(measurement); } } if (nestedDevice == null) return null; // Initialize object that will be stored under 'meta' in mongo document BsonDocument nestedMeta = SyncManager.Instance.getNestedMeta(measurement); // Initialize object that will be stored under 'data' in mongo document BsonDocument nestedData = SyncManager.Instance.getNestedData(tcd, excludeDataFields); // Custom code to move some set fields to meta object nestedMeta.Add("SetTemperature_C", nestedData["SetTemperature"]); nestedData.Remove("SetTemperature"); nestedMeta.Add("Channel", nestedData["Channel"]); nestedData.Remove("Channel"); nestedMeta.Add("SetVoltage", nestedData["SetVoltage"]); nestedData.Remove("SetVoltage"); //System.Diagnostics.Trace.WriteLine("D " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt")); String st = ""; String[] racks = { "DL_ST", "QSFP-DEV-PC2", "Production-4"}; if (racks.Contains(nestedMeta["Rack"].ToString())) { st = "rxfunctionality"; } String[] racks2 = { "Rack_1", "Rack_3", "Rack_4", "Rack_5", "Rack_6", "Rack_7", "Rack_8", "Rack_9" }; if (racks2.Contains(nestedMeta["Rack"].ToString())) { st = "rxamplitude"; } if (st == "") { return null; } // Initialize object in root of the document BsonDocument rootDoc = new BsonDocument { { "_id", tcd.Id.ToString()}, { "mid", measurement.Id.ToString() }, { "timestamp", tcd.TimeStamp}, { "type", domain() }, { "subtype", st}, { "result", getResult( nestedData["Result"].ToString()) }, { "downstatus", getDownStatus( nestedData["Result"].ToString()) }, { "status", getStatus(measurement.Result) } }; nestedData.Remove("Result"); rootDoc.Add("device", nestedDevice); rootDoc.Add("meta", nestedMeta); rootDoc.Add("data", nestedData); return rootDoc; }
private BsonDocument buildRxAmplitudeTest(RxAmplitudeTest tcd) { Measurement measurement = null; // Initialize object that will be stored under 'device' in mongo document BsonDocument nestedDevice = null; if (tcd.RxTest != null) { try { measurement = tcd.RxTest.Measurement; } catch (Exception exc) { Program.log("ERROR RXAMPLITUDE: " + tcd.Id + " - " + exc.Message); } finally { nestedDevice = SyncManager.Instance.getNestedDevice(measurement); } } if (nestedDevice == null) { return(null); } // Initialize object that will be stored under 'meta' in mongo document BsonDocument nestedMeta = SyncManager.Instance.getNestedMeta(measurement); // Initialize object that will be stored under 'data' in mongo document BsonDocument nestedData = SyncManager.Instance.getNestedData(tcd, excludeDataFields); // Custom code to move some set fields to meta object nestedMeta.Add("SetTemperature_C", nestedData["SetTemperature"]); nestedData.Remove("SetTemperature"); nestedMeta.Add("Channel", nestedData["Channel"]); nestedData.Remove("Channel"); nestedMeta.Add("SetVoltage", nestedData["SetVoltage"]); nestedData.Remove("SetVoltage"); //System.Diagnostics.Trace.WriteLine("D " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt")); String st = ""; String[] racks = { "DL_ST", "QSFP-DEV-PC2", "Production-4" }; if (racks.Contains(nestedMeta["Rack"].ToString())) { st = "rxfunctionality"; } String[] racks2 = { "Rack_1", "Rack_3", "Rack_4", "Rack_5", "Rack_6", "Rack_7", "Rack_8", "Rack_9" }; if (racks2.Contains(nestedMeta["Rack"].ToString())) { st = "rxamplitude"; } if (st == "") { return(null); } // Initialize object in root of the document BsonDocument rootDoc = new BsonDocument { { "_id", tcd.Id.ToString() }, { "mid", measurement.Id.ToString() }, { "timestamp", tcd.TimeStamp }, { "type", domain() }, { "subtype", st }, { "result", getResult(nestedData["Result"].ToString()) }, { "downstatus", getDownStatus(nestedData["Result"].ToString()) }, { "status", getStatus(measurement.Result) } }; nestedData.Remove("Result"); rootDoc.Add("device", nestedDevice); rootDoc.Add("meta", nestedMeta); rootDoc.Add("data", nestedData); return(rootDoc); }