Exemple #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            using (AdoDataConnection connection = new AdoDataConnection("systemSettings"))
            {
                GSF.Data.Model.TableOperations <PQds.Model.CustomField> customFldTbl = new GSF.Data.Model.TableOperations <PQds.Model.CustomField>(connection);

                if (this.textBox1.Text.Length < 1)
                {
                    MessageBox.Show("A Domain name has to be selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (customFldTbl.QueryRecordCountWhere("domain = {0}", this.textBox1.Text) > 0)
                {
                    MessageBox.Show("This domain already exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    PQds.Model.CustomField fld = new Model.CustomField()
                    {
                        EventID = m_eventid, AssetID = m_assetid, key = "Key", Value = "Value", Type = "T", domain = this.textBox1.Text
                    };
                    customFldTbl.AddNewRecord(fld);
                }
            }

            this.Close();
        }
        private void button2_Click(object sender, EventArgs e)
        {
            string localAppData     = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}{Path.DirectorySeparatorChar}PQio{Path.DirectorySeparatorChar}DataBase.db";
            string connectionstring = $"Data Source={localAppData}; Version=3; Foreign Keys=True; FailIfMissing=True";

            using (AdoDataConnection connection = new AdoDataConnection(connectionstring, dataprovider))
            {
                GSF.Data.Model.TableOperations <PQio.Model.CustomField> customFldTbl = new GSF.Data.Model.TableOperations <PQio.Model.CustomField>(connection);

                if (this.textBox1.Text.Length < 1)
                {
                    MessageBox.Show("A Domain name has to be selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (customFldTbl.QueryRecordCountWhere("domain = {0}", this.textBox1.Text) > 0)
                {
                    MessageBox.Show("This domain already exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    PQio.Model.CustomField fld = new Model.CustomField()
                    {
                        EventID = m_eventid, AssetID = m_assetid, key = "Key", Value = "Value", Type = "T", domain = this.textBox1.Text
                    };
                    customFldTbl.AddNewRecord(fld);
                }
            }

            this.Close();
        }
Exemple #3
0
        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 = "";
            }

            this.m_channel.MeterID = (comboDevice.SelectedItem as dynamic).Value;

            using (AdoDataConnection connection = new AdoDataConnection(connectionstring, dataprovider))
            {
                (new GSF.Data.Model.TableOperations <PQio.Model.Channel>(connection)).UpdateRecord(this.m_channel);

                GSF.Data.Model.TableOperations <PQio.Model.DataSensitivity> dataSensitivityTbl = new GSF.Data.Model.TableOperations <PQio.Model.DataSensitivity>(connection);

                PQio.Model.DataSensitivity dataSensitivity;

                if (this.m_channel.AssetID != null)
                {
                    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();
                    }

                    else
                    {
                        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.AddNewOrUpdateRecord(dataSensitivity);
                }
            }



            this.Close();
        }
        private Boolean RemoveEmptyEvents(Event evt, AdoDataConnection connection)
        {
            GSF.Data.Model.TableOperations <DataSeries> dataSeriesTable = new GSF.Data.Model.TableOperations <DataSeries>(connection);
            GSF.Data.Model.TableOperations <Event>      evtTable        = new GSF.Data.Model.TableOperations <Event>(connection);

            int nEvents = dataSeriesTable.QueryRecordCountWhere("EventID = {0} ", evt.ID);

            if (nEvents == 0)
            {
                evtTable.DeleteRecord(evt);
                return(false);
            }
            else
            {
                return(true);
            }
        }
        private Boolean RemoveEmptyChannel(Channel channel, AdoDataConnection connection)
        {
            GSF.Data.Model.TableOperations <DataSeries> dataSeriesTable = new GSF.Data.Model.TableOperations <DataSeries>(connection);
            GSF.Data.Model.TableOperations <Channel>    channelTable    = new GSF.Data.Model.TableOperations <Channel>(connection);

            int nEvents = dataSeriesTable.QueryRecordCountWhere("ChannelID = {0} ", channel.ID);

            if (nEvents == 0)
            {
                //remove corresponsing MeasurmentID
                channelTable.DeleteRecord(channel);
                return(false);
            }
            else
            {
                return(true);
            }
        }
Exemple #6
0
        private Boolean RemoveEmptyEvents(PQds.Model.Event evt)
        {
            using (AdoDataConnection connection = new AdoDataConnection("systemSettings"))
            {
                GSF.Data.Model.TableOperations <PQds.Model.DataSeries> dataSeriesTable = new GSF.Data.Model.TableOperations <PQds.Model.DataSeries>(connection);
                GSF.Data.Model.TableOperations <PQds.Model.Event>      evtTable        = new GSF.Data.Model.TableOperations <PQds.Model.Event>(connection);

                int nEvents = dataSeriesTable.QueryRecordCountWhere("EventID = {0} ", evt.ID);

                if (nEvents == 0)
                {
                    evtTable.DeleteRecord(evt);
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }
Exemple #7
0
        private void GenereateDataSensitivities(string note, int code)
        {
            // If we overwrite we need to create a set of Asset and event IDs that need to create a Data Sesitivity Code
            List <Tuple <int, int> > combinations = new List <Tuple <int, int> >();

            using (AdoDataConnection connection = new AdoDataConnection(connectionstring, dataprovider))
            {
                GSF.Data.Model.TableOperations <PQio.Model.Channel>         channelTbl     = new GSF.Data.Model.TableOperations <PQio.Model.Channel>(connection);
                GSF.Data.Model.TableOperations <PQio.Model.Asset>           assetTbl       = new GSF.Data.Model.TableOperations <PQio.Model.Asset>(connection);
                GSF.Data.Model.TableOperations <PQio.Model.DataSeries>      seriesTbl      = new GSF.Data.Model.TableOperations <PQio.Model.DataSeries>(connection);
                GSF.Data.Model.TableOperations <PQio.Model.DataSensitivity> sensitivityTbl = new GSF.Data.Model.TableOperations <PQio.Model.DataSensitivity>(connection);

                foreach (int assetID in assetTbl.QueryRecords().Select(item => item.ID))
                {
                    foreach (int channelID in channelTbl.QueryRecordsWhere("AssetID = {0}", assetID).Select(item => item.ID))
                    {
                        foreach (int evtID in seriesTbl.QueryRecordsWhere("ChannelID = {0}", channelID).Select(item => item.EventID))
                        {
                            combinations.Add(new Tuple <int, int>(assetID, evtID));
                        }
                    }
                }


                combinations = combinations.Distinct().ToList();

                foreach (Tuple <int, int> item in combinations)
                {
                    if (sensitivityTbl.QueryRecordCountWhere("Event = {0} AND Asset = {1}", item.Item2, item.Item1) == 0)
                    {
                        sensitivityTbl.AddNewRecord(new Model.DataSensitivity()
                        {
                            Asset = item.Item1,
                            Event = item.Item2,
                            DataSensitivityCode = code,
                            Note = note
                        });
                    }
                }
            }
        }
Exemple #8
0
        private void PQioChannel_Load(object sender, EventArgs e)
        {
            // Populate Combo Boxes
            comboBox1.Items.AddRange(Model.SignalType.DisplayOptions());
            comboBox2.Items.AddRange(Model.MeasurementType.DisplayOptions());
            comboBox3.Items.AddRange(Model.DataSensitivityCode.DisplayOptions());


            if (m_channel.SignalType != null)
            {
                comboBox1.SelectedIndex = Array.FindIndex(Model.SignalType.DisplayOptions(),
                                                          item => item == Model.SignalType.ToDisplay((int)m_channel.SignalType));
            }
            else
            {
                comboBox1.SelectedIndex = Array.FindIndex(Model.SignalType.DisplayOptions(),
                                                          item => item == Model.SignalType.ToDisplay(-1));
            }

            if (m_channel.MeasurementType != null)
            {
                comboBox2.SelectedIndex = Array.FindIndex(Model.MeasurementType.DisplayOptions(),
                                                          item => item == Model.MeasurementType.ToDisplay(m_channel.MeasurementType));
            }
            else
            {
                comboBox2.SelectedIndex = Array.FindIndex(Model.MeasurementType.DisplayOptions(),
                                                          item => item == Model.MeasurementType.ToDisplay(""));
            }

            using (AdoDataConnection connection = new AdoDataConnection(connectionstring, dataprovider))
            {
                GSF.Data.Model.TableOperations <PQio.Model.DataSensitivity> dataSensitivityTbl = new GSF.Data.Model.TableOperations <PQio.Model.DataSensitivity>(connection);
                GSF.Data.Model.TableOperations <PQio.Model.Meter>           deviceTbl          = new GSF.Data.Model.TableOperations <PQio.Model.Meter>(connection);


                if (this.m_channel.AssetID != null)
                {
                    // Make sure we check if there is any Data Sensitivity associated with this event

                    if (dataSensitivityTbl.QueryRecordCountWhere("Event = {0} AND Asset = {1}", this.m_evt.ID, this.m_channel.AssetID) > 0)
                    {
                        PQio.Model.DataSensitivity dataSensitivity = dataSensitivityTbl.QueryRecordsWhere("Event = {0} AND Asset = {1}", this.m_evt.ID, this.m_channel.AssetID).First();


                        comboBox3.SelectedIndex = Array.FindIndex(Model.DataSensitivityCode.DisplayOptions(),
                                                                  item => item == Model.DataSensitivityCode.ToDisplay((int)dataSensitivity.DataSensitivityCode));

                        DataSensitivityNoteText.Text = dataSensitivity.Note;
                    }
                    else
                    {
                        comboBox3.SelectedIndex = Array.FindIndex(Model.DataSensitivityCode.DisplayOptions(),
                                                                  item => item == Model.DataSensitivityCode.ToDisplay(-1));
                        DataSensitivityNoteText.Text = "";
                    }
                }
                else
                {
                    comboBox3.Enabled       = false;
                    comboBox3.SelectedIndex = Array.FindIndex(Model.DataSensitivityCode.DisplayOptions(),
                                                              item => item == Model.DataSensitivityCode.ToDisplay(-1));
                    tabControl1.Enabled = false;
                }

                comboDevice.DisplayMember = "Text";
                comboDevice.ValueMember   = "Value";

                PQio.Model.Meter[] meters = deviceTbl.QueryRecords("").ToArray();

                comboDevice.Items.AddRange(meters.Select(item => new { Text = item.DeviceName, Value = item.ID }).ToArray());
                comboDevice.SelectedIndex = Array.FindIndex(meters, item => item.ID == this.m_channel.MeterID);
            }
            if (this.m_evt != null)
            {
                UpdateCustomFields();
            }
            else
            {
                this.tabControl1.Enabled = false;
            }

            this.MouseDown += new MouseEventHandler(OnClick);
        }