Ejemplo n.º 1
0
        /// <summary>
        /// 保存集中器信息
        /// </summary>
        /// <param name="Gw"></param>
        /// <returns></returns>
        public int YdModuleOnSaveGw(v1_gatewayVModel Gw)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Clear();
            DataTable obj = new DataTable();

            if (Gw.Gw_id == 0)
            {
                strSql.Clear();
                strSql.Append("select max(Gw_id) as cnt from v1_gateway where Ledger=@Ledger");
                obj      = SQLHelper.Query(strSql.ToString(), new { Ledger = this.Ledger });
                Gw.Gw_id = obj.Rows.Count > 0 ? CommFunc.ConvertDBNullToInt32(obj.Rows[0]["cnt"]) + 1 : 1;
                //Gw.Gw_id = CommFunc.ConvertDBNullToInt32(obj.Rows[0]["cnt"]) + 1;
                //Gw.Gw_id = CommFunc.ConvertDBNullToInt32(SQLUtilities.ExecuteScalar(strSql.ToString(), params01)) + 1;
                //params01[1].Value = Gw.Gw_id;
                strSql.Clear();
                strSql.Append("insert into v1_gateway(");
                strSql.Append("Ledger,Gw_id,GwName,GwAddr,GwIp,GwPort,Timeout,GwType,Inst_loc,Remark,Disabled,Create_by,Create_dt,Update_by,Update_dt)");
                strSql.Append(" values (");
                strSql.Append("@Ledger,@Gw_id,@GwName,@GwAddr,@GwIp,@GwPort,@Timeout,@GwType,@Inst_loc,@Remark,@Disabled,@Uid,now(),@Uid,now())");
                if (SQLHelper.Execute(strSql.ToString(), new { Ledger = this.Ledger, Gw_id = Gw.Gw_id, GwName = Gw.GwName, GwAddr = Gw.GwAddr, GwIp = Gw.GwIp, GwPort = Gw.GwPort, Timeout = Gw.Timeout, GwType = Gw.GwType, Inst_loc = Gw.Inst_loc, Remark = Gw.Remark, Disabled = Gw.Disabled, Uid = this.SysUid }) > 0)
                {
                    return(Gw.Gw_id);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                strSql.Clear();
                strSql.Append("update v1_gateway set ");
                strSql.Append("GwName=@GwName,");
                strSql.Append("GwAddr=@GwAddr,");
                strSql.Append("GwIp=@GwIp,");
                strSql.Append("GwPort=@GwPort,");
                strSql.Append("Timeout=@Timeout,");
                strSql.Append("GwType=@GwType,");
                strSql.Append("Inst_loc=@Inst_loc,");
                strSql.Append("Remark=@Remark,");
                strSql.Append("Disabled=@Disabled,");
                strSql.Append("Update_by=@Uid,");
                strSql.Append("Update_dt=now()");
                strSql.Append(" where Ledger=@Ledger and Gw_id=@Gw_id ");
                if (SQLHelper.Execute(strSql.ToString(), new { Ledger = this.Ledger, Gw_id = Gw.Gw_id, GwName = Gw.GwName, GwAddr = Gw.GwAddr, GwIp = Gw.GwIp, GwPort = Gw.GwPort, Timeout = Gw.Timeout, GwType = Gw.GwType, Inst_loc = Gw.Inst_loc, Remark = Gw.Remark, Disabled = Gw.Disabled, Uid = this.SysUid }) > 0)
                {
                    return(Gw.Gw_id);
                }
                else
                {
                    return(0);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 保存集中器信息
        /// </summary>
        /// <param name="gw">对象</param>
        /// <returns></returns>
        public APIRst YdModuleOnSaveGw(v1_gatewayVModel gw)
        {
            APIRst rst = new APIRst();

            try
            {
                if (string.IsNullOrEmpty(gw.GwName))
                {
                    throw new Exception("集中器名称不能为空");
                }
                var gwid = bll.IsExistYdGwName(gw.GwName);
                if (gwid > 0 && (gw.Gw_id == 0 || (gw.Gw_id > 0 && gw.Gw_id != gwid)))
                {
                    throw new Exception("集中器名称:" + gw.GwName + "重复,请查询后再操作");
                }
                if (string.IsNullOrEmpty(gw.GwAddr))
                {
                    throw new Exception("集中器地址不能为空");
                }
                gwid = bll.IsExistYdGwAddr(gw.GwAddr);
                if (gwid > 0 && (gw.Gw_id == 0 || (gw.Gw_id > 0 && gw.Gw_id != gwid)))
                {
                    throw new Exception("集中器地址:" + gw.GwAddr + "重复,请查询后再操作");
                }
                if (gw.Timeout == 0)
                {
                    throw new Exception("集中器延时设置(毫秒)不能为零");
                }

                int total = 0;
                bll.YdModuleOnSaveGw(gw);
                object rows = this.GetYdModuleOnGatewayList(gw.Gw_id, out total);

                object obj = new { total = total, rows = rows };
                rst.data = obj;
            }
            catch (Exception ex)
            {
                rst.rst      = false;
                rst.err.code = (int)ResultCodeDefine.Error;
                rst.err.msg  = ex.Message;
                FileLog.WriteLog("设置集中器数据错误:" + ex.Message + ex.StackTrace);
            }
            return(rst);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 设置集中器信息
 /// </summary>
 /// <param name="Gw"></param>
 /// <returns></returns>
 public int YdModuleOnSaveGw(v1_gatewayVModel Gw)
 {
     return(dal.YdModuleOnSaveGw(Gw));
 }
Ejemplo n.º 4
0
 public APIRst SetYdModuleOnSaveGw(v1_gatewayVModel v1_gateway)
 {
     return(infoHelper.YdModuleOnSaveGw(v1_gateway));
 }