コード例 #1
0
        public void StartLog(ErrorLog logger)
        {
            using (var services = new DbServices())
            {
                services.Command((db) =>
                {
                    db.Insert <ErrorLog>(logger);
                });
            }

            MailHelper.SendTextEmail("百签软件有限公司 技术支持", "*****@*****.**", "百小僧", "*****@*****.**", "应用程序异常通知",
                                     @"<p>引起异常会员ID:" + logger.LogMemberID + @"</p>

            <p>引起异常会员账号:" + logger.Account + @"</p>

            <p>当前异常应用程序:" + logger.Source + @"</p>

            <p>引起异常链接地址:" + logger.ErrorUrl + @"</p>

            <p>异常消息:" + logger.Message + @"</p>

            <p>引起异常的方法:" + logger.TargetSite + @"</p>

            <p>异常堆栈信息:<pre>" + logger.StackTrace + @"</pre></p>

            <p>异常编码数字:" + logger.HResult + @"</p>

            <p>异常帮助文档:" + logger.HelpLink + @"</p>

            <p>异常记录时间:" + logger.LogTime + @"</p>

            <p style='text-align:right;'><br /><br />来至:<a title='百签软件(中山)有限公司' href='http://www.baisoft.org/'>百签软件(中山)有限公司</a> 异常监控

           <br />" + DateTime.Now + @"</p>");
        }
コード例 #2
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (filterContext.ActionDescriptor.IsDefined(typeof(ExemptionInjectionAttribute), false) || filterContext.ActionDescriptor.ControllerDescriptor.IsDefined(typeof(ExemptionInjectionAttribute), false))
            {
                return;
            }
            var viewModel = new SysSetVM();

            if (!CacheManager.Contains(Keys.SysSetCacheKey))
            {
                using (var services = new DbServices())
                {
                    services.Command((db) =>
                    {
                        Mapper.Initialize(c => c.CreateMap <SysSet, SysSetVM>());
                        viewModel = Mapper.Map <SysSetVM>(db.Queryable <SysSet>().FirstOrDefault());
                    });
                }
                CacheManager.Set(Keys.SysSetCacheKey, viewModel);
            }
            else
            {
                viewModel = CacheManager.Get <SysSetVM>(Keys.SysSetCacheKey);
            }
            if (filterContext.RouteData.DataTokens[Keys.SysSetInfoInjectionKey] == null)
            {
                filterContext.RouteData.DataTokens.Add(Keys.SysSetInfoInjectionKey, viewModel);
            }
        }
コード例 #3
0
        public override void OnResultExecuting(ResultExecutingContext filterContext)
        {
            if (filterContext.Result is ViewResult || filterContext.Result is PartialViewResult)
            {
                var _area = filterContext.RouteData.DataTokens["area"];
                if (filterContext.Result is ViewResult || filterContext.Result is PartialViewResult)
                {
                    if (_area != null && Keys.AccessVerifyAreas.Any(u => u.ToLower() == _area.ToString().ToLower()))
                    {
                        var _controller = filterContext.RouteData.Values["controller"].ToString();
                        var _action     = filterContext.RouteData.Values["action"].ToString();
                        var _httpMethod = filterContext.HttpContext.Request.HttpMethod;
                        var key         = (_area.ToString() + "_" + _controller + "_" + _action + "_" + _httpMethod).ToLower();

                        var viewModel  = new V_HaviorVM();
                        var buttonlist = new List <V_ButtonVM>();
                        var moduleList = new List <V_ModuleVM>();
                        if (!CacheManager.Contains(key))
                        {
                            var cfg = new MapperConfigurationExpression();
                            cfg.CreateMap <V_Havior, V_HaviorVM>();
                            cfg.CreateMap <V_Module, V_ModuleVM>();
                            cfg.CreateMap <V_Button, V_ButtonVM>();
                            Mapper.Initialize(cfg);
                            using (var services = new DbServices())
                            {
                                services.Command((db) =>
                                {
                                    viewModel = Mapper.Map <V_HaviorVM>(db.Queryable <V_Havior>().SingleOrDefault(u => u.Area == _area.ToString() && u.Controller == _controller.ToLower() && u.Action == _action.ToLower() && u.HttpMethod == _httpMethod.ToUpper()));
                                    if (viewModel != null)
                                    {
                                        moduleList = Mapper.Map <List <V_ModuleVM> >(db.Queryable <V_Module>().Where(c => true).ToList());
                                        buttonlist = Mapper.Map <List <V_ButtonVM> >(db.Queryable <V_Button>().Where(b => b.HaviorID == viewModel.HaviorID && b.Enable == true).OrderBy(u => u.Sort).OrderBy(u => u.SerialNo).ToList());
                                    }
                                });
                            }

                            if (viewModel != null)
                            {
                                // 生成面包屑导航
                                var crumbHtml = string.Empty;
                                CreateCrumbs(moduleList, viewModel.ModuleID, ref crumbHtml);
                                viewModel.Crumbs = crumbHtml + "<label class=\"backend-crumbs-separator\">/</label>\r\n<a href=\"" + viewModel.Url + "\" title=\"" + viewModel.Name + "\">" + viewModel.Name + "</a>";
                                // 生成列表按钮
                                viewModel.SelectButtons = CreateSelectButtons(buttonlist);
                                // 生成表单按钮
                                viewModel.FormButtons = CreateFormButtons(buttonlist);

                                CacheManager.Set(key, viewModel);
                            }
                        }
                        else
                        {
                            viewModel = CacheManager.Get <V_HaviorVM>(key);
                        }

                        var result = filterContext.Result;
                        if (result is ViewResult)
                        {
                            var vresult = result as ViewResult;
                            vresult.ViewData[Keys.HaviorInfoInjectionKey] = viewModel == null ? new V_HaviorVM() : viewModel;
                            filterContext.Result = vresult;
                        }
                        else if (result is PartialViewResult)
                        {
                            var presult = result as PartialViewResult;
                            presult.ViewData[Keys.HaviorInfoInjectionKey] = viewModel == null ? new V_HaviorVM() : viewModel;
                            filterContext.Result = presult;
                        }
                    }
                }
            }
        }