public JsonResult QueryAll()
        {
            LogOuts.Info("Query");
            var list = Service.FetchAll();

            return(Json(list));
        }
        public JsonResult QueryNoPages(TQuery query)
        {
            LogOuts.Info("Query");
            var list = Service.FetchAll(query);

            return(Json(list));
        }
Exemple #3
0
        //private const String _errLogFilePath = @"aoplog.txt";

        public static void Writelog(String message)
        {
            //StreamWriter sw = new StreamWriter(_errLogFilePath, true);
            //String logContent = String.Format("[{0}]{1}", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), message);
            //sw.WriteLine(logContent);
            //sw.Flush();
            //sw.Close();
            LogOuts.Info("aoplog:" + message);
        }
 public virtual ActionResult Save(TDto dto)
 {
     LogOuts.Info("Save");
     if (!ModelState.IsValid)
     {
         return(View(dto));
     }
     Service.Add(dto);
     return(Ok("SaveSuccess"));
 }
Exemple #5
0
        public IList <AppUsersDto> FetchLogonUser(string userName, string pwd)
        {
            LogOuts.Debug("user:"******" login system");
            string        sqlId     = GetLogonSqlId();
            AppUsersQuery parameter = new AppUsersQuery();

            parameter.LogOnName     = userName;
            parameter.LocalPassword = InfraUtils.Encrypt(pwd);
            return(DataMapper.QueryForList <AppUsersDto>(sqlId, parameter));
        }
        public FileResult Download(TQuery query)
        {
            LogOuts.Info("Download");
            var list   = Service.FetchAll(query);
            var stream = Service.ExportExcel(list);

            stream.Seek(0, SeekOrigin.Begin);
            string name = DateTime.Now.Millisecond.ToString();

            return(File(stream.ToArray(), "application/vnd.ms-excel", name + ".xls"));;
        }
 public virtual ActionResult Delete(string ids)
 {
     LogOuts.Info("Delete");
     if (ids.Contains(","))
     {
         Service.BatchDelete(ids);
     }
     else
     {
         Service.Delete(ids);
     }
     return(Ok("Sucess"));
 }
Exemple #8
0
        protected void Application_Start()
        {
            log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo(Server.MapPath("~") + @"\log4net.config"));
            LogOuts.Info("Application_Start");

            AreaRegistration.RegisterAllAreas();
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            Container.RegisterMvc(typeof(MvcApplication).Assembly, new SecurityConfig());
            LogOuts.Info("Application_End");
        }
        public virtual ActionResult Query(TQuery query)
        {
            LogOuts.Info("Query");
            SetPage(query);
            PagerList <TDto> list = null;

            try
            {
                list = Service.FetchPages(query);
            }
            catch (Exception e)
            {
                LogOuts.Info("FetchPages Error:" + e.Message);
            }

            return(ToDataGridResult(list, list.TotalCount));
        }
Exemple #10
0
        protected void Application_Error(object sender, EventArgs e)
        {
            /*捕捉异常的最后一道防线*/
            var ex = Server.GetLastError();

            LogOuts.Error(ex.ToString());                                                           //记录日志信息
            var httpStatusCode = (ex is HttpException) ? (ex as HttpException).GetHttpCode() : 500; //这里仅仅区分两种错误
            var httpContext    = ((MvcApplication)sender).Context;

            httpContext.ClearError();
            httpContext.Response.Clear();
            httpContext.Response.StatusCode = httpStatusCode;
            var             shouldHandleException = true;
            HandleErrorInfo errorModel;

            var routeData = new RouteData();

            routeData.Values["controller"] = "AppError";

            switch (httpStatusCode)
            {
            case 404:
                routeData.Values["action"] = "PageNotFound";
                errorModel = new HandleErrorInfo(new Exception(string.Format("No page Found", httpContext.Request.UrlReferrer), ex), "AppError", "PageNotFound");
                break;

            default:
                routeData.Values["action"] = "Error";
                Exception exceptionToReplace = null;     //这里使用了EntLib的异常处理模块的一些功能
                shouldHandleException = true;
                errorModel            = new HandleErrorInfo(exceptionToReplace, "AppError", "Error");
                break;
            }

            if (shouldHandleException)
            {
                var controller = new AppErrorController();
                controller.ViewData.Model = errorModel; //通过代码路由到指定的路径
                ((IController)controller).Execute(new RequestContext(new HttpContextWrapper(httpContext), routeData));
            }
        }
Exemple #11
0
        public virtual PagerList <TDto> FetchPages(TQuery query)
        {
            PagerList <TDto> pagers = new PagerList <TDto>(0);

            try
            {
                string       fetchQuery     = GetQuerySqlId();
                int          total          = 0;
                int          wiilShowedPage = query.Page;
                int          pageSize       = query.PageSize;
                IList <TDto> list           = DataMapper.QueryForListWithPage <TDto>(fetchQuery, query, query.Order, wiilShowedPage, pageSize, ref total);
                query.TotalCount = total;
                pagers           = new PagerList <TDto>(query);
                pagers.AddRange(list);
            }
            catch (Exception e)
            {
                LogOuts.Info("FetchPages error:" + e.ToString());
            }
            return(pagers);
        }
 public virtual ActionResult Update(TDto dto)
 {
     LogOuts.Info("Update");
     Service.Update(dto);
     return(Ok("UpdateSuccess"));
 }
 public virtual PartialViewResult Look(string id)
 {
     LogOuts.Info("Look");
     return(PartialView(CommonName.LookForm, Service.FetchOne(id)));
 }
 public virtual PartialViewResult Edit(string id)
 {
     LogOuts.Info("Edit");
     return(PartialView(CommonName.EditForm, Service.FetchOne(id)));
 }
 public virtual PartialViewResult Add()
 {
     LogOuts.Info("Add");
     return(PartialView(CommonName.AddForm, Service.Create()));
 }