/// <summary> /// Constructor with required Sensors Group parameter /// </summary> /// <param name="group">start editing with this group</param> public GroupsManagerForm(Group group = null) { _group = group; InitializeComponent(); initialAddSensorForm(); LoadGroupSensor(); }
public ChartMainForm(Sensor sensor = null, Group group = null, PictureView pictureView = null, DateTime? startDate = null, DateTime? endDate = null) { _sensor = sensor; _group = group; _pictureView = pictureView; _startDate = startDate; _endDate = endDate; InitializeComponent(); }
public bool InsertGroup(Group obj) { using (var entityConntext = new GeoViewerEntities()) { SecurityBLL.Current.CheckPermissionThrowException(SecurityBLL.ROLE_VIEWS_MANAGE); ValidateGroup(obj); obj.ProjectID = AppContext.Current.OpenProject.ProjectID; obj.CreatedDate = obj.LastEditedDate = DateTime.Now; obj.CreatedUser = obj.LastEditedUser = AppContext.Current.LogedInUser.Username; entityConntext.Groups.AddObject(obj); return entityConntext.SaveChanges() > 0; } }
private void btncreategroup_Click(object sender, EventArgs e) { try { var group = new Group(); group.Name = txtgroupname.Text; if (ChartViewBLL.Current.InsertGroup(group)) { ShowSuccessMessage(Resources.Message_CreateGroup_Success); } this.Close(); } catch (Exception exception) { Console.WriteLine(exception.Message); } }
/// <summary> /// Pass params to display text view data on start up, set null (is default) for nothing display /// </summary> /// <param name="sensors">List sensors will be displayed</param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <param name="showCalcValue"></param> public TextViewForm(List<Sensor> sensors = null, PictureView pictureView = null, Group group = null, DateTime? startDate = null, DateTime? endDate = null, bool showCalcValue = true) { // set value to private field _sensors = sensors; _pictureView = pictureView; _group = group; _startDate = startDate; _endDate = endDate; _showCalcValue = showCalcValue; InitializeComponent(); //BindingData(); if (_group != null) _sensors = _group.Sensors.ToList(); if (_pictureView != null) _sensors = PictureViewBLL.Current.GetSensorsInPictureView(_pictureView); dataGridView.DataSource = TextViewBLL.Current.BindToDataTable(_sensors, !_showCalcValue, _startDate, _endDate); }
/// <summary> /// Pass params to build the chart on start up, set null (is default) for nothing display /// </summary> /// <param name="sensor"></param> /// <param name="group"></param> /// <param name="pictureView"></param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <param name="chartName"></param> /// <param name="xLabel"></param> /// <param name="yLabel"></param> /// <param name="showCalcValue"></param> public ChartViewForm(Sensor sensor = null, Group group = null, PictureView pictureView = null, DateTime? startDate = null, DateTime? endDate = null, string chartName = "Chart View", string xLabel = "Value", string yLabel = "Datetime", bool showCalcValue = true) { // set value to private field _sensor = sensor; _group = group; // ... // continue here InitializeComponent(); GraphPane myPane; LineItem mycurve; Random randomGen = new Random(); myPane = zedChartMain.GraphPane; myPane.XAxis.Type = AxisType.Date; myPane.XAxis.Scale.Format = "HH:mm:ss\ndd-MM-yyyy"; myPane.Title.Text = chartName; myPane.XAxis.Title.Text = xLabel; myPane.YAxis.Title.Text = yLabel; myPane.XAxis.MajorGrid.IsVisible = true; myPane.YAxis.MajorGrid.IsVisible = true; if (sensor != null) { List<SensorValue> listvalue = entityConntext.SensorValues.Where(ent => ent.SensorID == sensor.SensorID).ToList(); DataSourcePointList dsp = new DataSourcePointList(); dsp.DataSource = listvalue; if (!showCalcValue) { dsp.YDataMember = "RawValue"; } if (showCalcValue) { dsp.YDataMember = "CalcValue"; } dsp.XDataMember = "MeaTime"; mycurve = myPane.AddCurve(sensor.Name, dsp, Color.FromArgb(randomGen.Next(255), randomGen.Next(255), randomGen.Next(255))); mycurve.Line.Width = 1; } if (group != null) { List<Sensor> sensorsInGroup = group.Sensors.ToList(); for (int i = 0; i < sensorsInGroup.Count; i++) { int idsen = Convert.ToInt16(sensorsInGroup[i].SensorID); List<SensorValue> listvalue = entityConntext.SensorValues.Where(ent => ent.SensorID == idsen).ToList(); DataSourcePointList dsp = new DataSourcePointList(); dsp.DataSource = listvalue; if (!showCalcValue) { dsp.YDataMember = "RawValue"; } if (showCalcValue) { dsp.YDataMember = "CalcValue"; } dsp.XDataMember = "MeaTime"; mycurve = myPane.AddCurve(sensorsInGroup[i].Name, dsp, Color.FromArgb(randomGen.Next(255), randomGen.Next(255), randomGen.Next(255))); mycurve.Line.Width = 1; } } //lenh hien thi chart zedChartMain.IsShowPointValues = true; zedChartMain.AxisChange(); zedChartMain.Invalidate(); zedChartMain.Refresh(); }
public bool UpdateGroup(Group obj) { using (var entityConntext = new GeoViewerEntities()) { SecurityBLL.Current.CheckPermissionThrowException(new string[] { SecurityBLL.ROLE_VIEWS_EDIT, SecurityBLL.ROLE_VIEWS_MANAGE }); ValidateGroup(obj); obj.LastEditedDate = DateTime.Now; obj.LastEditedUser = AppContext.Current.LogedInUser.Username; entityConntext.AttachUpdatedObject(obj); return entityConntext.SaveChanges() > 0; } }
public void ValidateGroup(Group obj) { if (!obj.Name.IsValidLength(1, 200)) throw new Exception(Resources.Error_GroupNameInvalid); }
private void ChartGridView_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) return; // Modify by binhpro 19/10/2012 int id = ChartGridView.Rows[e.RowIndex].Cells[0].Value.ToInt32TryParse(); if (combochart.SelectedIndex == 0) { _sensor = SensorBLL.Current.GetByID(id); _group = null; _pictureView = null; } else if (combochart.SelectedIndex == 1) { _group = ChartViewBLL.Current.GetGroupByID(id); _sensor = null; _pictureView = null; } else if (combochart.SelectedIndex == 2) { _pictureView = PictureViewBLL.Current.GetByID(id); _sensor = null; _group = null; } BindingData(); }
/// <summary> /// Create a new Group object. /// </summary> /// <param name="groupID">Initial value of the GroupID property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="rawData">Initial value of the RawData property.</param> public static Group CreateGroup(global::System.Int32 groupID, global::System.String name, global::System.Boolean rawData) { Group group = new Group(); group.GroupID = groupID; group.Name = name; group.RawData = rawData; return group; }
/// <summary> /// Deprecated Method for adding a new object to the Groups EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToGroups(Group group) { base.AddObject("Groups", group); }
private void BindingGrid() { try { _startDate = fromdateTextBox.Text.ToDateTimeTryParse(null); _endDate = todateTextBox.Text.ToDateTimeTryParse(null); _showCalcValue = calcRadio.Checked; if (choiseTab.SelectedTab == sensorTab && sensorGridView.SelectedRows.Count > 0) { _sensors = new List<Sensor>(); _group = null; _pictureView = null; for (int i = 0; i < sensorGridView.SelectedRows.Count; i++) { _sensors.Add(SensorBLL.Current.GetByID(sensorGridView.SelectedRows[sensorGridView.SelectedRows.Count - 1 - i].Cells["SensorID"].Value.ToInt32TryParse())); } } else if (choiseTab.SelectedTab == groupTab) { if (groupGridView.SelectedRows.Count > 0) { _group = ChartViewBLL.Current.GetGroupByID(groupGridView.SelectedRows[0].Cells["GroupID"].Value.ToInt32TryParse()); _pictureView = null; } } else if (choiseTab.SelectedTab == pictureTab) { if (pictureGridView.SelectedRows.Count > 0) { _pictureView = PictureViewBLL.Current.GetByID(pictureGridView.SelectedRows[0].Cells["PictureViewID"].Value.ToInt32TryParse()); _group = null; } } if (_group != null) { _sensors = entityConntext.Groups.SingleOrDefault(ent => ent.GroupID == _group.GroupID).Sensors.ToList(); } if (_pictureView != null) { _sensors = PictureViewBLL.Current.GetSensorsInPictureView(_pictureView); } if(_sensors !=null && _sensors.Count > 0) { _sensors = _sensors.OrderBy(ent => ent.ColumnIndex).ToList(); dataGridView.DataSource = TextViewBLL.Current.BindToDataTable(_sensors, !_showCalcValue, _startDate, _endDate); } } catch (Exception exception) { //ShowErrorMessage(exception.Message); Console.WriteLine(exception.ToString()); } }