public string ReLoadStationData(int stationID, out string statusCode, out string errMsg) { statusCode = "0000"; errMsg = ""; // 服务器参数检查 if (!iotParam.Check(out errMsg)) { statusCode = "401"; return(""); } CommandServerType type = getStationCommmandServerType(stationID, out errMsg); if (!string.IsNullOrWhiteSpace(errMsg)) { statusCode = "402"; return(""); } RequestCommand request = new RequestCommand() { ID = Guid.NewGuid().ToString(), sonServerType = type, operType = CommandOperType.ReLoadData, state = CommandState.Pending, beginTime = DateTime.Now }; return(SendRequest(request, out statusCode, out errMsg)); }
// 将枚举值转字符串方便存储 public static string ToCommandServerTypeStr(CommandServerType type) { switch (type) { case CommandServerType.Pump_WEB: return("二供-WEB"); case CommandServerType.Pump_OPC: return("二供_OPC"); case CommandServerType.YL_WEB: return("压力监测点_WEB"); case CommandServerType.ZHCD_WEB: return("综合测点_WEB"); case CommandServerType.SCADA_OPC: return("SCADA_OPC"); case CommandServerType.SpecialProject: return("特殊项目"); default: return("未知服务类型"); } }
// 控制请求接口 public string WriteJZValue(int userID, int jzID, string fDBAddress, double value, out string statusCode, out string errMsg) { statusCode = "0000"; errMsg = ""; // 服务器参数检查 if (!iotParam.Check(out errMsg)) { statusCode = "401"; return(""); } // 控制参数检查 if (userID == 0) { errMsg = "用户ID不能为空"; statusCode = "402"; return(""); } if (!CheckControlRole(userID, out errMsg)) { statusCode = "430"; return(""); } if (jzID == 0) { errMsg = "机组ID不能为空"; statusCode = "403"; return(""); } if (string.IsNullOrWhiteSpace(fDBAddress)) { errMsg = "数据业务地址不能为空"; statusCode = "404"; return(""); } // 加载机组通信模式 CommandServerType commandServerType = GetJZCommandServerType(jzID, out errMsg); if (!string.IsNullOrWhiteSpace(errMsg)) { statusCode = "405"; return(""); } RequestCommand request = new RequestCommand() { ID = Guid.NewGuid().ToString(), sonServerType = commandServerType, operType = CommandOperType.Write, userID = userID, jzID = jzID, fDBAddress = fDBAddress, value = value, state = CommandState.Pending, beginTime = DateTime.Now }; return(SendRequest(request, out statusCode, out errMsg)); }
private CommandServerType getStationCommmandServerType(int stationID, out string errMsg) { CommandServerType type = CommandServerType.UnKnown; errMsg = ""; if (stationID == 0) { errMsg = "站点ID" + stationID + "为空"; return(type); } string sql = string.Format(@"select top 1 t.ReadMode from SCADA_Station t where t.ID={0}", stationID); object val = DBUtil.ExecuteScalar(sql, out errMsg); if (!string.IsNullOrWhiteSpace(errMsg)) { return(type); } return(GetStationCommandServerType(val.ToString())); }
// 根据机组ID得到子服务类型 private CommandServerType getJZCommmandServerType(int jzID, out string errMsg) { CommandServerType type = CommandServerType.UnKnown; errMsg = ""; if (jzID == 0) { errMsg = "机组ID" + jzID + "为空"; return(type); } string sql = string.Format(@"select top 1 t1.PumpJZReadMode from Pump t,PumpJZ t1 where t.ID=t1.PumpId and (t.是否删除=0 or t.是否删除 is null) and (t1.是否删除=0 or t1.是否删除 is null) and t1.ID={0}", jzID); object val = DBUtil.ExecuteScalar(sql, out errMsg); if (!string.IsNullOrWhiteSpace(errMsg)) { return(type); } return(GetJZCommandServerType(val.ToString())); }