Exemplo n.º 1
0
        /// <summary>
        /// 得到最大ID
        /// </summary>
        public long GetMaxTaskCode()
        {
            long maxTaskCode   = 0;
            long controlTaskID = dal.GetMaxTaskCode();

            if (controlTaskID != 1)
            {
                ControlInterfaceModel interfaceModel = GetModel(controlTaskID);
                if (interfaceModel != null)
                {
                    maxTaskCode = long.Parse(interfaceModel.TaskCode);
                }
            }
            return(maxTaskCode);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ControlInterfaceModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ControlInterface set ");
            strSql.Append("InterfaceType=@InterfaceType,");
            strSql.Append("DeviceCode=@DeviceCode,");
            strSql.Append("TaskCode=@TaskCode,");
            strSql.Append("InterfaceStatus=@InterfaceStatus,");
            strSql.Append("CreateTime=@CreateTime,");
            strSql.Append("InterfaceParameter=@InterfaceParameter,");
            strSql.Append("Remarks=@Remarks");
            strSql.Append(" where ControlInterfaceID=@ControlInterfaceID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@InterfaceType",      SqlDbType.NVarChar,   50),
                new SqlParameter("@DeviceCode",         SqlDbType.NVarChar,   50),
                new SqlParameter("@TaskCode",           SqlDbType.NVarChar,    6),
                new SqlParameter("@InterfaceStatus",    SqlDbType.NVarChar,   50),
                new SqlParameter("@CreateTime",         SqlDbType.DateTime),
                new SqlParameter("@InterfaceParameter", SqlDbType.NVarChar,  200),
                new SqlParameter("@Remarks",            SqlDbType.NVarChar,  100),
                new SqlParameter("@ControlInterfaceID", SqlDbType.BigInt, 8)
            };
            parameters[0].Value = model.InterfaceType;
            parameters[1].Value = model.DeviceCode;
            parameters[2].Value = model.TaskCode;
            parameters[3].Value = model.InterfaceStatus;
            parameters[4].Value = model.CreateTime;
            parameters[5].Value = model.InterfaceParameter;
            parameters[6].Value = model.Remarks;
            parameters[7].Value = model.ControlInterfaceID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ControlInterfaceModel DataRowToModel(DataRow row)
        {
            ControlInterfaceModel model = new ControlInterfaceModel();

            if (row != null)
            {
                if (row["ControlInterfaceID"] != null && row["ControlInterfaceID"].ToString() != "")
                {
                    model.ControlInterfaceID = long.Parse(row["ControlInterfaceID"].ToString());
                }
                if (row["InterfaceType"] != null)
                {
                    model.InterfaceType = row["InterfaceType"].ToString();
                }
                if (row["DeviceCode"] != null)
                {
                    model.DeviceCode = row["DeviceCode"].ToString();
                }
                if (row["TaskCode"] != null)
                {
                    model.TaskCode = row["TaskCode"].ToString();
                }
                if (row["InterfaceStatus"] != null)
                {
                    model.InterfaceStatus = row["InterfaceStatus"].ToString();
                }
                if (row["CreateTime"] != null && row["CreateTime"].ToString() != "")
                {
                    model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
                }
                if (row["InterfaceParameter"] != null)
                {
                    model.InterfaceParameter = row["InterfaceParameter"].ToString();
                }
                if (row["Remarks"] != null)
                {
                    model.Remarks = row["Remarks"].ToString();
                }
            }
            return(model);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(ControlInterfaceModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ControlInterface(");
            strSql.Append("InterfaceType,DeviceCode,TaskCode,InterfaceStatus,CreateTime,InterfaceParameter,Remarks)");
            strSql.Append(" values (");
            strSql.Append("@InterfaceType,@DeviceCode,@TaskCode,@InterfaceStatus,@CreateTime,@InterfaceParameter,@Remarks)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@InterfaceType",      SqlDbType.NVarChar,   50),
                new SqlParameter("@DeviceCode",         SqlDbType.NVarChar,   50),
                new SqlParameter("@TaskCode",           SqlDbType.NVarChar,    6),
                new SqlParameter("@InterfaceStatus",    SqlDbType.NVarChar,   50),
                new SqlParameter("@CreateTime",         SqlDbType.DateTime),
                new SqlParameter("@InterfaceParameter", SqlDbType.NVarChar,  200),
                new SqlParameter("@Remarks",            SqlDbType.NVarChar, 100)
            };
            parameters[0].Value = model.InterfaceType;
            parameters[1].Value = model.DeviceCode;
            parameters[2].Value = model.TaskCode;
            parameters[3].Value = model.InterfaceStatus;
            parameters[4].Value = model.CreateTime;
            parameters[5].Value = model.InterfaceParameter;
            parameters[6].Value = model.Remarks;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt64(obj));
            }
        }
Exemplo n.º 5
0
        /*
         * /// <summary>
         * /// 分页获取数据列表
         * /// </summary>
         * public DataSet GetList(int PageSize,int PageIndex,string strWhere)
         * {
         *  SqlParameter[] parameters = {
         *          new SqlParameter("@tblName", SqlDbType.VarChar, 255),
         *          new SqlParameter("@fldName", SqlDbType.VarChar, 255),
         *          new SqlParameter("@PageSize", SqlDbType.Int),
         *          new SqlParameter("@PageIndex", SqlDbType.Int),
         *          new SqlParameter("@IsReCount", SqlDbType.Bit),
         *          new SqlParameter("@OrderType", SqlDbType.Bit),
         *          new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
         *          };
         *  parameters[0].Value = "ControlInterface";
         *  parameters[1].Value = "ControlInterfaceID";
         *  parameters[2].Value = PageSize;
         *  parameters[3].Value = PageIndex;
         *  parameters[4].Value = 0;
         *  parameters[5].Value = 0;
         *  parameters[6].Value = strWhere;
         *  return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
         * }*/

        #endregion  BasicMethod
        #region  ExtensionMethod
        /// <summary>
        /// 获取更新控制任务接口hash用于事物
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public Hashtable GetUpdateHash(ControlInterfaceModel model)
        {
            Hashtable     hs     = new Hashtable();
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ControlInterface set ");
            strSql.Append("InterfaceType=@InterfaceType,");
            strSql.Append("DeviceCode=@DeviceCode,");
            strSql.Append("TaskCode=@TaskCode,");
            strSql.Append("InterfaceStatus=@InterfaceStatus,");
            strSql.Append("CreateTime=@CreateTime,");
            strSql.Append("InterfaceParameter=@InterfaceParameter,");
            strSql.Append("Remarks=@Remarks");
            strSql.Append(" where ControlInterfaceID=@ControlInterfaceID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@InterfaceType",      SqlDbType.NVarChar,   50),
                new SqlParameter("@DeviceCode",         SqlDbType.NVarChar,   50),
                new SqlParameter("@TaskCode",           SqlDbType.NVarChar,   50),
                new SqlParameter("@InterfaceStatus",    SqlDbType.NVarChar,   50),
                new SqlParameter("@CreateTime",         SqlDbType.DateTime),
                new SqlParameter("@InterfaceParameter", SqlDbType.NVarChar,   50),
                new SqlParameter("@Remarks",            SqlDbType.NVarChar,  100),
                new SqlParameter("@ControlInterfaceID", SqlDbType.BigInt, 8)
            };
            parameters[0].Value = model.InterfaceType;
            parameters[1].Value = model.DeviceCode;
            parameters[2].Value = model.TaskCode;
            parameters[3].Value = model.InterfaceStatus;
            parameters[4].Value = model.CreateTime;
            parameters[5].Value = model.InterfaceParameter;
            parameters[6].Value = model.Remarks;
            parameters[7].Value = model.ControlInterfaceID;


            hs.Add(strSql.ToString(), parameters);
            return(hs);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 根据条件得到一条任务申请记录
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public IList <ControlInterfaceModel> GetConditionedModel(string strWhere)
        {
            IList <ControlInterfaceModel> modelList = new List <ControlInterfaceModel>();
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * ");
            strSql.Append(" FROM ControlInterface ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    ControlInterfaceModel m = DataRowToModel(dr);
                    modelList.Add(m);
                }
            }

            return(modelList);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ControlInterfaceModel GetModel(long ControlInterfaceID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ControlInterfaceID,InterfaceType,DeviceCode,TaskCode,InterfaceStatus,CreateTime,InterfaceParameter,Remarks from ControlInterface ");
            strSql.Append(" where ControlInterfaceID=@ControlInterfaceID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ControlInterfaceID", SqlDbType.BigInt)
            };
            parameters[0].Value = ControlInterfaceID;

            ControlInterfaceModel model = new ControlInterfaceModel();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(ControlInterfaceModel model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 9
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public long Add(ControlInterfaceModel model)
 {
     return(dal.Add(model));
 }
Exemplo n.º 10
0
 /// <summary>
 /// 获取更新控制任务接口hash用于事物
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public Hashtable GetUpdateHash(ControlInterfaceModel model)
 {
     return(dal.GetUpdateHash(model));
 }