My .Net

我的.net资源

导航

test

Disclaimer/Info

using System;
using System.Configuration;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

using Dottext.Framework.Data;
using Dottext.Framework.Components;
using Dottext.Framework;
using Dottext.Framework.Util;
using Dottext.Framework.Configuration;

namespace Dottext.Web
{
    
/// <summary>
    
/// Summary description for _default.
    
/// </summary>

    public class _default : System.Web.UI.Page
    
{

        
protected System.Web.UI.WebControls.Repeater Bloggers;
        
protected System.Web.UI.WebControls.Literal BlogCount;
        
protected System.Web.UI.WebControls.Literal PostCount;
        
protected System.Web.UI.WebControls.Literal StoryCount;
        
protected System.Web.UI.WebControls.Literal CommentCount;
        
protected System.Web.UI.WebControls.Literal PingtrackCount;
        
protected System.Web.UI.WebControls.Repeater RecentPosts;
        
protected System.Web.UI.WebControls.HyperLink HyperLink1;
        
protected System.Web.UI.WebControls.HyperLink OpmlLink;
        
protected System.Web.UI.WebControls.HyperLink RssLink;
        
protected System.Web.UI.WebControls.HyperLink TitleLink;
        
protected System.Web.UI.WebControls.Literal Style;
        
protected System.Web.UI.WebControls.HyperLink Hyperlink6;
        
protected System.Web.UI.WebControls.HyperLink Hyperlink7;
        
protected System.Web.UI.WebControls.HyperLink Hyperlink4;
        
protected System.Web.UI.WebControls.HyperLink Hyperlink5;
        
protected Literal TitleTag;

        
private void Page_Load(object sender, System.EventArgs e)
        
{
            
            TitleTag.Text 
= TitleLink.Text = ConfigurationSettings.AppSettings["AggregateTitle"as string;
            TitleLink.NavigateUrl 
= ConfigurationSettings.AppSettings["AggregateUrl"as string;


            
//No postbacks on this page. It is output cached.
            BindData();
            SetStyle();
        }


        
protected string GetEntryUrl(string host, string app, string entryName, DateTime dt)
        
{
            
            
return string.Format("{0}archive/{1}/{2}.aspx",GetFullUrl(host,app),dt.ToString("yyyy/MM/dd"),entryName);
        }


        
private void SetStyle()
        
{
            
const string style = "<LINK href="{0}{1}" type="text/css" rel="stylesheet">";
            
string apppath = Request.ApplicationPath.EndsWith("/"? Request.ApplicationPath : Request.ApplicationPath + "/";
            Style.Text 
= string.Format(style,apppath,"Style.css"+ " " + string.Format(style,apppath,"blue.css");

        }


        
private string appPath = null;
        
const string fullUrl = "http://{0}{1}{2}/";
        
protected string GetFullUrl(string host, string app)
        
{
            
if(appPath == null)
            
{
                appPath 
= Request.ApplicationPath;
                
if(!appPath.ToLower().EndsWith("/"))
                
{
                    appPath 
+= "/";
                }

            }

            
return string.Format(fullUrl,host,appPath,app);

        }


        
private void BindData()
        
{
            
int GroupID = 1;

            
if(Request.QueryString["GroupID"!=null)
            
{
                
try
                
{
                    GroupID 
= Int32.Parse(Request.QueryString["GroupID"]);
                }

                
catch{}

            }

            
string sql = "DNW_HomePageData";
            
            
string conn = Dottext.Framework.Providers.DbProvider.Instance().ConnectionString;


            SqlParameter[] p 
= 
                
{
                    SqlHelper.MakeInParam(
"@Host",SqlDbType.NVarChar,100,ConfigurationSettings.AppSettings["AggregateHost"as string),
                    SqlHelper.MakeInParam(
"@GroupID",SqlDbType.Int,4,GroupID)
                }
;

                    DataSet ds 
= SqlHelper.ExecuteDataset(conn,CommandType.StoredProcedure,sql,p);

            Bloggers.DataSource 
= ds.Tables[0];
            RecentPosts.DataSource 
= ds.Tables[1];

            DataTable dtCounts 
= ds.Tables[2];
            
if(dtCounts != null)
            
{
                DataRow dr 
= dtCounts.Rows[0];
                BlogCount.Text 
= dr["BlogCount"].ToString();
                PostCount.Text 
= dr["PostCount"].ToString();
                StoryCount.Text 
= dr["StoryCount"].ToString();
                CommentCount.Text 
= dr["CommentCount"].ToString();
                PingtrackCount.Text 
= dr["PingtrackCount"].ToString();

            }


            Bloggers.DataBind();
            RecentPosts.DataBind();

            ds.Clear();
            ds.Dispose();

        }


        
protected string FormatDate(string date)
        
{
            DateTime dt 
= DateTime.Parse(date);
            
return dt.ToString("MMddyyyy");
        }



        
Web Form Designer generated code
    }

}


posted on 2004-09-02 15:20  青岛狼  阅读(315)  评论(0)    收藏  举报