static void Main(string[] args) { try { using (AdoDataConnection connection = new AdoDataConnection("systemSettings")) { GSF.Data.Model.TableOperations <PQds.Model.Setting> tableOperations = new GSF.Data.Model.TableOperations <PQds.Model.Setting>(connection); Setting company = tableOperations.QueryRecordWhere("Name = {0}", "contact.utility"); Setting email = tableOperations.QueryRecordWhere("Name = {0}", "contact.email"); int n = args.Count(); company.value = String.Join(" ", args.Take(n - 1)); email.value = args[n - 1]; tableOperations.UpdateRecord(company); tableOperations.UpdateRecord(email); } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.InnerException.Message); } }
private void save_Click(object sender, EventArgs e) { if (Model.SignalType.ToValue((string)comboBox1.SelectedItem) != -1) { this.m_channel.SignalType = Model.SignalType.ToValue((string)comboBox1.SelectedItem); } else { this.m_channel.SignalType = null; } if (Model.MeasurementType.ToValue((string)comboBox2.SelectedItem) != "") { this.m_channel.MeasurementType = Model.MeasurementType.ToValue((string)comboBox2.SelectedItem); } else { this.m_channel.MeasurementType = null; } this.m_channel.MeterID = (comboDevice.SelectedItem as dynamic).Value; using (AdoDataConnection connection = new AdoDataConnection("systemSettings")) { (new GSF.Data.Model.TableOperations <PQds.Model.Channel>(connection)).UpdateRecord(this.m_channel); GSF.Data.Model.TableOperations <PQds.Model.DataSensitivity> dataSensitivityTbl = new GSF.Data.Model.TableOperations <PQds.Model.DataSensitivity>(connection); PQds.Model.DataSensitivity dataSensitivity; if (dataSensitivityTbl.QueryRecordCountWhere("Event = {0} AND Asset = {1}", this.m_evt.ID, this.m_channel.AssetID) > 0) { dataSensitivity = dataSensitivityTbl.QueryRecordsWhere("Event = {0} AND Asset = {1}", this.m_evt.ID, this.m_channel.AssetID).First(); } dataSensitivity = new Model.DataSensitivity() { Event = this.m_evt.ID, Asset = (int)this.m_channel.AssetID }; dataSensitivity.DataSensitivityCode = Model.DataSensitivityCode.ToValue((string)comboBox3.SelectedItem); dataSensitivity.Note = DataSensitivityNoteText.Text; dataSensitivityTbl.UpdateRecord(dataSensitivity); } this.Close(); }
private void Parse(string filename) { List <ObservationRecord> observationRecords; List <DataSourceRecord> dataSourceRecords; using (LogicalParser logicalParser = new LogicalParser(filename)) { observationRecords = new List <ObservationRecord>(); logicalParser.Open(); while (logicalParser.HasNextObservationRecord()) { observationRecords.Add(logicalParser.NextObservationRecord()); } dataSourceRecords = logicalParser.DataSourceRecords; } this.m_previousProgress = this.m_previousProgress + 50; this.mProgress.Report(this.m_previousProgress); if (observationRecords.Count == 0) { return; } if (dataSourceRecords.Count != 1) { return; } //create Meter Definition //For now assume a single meter Meter meter = new Meter(); meter.DeviceName = dataSourceRecords[0].DataSourceName; meter.Owner = dataSourceRecords[0].DataSourceOwner; meter.DeviceAlias = GSF.PQDIF.Logical.Equipment.ToString(dataSourceRecords[0].EquipmentID); meter.DeviceLocation = dataSourceRecords[0].DataSourceLocation; if (dataSourceRecords[0].Latitude < uint.MaxValue) { meter.Latitude = dataSourceRecords[0].Latitude; } if (dataSourceRecords[0].Longitude < uint.MaxValue) { meter.Longitude = dataSourceRecords[0].Longitude; } meter.AccountName = GSF.PQDIF.Logical.Vendor.ToString(dataSourceRecords[0].VendorID); using (TransactionScope scope = new TransactionScope()) { AdoDataConnection connection = new AdoDataConnection(connectionstring, dataprovider); GSF.Data.Model.TableOperations <Meter> meterTable = new GSF.Data.Model.TableOperations <Meter>(connection); meterTable.AddNewRecord(meter); meter.ID = ModelID.GetID <Meter>(connection); //create Channel Definitions List <PQio.Model.Channel> channels = dataSourceRecords[0].ChannelDefinitions.Select(channel => ParseChannel(meter, channel, connection)).ToList(); List <PQio.Model.Event> events = new List <Event>(); //create Event Definitions foreach (ObservationRecord record in observationRecords) { //Create Event Event evt = ParseObservationRecord(record, connection); //create DataSeries objects foreach (ChannelInstance channelInstance in record.ChannelInstances) { ParseSeries(channelInstance, channels[(int)channelInstance.ChannelDefinitionIndex], evt, connection); } events.Add(evt); } // Remove Channels whithout data channels = channels.FindAll(item => RemoveEmptyChannel(item, connection)).ToList(); events = events.FindAll(item => RemoveEmptyEvents(item, connection)).ToList(); // Remove Channels whithout data channels = channels.FindAll(item => RemoveEmptyChannel(item, connection)).ToList(); // If only one set of data it's easy to keep only single line int nVa = channels.Count(channel => channel.MeasurementType.ToLower() == MeasurementType.VoltageA); int nVb = channels.Count(channel => channel.MeasurementType.ToLower() == MeasurementType.VoltageB); int nVc = channels.Count(channel => channel.MeasurementType.ToLower() == MeasurementType.VoltageC); int nIa = channels.Count(channel => channel.MeasurementType.ToLower() == MeasurementType.CurrentA); int nIb = channels.Count(channel => channel.MeasurementType.ToLower() == MeasurementType.CurrentB); int nIc = channels.Count(channel => channel.MeasurementType.ToLower() == MeasurementType.CurrentC); if (nVa == 1 && nVb == 1 && nVc == 1) { //Create new asset Asset asset = new Asset() { AssetKey = String.Format("Asset 1 ({0})", meter.AccountName) }; GSF.Data.Model.TableOperations <Asset> assetTable = new GSF.Data.Model.TableOperations <Asset>(connection); assetTable.AddNewRecord(asset); asset.ID = ModelID.GetID <Asset>(connection); GSF.Data.Model.TableOperations <Channel> channelTable = new GSF.Data.Model.TableOperations <Channel>(connection); Channel Va = channels.Find(item => item.MeasurementType.ToLower() == MeasurementType.VoltageA); Channel Vb = channels.Find(item => item.MeasurementType.ToLower() == MeasurementType.VoltageB); Channel Vc = channels.Find(item => item.MeasurementType.ToLower() == MeasurementType.VoltageC); Va.AssetID = asset.ID; Vb.AssetID = asset.ID; Vc.AssetID = asset.ID; channelTable.UpdateRecord(Va); channelTable.UpdateRecord(Vb); channelTable.UpdateRecord(Vc); if (nIa == 1 && nIb == 1 && nIc == 1) { Channel Ia = channels.Find(item => item.MeasurementType.ToLower() == MeasurementType.CurrentA); Channel Ib = channels.Find(item => item.MeasurementType.ToLower() == MeasurementType.CurrentB); Channel Ic = channels.Find(item => item.MeasurementType.ToLower() == MeasurementType.CurrentC); Ia.AssetID = asset.ID; Ib.AssetID = asset.ID; Ic.AssetID = asset.ID; channelTable.UpdateRecord(Ia); channelTable.UpdateRecord(Ib); channelTable.UpdateRecord(Ic); } } scope.Complete(); } this.m_previousProgress = this.m_previousProgress + 50; this.mProgress.Report(this.m_previousProgress); }