Ejemplo n.º 1
0
        private void SyncChannel(string address, MetersToDataPush meter, LinesToDataPush line)
        {
            // ensure remote and local line impedance matches
            IEnumerable <ChannelDetail> local  = DataContext.Table <ChannelDetail>().QueryRecordsWhere("MeterID = {0} AND LineID = {1}", meter.LocalXDAMeterID, line.LocalXDALineID);
            List <ChannelDetail>        remote = WebAPIHub.GetChannels(address, $"MeterID = {meter.RemoteXDAMeterID} AND LineID = {line.RemoteXDALineID}").ToList();

            // if there is a local record but not a remote record
            foreach (ChannelDetail summary in local)
            {
                if (!remote.Where(x => x.MeasurementType == summary.MeasurementType && x.MeasurementCharacteristic == summary.MeasurementCharacteristic && x.Phase == summary.Phase && x.Name == summary.Name).Any())
                {
                    JObject record = new JObject();
                    record.Add("MeterID", meter.RemoteXDAMeterID);
                    record.Add("LineID", line.RemoteXDALineID);
                    record.Add("MeasurementType", summary.MeasurementType);
                    record.Add("MeasurementCharacteristic", summary.MeasurementCharacteristic);
                    record.Add("Phase", summary.Phase);
                    record.Add("Name", summary.Name);
                    record.Add("SamplesPerHour", summary.SamplesPerHour);
                    record.Add("PerUnitValue", summary.PerUnitValue);
                    record.Add("HarmonicGroup", summary.HarmonicGroup);
                    record.Add("Description", summary.Description);
                    record.Add("Enabled", summary.Enabled);

                    int remoteChannelId = WebAPIHub.CreateChannel(address, record);

                    SyncSeries(address, summary.ID, remoteChannelId);
                    //SyncAlarmLogs(address, summary.ID, remoteChannelId);
                    //SyncAlarmRangeLimit(address, summary.ID, remoteChannelId);
                    //SyncBreakerChannel(address, summary.ID, remoteChannelId);
                    //SyncChannelAlarmSummary(address, summary.ID, remoteChannelId);
                    //SyncChannelDataQualitySummary(address, summary.ID, remoteChannelId);
                    //SyncDailyTrendingSummary(address, summary.ID, remoteChannelId);
                    //SyncDailyQualityRangeLimit(address, summary.ID, remoteChannelId);
                }
            }
        }