/// <summary> /// 添加一条数据 /// </summary> /// <param name="type"></param> /// <returns></returns> public int Insert(BulletinType type) { string sql = "insert into [dbo].[T_BulletinType] values(@typeName)"; SqlParameter pm = new SqlParameter("@typeName", SqlDbType.NVarChar, 16) { Value = type.TypeName }; return(SqlHelper.ExecuteNonQuery(sql, CommandType.Text, pm)); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; BulletinType type = new BulletinType(); type.TypeName = context.Request["TypeName"]; BulletinTypeBll bll = new BulletinTypeBll(); if (bll.Add(type)) { context.Response.Write("Ok"); } }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="setting"></param> /// <returns></returns> public int Update(BulletinType type) { string sql = "update [dbo].[T_BulletinType] set TypeName=@typeName where Id=@id"; SqlParameter[] pms = { new SqlParameter("@typeName", SqlDbType.NVarChar, 16) { Value = type.TypeName }, new SqlParameter("@id", SqlDbType.Int) { Value = type.Id } }; return(SqlHelper.ExecuteNonQuery(sql, CommandType.Text, pms)); }
/// <summary> /// 得到一个对象实体 /// </summary> public BulletinType DataRowToModel(DataRow row) { BulletinType model = new BulletinType(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["TypeName"] != null) { model.TypeName = row["TypeName"].ToString(); } } return(model); }
public void Read(Stream stream) { using (var reader = IoBuffer.FromStream(stream)) { var magic = reader.ReadCString(4); Version = reader.ReadInt32(); ID = reader.ReadUInt32(); NhoodID = reader.ReadUInt32(); SenderID = reader.ReadUInt32(); Subject = reader.ReadLongPascalString(); Body = reader.ReadLongPascalString(); SenderName = reader.ReadLongPascalString(); Time = reader.ReadInt64(); Type = (BulletinType)reader.ReadInt32(); Flags = (BulletinFlags)reader.ReadInt32(); LotID = reader.ReadUInt32(); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; BulletinTypeBll bll = new BulletinTypeBll(); if (context.Request.RequestType.ToUpper() == "GET") { int id = int.Parse(context.Request["Id"] ?? "0"); BulletinType type = bll.GetModelById(id); //根据Id 获取数据 System.Web.Script.Serialization.JavaScriptSerializer javaScriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer(); string jsonStr = javaScriptSerializer.Serialize(type); //将对象序列化成json context.Response.Write(jsonStr); } else { BulletinType type = new BulletinType(); type.Id = int.Parse(context.Request["EditId"] ?? "0"); type.TypeName = context.Request["EditText"]; if (bll.Update(type)) { context.Response.Write("Ok"); } } }
protected BulletinBase(IBulletin data) { CommentCount = data.CommentCount; BulletinType = new BulletinType(data.BulletinType); }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="t"></param> /// <returns></returns> public bool Update(BulletinType t) { return(dal.Update(t) > 0); }
/// <summary> /// 添加一条数据 /// </summary> /// <param name="t"></param> /// <returns></returns> public bool Add(BulletinType t) { return(dal.Insert(t) > 0); }
/// <summary> /// Get all bulletins of the specified type. /// </summary> /// <param name="bulletinType">The bulletin type.</param> /// <param name="limit">The maximum number of bulletins to get.</param> /// <returns>Bulletins of the specified type.</returns> public IList <BulletinModel> List(BulletinType bulletinType, int limit) { var key = new KeyModel(CacheType.Global, "BulletinList"); IList <BulletinModel> data; if (!CacheService.TryGet(key, out data)) { var sqlParameters = new List <SqlParameter> { new SqlParameter { ParameterName = "@SiteId", SqlDbType = SqlDbType.VarChar, Value = SiteID } }; var bulletinList = SqlService.Execute <BulletinModel>(connectionName, "AjsCmsPageGetAll", sqlParameters, reader => { var contentPage = new BulletinModel(); contentPage.Url = reader.GetString(0).ToLower(); contentPage.Title = reader.GetString(1); contentPage.PageId = reader.GetInt32(2); contentPage.ExtensionType = reader[10] as string; contentPage.LiveDate = reader.GetDateTime(12); contentPage.ExtensionData = reader[14] as string; return(contentPage); } ).ToList(); foreach (var bulletin in bulletinList) { if (bulletin.ExtensionType == "BULLETIN" && !string.IsNullOrEmpty(bulletin.ExtensionData)) { var contractData = Deserialize <BulletinExtensionData>(bulletin.ExtensionData); bulletin.BulletinContracts = contractData != null ? contractData.Contracts : null; } } data = bulletinList.OrderByDescending(b => b.LiveDate).ToList(); if (data.Any()) { CacheService.Set(key, data, defaultTimeSpan); } } // Filter by contract data = data.AsParallel().Where(b => b.BulletinContracts != null && b.BulletinContracts.Any(c => c.Equals(bulletinType.ToString(), StringComparison.OrdinalIgnoreCase))).ToList(); // Then apply limit if (limit > 0) { data = data.Take(limit).ToList(); } return(data); }