using System;
using System.Data;
using System.Xml;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Web;
using IlgharCMS;
using IlgharCMS.SystemModule;
public partial class CIlgharCMS : IlgharCMS.Lib.AdminPageBase
{
public CIlgharCMS()
: base("IlgharCMS.SystemModule/log/ajax_list.dwt.aspx")
{}
protected XmlDocument _xmlTemplate;
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
_xmlTemplate = XmlData.GetXmlDocument();
if (!String.IsNullOrEmpty(Request.QueryString["GetPageCount"]))
                            {
                                Response.Write(t506);
                                Response.End();
                            }
                        
}

                        protected int ListRecordCount
                        {
                            get
                            {
                                int instanceID;
instanceID = InstanceID;
                                using (IlgharCMS.SystemModule.ILog bll = (IlgharCMS.SystemModule.ILog)Manager.CreateObject("Log", instanceID, ContentLang, false))
                                {
                                    string condition = null;


                                    return bll.GetRecordCount(condition);
                                }
                            }
                        }
                        
                            protected int ListCounter = 0;
                            protected object ListRecord = null;
                            private DataTable ListData;
                            protected DataTable List
                            {
                                get
                                {
                                    if (ListData != null)
                                        return ListData;

                                    ListData = List_;
                                    return ListData;
                                }
                            }
                        
                                private DataTable List_
                                {
                                    get
                                    {
                                        string condition = null;


                                        string sort = null;

                                        int instanceID;
instanceID = InstanceID;

                                        using (IlgharCMS.SystemModule.ILog bll = (IlgharCMS.SystemModule.ILog)Manager.CreateObject("Log", instanceID, ContentLang, false))
                                        {
                                            ListData = bll.List(Convert.ToInt32(PageNumber), 20, condition, sort);
                                        }

                                        return ListData;
                                    }
                                }
                            
                            protected string t125
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t125");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    replacementPair["{#InnerID#}"] = IlgharCMS.SystemModule.Alias.Log.InnerID;replacementPair["{#CreateTime#}"] = IlgharCMS.SystemModule.Alias.Log.CreateTime;replacementPair["{#IP#}"] = IlgharCMS.SystemModule.Alias.Log.IP;replacementPair["{#URL#}"] = IlgharCMS.SystemModule.Alias.Log.URL;replacementPair["{#Referrer#}"] = IlgharCMS.SystemModule.Alias.Log.Referrer;replacementPair["{#Message#}"] = IlgharCMS.SystemModule.Alias.Log.Message;
                                    StringBuilder all = Manager.Build(node, List_, replacementPair, ref ListRecord, ref ListCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          
                            
                        private string t506URL_ = null;
                        private string t506URL
                        {
                            get
                            {
                                if (t506URL_ != null)
                                    return t506URL_;

                                StringBuilder result = new StringBuilder("?Page={Page}");
                                for (int i = 0; i < Request.QueryString.Count; i++)
                                {
                                    if (Request.QueryString.GetKey(i).ToLower() == "page")
                                        continue;

                                    result.Append("&amp;" + Request.QueryString.GetKey(i) + "=" + Server.UrlEncode(Request.QueryString[i]));
                                }

                                t506URL_ = result.ToString();
                                return t506URL_;
                            }
                        }
                        
                            private int t506Page;
                            private int t506PageCount;
                            private int t506RecordCount;
                            private int t506PageSize;
                            private int t506Index;
                            protected string t506
                            {
                                get
                                {
                                    t506Page = Convert.ToInt32(PageNumber);
                                    if (t506Page <= 0)
                                        t506Page = 1;
                                    t506PageSize = 20;
                                    t506RecordCount = Convert.ToInt32(ListRecordCount);

                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t506");

                                    StringBuilder all = new StringBuilder(node.SelectSingleNode("All").InnerText);

                                    t506PageCount = t506RecordCount / t506PageSize;
                                    if (t506RecordCount % t506PageSize > 0)
                                        t506PageCount += 1;

                                    if (!String.IsNullOrEmpty(Request.QueryString["GetPageCount"]))
                                        return t506PageCount.ToString();

                                    //--------------------------------------
                                    //Start : FirstPage
                                    StringBuilder firstPage = new StringBuilder();
                                    string firstPageYesTpl = node.SelectSingleNode("FirstPage/Yes").InnerText;
                                    string firstPageNoTpl = node.SelectSingleNode("FirstPage/No").InnerText;
                                    if (t506Page > 1)
                                    {
                                        firstPage.Append(firstPageNoTpl);
                                        object t998 = ImagePath;
firstPage.Replace("{#t998#}", t998 == null ? "" : t998.ToString());
object t1077 = PageNumber;
firstPage.Replace("{#t1077#}", t1077 == null ? "" : t1077.ToString());
object t1123 = ImagePath;
firstPage.Replace("{#t1123#}", t1123 == null ? "" : t1123.ToString());

                                    }
                                    else
                                    {
                                        firstPage.Append(firstPageYesTpl);
                                        object t806 = ImagePath;
firstPage.Replace("{#t806#}", t806 == null ? "" : t806.ToString());
object t869 = ImagePath;
firstPage.Replace("{#t869#}", t869 == null ? "" : t869.ToString());

                                    }
                                    all.Replace("{#FirstPage#}", firstPage.ToString());
                                    //End : FirstPage
                                    //--------------------------------------

                                    //--------------------------------------
                                    //Start : CurrentPage
                                    StringBuilder currentPage = new StringBuilder();

                                    if (t506PageCount > 1)
                                    {
                                        string currentPageYesTpl = node.SelectSingleNode("CurrentPage/Yes").InnerText;
                                        string currentPageNoTpl = node.SelectSingleNode("CurrentPage/No").InnerText;

                                        bool isAll = false;
                                        int pageEnd = 0;
                                        if (isAll)
                                        {
                                            t506Index = 1;
                                            pageEnd = t506PageCount;
                                        }
                                        else
                                        {
                                            t506Index = t506Page - 5;
                                            if (t506Index <= 0)
                                                t506Index = 1;

                                            pageEnd = t506Page + 5;
                                            if (pageEnd > t506PageCount)
                                                pageEnd = t506PageCount;
                                        }

                                        while (t506Index <= pageEnd)
                                        {
                                            if (t506Index == t506Page)
                                            {
                                                currentPage.Append(currentPageYesTpl);
                                                object t1299 = t506Index;
currentPage.Replace("{#t1299#}", t1299 == null ? "" : t1299.ToString());

                                            }
                                            else
                                            {
                                                currentPage.Append(currentPageNoTpl);
                                                object t1388 = t506Index;
currentPage.Replace("{#t1388#}", t1388 == null ? "" : t1388.ToString());
object t1402 = t506Index;
currentPage.Replace("{#t1402#}", t1402 == null ? "" : t1402.ToString());

                                            }
                                            t506Index++;
                                        }
                                    }
                                    all.Replace("{#CurrentPage#}", currentPage.ToString());
                                    //End : CurrentPage
                                    //--------------------------------------

                                    //--------------------------------------
                                    //Start : LastPage
                                    StringBuilder lastPage = new StringBuilder();

                                    string lastPageYesTpl = node.SelectSingleNode("LastPage/Yes").InnerText;
                                    string lastPageNoTpl = node.SelectSingleNode("LastPage/No").InnerText;

                                    if (t506Page < t506PageCount)
                                    {
                                        lastPage.Append(lastPageNoTpl);
                                        object t1691 = PageNumber;
lastPage.Replace("{#t1691#}", t1691 == null ? "" : t1691.ToString());
object t1737 = ImagePath;
lastPage.Replace("{#t1737#}", t1737 == null ? "" : t1737.ToString());
object t1815 = t506PageCount;
lastPage.Replace("{#t1815#}", t1815 == null ? "" : t1815.ToString());
object t1842 = ImagePath;
lastPage.Replace("{#t1842#}", t1842 == null ? "" : t1842.ToString());

                                    }
                                    else
                                    {
                                        lastPage.Append(lastPageYesTpl);
                                        object t1518 = ImagePath;
lastPage.Replace("{#t1518#}", t1518 == null ? "" : t1518.ToString());
object t1580 = ImagePath;
lastPage.Replace("{#t1580#}", t1580 == null ? "" : t1580.ToString());

                                    }
                                    all.Replace("{#LastPage#}", lastPage.ToString());
                                    //End : LastPage
                                    //--------------------------------------

                                    object t640 = t506RecordCount;
all.Replace("{#t640#}", t640 == null ? "" : t640.ToString());
object t665 = PageNumber;
all.Replace("{#t665#}", t665 == null ? "" : t665.ToString());
object t685 = (t506Page - 1) * t506PageSize + 1;
all.Replace("{#t685#}", t685 == null ? "" : t685.ToString());
object t701 = t506RecordCount < t506Page * t506PageSize ? t506RecordCount : t506Page * t506PageSize;
all.Replace("{#t701#}", t701 == null ? "" : t701.ToString());


                                    return all.ToString();
                                }
                            }
                          }
