Beispiel #1
0
        /// <summary>
        /// 修改指定站点的所有可修改的信息
        /// </summary>
        /// 可能出现:信息超过允许的范围,站点不存在。
        /// <param name="station">传入一个站点对象。</param>
        /// <returns></returns>
        public static helper.DBReturnCode AlterStation(Models.Maintain db, Models.ID_TO_STCD_DK station)
        {
            if (!db.ID_TO_STCD_DK.Any(i => i.ID == station.ID)) //站点不存在
            {
                return(helper.DBReturnCode.NOT_EXIST);
            }
            ID_TO_STCD_DK target = db.ID_TO_STCD_DK.First(i => i.ID == station.ID);

            //修改所有属性
            target.STTYPE       = station.STTYPE;
            target.CNAME        = station.CNAME;
            target.WATERMAX     = station.WATERMAX;
            target.WATERMIN     = station.WATERMIN;
            target.WATERCHANGE  = station.WATERCHANGE;
            target.RAINCHANGE   = station.RAINCHANGE;
            target.BRAIN        = station.BRAIN;
            target.DAYWATERTJ   = station.DAYWATERTJ;
            target.DAYRAINTJ    = station.DAYRAINTJ;
            target.XUNWATERTJ   = station.XUNWATERTJ;
            target.XUNRAINTJ    = station.XUNRAINTJ;
            target.MONTHWATERTJ = station.MONTHWATERTJ;
            target.MONTHRAINTJ  = station.MONTHRAINTJ;
            target.sendflag     = station.sendflag;
            try
            {
                db.SaveChanges();
                return(helper.DBReturnCode.SUCCESS);
            }catch (Exception e)
            {
                return(helper.DBReturnCode.OP_ERROR);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 删除错误信息
 /// </summary>
 /// <param name="stationid">8位报讯站号</param>
 /// <param name="time"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public static helper.DBReturnCode DeleteErrorData(Models.Maintain db, string station8Id, DateTime time, string type)
 {
     if (!db.DK_E_INFO.Any(i => i.STCD == station8Id && i.TM == time && i.DTYPE == type))
     {
         return(helper.DBReturnCode.NOT_EXIST);
     }
     try
     {
         Models.DK_E_INFO data = db.DK_E_INFO.First(i => i.STCD == station8Id && i.TM == time && i.DTYPE == type);
         db.DK_E_INFO.Remove(data);
         db.SaveChanges();
         return(helper.DBReturnCode.SUCCESS);
     }catch (Exception e)
     {
         return(helper.DBReturnCode.OP_ERROR);
     }
 }
Beispiel #3
0
 /// <summary>
 /// 根据给定的信息添加一个站点。
 /// </summary>
 /// 可能站点信息缺失,站点ID和报讯ID和其他站冲突。
 /// <param name="station"></param>
 /// <returns></returns>
 public static helper.DBReturnCode AddStation(Models.Maintain db, Models.ID_TO_STCD_DK station)
 {
     //联合主键不能冲突
     if (db.ID_TO_STCD_DK.Any(i => i.ID == station.ID) || db.ID_TO_STCD_DK.Any(i => i.STCD == station.STCD))
     {
         return(helper.DBReturnCode.DATA_CONFLICT);
     }
     db.ID_TO_STCD_DK.Add(station);
     try
     {
         db.SaveChanges();
         return(helper.DBReturnCode.SUCCESS);
     }catch (Exception e)
     {
         return(helper.DBReturnCode.OP_ERROR);
     }
 }
Beispiel #4
0
 /// <summary>
 /// 根据站点ID删除一个站点
 /// </summary>
 /// 可能出现:站点不存在
 /// <param name="id"></param>
 /// <returns></returns>
 public static helper.DBReturnCode DeleteStation(Models.Maintain db, string station8Id, string stationId)
 {
     if (!db.ID_TO_STCD_DK.Any(i => i.ID == station8Id && i.STCD == stationId))
     {
         return(helper.DBReturnCode.NOT_EXIST);
     }
     try
     {
         ID_TO_STCD_DK station = db.ID_TO_STCD_DK.First(i => i.ID == stationId && i.STCD == station8Id);
         db.ID_TO_STCD_DK.Remove(station);
         db.SaveChanges();
         return(helper.DBReturnCode.SUCCESS);
     }catch (Exception e)
     {
         return(helper.DBReturnCode.OP_ERROR);
     }
 }
 /// <summary>
 /// 修改数据库配置表,database_type字段是不可修改的而且必须等于source或target。
 /// </summary>
 /// <param name="db">数据库对象</param>
 /// <param name="data">需要修改的数据对象,字段database_type:转储的2个库的库类target/source</param>
 /// <returns></returns>
 public static helper.DBReturnCode AlterDbConfig(Models.Maintain db, Models.DK_DB data)
 {
     //type限定在原始库和目标库2个字段中间。
     if (data.database_type != "source" || data.database_type != "target")
     {
         return(helper.DBReturnCode.BAD_REQUEST);
     }
     Models.DK_DB target = db.DK_DB.First(i => i.database_type == data.database_type);
     //修改所有字段除了库类
     target.server_name   = data.server_name;
     target.database_name = data.database_name;
     target.username      = data.username;
     target.password      = data.password;
     try
     {
         db.SaveChanges();
         return(helper.DBReturnCode.SUCCESS);
     }
     catch (Exception e)
     {
         return(helper.DBReturnCode.OP_ERROR);
     }
 }