public void OnAuthorization(AuthorizationFilterContext filterContext)
        {
            //if (!ValidateToken(filterContext.HttpContext.Request.Headers["token"]))
            //{
            //    filterContext.Result = new UnauthorizedResult();
            //}
            IDictionary <string, string> RouteValues = filterContext.ActionDescriptor.RouteValues;
            string route = GetRouteInfo(RouteValues);

            LogNHelper.Info(route, "路由记录");
        }
예제 #2
0
 public void Excute()
 {
     try
     {
         LogNHelper.Info($"执行任务ID为{JobInfo.id}的测试任务");
         OnComplete?.Invoke(JobInfo.id);
     }
     catch (Exception ex)
     {
         OnError?.Invoke(JobInfo.id, ex);
     }
 }
 public override void Excute()
 {
     try
     {
         LogNHelper.Info($"DemoAbstractJob 执行任务ID为{JobInfo.id}的测试任务");
         OnComplete?.Invoke(JobInfo.id);
     }
     catch (Exception ex)
     {
         OnError?.Invoke(JobInfo.id, ex);
     }
 }
예제 #4
0
        private void xtabAccont_CloseButtonClick(object sender, EventArgs e)
        {
            LogNHelper.Info("关闭");
            ClosePageButtonEventArgs arg = e as ClosePageButtonEventArgs;

            XtraTabPage page = (arg.Page as XtraTabPage);

            if (page.Text == "系统导航")
            {
                Msg.ShowInformation("禁止关闭");
                return;
            }

            LogNHelper.Info(page.Text);
        }
예제 #5
0
 /// <summary>
 /// 尝试获取用户信息
 /// </summary>
 private void GetUserInfo(string access_token, string openid)
 {
     try
     {
         //已关注,可以得到详细信息
         OAuthUserInfo userInfo = OAuthApi.GetUserInfo(access_token, openid);
         if (userInfo != null)
         {
             string json = userInfo.ToJson();
             LogNHelper.Info(json);
         }
     }
     catch (Exception ex)
     {
         LogNHelper.Exception(ex);
     }
 }
예제 #6
0
        /// <summary>
        /// 返回渲染后的页面文件
        /// </summary>
        /// <param name="content"></param>
        /// <param name="template"></param>
        /// <returns></returns>
        public (bool genStatus, string contentHtml) GenerateContentHtml(int channelId, int id)
        {
            try
            {
                Stopwatch watcher = new Stopwatch();
                watcher.Start();
                var templateModel = ChannelManagerCache.GetContentTemplate(channelId);
                if (templateModel == null)
                {
                    return(false, "");
                }
                var content = _contentApp.GetContentInfo(id);
                if (content == null)
                {
                    return(false, "");
                }
                //加载模板 先取缓存,没有再初始化一个并且加入缓存
                this.Document = RenderDocumentCache.GetRenderDocument(templateModel.id);
                if (this.Document == null)
                {
                    string templateFile = Path.Combine(GlobalParamsDto.WebRoot, templateModel.template_file);
                    this.Document = new TemplateDocument(templateModel.template_content, GlobalParamsDto.WebRoot, templateFile);
                    RenderDocumentCache.AddRenderDocument(templateModel.id, this.Document);
                }

                this.Document.Variables.SetValue("this", this);
                this.Document.Variables.SetValue("news", content);
                string renderHtml = this.Document.GetRenderText();
                renderHtml = HtmlPlayerHandler.CreateVideo(renderHtml);
                watcher.Stop();
                string msg = $"渲染内容页耗时:{watcher.ElapsedMilliseconds} ms";

                LogNHelper.Info(msg);
                return(true, renderHtml);
            }
            catch (Exception ex)
            {
                LogNHelper.Exception(ex);
            }
            return(false, "");
        }
예제 #7
0
        /// <summary>
        /// 添加Ribbon的Page页面
        /// </summary>
        /// <param name="MainControl"></param>
        void AddRibbonPage(RibbonControl MainControl)
        {
            MainControl.SuspendLayout();
            //获得当前登录用户权限表
            DataView _PageView = new DataView(SystemAuthentication.UserAuthorities);

            //按照菜单排序进行重新排序
            _PageView.Sort = "MenuOrder DESC";
            //获取Page菜单
            _PageView.RowFilter = "MenuLevel = 1";
            foreach (DataRowView drv in _PageView)
            {
                RibbonPage addgp = new RibbonPage();
                //菜单显示名称
                addgp.Text       = drv.Row["MenuText"].ToString();
                addgp.Tag        = drv.Row["MenuNewID"].ToString();
                addgp.Name       = drv.Row["MenuName"].ToString();
                addgp.Image      = Globals.LoadImage(drv.Row["MenuIcon"].ToString(), 16);
                addgp.MergeOrder = Convertto.ToInt(drv.Row["MenuOrder"]);
                //添加分组
                AddRibbonGroup(addgp, drv.Row["MenuID"].ToString());
                //page添加在第一个后面进行倒叙插入
                MainControl.Pages.Insert(1, addgp);

                LogNHelper.Info(addgp.Text);
                LogNHelper.Info(drv.Row["MenuNewID"].ToString());
                LogNHelper.Info(addgp.Name);
                LogNHelper.Info(drv.Row["MenuIcon"].ToString());
                // LogNHelper.Info(drv.Row["MenuTips"].ToString());
                LogNHelper.Info(drv.Row["MenuID"].ToString());
                LogNHelper.Info("-------");
            }


            MainControl.ResumeLayout();
        }
예제 #8
0
        /// <summary>
        /// 返回渲染后的模板文件
        /// </summary>
        /// <param name="content"></param>
        /// <param name="template"></param>
        /// <returns></returns>
        public void GenerateHomeHtml()
        {
            try
            {
                Stopwatch watcher = new Stopwatch();
                watcher.Start();
                var templateModel = TemplateManagerCache.GetHomeTemplate();
                if (templateModel.id==0)
                {
                    throw new Exception("找不到模板");
                }
                //加载模板 先取缓存,没有再初始化一个并且加入缓存
                this.Document = RenderDocumentCache.GetRenderDocument(templateModel.id);
                if (this.Document == null)
                {
                    string templateFile = Path.Combine(GlobalParamsDto.WebRoot, templateModel.template_file);
                    this.Document = new TemplateDocument(templateModel.template_content, GlobalParamsDto.WebRoot, templateFile);
                    RenderDocumentCache.AddRenderDocument(templateModel.id, this.Document);
                }
                //this.LoadTemplate(templateModel.template_content);

                this.Document.Variables.SetValue("this", this);
                //站点基本信息
                var site = SiteManagerCache.GetSiteInfo();
                this.Document.Variables.SetValue("site", site);
                //设置顶部导航条数据
                var navigations = _generateContentApp.GetChannelTree();
                this.Document.Variables.SetValue("navigations", navigations);

                //获取栏目文章模板
                ElementCollection<Template> templates = this.Document.GetChildTemplatesByName("channels");
                foreach (Template template in templates)
                {
                    string total = template.Attributes.GetValue("total", "10");
                    //根据模板块里定义的type属性条件取得新闻数据
                    var data = _generateContentApp.GetContentSummary(template.Attributes.GetValue("type"),1,int.Parse(total));
                    //设置变量newsdata的值
                    template.Variables.SetValue("contents", data);

                    //取得模板块下Id为newslist的标签(也即是在cnblogs_newsdata.html文件中定义的foreach标签)
                    //Tag tag = template.GetChildTagById("newslist");
                    //if (tag is ForEachTag)
                    //{
                    //    //如果标签为foreach标签则设置其BeforeRender事件用于设置变量表达式{$:#.news.url}的值
                    //    tag.BeforeRender += new System.ComponentModel.CancelEventHandler(Tag_BeforeRender);
                    //}
                }

                string contentFilePath = Path.Combine(GlobalParamsDto.WebRoot, "index.html");
                using (var filestream = new FileStream(contentFilePath, FileMode.Create, FileAccess.ReadWrite))
                {
                    string renderHtml = this.Document.GetRenderText();

                    using (StreamWriter writer = new StreamWriter(filestream, Encoding.UTF8))
                    {

                        writer.WriteLine(renderHtml);
                        writer.Flush();
                    }
                }
                watcher.Stop();
                string msg = $"渲染首页耗时:{watcher.ElapsedMilliseconds} ms";

                LogNHelper.Info(msg);
            }
            catch (Exception ex)
            {
                LogNHelper.Exception(ex);

            }
        }
예제 #9
0
 /// <summary>
 /// 任务完成回调
 /// </summary>
 private static void OnError(string jobId, Exception ex)
 {
     LogNHelper.Info($"任务异常回调,任务ID:{jobId},异常信息:{ex.Message}");
 }
예제 #10
0
 /// <summary>
 /// 任务完成回调
 /// </summary>
 private static void OnComplete(string jobId)
 {
     LogNHelper.Info($"任务完成回调,任务ID:{jobId}");
 }