Exemple #1
0
        public string CreateExceptionUrl(UploadItem item)
        {
            var themeType  = 2;                           //主题
            var factorType = item.SJLX == "CJ" ? 40 : 41; //监测因素

            return(string.Format(Config.ExceptionUrl, themeType, factorType, item.Id));
        }
Exemple #2
0
 private string CreateRequest(DataRow data, UploadItem item)
 {
     item.GDCJ_SL = Convert.ToDouble(data["VALUE"]);
     item.FHDZ    = "";
     item.CJSJ    = DateTime.Parse(data["ACQUISITION_DATETIME"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
     return(JsonConvert.SerializeObject(new[] { item }));
 }
Exemple #3
0
        public string CreateExceptionUrl(UploadItem item)
        {
            var structId   = QueryStructIdBySensor((int)item.Id) ?? 82;
            var themeType  = 2;                           //主题
            var factorType = item.SJLX == "CJ" ? 40 : 41; //监测因素

            return(string.Format(this.Config.ExceptionUrl, structId, themeType, factorType, item.Id));
        }
Exemple #4
0
        private string CreateRequest(SensorAcqResult sensorResult, UploadItem item)
        {
            if (sensorResult.Data.ThemeValues[0] != null || sensorResult.ErrorCode != (int)Errors.SUCCESS)
            {
                item.GDCJ_SL = sensorResult.Data.ThemeValues[0];
                item.FHDZ    = "";
            }
            else
            {
                //数据异常就记为0
                item.GDCJ_SL = 0;
                item.FHDZ    = CreateExceptionUrl(item);
            }

            item.CJSJ = sensorResult.ResponseTime.ToString("yyyy-MM-dd HH:mm:ss");
            if (item.SBWZ == string.Empty)
            {
                item.SBWZ = sensorResult.Sensor.Name;
            }
            return(JsonConvert.SerializeObject(new[] { item }));
        }
Exemple #5
0
        public Dictionary <uint, UploadItem> ReloadSensorConfig()
        {
            var items = new Dictionary <uint, UploadItem>();

            if (File.Exists("upload.xml"))
            {
                try
                {
                    var doc  = XDocument.Load("upload.xml");
                    var root = doc.Root;
                    //items
                    var sensors = root.Elements("sensor");
                    foreach (var sensor in sensors)
                    {
                        var item = new UploadItem
                        {
                            Enable = Convert.ToInt16(sensor.Attribute("enable").Value),
                            Id     = Convert.ToUInt32(sensor.Attribute("id").Value),
                            BDBH   = sensor.Attribute("BDBH").Value,
                            SDMC   = sensor.Attribute("SDMC").Value,
                            SDZH   = sensor.Attribute("SDZH").Value,
                            ZYF    = sensor.Attribute("ZYF").Value,
                            SBWZ   = sensor.Attribute("SBWZ").Value,
                            SBSM   = sensor.Attribute("SBSM").Value,
                            SJLX   = sensor.Attribute("SJLX").Value
                        };
                        items[item.Id] = item;
                    }
                }
                catch (Exception ex)
                {
                    _log.Error("Failed to load config file.", ex);
                }
            }
            else
            {
                _log.Error("Config file not exist.");
            }
            return(items);
        }