Exemplo n.º 1
0
 public int Delete(UPSList entityToInsert)
 {
     using (Conn)
     {
         return(Conn.Delete(entityToInsert));
     }
 }
Exemplo n.º 2
0
 public int Update(UPSList entityToInsert)
 {
     using (Conn)
     {
         return(Conn.Update(entityToInsert));
     }
 }
Exemplo n.º 3
0
 public Guid Insert(UPSList entityToInsert)
 {
     using (Conn)
     {
         return(Conn.Insert <Guid>(entityToInsert));
     }
 }
Exemplo n.º 4
0
        private void ToolStripMenuItem_add_Click(object sender, EventArgs e)
        {
            UPSList        _tmpData          = null;
            Add_Modify_UPS tmpAdd_Modify_UPS = new Add_Modify_UPS(_tmpData);

            tmpAdd_Modify_UPS.ShowDialog();
            if (tmpAdd_Modify_UPS.result == DialogResult.OK)
            {
                GetUPSList();
            }
        }
Exemplo n.º 5
0
 public Add_Modify_UPS(UPSList _tmpData)
 {
     InitializeComponent();
     if (_tmpData == null)
     {
         TypeNameDataBinding();
     }
     else if (_tmpData != null)
     {
         tmpStation = _tmpData;
         TypeNameDataBinding();
         UPSData(tmpStation);
     }
 }
Exemplo n.º 6
0
 private void dataGridViewX_UPSExceptionList_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex < 0 || e.RowIndex < 0)
         return;
     DataGridViewColumn column = dataGridViewX_UPSExceptionList.Columns[e.ColumnIndex];
     if (column is DataGridViewButtonColumn)
     {
         string deviceID = dataGridViewX_UPSExceptionList.Rows[e.RowIndex].Cells[0].Value.ToString();
         UPSList ups = OMClientManager.deviceInfo.UPSList.Find(_ => _.DeviceID == Guid.Parse(deviceID));
         if (!ups.Lat.HasValue || !ups.Lon.HasValue)
             return;
         mapControl.Position = new PointLatLng(ups.Lat.Value, ups.Lon.Value);
         mapControl.Zoom = MapSkipLevel;
     }
 }
Exemplo n.º 7
0
        public void UPSData(UPSList _tmpData)
        {
            txtname.Text            = _tmpData.Name;
            txtlon.Text             = _tmpData.Lon.ToString();
            txtalt.Text             = _tmpData.Alt.ToString();
            txtlat.Text             = _tmpData.Lat.ToString();
            comboBox3.SelectedValue = _tmpData.ProtocolType;
            if (_tmpData.CommunicationID != null)
            {
                comboBox2.SelectedValue = _tmpData.CommunicationID;
            }

            comboBoxCommunicationInternet.SelectedValue = _tmpData.CommunicationType;
            if (_tmpData.StationID != null)
            {
                comboBox1.SelectedValue = _tmpData.StationID;
            }
        }
Exemplo n.º 8
0
        private void ProcessUPSSerialData(byte[] receiveData, Guid serialPortID)
        {
            UPSList UPSList = deviceInfo.UPSList.Find(_ => _.CommunicationID == serialPortID);

            if (UPSList == null)
            {
                return;
            }
            string upsData = Encoding.ASCII.GetString(receiveData);
            ProtocolHandlerBase protocol = new ProtocolHandlerBase();

            string[] protocolArray = protocol.GetProtocol(upsData);
            foreach (var oneProtocl in protocolArray)
            {
                if (!oneProtocl.StartsWith("("))
                {
                    continue;
                }
                string[] oneProtoclArray = oneProtocl.Substring(1).Split(' ');
                if (oneProtoclArray.Length != 8)
                {
                    continue;
                }
                UPSStatusList UPSStatus = new UPSStatusList();
                UPSStatus.DeviceID    = UPSList.DeviceID;
                UPSStatus.Name        = UPSList.Name;
                UPSStatus.InVoltage   = oneProtoclArray[0];
                UPSStatus.LVoltage    = oneProtoclArray[1];
                UPSStatus.OutVoltage  = oneProtoclArray[2];
                UPSStatus.OutputLoad  = oneProtoclArray[3];
                UPSStatus.Freq        = oneProtoclArray[4];
                UPSStatus.CellVoltage = oneProtoclArray[5];
                UPSStatus.Temperature = oneProtoclArray[6];
                UPSStatus.Alarm       = oneProtoclArray[7];
                UPSStatus.Time        = DateTime.Now;
                UPSStatusList.Add(UPSStatus);
            }
            if (upsmre != null)
            {
                upsmre.SetOne();
            }
        }
Exemplo n.º 9
0
        private void ToolStripMenuItem_edittype_Click(object sender, EventArgs e)
        {
            UPSList _tmpData = new UPSList();

            for (int i = 0; i < tmpListUPS.Count; i++)
            {
                if (tmpListUPS[i].DeviceID == _tmpUPSList.DeviceID)
                {
                    _tmpData = tmpListUPS[i];
                    break;
                }
            }

            Add_Modify_UPS tmpAdd_Modify_UPS = new Add_Modify_UPS(_tmpData);

            tmpAdd_Modify_UPS.ShowDialog();
            if (tmpAdd_Modify_UPS.result == DialogResult.OK)
            {
                GetUPSList();
            }
        }
Exemplo n.º 10
0
        private void btnsure_Click(object sender, EventArgs e)
        {
            double          lon = 0.0, lat = 0.0, alt = 0.0;
            List <UPSList>  tmpUpsList         = new List <UPSList>();
            UPSList         _UPSList           = new UPSList();
            UPSData_Command tmpUPSData_Command = new UPSData_Command();

            if (txtname.Text.Trim() == "")
            {
                MessageBox.Show("请填写设备名字"); return;
            }

            if (txtlon.Text.Trim() == "")
            {
                MessageBox.Show("请填写经度");
            }
            else
            {
                if (!double.TryParse(txtlon.Text.Trim(), out lon))
                {
                    MessageBox.Show("经度为数值类型");
                    return;
                }
            }
            if (txtlat.Text.Trim() == "")
            {
                MessageBox.Show("请填写纬度"); return;
            }
            else
            {
                if (!double.TryParse(txtlat.Text.Trim(), out lat))
                {
                    MessageBox.Show("纬度为数值类型");
                    return;
                }
            }

            if (txtalt.Text.Trim() == "")
            {
                MessageBox.Show("请填写海拔"); return;
            }
            else
            {
                if (!double.TryParse(txtalt.Text.Trim(), out alt))
                {
                    MessageBox.Show("海拔为数值类型");
                    return;
                }
            }

            if (tmpStation != null)
            {
                _UPSList.DeviceID = tmpStation.DeviceID;
            }
            _UPSList.Name              = txtname.Text;
            _UPSList.TypeID            = Convert.ToInt32(DeviceParamType.UPSDevice);
            _UPSList.Lon               = Convert.ToDouble(txtlon.Text.Trim());
            _UPSList.Lat               = Convert.ToDouble(txtlat.Text.Trim());
            _UPSList.Alt               = Convert.ToDouble(txtalt.Text.Trim());
            _UPSList.StationID         = new Guid(comboBox1.SelectedValue.ToString());
            _UPSList.ProtocolType      = Convert.ToInt32(comboBox3.SelectedValue);
            _UPSList.CommunicationID   = new Guid(comboBox2.SelectedValue.ToString());
            _UPSList.CommunicationType = Convert.ToInt32(comboBoxCommunicationInternet.SelectedValue);
            _UPSList.Description       = txtdescription.Text;
            _UPSList.Mark              = null;
            tmpUpsList.Add(_UPSList);

            if (tmpStation == null)
            {
                tmpUPSData_Command._AddData(tmpUpsList);
                result = MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK);
            }
            else if (tmpStation != null)
            {
                tmpUPSData_Command._ReviseData(tmpUpsList);
                result = MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK);
            }
            this.Close();
        }