Esempio n. 1
0
        public int AddRegulation(Regulation aRegulation)
        {
            var regulation = new RegulationImpl {
                DimentionId = aRegulation.DimentionId,
                StandartSizeId = aRegulation.StandartSizeId,
                MaxValue = aRegulation.MaxValue,
                MinValue = aRegulation.MinValue
            };

            return regulationsReaderWriter.CreateRegulation(regulation);
        }
Esempio n. 2
0
 public int AddRegulation(long aSessionId, Regulation aRegulation)
 {
     try {
         logger.Debug("Сессия: " + aSessionId + " " +
                      "Запрос AddRegulation(RegulationId:" + aRegulation.Id + ")");
         return gcsServer.AddRegulation(aRegulation);
     }
     catch (Exception ex) {
         logger.Error("Сессия: " + aSessionId + " Ошибка: " + ex.Message);
         return -1;
     }
 }
 public void SetRegulation(Regulation aRegulation)
 {
     if (aRegulation != null) {
         limitLabel.Text = aRegulation.MinValue + @" - " + aRegulation.MaxValue;
         if (dimentionPrimitive != null) {
             if (dimentionPrimitive.Result != null) {
                 var value = dimentionPrimitive.Result.Value;
                 if (value >= aRegulation.MinValue && value <= aRegulation.MaxValue) {
                     regulationLabel.Text = @"Соответствует";
                     regulationLabel.ForeColor = Color.Green;
                 }
                 else {
                     regulationLabel.Text = @"Не соответствует";
                     regulationLabel.ForeColor = Color.Red;
                 }
             }
         }
     }
     else {
         regulationLabel.Text = @"";
         limitLabel.Text = @"Отсутствуют";
     }
 }
 public void SetRegulations(Regulation[] aRegulations)
 {
     regulations = aRegulations;
 }
        private void button2_Click(object sender, EventArgs e)
        {
            if (client == null || !client.IsConnected) {
                MessageBox.Show(@"Не удалось выполнить операцию: нет подключения к сервису.");
                return;
            }

            for (var i = 0; i < dataGridView1.Rows.Count; ++i) {
                var row = dataGridView1.Rows[i];
                var mask = Convert.ToInt32(row.Cells["Mask"].Value);
                if ((mask & (int) ModifiedMask.DELETED) != 0) {
                    var sId = row.Cells["Id"].Value.ToString();
                    try {
                        if (!string.IsNullOrEmpty(sId)) {
                            var id = Convert.ToInt32(sId);
                            client.RemoveRegulation(id);
                        }
                    }
                    catch (Exception ex) {
                        MessageBox.Show(@"Не удалось удалить правило. Исключение: " + ex.Message);
                    }
                }
                else if ((mask & (int) ModifiedMask.ADDED) != 0) {
                    try {
                        var standartSize =
                            standartSizes.FirstOrDefault(s => s.ToString() == row.Cells["StandartSize"].Value.ToString());
                        var dimention = dimentions.FirstOrDefault(d => d.Description == row.Cells["Dimention"].Value.ToString());

                        var regulation = new Regulation();
                        regulation.DimentionId = dimention.Id;
                        regulation.StandartSizeId = standartSize.Id;
                        regulation.MinValue = Convert.ToDouble(row.Cells["Min"].Value);
                        regulation.MaxValue = Convert.ToDouble(row.Cells["Max"].Value);
                        client.AddRegulation(regulation);
                    }
                    catch (Exception ex) {
                        MessageBox.Show(@"Не удалось добавить правило. Исключение: " + ex.Message);
                    }
                }
                else if ((mask & (int) ModifiedMask.CHANGED) != 0) {
                    try {
                        var standartSize =
                            standartSizes.FirstOrDefault(s => s.ToString() == row.Cells["StandartSize"].Value.ToString());
                        var dimention = dimentions.FirstOrDefault(d => d.Description == row.Cells["Dimention"].Value.ToString());

                        var regulation = new Regulation();
                        regulation.Id = Convert.ToInt32(row.Cells["Id"].Value);
                        regulation.DimentionId = dimention.Id;
                        regulation.StandartSizeId = standartSize.Id;
                        regulation.MinValue = Convert.ToDouble(row.Cells["Min"].Value);
                        regulation.MaxValue = Convert.ToDouble(row.Cells["Max"].Value);
                        client.EditRegulation(regulation);
                    }
                    catch (Exception ex) {
                        MessageBox.Show(@"Не удалось изменить правило. Исключение: " + ex.Message);
                    }
                }
            }

            Close();
        }
Esempio n. 6
0
        public void EditRegulation(Regulation aRegulation)
        {
            var regulation = new RegulationImpl {
                Id = aRegulation.Id,
                DimentionId = aRegulation.DimentionId,
                StandartSizeId = aRegulation.StandartSizeId,
                MaxValue = aRegulation.MaxValue,
                MinValue = aRegulation.MinValue
            };

            regulationsReaderWriter.EditRegulation(regulation);
        }