private LinesToDataPush AddLine(string address, MeterLine meterLine, bool obsfucate) { Line localLine = DataContext.Table <Line>().QueryRecordWhere("ID = {0}", meterLine.LineID); List <LinesToDataPush> selectedLines = DataContext.Table <LinesToDataPush>().QueryRecords("LocalXDAAssetKey").ToList(); List <Line> remoteLines = WebAPIHub.GetRecords(address, "Line", "all").Select(x => (Line)x).ToList(); //if the line does not exist in the PQMarkPusher Database to allow for obsfucation add it. if (!selectedLines.Where(x => x.LocalXDALineID == meterLine.LineID).Any()) { LinesToDataPush record = new LinesToDataPush() { LocalXDALineID = localLine.ID, RemoteXDALineID = 0, LocalXDAAssetKey = localLine.AssetKey, RemoteXDAAssetKey = (obsfucate ? Guid.NewGuid().ToString(): localLine.AssetKey) }; Line newRecord = new Line() { AssetKey = (obsfucate? record.RemoteXDAAssetKey.ToString() : localLine.AssetKey), VoltageKV = localLine.VoltageKV, ThermalRating = localLine.ThermalRating, Length = localLine.Length, Description = (obsfucate? "" : localLine.Description) }; record.RemoteXDALineID = WebAPIHub.CreateRecord(address, "Line", JObject.FromObject(newRecord)); DataContext.Table <LinesToDataPush>().AddNewRecord(record); return(record); } else { return(DataContext.Table <LinesToDataPush>().QueryRecordWhere("LocalXDALineID = {0}", meterLine.LineID)); } }
private void AddMeterLine(string address, MetersToDataPush meter, LinesToDataPush selectedLine) { List <MeterLine> remoteMeterLines = WebAPIHub.GetRecordsWhere(address, "MeterLine", $"MeterID = {meter.RemoteXDAMeterID} AND LineID = {selectedLine.RemoteXDALineID}").Select(x => (MeterLine)x).ToList(); // if MeterLine association has not been previously made, make it if (!remoteMeterLines.Any()) { MeterLine record = new MeterLine() { MeterID = meter.RemoteXDAMeterID, LineID = selectedLine.RemoteXDALineID, LineName = selectedLine.RemoteXDAAssetKey.ToString() }; WebAPIHub.CreateRecord(address, "MeterLine", JObject.FromObject(record)); } }
private static MeterLine Link(Meter meter, Line line, XElement lineElement, Dictionary <Tuple <string, string>, MeterLine> meterLineLookup) { Tuple <string, string> key = Tuple.Create(meter.AssetKey, line.AssetKey); MeterLine meterLine; if (!meterLineLookup.TryGetValue(key, out meterLine)) { meterLine = new MeterLine() { Meter = meter, Line = line, LineName = (string)lineElement.Element("name") }; meterLineLookup.Add(key, meterLine); } return(meterLine); }
private static void Link(int meterID, int lineID, XElement lineElement, AdoDataConnection connection) { TableOperations <MeterLine> table = new TableOperations <MeterLine>(connection); MeterLine record = table.QueryRecordWhere("MeterID = {0} AND LineID = {1}", meterID, lineID); if (record == null) { record = new MeterLine() { MeterID = meterID, LineID = lineID, LineName = (string)lineElement.Element("name") }; table.AddNewRecord(record); } else { record.LineName = (string)lineElement.Element("name"); table.UpdateRecord(record); } }
public void UpdateMeterLine(MeterLine record) { DataContext.Table <MeterLine>().UpdateRecord(record); }
public void AddNewMeterLine(MeterLine record) { DataContext.Table <MeterLine>().AddNewRecord(record); }