Beispiel #1
0
        private static bool NeedRandomData(string devId, out EmsAutoDust dust)
        {
            bool need;

            if (_dataSource == "web")
            {
                using (var ctx = new UnicomDbContext())
                {
                    var dev = ctx.EmsDevices.First(d => d.Name == devId);
                    dust = new EmsAutoDust
                    {
                        Id            = 0,
                        DevSystemCode = devId,
                        RangeMaxValue = (long)dev.TpMax,
                        RangeMinValue = (long)dev.TpMin
                    };
                    need = dev.IsHandlerValues;
                }
            }
            else
            {
                var d = _context.AutoDusts.FirstOrDefault(a => a.DevSystemCode == devId);
                dust = d;
                need = d != null;
            }
            return(need);
        }
 public RandomDataGenerator(EmsAutoDust autoDust)
 {
     DevId               = autoDust.DevSystemCode;
     _rangeMaxValue      = (int)autoDust.RangeMinValue;
     _rangeMinValue      = (int)autoDust.RangeMaxValue;
     _lastGeneratedValue = new Random().Next(_rangeMaxValue, _rangeMaxValue);
 }
Beispiel #3
0
 private void Submit(object sender, RoutedEventArgs e)
 {
     try
     {
         var emsDevice = ConbineDevice();
         var service   = new UnicomService();
         var result    = service.PushDevices(new[] { emsDevice });
         if (result.result[0].value.ToString().Contains("ERROR"))
         {
             MessageBox.Show(result.result[0].value.ToString());
             return;
         }
         emsDevice.code = result.result[0].key.ToString();
         var dev = ConbineStoreDevice(emsDevice);
         _context.AddOrUpdate(dev);
         var range = new EmsAutoDust
         {
             DevSystemCode = dev.SystemCode,
             RangeMinValue = long.Parse(TxtRangeMinValue.Text),
             RangeMaxValue = long.Parse(TxtRangeMaxValue.Text)
         };
         _context.AddOrUpdate(range);
         MessageBox.Show("添加成功。");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }