dsssss

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

using NPOI.HPSF;
using System.IO;
using System.Data;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using System.Web;
using Common;
using System.Reflection;
using System.Web.Script.Serialization;
using System.Web.SessionState;
using Langben.DAL;

namespace Models
{
    public class BaseApiController : ApiController
    {
        /// <summary>
        /// 获取当前登陆人的ID
        /// </summary>
        /// <returns></returns>
        public string CurrentPersonId
        {
            get
            {
                Langben.App.Models.Account_Resume account = CurrentAccount;
                if (account != null && account.account != null && !string.IsNullOrWhiteSpace(account.account.Id))
                {
                    return account.account.Id;
                }
                return string.Empty;
            }

        }
        /// <summary>
        /// 获取当前登陆人的名称
        /// </summary>
        /// <returns></returns>
        public string CurrentPerson
        {
            get
            {
                Langben.App.Models.Account_Resume account = CurrentAccount;
                if (account != null  && account.account!=null && !string.IsNullOrWhiteSpace(account.account.Name))
                {
                    return account.account.Name;
                }
                return string.Empty;
            }

        }
        /// <summary>
        /// 获取当前登陆人的账户信息
        /// </summary>
        /// <returns>账户信息</returns>
        public Langben.App.Models.Account_Resume CurrentAccount
        {
            get
            {
                Langben.App.Models.Account_Resume currentAccount = null;

                if (HttpContext.Current.Session["account"] != null)
                {
                    currentAccount = HttpContext.Current.Session["account"] as Langben.App.Models.Account_Resume;
                }
                else
                {
                    HttpContext.Current.Session.Clear();

                    //测试
                    //Langben.App.Models.Account_Resume account = new Langben.App.Models.Account_Resume();
                    //Langben.IBLL.IAccountBLL bll = new Langben.BLL.AccountBLL();
                    //AccountArg arg = new AccountArg();
                    //arg.Name = "test";
                    //account.account = bll.GetByParam(arg);
                    //if (account.account != null)
                    //{
                    //    Langben.IBLL.IResumeBLL rBll = new Langben.BLL.ResumeBLL();
                    //    account.resume = rBll.GetFirstByAccountID(account.account.Id);
                    //}
                    //HttpContext.Current.Session["account"] = account;
                    //currentAccount = account;

                    //Response.Redirect("/Blog/Index");
                }

                return currentAccount;
            }
            set
            {
                HttpContext.Current.Session["account"] = value;
            }

        }

        
        public class GetDataParam
        {
            public string sort { get; set; }
            public string order { get; set; }
            public int page { get; set; }
            public int rows { get; set; }
            public string id { get; set; }
            public string search { get; set; }
        }
        public class ExportParam
        {
            public string id { get; set; }
            public string title { get; set; }
            public string field { get; set; }
            public string sortName { get; set; }
            public string sortOrder { get; set; }
            public string search { get; set; }

        }

        public static HttpResponseMessage toJson(Object obj)
        {
            String str;
            if (obj is String || obj is Char)
            {
                str = obj.ToString();
            }
            else
            {
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                str = serializer.Serialize(obj);
            }
            HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(str, System.Text.Encoding.GetEncoding("UTF-8"), "application/json") };
          
            return result;
        }

        public void ProcessRequest(HttpContext context)
        {
            throw new NotImplementedException();
        }
    }
}

posted @   狼奔代码生成器  阅读(501)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示