提交代码
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
using Model;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 环境监测数据
|
||||
/// </summary>
|
||||
public static class EnvironmentalCheckService
|
||||
{
|
||||
public static Model.SGGLDB db = Funs.DB;
|
||||
|
||||
#region 推送环境监测数据
|
||||
|
||||
/// <summary>
|
||||
/// 推送环境监测数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static ReturnData PushEnvironmentalCheckData()
|
||||
{
|
||||
var items = (from x in db.EnvironmentalCheck where x.IsPushed == false select x).ToList();
|
||||
Model.ReturnData responeData = new Model.ReturnData();
|
||||
if (items.Count() > 0)
|
||||
{
|
||||
var thisUnit = CommonService.GetIsThisUnit();
|
||||
var newItem = new { CollCropCode = thisUnit.CollCropCode, Items = items };
|
||||
var str = JsonConvert.SerializeObject(newItem);
|
||||
var baseurl = "/api/Environmental/SaveEnvironmentalCheckData";
|
||||
responeData = ServerService.PushCNCEC(str, baseurl);
|
||||
if (responeData.code == 1)
|
||||
{//推送成功后,修改数据状态
|
||||
foreach (var item in items)
|
||||
{
|
||||
Model.EnvironmentalCheck envModel = db.EnvironmentalCheck.FirstOrDefault(e => e.Id == item.Id);
|
||||
if (envModel != null)
|
||||
{
|
||||
envModel.IsPushed = true;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "当前没有环境监测数据";
|
||||
}
|
||||
return responeData;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user