Esempio n. 1
0
 public ActionResult AddAjax(DBServerInfoEntity dbServerEntity)
 {
     try
     {
         if (!Request.IsAjaxRequest())
         {
             return Content("{\"result\":\"failure\",\"msg\":\"非法请求\"}");
         }
         string msg = "";
         if (ModelState.IsValid)
         {
             IDBServerInfoService dbServerService = ServiceContainer.Instance.Container.Resolve<IDBServerInfoService>();
             dbServerEntity.Pwd = WKT.Common.Security.DES.Encrypt(dbServerEntity.Pwd);
             bool flag = dbServerService.AddDBServerInfo(dbServerEntity);
             if (flag)
             {
                 msg = "{\"result\":\"success\"}";
             }
             else
             {
                 msg = "{\"result\":\"failure\",\"msg\":\"新增DB Server 失败,请检查\"}";
             }
         }
         else
         {
             msg = "{\"result\":\"failure\",\"msg\":\"" + this.ExpendErrors() + "\"}";
         }
         return Content(msg);
     }
     catch (Exception ex)
     {
         LogProvider.Instance.Error("新增DB Server失败:" + ex.Message);
         return Content("{\"result\":\"error\",\"msg\":\"" + ex.Message + "\"}");
     }
 }
        public bool AddDBServerInfo(DBServerInfoEntity dBServerInfoEntity)
        {
            bool flag = false;
            StringBuilder sqlCommandText = new StringBuilder();
            sqlCommandText.Append("@ServerIP");
            sqlCommandText.Append(", @Port");
            sqlCommandText.Append(", @Account");
            sqlCommandText.Append(", @Pwd");
            sqlCommandText.Append(", @Note");
            sqlCommandText.Append(", @Status");

            DbCommand cmd = db.GetSqlStringCommand(String.Format("INSERT INTO dbo.DBServerInfo ({0}) VALUES ({1})",sqlCommandText.ToString().Replace("@", ""),sqlCommandText.ToString()));

            db.AddInParameter(cmd,"@ServerIP",DbType.AnsiString,dBServerInfoEntity.ServerIP);
            db.AddInParameter(cmd,"@Port",DbType.Int32,dBServerInfoEntity.Port);
            db.AddInParameter(cmd,"@Account",DbType.AnsiString,dBServerInfoEntity.Account);
            db.AddInParameter(cmd,"@Pwd",DbType.AnsiString,dBServerInfoEntity.Pwd);
            db.AddInParameter(cmd,"@Note",DbType.AnsiString,dBServerInfoEntity.Note);
            db.AddInParameter(cmd,"@Status",DbType.Byte,dBServerInfoEntity.Status);

            try
            {
                db.ExecuteNonQuery(cmd);
                flag = true;
            }
            catch(SqlException sqlEx)
            {
                throw sqlEx;
            }
            return flag;
        }
 /// <summary>
 /// 从存储媒介删除实体数据
 /// </summary>
 /// <param name="dBServerInfo">DBServerInfoEntity实体对象</param>
 /// <returns>true:删除成功 false:删除失败</returns>
 public bool DeleteDBServerInfo(DBServerInfoEntity dBServerInfo)
 {
     return DBServerInfoDataAccess.Instance.DeleteDBServerInfo(dBServerInfo);
 }
 /// <summary>
 /// 将实体数据存入存储媒介(持久化一个对象)
 /// </summary>
 /// <param name="dBServerInfo">DBServerInfoEntity实体对象</param>
 /// <returns>true:存储成功 false:存储失败</returns>
 public bool AddDBServerInfo(DBServerInfoEntity dBServerInfo)
 {
     return DBServerInfoDataAccess.Instance.AddDBServerInfo(dBServerInfo);
 }
        public bool UpdateDBServerInfo(DBServerInfoEntity dBServerInfoEntity)
        {
            bool flag = false;
            StringBuilder whereCommandText = new StringBuilder();
            whereCommandText.Append("  DBServerID=@DBServerID");
            StringBuilder sqlCommandText = new StringBuilder();
            sqlCommandText.Append(" ServerIP=@ServerIP");
            sqlCommandText.Append(", Port=@Port");
            sqlCommandText.Append(", Account=@Account");
            sqlCommandText.Append(", Pwd=@Pwd");
            sqlCommandText.Append(", Note=@Note");
            sqlCommandText.Append(", Status=@Status");
            sqlCommandText.Append(", AddDate=@AddDate");

            DbCommand cmd = db.GetSqlStringCommand(String.Format("UPDATE dbo.DBServerInfo SET {0} WHERE  {1}",sqlCommandText.ToString(),whereCommandText.ToString()));

            db.AddInParameter(cmd,"@DBServerID",DbType.Int32,dBServerInfoEntity.DBServerID);
            db.AddInParameter(cmd,"@ServerIP",DbType.AnsiString,dBServerInfoEntity.ServerIP);
            db.AddInParameter(cmd,"@Port",DbType.Int32,dBServerInfoEntity.Port);
            db.AddInParameter(cmd,"@Account",DbType.AnsiString,dBServerInfoEntity.Account);
            db.AddInParameter(cmd,"@Pwd",DbType.AnsiString,dBServerInfoEntity.Pwd);
            db.AddInParameter(cmd,"@Note",DbType.AnsiString,dBServerInfoEntity.Note);
            db.AddInParameter(cmd,"@Status",DbType.Byte,dBServerInfoEntity.Status);
            db.AddInParameter(cmd,"@AddDate",DbType.DateTime,dBServerInfoEntity.AddDate);

            try
            {
                db.ExecuteNonQuery(cmd);
                flag = true;
            }
            catch(SqlException sqlEx)
            {
                throw sqlEx;
            }
            return flag;
        }
 public List<DBServerInfoEntity> MakeDBServerInfoList(IDataReader dr)
 {
     List<DBServerInfoEntity> list=new List<DBServerInfoEntity>();
     while(dr.Read())
     {
      DBServerInfoEntity dBServerInfoEntity=new DBServerInfoEntity();
     dBServerInfoEntity.DBServerID = (Int32)dr["DBServerID"];
     dBServerInfoEntity.ServerIP = (String)dr["ServerIP"];
     dBServerInfoEntity.Port = (Int32)dr["Port"];
     dBServerInfoEntity.Account = (String)dr["Account"];
     dBServerInfoEntity.Pwd = (String)dr["Pwd"];
     dBServerInfoEntity.Note = (String)dr["Note"];
     dBServerInfoEntity.Status = (Byte)dr["Status"];
     dBServerInfoEntity.AddDate = (DateTime)dr["AddDate"];
        list.Add(dBServerInfoEntity);
     }
     dr.Close();
     return list;
 }
 public DBServerInfoEntity MakeDBServerInfo(DataRow dr)
 {
     DBServerInfoEntity dBServerInfoEntity=null;
     if(dr!=null)
     {
          dBServerInfoEntity=new DBServerInfoEntity();
          dBServerInfoEntity.DBServerID = (Int32)dr["DBServerID"];
          dBServerInfoEntity.ServerIP = (String)dr["ServerIP"];
          dBServerInfoEntity.Port = (Int32)dr["Port"];
          dBServerInfoEntity.Account = (String)dr["Account"];
          dBServerInfoEntity.Pwd = (String)dr["Pwd"];
          dBServerInfoEntity.Note = (String)dr["Note"];
          dBServerInfoEntity.Status = (Byte)dr["Status"];
          dBServerInfoEntity.AddDate = (DateTime)dr["AddDate"];
     }
     return dBServerInfoEntity;
 }
        public bool DeleteDBServerInfo(DBServerInfoEntity dBServerInfoEntity)
        {
            bool flag = false;
            StringBuilder sqlCommandText = new StringBuilder();
            sqlCommandText.Append("DELETE FROM dbo.DBServerInfo");
            sqlCommandText.Append(" WHERE  DBServerID=@DBServerID");

            DbCommand cmd = db.GetSqlStringCommand(sqlCommandText.ToString());

            db.AddInParameter(cmd,"@DBServerID",DbType.Int32,dBServerInfoEntity.DBServerID);

            try
            {
                db.ExecuteNonQuery(cmd);
                flag = true;
            }
            catch(SqlException sqlEx)
            {
                throw sqlEx;
            }
            return flag;
        }
Esempio n. 9
0
 /// <summary>
 /// 从存储媒介删除实体数据
 /// </summary>
 /// <param name="dBServerInfo">DBServerInfoEntity实体对象</param>
 /// <returns>true:删除成功 false:删除失败</returns>
 public bool DeleteDBServerInfo(DBServerInfoEntity dBServerInfo)
 {
     return DBServerInfoBusProvider.DeleteDBServerInfo(dBServerInfo);
 }
Esempio n. 10
0
 /// <summary>
 /// 将实体数据存入存储媒介(持久化一个对象)
 /// </summary>
 /// <param name="dBServerInfo">DBServerInfoEntity实体对象</param>
 /// <returns>true:存储成功 false:存储失败</returns>
 public bool AddDBServerInfo(DBServerInfoEntity dBServerInfo)
 {
     return DBServerInfoBusProvider.AddDBServerInfo(dBServerInfo);
 }
Esempio n. 11
0
 /// <summary>
 /// 更新存储媒介中的实体数据
 /// </summary>
 /// <param name="dBServerInfo">DBServerInfoEntity实体对象</param>
 /// <returns>true:更新成功 false:更新失败</returns>
 public bool UpdateDBServerInfo(DBServerInfoEntity dBServerInfo)
 {
     return DBServerInfoBusProvider.UpdateDBServerInfo(dBServerInfo);
 }