function readNews(newsIdx){
http.open("GET","readNews4Edit.aspx?ID="+newsIdx,false );
http.send("");
var data=http.responseText;
if(data.charAt(0)=='1'&& data.charAt(1)==':'){
alert(data );
}
else {
/*"{typeId:0,author:/"/",chl:0,content:/"/",url:/"/",examid:0,dir1:0,dir2:0,dir3:0,dir4:0,vic:0,vie:0,vip:0,key:/"/",desc:/"/",
pub:/"/",ord:0, src:/"/",subject:0,tit:/"/",
tc:/"/",tf:/"/"}"*/
var json=eval("("+data+")");
var nes=new newsData();
nes.title =decodeURI(json.tit);
nes.titleColor =decodeURI(json.tc);
nes.titleFont =decodeURI(json.tf);
nes.description = decodeURI(json.desc);
nes.keyword = decodeURI(json.key);
nes.source =decodeURI(json.src);
nes.typeid =json.typeId;
nes.channelId = json.chl;
nes.examId =json.examid;
nes.subjectId = json.subject;
nes.newsDirId1 = json.dir1;
nes.newsDirId2 = json.dir2;
nes.newsDirId3 = json.dir3;
nes.newsDirId4 = json.dir4;
nes.author =decodeURI( json.author);
nes.publisher =decodeURI( json.pub);
nes.orderId = json.ord;
nes.content =decodeURI( json.content);
nes.urlSkipLink =decodeURI( json.url);
nes.viewInPage=json.vip;
nes.viewInChannel=json.vic;
nes.viewInExam=json.vie;
initNews(nes);
}
}
public class ReadNewsHttpHandler:IHttpHandler
{
public ReadNewsHttpHandler()
{
//
// TODO: Add constructor logic here
//
}
#region IHttpHandler Members
public bool IsReusable
{
get { return false ; }
}
public void ProcessRequest(HttpContext context)
{
string res = context.Request.QueryString["id"].Trim ();
context.Response.Clear ();
context.Response.Expires =-1;
if (string.IsNullOrEmpty(res )==false && Regex.IsMatch(res, @"^[1-9]/d{0,8}$")==true )
{
int ks = int.Parse(res);
DataAccess.InforDataAccess ida = new InforDataAccess();
Information[] nfs = ida.InformationGetList(0, 1, string.Format(" Idx={0} ", ks), "");
if (nfs != null && nfs.Length == 1)
{
Information nf = nfs[0];
nf.Contents =ida.InformationGetContent(nf.Idx );
StringBuilder sb = new StringBuilder();
sb.Append("{");
sb.AppendFormat("typeId:{0},", nf.TypeId);
sb.AppendFormat("author:/"{0}/",", HttpUtility.UrlEncode(nf.Author));
sb.AppendFormat("chl:{0},", nf.ChannelId);
sb.AppendFormat("content:/"{0}/",", HttpUtility.UrlEncode(nf.Contents ));
sb.AppendFormat("url:/"{0}/",", HttpUtility.UrlEncode(nf.DirectUrl));
sb.AppendFormat("examid:{0},", nf.ExamId);
sb.AppendFormat("dir1:{0},", nf.FirstLM);
sb.AppendFormat("dir2:{0},", nf.SecodLM);
sb.AppendFormat("dir3:{0},", nf.ThirdLM);
sb.AppendFormat("dir4:{0},", nf.ForthLM);
sb.AppendFormat("vic:{0},", nf.IfViewInChannel ? 1 : 0);
sb.AppendFormat("vie:{0},", nf.IfViewInExam ? 1 : 0);
sb.AppendFormat("vip:{0},", nf.IfViewInPage ? 1 : 0);
sb.AppendFormat("key:/"{0}/",", HttpUtility.UrlEncode(nf.KeyWords));
sb.AppendFormat("desc:/"{0}/",", HttpUtility.UrlEncode(nf.PageDesc));
sb.AppendFormat("pub:/"{0}/",", HttpUtility.UrlEncode(nf.Publisher));
sb.AppendFormat("ord:{0}, ", nf.ShowOrder);
sb.AppendFormat("src:/"{0}/",", HttpUtility.UrlEncode(nf.Source));
sb.AppendFormat("subject:{0},", nf.Subjects);
sb.AppendFormat("tit:/"{0}/",", HttpUtility.UrlEncode(nf.Title));
sb.AppendFormat("tc:/"{0}/",", HttpUtility.UrlEncode(nf.TitleColor));
sb.AppendFormat("tf:/"{0}/"", HttpUtility.UrlEncode(nf.TitleFont));
sb.Append("}");
context.Response.Write(sb.ToString());
}
else
{
context.Response.Write("1:指定的咨讯条目不存在!");
}
}
else
{
context.Response.Write("1:参数ID不存在或是格式不正确!");
}
}
#endregion
}