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/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(t2538);
                                Response.End();
                            }
                        
}

                        protected int ListRecordCount
                        {
                            get
                            {
                                int instanceID;
instanceID = InstanceID;
                                using (IlgharCMS.SystemModule.ILog bll = (IlgharCMS.SystemModule.ILog)Manager.CreateObject("Log", instanceID, ContentLang, true))
                                {
                                    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, true))
                                        {
                                            ListData = bll.List(Convert.ToInt32(PageNumber), 20, condition, sort);
                                        }

                                        return ListData;
                                    }
                                }
                            
                            protected string t2117
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t2117");
                                    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 t2538URL_ = null;
                        private string t2538URL
                        {
                            get
                            {
                                if (t2538URL_ != null)
                                    return t2538URL_;

                                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]));
                                }

                                t2538URL_ = result.ToString();
                                return t2538URL_;
                            }
                        }
                        
                            private int t2538Page;
                            private int t2538PageCount;
                            private int t2538RecordCount;
                            private int t2538PageSize;
                            private int t2538Index;
                            protected string t2538
                            {
                                get
                                {
                                    t2538Page = Convert.ToInt32(PageNumber);
                                    if (t2538Page <= 0)
                                        t2538Page = 1;
                                    t2538PageSize = 20;
                                    t2538RecordCount = Convert.ToInt32(ListRecordCount);

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

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

                                    t2538PageCount = t2538RecordCount / t2538PageSize;
                                    if (t2538RecordCount % t2538PageSize > 0)
                                        t2538PageCount += 1;

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

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

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

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

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

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

                                        bool isAll = false;
                                        int pageEnd = 0;
                                        if (isAll)
                                        {
                                            t2538Index = 1;
                                            pageEnd = t2538PageCount;
                                        }
                                        else
                                        {
                                            t2538Index = t2538Page - 5;
                                            if (t2538Index <= 0)
                                                t2538Index = 1;

                                            pageEnd = t2538Page + 5;
                                            if (pageEnd > t2538PageCount)
                                                pageEnd = t2538PageCount;
                                        }

                                        while (t2538Index <= pageEnd)
                                        {
                                            if (t2538Index == t2538Page)
                                            {
                                                currentPage.Append(currentPageYesTpl);
                                                object t3363 = t2538Index;
currentPage.Replace("{#t3363#}", t3363 == null ? "" : t3363.ToString());

                                            }
                                            else
                                            {
                                                currentPage.Append(currentPageNoTpl);
                                                object t3458 = t2538Index;
currentPage.Replace("{#t3458#}", t3458 == null ? "" : t3458.ToString());
object t3472 = t2538Index;
currentPage.Replace("{#t3472#}", t3472 == null ? "" : t3472.ToString());

                                            }
                                            t2538Index++;
                                        }
                                    }
                                    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 (t2538Page < t2538PageCount)
                                    {
                                        lastPage.Append(lastPageNoTpl);
                                        object t3779 = PageNumber;
lastPage.Replace("{#t3779#}", t3779 == null ? "" : t3779.ToString());
object t3825 = ImagePath;
lastPage.Replace("{#t3825#}", t3825 == null ? "" : t3825.ToString());
object t3905 = t2538PageCount;
lastPage.Replace("{#t3905#}", t3905 == null ? "" : t3905.ToString());
object t3932 = ImagePath;
lastPage.Replace("{#t3932#}", t3932 == null ? "" : t3932.ToString());

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

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

                                    object t2676 = t2538RecordCount;
all.Replace("{#t2676#}", t2676 == null ? "" : t2676.ToString());
object t2701 = PageNumber;
all.Replace("{#t2701#}", t2701 == null ? "" : t2701.ToString());
object t2721 = (t2538Page - 1) * t2538PageSize + 1;
all.Replace("{#t2721#}", t2721 == null ? "" : t2721.ToString());
object t2737 = t2538RecordCount < t2538Page * t2538PageSize ? t2538RecordCount : t2538Page * t2538PageSize;
all.Replace("{#t2737#}", t2737 == null ? "" : t2737.ToString());


                                    return all.ToString();
                                }
                            }
                          }
