示例#1
0
        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));
            }
        }
示例#2
0
        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));
            }
        }
示例#3
0
文件: Program.cs 项目: daozh/openXDA
        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);
        }
示例#4
0
        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);
            }
        }
示例#5
0
 public void UpdateMeterLine(MeterLine record)
 {
     DataContext.Table <MeterLine>().UpdateRecord(record);
 }
示例#6
0
 public void AddNewMeterLine(MeterLine record)
 {
     DataContext.Table <MeterLine>().AddNewRecord(record);
 }