public ActionResult AddAjax(ApiServerInfoEntity apiServerEntity)
 {
     try
     {
         if (!Request.IsAjaxRequest())
         {
             return Content("{\"result\":\"failure\",\"msg\":\"非法请求\"}");
         }
         string msg = "";
         if (ModelState.IsValid)
         {
             IApiServerInfoService apiServerService = ServiceContainer.Instance.Container.Resolve<IApiServerInfoService>();
             bool flag = apiServerService.AddApiServerInfo(apiServerEntity);
             if (flag)
             {
                 msg = "{\"result\":\"success\"}";
             }
             else
             {
                 msg = "{\"result\":\"failure\",\"msg\":\"新增 API Server 失败,请检查\"}";
             }
         }
         else
         {
             msg = "{\"result\":\"failure\",\"msg\":\"" + this.ExpendErrors() + "\"}";
         }
         return Content(msg);
     }
     catch (Exception ex)
     {
         LogProvider.Instance.Error("新增 API Server失败:" + ex.Message);
         return Content("{\"result\":\"error\",\"msg\":\"" + ex.Message + "\"}");
     }
 }
        public bool AddApiServerInfo(ApiServerInfoEntity apiServerInfoEntity)
        {
            bool flag = false;
            StringBuilder sqlCommandText = new StringBuilder();
            sqlCommandText.Append("@SiteName");
            sqlCommandText.Append(", @SiteUrl");
            sqlCommandText.Append(", @Status");
            sqlCommandText.Append(", @Note");

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

            db.AddInParameter(cmd,"@SiteName",DbType.AnsiString,apiServerInfoEntity.SiteName);
            db.AddInParameter(cmd,"@SiteUrl",DbType.AnsiString,apiServerInfoEntity.SiteUrl);
            db.AddInParameter(cmd,"@Status",DbType.Byte,apiServerInfoEntity.Status);
            db.AddInParameter(cmd,"@Note",DbType.AnsiString,apiServerInfoEntity.Note);

            try
            {
                db.ExecuteNonQuery(cmd);
                flag = true;
            }
            catch(SqlException sqlEx)
            {
                throw sqlEx;
            }
            return flag;
        }
 /// <summary>
 /// 从存储媒介删除实体数据
 /// </summary>
 /// <param name="apiServerInfo">ApiServerInfoEntity实体对象</param>
 /// <returns>true:删除成功 false:删除失败</returns>
 public bool DeleteApiServerInfo(ApiServerInfoEntity apiServerInfo)
 {
     return ApiServerInfoBusProvider.DeleteApiServerInfo(apiServerInfo);
 }
 /// <summary>
 /// 将实体数据存入存储媒介(持久化一个对象)
 /// </summary>
 /// <param name="apiServerInfo">ApiServerInfoEntity实体对象</param>
 /// <returns>true:存储成功 false:存储失败</returns>
 public bool AddApiServerInfo(ApiServerInfoEntity apiServerInfo)
 {
     return ApiServerInfoBusProvider.AddApiServerInfo(apiServerInfo);
 }
 /// <summary>
 /// 更新存储媒介中的实体数据
 /// </summary>
 /// <param name="apiServerInfo">ApiServerInfoEntity实体对象</param>
 /// <returns>true:更新成功 false:更新失败</returns>
 public bool UpdateApiServerInfo(ApiServerInfoEntity apiServerInfo)
 {
     return ApiServerInfoBusProvider.UpdateApiServerInfo(apiServerInfo);
 }
        public bool UpdateApiServerInfo(ApiServerInfoEntity apiServerInfoEntity)
        {
            bool flag = false;
            StringBuilder whereCommandText = new StringBuilder();
            whereCommandText.Append("  ApiServerID=@ApiServerID");
            StringBuilder sqlCommandText = new StringBuilder();
            sqlCommandText.Append(" SiteName=@SiteName");
            sqlCommandText.Append(", SiteUrl=@SiteUrl");
            sqlCommandText.Append(", Status=@Status");
            sqlCommandText.Append(", Note=@Note");

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

            db.AddInParameter(cmd,"@ApiServerID",DbType.Int32,apiServerInfoEntity.ApiServerID);
            db.AddInParameter(cmd,"@SiteName",DbType.AnsiString,apiServerInfoEntity.SiteName);
            db.AddInParameter(cmd,"@SiteUrl",DbType.AnsiString,apiServerInfoEntity.SiteUrl);
            db.AddInParameter(cmd,"@Status",DbType.Byte,apiServerInfoEntity.Status);
            db.AddInParameter(cmd,"@Note",DbType.AnsiString,apiServerInfoEntity.Note);

            try
            {
                db.ExecuteNonQuery(cmd);
                flag = true;
            }
            catch(SqlException sqlEx)
            {
                throw sqlEx;
            }
            return flag;
        }
        public List<ApiServerInfoEntity> MakeApiServerInfoList(IDataReader dr)
        {
            List<ApiServerInfoEntity> list=new List<ApiServerInfoEntity>();
            while(dr.Read())
            {
             ApiServerInfoEntity apiServerInfoEntity=new ApiServerInfoEntity();
            apiServerInfoEntity.ApiServerID = (Int32)dr["ApiServerID"];
            apiServerInfoEntity.SiteName = (String)dr["SiteName"];
            apiServerInfoEntity.SiteUrl = (String)dr["SiteUrl"];
            apiServerInfoEntity.Status = (Byte)dr["Status"];
            apiServerInfoEntity.Note = (String)dr["Note"];
            apiServerInfoEntity.AddDate = (DateTime)dr["AddDate"];
               list.Add(apiServerInfoEntity);
            }

            dr.Close();
            return list;
        }
 public ApiServerInfoEntity MakeApiServerInfo(DataRow dr)
 {
     ApiServerInfoEntity apiServerInfoEntity=null;
     if(dr!=null)
     {
          apiServerInfoEntity=new ApiServerInfoEntity();
          apiServerInfoEntity.ApiServerID = (Int32)dr["ApiServerID"];
          apiServerInfoEntity.SiteName = (String)dr["SiteName"];
          apiServerInfoEntity.SiteUrl = (String)dr["SiteUrl"];
          apiServerInfoEntity.Status = (Byte)dr["Status"];
          apiServerInfoEntity.Note = (String)dr["Note"];
          apiServerInfoEntity.AddDate = (DateTime)dr["AddDate"];
     }
     return apiServerInfoEntity;
 }
 public ApiServerInfoEntity MakeApiServerInfo(IDataReader dr)
 {
     ApiServerInfoEntity apiServerInfoEntity = null;
     if(dr.Read())
     {
      apiServerInfoEntity=new ApiServerInfoEntity();
      apiServerInfoEntity.ApiServerID = (Int32)dr["ApiServerID"];
      apiServerInfoEntity.SiteName = (String)dr["SiteName"];
      apiServerInfoEntity.SiteUrl = (String)dr["SiteUrl"];
      apiServerInfoEntity.Status = (Byte)dr["Status"];
      apiServerInfoEntity.Note = (String)dr["Note"];
      apiServerInfoEntity.AddDate = (DateTime)dr["AddDate"];
     }
     dr.Close();
     return apiServerInfoEntity;
 }
        public bool DeleteApiServerInfo(ApiServerInfoEntity apiServerInfoEntity)
        {
            bool flag = false;
            StringBuilder sqlCommandText = new StringBuilder();
            sqlCommandText.Append("DELETE FROM dbo.ApiServerInfo");
            sqlCommandText.Append(" WHERE  ApiServerID=@ApiServerID");

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

            db.AddInParameter(cmd,"@ApiServerID",DbType.Int32,apiServerInfoEntity.ApiServerID);

            try
            {
                db.ExecuteNonQuery(cmd);
                flag = true;
            }
            catch(SqlException sqlEx)
            {
                throw sqlEx;
            }
            return flag;
        }
 /// <summary>
 /// 从存储媒介删除实体数据
 /// </summary>
 /// <param name="apiServerInfo">ApiServerInfoEntity实体对象</param>
 /// <returns>true:删除成功 false:删除失败</returns>
 public bool DeleteApiServerInfo(ApiServerInfoEntity apiServerInfo)
 {
     return ApiServerInfoDataAccess.Instance.DeleteApiServerInfo(apiServerInfo);
 }
 /// <summary>
 /// 将实体数据存入存储媒介(持久化一个对象)
 /// </summary>
 /// <param name="apiServerInfo">ApiServerInfoEntity实体对象</param>
 /// <returns>true:存储成功 false:存储失败</returns>
 public bool AddApiServerInfo(ApiServerInfoEntity apiServerInfo)
 {
     return ApiServerInfoDataAccess.Instance.AddApiServerInfo(apiServerInfo);
 }