⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clist.aspx.cs

📁 如果不使用IIS,请先运行 XSP.exe,待提示已侦听 8080端口后
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DNNLite.Entites.Modules;
using DNNLite.Service;
using DNNLite.DesktopModules.Comment;
using System.Web.Configuration;
using Ader.TemplateEngine;
using NHibernate.Expression;
using Castle.ActiveRecord.Queries;

public partial class DesktopModules_Comment_CList : System.Web.UI.Page
{
    private string key = string.Empty;
    private string subject = string.Empty;
    private bool cancomment;
    private bool needcomment;

    IDictionary<string, string> Settings = null;

    private CommentSubject csubject;

    protected void Page_Load(object sender, EventArgs e)
    {

        if (!CheckRequest() || ! needcomment  )
        {
            Response.End();
        }

        if (string.IsNullOrEmpty(Request["commentid"]))
        {
            Response.End();
        }

        int commenttabmoduleid = int.Parse(Request["commenttabmoduleid"]);

        Settings =TabModuleController.GetTabModuleSettings(commenttabmoduleid);

        csubject = CommentSubject.Find(int.Parse(Request["commentid"]));

        //System.Threading.Thread.Sleep(3000);

        CreateTemplet( );
        
    }

    private void CreateTemplet()
    { 
        string templetfile =
                Settings.ContainsKey("Templet") ?
                                        Settings["Templet"] :
                                        "~/Templets/Comment/评论列表.htm";


        TemplateManager tm = TemplateManager.FromFile(
            Server.MapPath(templetfile)
            );
        IDictionary<string, object> databag = new Dictionary<string, object>();

        DNNLite.Entites.Modules.TempletPortalModuleBase.AddCommBag(ref databag);

        foreach (string key in databag.Keys)
        {
            tm.SetValue(key, databag[key]);
        }

        tm.SetValue("subject", csubject );
        tm.SetValue("data", this);
        //tm.SetValue("flowereggurl", ResolveUrl("~/DesktopModules/Comment/FlowerEgg.aspx") );

        litlist.Text = tm.Process();

    }

    #region "模板相关"

    public string PageFlag
    {
        get 
        {
            return "pageidx";
        }
    }
    /// <summary>
    /// 默认降序排
    /// </summary>
    /// <param name="recordsize"></param>
    /// <param name="pageindex"></param>
    /// <returns></returns>
    public Comment[] GetComment(int recordsize, int pageindex)
    {
        SimpleQuery<Comment> q = new SimpleQuery<Comment>(
            @"from Comment Where Subject=? and Visible=? 
                Order By CreateDate Desc"
            ,csubject 
            ,true 
            );
        q.SetQueryRange(pageindex * recordsize, recordsize);
        
        return q.Execute();

    }
    /// <summary>
    /// 加一标志位为升序排
    /// </summary>
    /// <param name="recordsize"></param>
    /// <param name="pageindex"></param>
    /// <param name="asc"></param>
    /// <returns></returns>
    public Comment[] GetComment(int recordsize, int pageindex,int asc)
    {
        SimpleQuery<Comment> q = new SimpleQuery<Comment>(
            @"from Comment Where Subject=? and Visible=? 
                Order By CreateDate ASC"
            , csubject
            , true
            );
        q.SetQueryRange(pageindex * recordsize, recordsize);

        return q.Execute();

    }

    public string GetPageUrl(int pageindex)
    {
        return "javascript:ReloadComment(" + pageindex + ")";
    }


    #endregion


    #region 检查request
    private bool CheckRequest()
    {
        int commenttabmoduleid=0;

        int sourcetabmoduleid = 0;

        if (!int.TryParse(Request["commenttabmoduleid"], out commenttabmoduleid))
        {
            return false;
        }

        if(!int.TryParse(Request["sourcetabmoduleid"],out sourcetabmoduleid))
        {
            return false;
        }

        string commentkey = Request["commentkey"];
        string check = Request["commentcheck"];

        if (string.IsNullOrEmpty(commentkey) || string.IsNullOrEmpty(check))
        {
            return false;
        }

        if (!DNNLite.Util.MD5CheckSum.CheckSum(commentkey, check))
        {
            return false;
        }

        IDictionary<string, string> Settings =
           TabModuleController.GetTabModuleSettings(commenttabmoduleid);

        if ( commenttabmoduleid !=sourcetabmoduleid  )
        {
            int tabmoduleid = sourcetabmoduleid;
            TabModule tm = SystemLoadController.GetTabModule(tabmoduleid);

            foreach (ModuleControlInfo ctl in tm.ModuleDefiniton.ModuleControls)
            {
                if (string.IsNullOrEmpty(ctl.ControlKey))
                {
                    PortalModuleBase p =
                        (PortalModuleBase)LoadControl(ctl.ControlSrc);

                    if (!(p is ICommentAble)) { return false ; }

                    ICommentAble comment = p as ICommentAble;

                    CommentOption opt = comment.GetCommentOption(commentkey);

                    key = opt.CommentKey;
                    subject = opt.Subject;
                    cancomment = opt.CanComment;
                    needcomment = opt.NeedComment;

                    return true;
                }
            }

            return false;
        }
        else
        {
            if (!Settings.ContainsKey("source")) { return false; }
            if (Settings["source"] == "module") { return false; }

            key = Settings["key"];
            subject = Settings["subject"];
            cancomment = bool.Parse(Settings["cancomment"]);
            needcomment = bool.Parse(Settings["needcomment"]);
            return true;
        }
    
    }
    #endregion



}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -