Browse Source

1.登录接口
2.获取价格表接口
3.获取/设置个性化布局接口

chen_yjin 7 months ago
parent
commit
145864f4c1

+ 132 - 0
JLHHJSvr/BLL/BllHelper.cs

@@ -3,6 +3,8 @@ using System.Collections.Generic;
 using System.Data;
 using System.Data.SqlClient;
 using System.Diagnostics;
+using System.IO;
+using System.IO.Compression;
 using JLHHJSvr.Com.Model;
 using JLHHJSvr.DBA.DBModle;
 using LJLib.DAL.SQL;
@@ -121,5 +123,135 @@ namespace JLHHJSvr.BLL
                 }
             }
         }
+
+
+
+        /// <summary>
+        /// 获取用户自定义值
+        /// </summary>
+        /// <param name="empid">用户ID</param>
+        /// <param name="dwname">窗口名</param>
+        /// <param name="itemname">表格名</param>
+        /// <param name="defaultvalue">默认值</param>
+        /// <returns></returns>
+        public static string GetValue(SqlCommand cmd, int empid, string dwname, string itemname, string defaultvalue, bool compress = false)
+        {
+            try
+            {
+                cmd.CommandText = "SELECT itemvalue FROM sys_user_filestring WHERE empid = @empid AND dwname = @dwname AND itemname = @itemname";
+                cmd.Parameters.Clear();
+                cmd.Parameters.AddWithValue("@empid", empid);
+                cmd.Parameters.AddWithValue("@dwname", dwname ?? string.Empty);
+                cmd.Parameters.AddWithValue("@itemname", itemname ?? string.Empty);
+                var val = defaultvalue;
+                using (var reader = cmd.ExecuteReader())
+                {
+                    if (reader.Read())
+                    {
+                        val = Convert.ToString(reader["itemvalue"]);
+                    }
+                }
+
+                if (compress)
+                {
+                    val = Uncompress(val);
+                }
+                else if (val.StartsWith("H4sIAAAA"))
+                {
+                    val = Uncompress(val);
+                    SetValue(cmd, empid, dwname, itemname, val);
+                }
+                return val;
+            }
+            catch (Exception ex)
+            {
+                Trace.Write(ex);
+                return defaultvalue;
+            }
+        }
+
+
+        /// <summary>
+        /// 设置用户自定义值
+        /// </summary>
+        /// <param name="empid">用户ID</param>
+        /// <param name="dwname">窗口名</param>
+        /// <param name="itemname">表格名</param>
+        /// <param name="strvalue">保存值</param>
+        /// <returns></returns>
+        public static bool SetValue(SqlCommand cmd, int empid, string dwname, string itemname, string strvalue, bool compress = false)
+        {
+            try
+            {
+                var newvalue = strvalue;
+                if (compress)
+                {
+                    newvalue = Compress(strvalue);
+                }
+                cmd.CommandText = "UPDATE sys_user_filestring SET itemvalue = @itemvalue WHERE empid = @empid AND dwname = @dwname AND itemname = @itemname";
+                cmd.Parameters.Clear();
+                cmd.Parameters.AddWithValue("@empid", empid);
+                cmd.Parameters.AddWithValue("@dwname", dwname ?? string.Empty);
+                cmd.Parameters.AddWithValue("@itemname", itemname ?? string.Empty);
+                cmd.Parameters.AddWithValue("@itemvalue", newvalue);
+
+                var nrows = cmd.ExecuteNonQuery();
+                if (nrows == 0)
+                {
+                    cmd.CommandText = "INSERT INTO sys_user_filestring(empid, dwname, itemname, itemvalue) VALUES(@empid, @dwname, @itemname, @itemvalue)";
+                    cmd.Parameters.Clear();
+                    cmd.Parameters.AddWithValue("@empid", empid);
+                    cmd.Parameters.AddWithValue("@dwname", dwname ?? string.Empty);
+                    cmd.Parameters.AddWithValue("@itemname", itemname ?? string.Empty);
+                    cmd.Parameters.AddWithValue("@itemvalue", newvalue);
+                    cmd.ExecuteNonQuery();
+                }
+                return true;
+            }
+            catch (Exception ex)
+            {
+                Trace.Write(strvalue, "错误参数");
+                Trace.Write(ex);
+                return false;
+            }
+        }
+
+        private static string Compress(string value)
+        {
+            using (var ms = new MemoryStream())
+            using (var gzip = new GZipStream(ms, CompressionMode.Compress, true))
+            using (var writer = new BinaryWriter(gzip))
+            {
+                writer.Write(value);
+                writer.Flush();
+                gzip.Close();
+                var data = ms.ToArray();
+                return Convert.ToBase64String(data);
+            }
+        }
+
+        private static string Uncompress(string value)
+        {
+            var data = Convert.FromBase64String(value);
+            using (var ms = new MemoryStream(data))
+            using (var gzip = new GZipStream(ms, CompressionMode.Decompress, true))
+            using (var reader = new BinaryReader(gzip))
+            {
+                return reader.ReadString();
+            }
+        }
+
+        /// <summary>
+        /// 删除某人的布局方案
+        /// </summary>
+        public static void delLayout(SqlCommand cmd, int empid, string dwname, string itemname)
+        {
+            cmd.CommandText = @"delete sys_user_filestring where empid = @empid and dwname = @dwname and  itemname = @itemname";
+            cmd.Parameters.Clear();
+            cmd.Parameters.AddWithValue("@empid", empid);
+            cmd.Parameters.AddWithValue("@dwname", dwname);
+            cmd.Parameters.AddWithValue("@itemname", itemname);
+            cmd.ExecuteNonQuery();
+        }
     }
 }

+ 200 - 0
JLHHJSvr/BLL/UserHelper.cs

@@ -0,0 +1,200 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SqlClient;
+using System.Diagnostics;
+using JLHHJSvr.Com.Model;
+using JLHHJSvr.DBA.DBModle;
+using LJLib.DAL.SQL;
+using LJLib.Tools.DEncrypt;
+using JLHHJSvr.LJException;
+using System.Linq;
+
+namespace JLHHJSvr.BLL
+{
+    internal sealed class UserHelper
+    {
+        private static Dictionary<string, TokenData> _tokens = new Dictionary<string, TokenData>();
+
+        ///// <summary>
+        ///// TODO: 保存Token信息, 登录成功后绑定token与tokendata
+        ///// </summary>
+        ///// <param name="token"></param>
+        ///// <param name="tokendata"></param>
+        //public static void SetToken(string token, TokenData tokendata)
+        //{
+        //    _tokens[token] = tokendata;
+        //}
+
+        ///// <summary>
+        ///// TODO: 带token请求是通过本方法获取tokendata
+        ///// </summary>
+        ///// <param name="token"></param>
+        ///// <returns>tokendata</returns>
+        //public static TokenData GetToken(string token)
+        //{
+        //    if (_tokens.ContainsKey(token))
+        //    {
+        //        return _tokens[token];
+        //    }
+        //    else
+        //    {
+        //        return null;
+        //    }
+        //}
+
+        ///// <summary>
+        ///// TODO: 获取ID
+        ///// </summary>
+        ///// <param name="cmd">数据库连接,事务</param>
+        ///// <param name="key">关联字</param>
+        ///// <param name="step">增幅,默认1</param>
+        ///// <returns>新ID上限</returns>
+        //public static int GetID(SqlCommand cmd, string key, int step = 1)
+        //{
+        //    int rslt = 0;
+        //    cmd.CommandText = "UPDATE cd_idfactory SET idvalue = idvalue + @step, @curid = idvalue + @step WHERE idkey = @idkey";
+        //    cmd.Parameters.Clear();
+        //    cmd.Parameters.Add("@idkey", SqlDbType.VarChar).Value = key;
+        //    cmd.Parameters.Add("@step", SqlDbType.Int).Value = step;
+        //    cmd.Parameters.Add("@curid", SqlDbType.Int).Direction = ParameterDirection.Output;
+        //    int nrows = cmd.ExecuteNonQuery();
+        //    if (nrows == 0)
+        //    {
+        //        rslt = 10 + step;
+        //        cmd.CommandText = "INSERT INTO cd_idfactory(idkey, idvalue) VALUES(@idkey, @curid)";
+        //        cmd.Parameters.Clear();
+        //        cmd.Parameters.Add("@idkey", SqlDbType.VarChar).Value = key;
+        //        cmd.Parameters.Add("@curid", SqlDbType.Int).Value = rslt;
+        //        cmd.ExecuteNonQuery();
+        //    }
+        //    else
+        //    {
+        //        rslt = Convert.ToInt32(cmd.Parameters["@curid"].Value);
+        //    }
+        //    return rslt;
+        //}
+
+        ///// <summary>
+        ///// 初始化超级用户
+        ///// </summary>
+        ///// <param name="constr">数居库连接字符串</param>
+        //public static void InitUser(string constr)
+        //{
+        //    using (var con = new SqlConnection(constr))
+        //    using (var cmd = con.CreateCommand())
+        //    {
+        //        con.Open();
+        //        using (cmd.Transaction = con.BeginTransaction())
+        //        {
+        //            try
+        //            {
+        //                var user = new st_user {userid = 11};
+        //                if (DbSqlHelper.SelectOne(cmd, user, "usercode") != 1)
+        //                {
+        //                    var id = GetID(cmd, "st_user");
+        //                    user.userid = id;
+        //                    user.usercode = "super";
+        //                    user.username = "超级用户";
+        //                    user.psw = DESEncrypt.Encrypt("super", "BC493812B6664BECBF44C21C3BB043C4");
+        //                    user.sex = "男";
+        //                    user.tel = string.Empty;
+        //                    user.dscrp = string.Empty;
+        //                    user.opemp = "初始化生成";
+        //                    user.opdate = DateTime.Now;
+        //                    user.modemp = "初始化生成";
+        //                    user.moddate = DateTime.Now;
+        //                    DbSqlHelper.InsertOrUpdate(cmd, user, "userid,usercode,username,psw,sex,tel,dscrp,opemp,opdate,modemp,moddate");
+        //                    var powers = new Power().GetAllPowers();
+        //                    var userPower = new st_user_power { userid = user.userid };
+        //                    foreach (var power in powers)
+        //                    {
+        //                        userPower.funid = power.funid;
+        //                        DbSqlHelper.Insert(cmd, userPower, "userid, funid");
+        //                    }
+        //                }
+        //                cmd.Transaction.Commit();
+        //            }
+        //            catch (Exception e)
+        //            {
+        //                cmd.Transaction.Rollback();
+        //                Trace.Write("初始化super用户数据失败:"+e.ToString());
+        //            }
+        //        }
+        //    }
+        //}
+
+
+
+
+        private static bool HasPower(int funcid, string sys_pwrstr)
+        {
+            bool hasPower;
+            hasPower = funcid > 0 && sys_pwrstr.Length >= funcid &&
+                       sys_pwrstr.Substring(funcid - 1, 1) == "1";
+            return hasPower;
+        }
+        private static Dictionary<int, sys_func_pwr> _funcCache = new Dictionary<int, sys_func_pwr>();
+        class sys_func_pwr
+        {
+            public int funcid { get; set; }
+            public byte functype { get; set; }
+            public int parentid { get; set; }
+        }
+        private static void LoadFuncCache(SqlCommand cmd)
+        {
+            if (_funcCache.Count == 0)
+            {
+                lock (_funcCache)
+                {
+                    if (_funcCache.Count == 0)
+                    {
+                        cmd.CommandText = "SELECT funcid,functype,parentid FROM sys_func_pwr";
+                        cmd.Parameters.Clear();
+                        using (var reader = cmd.ExecuteReader())
+                        {
+                            while (reader.Read())
+                            {
+                                var func = new sys_func_pwr
+                                {
+                                    funcid = Convert.ToInt32(reader["funcid"]),
+                                    functype = Convert.ToByte(reader["functype"]),
+                                    parentid = Convert.ToInt32(reader["parentid"]),
+                                };
+                                _funcCache[func.funcid] = func;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        /// <summary>
+        /// 过滤出当前用户有的权限列表
+        /// </summary>
+        /// <param name="empid">当前用户empid</param>
+        /// <returns></returns>
+        public static List<int> FilterMyFunids(SqlCommand cmd, int empid)
+        {
+            LoadFuncCache(cmd);
+            var rslt = new HashSet<int>();
+
+            var user = new u_user_jlhprice() { empid = empid};
+            if (DbSqlHelper.SelectOne(cmd, user, "empid,rightstring") != 1)
+            {
+                throw  new Exception(string.Format("查询用户信息失败,empid:{0}", empid));
+            }
+
+            foreach (var funcItem in _funcCache)
+            {
+                var hasPower = empid == 0 || HasPower(funcItem.Value.funcid, user.rightstring);
+
+                if (hasPower && !rslt.Contains(funcItem.Value.funcid))
+                {
+                    rslt.Add(funcItem.Value.funcid);
+                }
+            }
+
+            return rslt.ToList();
+        }
+    }
+}

+ 27 - 0
JLHHJSvr/Com/GetPriceList.cs

@@ -0,0 +1,27 @@
+using JLHHJSvr.Com.Model;
+using LJLib.Net.SPI.Com;
+using System.Collections.Generic;
+
+namespace JLHHJSvr.Com
+{
+    /// <summary>
+    /// 获取用户自定义值
+    /// </summary>
+    public sealed class GetPriceListRequest : ILJRequest<GetPriceListResponse>
+    {
+        public string token { get; set; }
+
+        public string GetApiName()
+        {
+            return "GetPriceList";
+        }
+    }
+
+    public sealed class GetPriceListResponse : LJResponse
+    {
+        /// <summary>
+        /// 自定义值
+        /// </summary>
+        public List<u_pricelist> list { get; set; }
+    }
+}

+ 45 - 0
JLHHJSvr/Com/GetSysUserFileString.cs

@@ -0,0 +1,45 @@
+using LJLib.Net.SPI.Com;
+
+namespace JLHHJSvr.Com
+{
+    /// <summary>
+    /// 获取用户自定义值
+    /// </summary>
+    public sealed class GetSysUserFileStringRequest : ILJRequest<GetSysUserFileStringResponse>
+    {
+        public string token { get; set; }
+        /// <summary>
+        /// 用户ID
+        /// </summary>
+        public int? empid { get; set; }
+        /// <summary>
+        /// 窗口名
+        /// </summary>
+        public string dwname { get; set; }
+        /// <summary>
+        /// 表格名
+        /// </summary>
+        public string itemname { get; set; }
+        /// <summary>
+        /// 是否压缩
+        /// </summary>
+        public byte ifcompress { get; set; }
+        /// <summary>
+        /// 是否删除token.empid的布局信息
+        /// </summary>
+        public byte? ifdel { get; set; }
+
+        public string GetApiName()
+        {
+            return "GetSysUserFileString";
+        }
+    }
+
+    public sealed class GetSysUserFileStringResponse : LJResponse
+    {
+        /// <summary>
+        /// 自定义值
+        /// </summary>
+        public string itemvalue { get; set; }
+    }
+}

+ 7 - 1
JLHHJSvr/Com/Login.cs

@@ -31,9 +31,15 @@ namespace JLHHJSvr.Com
     {
         public string token { get; set; }
         public string username { get; set; }
+        public string usercode { get; set; }
+        public int empid { get; set; }
         /// <summary>
         /// 有权限的模块id
         /// </summary>
-        public List<int> funidList { get; set; } 
+        //public List<int> funidList { get; set; }
+        /// <summary>
+        /// 可用权限列表
+        /// </summary>
+        public List<int> rsltFunids { get; set; }
     }
 }

+ 51 - 0
JLHHJSvr/Com/Model/u_pricelist.cs

@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace JLHHJSvr.Com.Model
+{
+    public sealed class u_pricelist
+    {
+        /// <summary>
+        /// 价格表ID
+        /// </summary>
+        public int pricelistid { get; set; }
+        /// <summary>
+        /// 序号
+        /// </summary>
+        public int RowNumber { get; set; }
+        /// <summary>
+        /// 价格表名称
+        /// </summary>
+        public string pricelistname { get; set; }
+        /// <summary>
+        /// 建立时间
+        /// </summary>
+        public DateTime? createtime { get; set; }
+        /// <summary>
+        /// 审核
+        /// </summary>
+        public byte flag { get; set; }
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string dscrp { get; set; }
+        /// <summary>
+        /// 审核人
+        /// </summary>
+        public string auditemp { get; set; }
+        /// <summary>
+        /// 审核时间
+        /// </summary>
+        public DateTime? auditdate { get; set; }
+        /// <summary>
+        /// 修改人
+        /// </summary>
+        public string modemp { get; set; }
+        /// <summary>
+        /// 修改时间
+        /// </summary>
+        public DateTime? moddate { get; set; }
+    }
+}

+ 41 - 0
JLHHJSvr/Com/SetSysUserFileString.cs

@@ -0,0 +1,41 @@
+using LJLib.Net.SPI.Com;
+
+namespace JLHHJSvr.Com
+{
+    /// <summary>
+    /// 设置用户自定义值
+    /// </summary>
+    public sealed class SetSysUserFileStringRequest : ILJRequest<SetSysUserFileStringResponse>
+    {
+        public string token { get; set; }
+        /// <summary>
+        /// 用户ID
+        /// </summary>
+        public int? empid { get; set; }
+        /// <summary>
+        /// 窗口名
+        /// </summary>
+        public string dwname { get; set; }
+        /// <summary>
+        /// 表格名
+        /// </summary>
+        public string itemname { get; set; }
+        /// <summary>
+        /// 自定义值
+        /// </summary>
+        public string itemvalue { get; set; }
+        /// <summary>
+        /// 是否压缩
+        /// </summary>
+        public byte ifcompress { get; set; }
+        public string GetApiName()
+        {
+            return "SetSysUserFileString";
+        }
+    }
+
+    public sealed class SetSysUserFileStringResponse : LJResponse
+    {
+
+    }
+}

+ 35 - 0
JLHHJSvr/DBA/DBModle/u_user_jlhprice.cs

@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using LJLib.DAL.SQL;
+
+namespace JLHHJSvr.DBA.DBModle
+{
+    [PK(new[] { "Empid" })]
+    public sealed class u_user_jlhprice
+    {
+        /// <summary>
+        /// 用户ID
+        /// </summary>
+        public int empid { get; set; }
+        /// <summary>
+        /// 用户名
+        /// </summary>
+        public string userid { get; set; }
+        /// <summary>
+        /// 真实名
+        /// </summary>
+        public string username { get; set; }
+        /// <summary>
+        /// 密码
+        /// </summary>
+        public string psw { get; set; }
+        public string rightstring { get; set; }
+        public string descrp { get; set; }
+        public string outrepstr { get; set; }
+        public string pricelist_seestr { get; set; }
+        public string pricelist_editstr { get; set; }
+        public int usermode { get; set; }
+    }
+}

+ 67 - 0
JLHHJSvr/Excutor/GetPriceListExcutor.cs

@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Data.SqlClient;
+using System.Diagnostics;
+using System.IO;
+using System.IO.Compression;
+using System.Linq;
+using System.Text;
+using JLHHJSvr.BLL;
+using JLHHJSvr.Com;
+using JLHHJSvr.Com.Model;
+using JLHHJSvr.DBA.DBModle;
+using LJLib.Net.SPI.Server;
+
+namespace JLHHJSvr.Excutor
+{
+    internal sealed class GetPriceListExcutor : ExcutorBase<GetPriceListRequest, GetPriceListResponse>
+    {
+        protected override void ExcuteInternal(GetPriceListRequest request, object state, GetPriceListResponse rslt)
+        {
+            var tokendata = BllHelper.GetToken(request.token);
+            if (tokendata == null)
+            {
+                rslt.ErrMsg = "会话已经中断";
+                return;
+            }
+
+            using (var con = new SqlConnection(GlobalVar.ConnectionString))
+            using (var cmd = con.CreateCommand())
+            {
+                con.Open();
+
+                cmd.CommandText = @"SELECT ROW_NUMBER() OVER (ORDER BY u_pricelist.pricelistid) AS RowNumber,   
+                                         u_pricelist.pricelistname,   
+                                         u_pricelist.createtime,   
+                                         u_pricelist.dscrp,
+                                         flag,
+                                         moddate,
+                                         modemp,
+                                         auditemp,
+                                         auditdate
+                                    FROM u_pricelist   ";
+                cmd.Parameters.Clear();
+                rslt.list = new List<u_pricelist>();
+                using (var reader = cmd.ExecuteReader())
+                {
+                    while (reader.Read())
+                    {
+                        var item = new u_pricelist();
+                        item.RowNumber = Convert.ToInt32(reader["RowNumber"]);
+                        item.pricelistname = Convert.ToString(reader["pricelistname"]);
+                        item.createtime = Convert.ToDateTime(reader["createtime"]);
+                        item.dscrp = Convert.ToString(reader["dscrp"]);
+                        item.flag = Convert.ToByte(reader["flag"]);
+                        item.moddate = reader["moddate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(reader["moddate"]);
+                        item.modemp = Convert.ToString(reader["modemp"]);
+                        item.auditemp = Convert.ToString(reader["auditemp"]);
+                        item.auditdate = reader["auditdate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(reader["auditdate"]);
+                        rslt.list.Add(item);
+                    }
+                }
+
+            }
+        }
+
+    }
+}

+ 71 - 0
JLHHJSvr/Excutor/GetSysUserFileStringExcutor.cs

@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.Data.SqlClient;
+using System.Diagnostics;
+using System.IO;
+using System.IO.Compression;
+using System.Linq;
+using System.Text;
+using JLHHJSvr.BLL;
+using JLHHJSvr.Com;
+using JLHHJSvr.DBA.DBModle;
+using LJLib.Net.SPI.Server;
+
+namespace JLHHJSvr.Excutor
+{
+    internal sealed class GetSysUserFileStringExcutor : ExcutorBase<GetSysUserFileStringRequest, GetSysUserFileStringResponse>
+    {
+        protected override void ExcuteInternal(GetSysUserFileStringRequest request, object state, GetSysUserFileStringResponse rslt)
+        {
+            if (request.empid == null)
+            {
+                rslt.ErrMsg = "参数错误,empid不能为null";
+                return;
+            }
+
+            if (request.dwname == null)
+            {
+                rslt.ErrMsg = "参数错误,dwname不能为null";
+                return;
+            }
+
+            if (request.itemname == null)
+            {
+                rslt.ErrMsg = "参数错误,itemname不能为null";
+                return;
+            }
+
+            var tokendata = BllHelper.GetToken(request.token);
+            if (tokendata == null)
+            {
+                rslt.ErrMsg = "会话已经中断";
+                return;
+            }
+            //if (string.IsNullOrEmpty(tokendata.ConStr))
+            //{
+            //    rslt.ErrMsg = "当前账套未设置数据库";
+            //    return;
+            //}
+
+            using (var con = new SqlConnection(GlobalVar.ConnectionString))
+            using (var cmd = con.CreateCommand())
+            {
+                con.Open();
+
+                //var ufs = HelperBase.GetHelper<SysUserFileString>(cmd);
+
+                rslt.itemvalue = BllHelper.GetValue(cmd, request.empid.Value, request.dwname, request.itemname, string.Empty, request.ifcompress == 1 ? true : false);
+                if (string.IsNullOrEmpty(rslt.itemvalue))//如果没有自己的布局方案,尝试获取系统的布局方案
+                {
+                    rslt.itemvalue = BllHelper.GetValue(cmd, -1, request.dwname, request.itemname, string.Empty, request.ifcompress == 1 ? true : false);
+                }
+                if (request.ifdel != null && request.ifdel == 1)
+                {
+                    BllHelper.delLayout(cmd, tokendata.userid, request.dwname, request.itemname);
+                }
+
+            }
+        }
+
+    }
+}

+ 20 - 21
JLHHJSvr/Excutor/LoginExcutor.cs

@@ -10,6 +10,7 @@ using JLHHJSvr.DBA.DBModle;
 using LJLib.DAL.SQL;
 using LJLib.Net.SPI.Server;
 using LJLib.Tools.DEncrypt;
+using LJLib.Tools.Encry;
 
 namespace JLHHJSvr.Excutor
 {
@@ -23,47 +24,45 @@ namespace JLHHJSvr.Excutor
                 return;
             }
 
-            if (string.IsNullOrEmpty(request.psw))
-            {
-                rslt.ErrMsg = "密码不能为空";
-            }
+            //if (string.IsNullOrEmpty(request.psw))
+            //{
+            //    rslt.ErrMsg = "密码不能为空";
+            //}
 
-            st_user stUser = new st_user() {usercode = request.usercode};
-            rslt.funidList = new List<int>();
+            u_user_jlhprice stUser = new u_user_jlhprice();
+            rslt.rsltFunids = new List<int>();
             using (var con = new SqlConnection(GlobalVar.ConnectionString))
             using (var cmd = con.CreateCommand())
             {
                 con.Open();
 
-                if (DbSqlHelper.SelectOne(cmd, "st_user", "usercode = @usercode",
+                if (DbSqlHelper.SelectOne(cmd, "u_user_jlhprice", "userid = @usercode",
                     new Dictionary<string, object>() {{"@usercode", request.usercode}}, stUser,
-                    "userid, usercode, username, psw") != 1)
+                    "userid, empid, username, psw") != 1)
                 {
                     rslt.ErrMsg = "用户名不存在或密码错误";
                     return;
                 }
 
-                cmd.CommandText = "SELECT funid FROM st_user_power WHERE userid = " + stUser.userid;
-                using (var reader = cmd.ExecuteReader())
+                psw_bczh3 pswhelper = new psw_bczh3();
+                if (pswhelper.GetEntrypt(request.psw, 0, "123457851239866") != stUser.psw)
                 {
-                    while (reader.Read())
-                    {
-                        rslt.funidList.Add(Convert.ToInt32(reader["funid"]));
-                    }
+                    rslt.ErrMsg = "用户名不存在或密码错误";
+                    return;
                 }
+
+                rslt.rsltFunids = UserHelper.FilterMyFunids(cmd, stUser.empid);
             }
-            if (DESEncrypt.Encrypt(request.psw, "BC493812B6664BECBF44C21C3BB043C4") != stUser.psw)
-            {
-                rslt.ErrMsg = "用户名不存在或密码错误";
-                return;
-            }
+
             string token = Guid.NewGuid().ToString();
             rslt.token = token;
             rslt.username = stUser.username;
+            rslt.usercode = stUser.userid;
+            rslt.empid = stUser.empid;
             var tokenData = new TokenData
             {
-                usercode = stUser.usercode,
-                userid = stUser.userid.Value,
+                usercode = stUser.userid,
+                userid = stUser.empid,
                 username = stUser.username
             };
             BllHelper.SetToken(token,tokenData);

+ 89 - 0
JLHHJSvr/Excutor/SetSysUserFileStringExcutor.cs

@@ -0,0 +1,89 @@
+using System;
+using System.Collections.Generic;
+using System.Data.SqlClient;
+using System.Diagnostics;
+using System.IO;
+using System.IO.Compression;
+using System.Linq;
+using System.Text;
+using JLHHJSvr;
+using JLHHJSvr.BLL;
+using JLHHJSvr.Com;
+using JLHHJSvr.DBA.DBModle;
+using LJLib.Net.SPI.Server;
+
+namespace JLHHJSvr.Excutor
+{
+    internal sealed class SetSysUserFileStringExcutor : ExcutorBase<SetSysUserFileStringRequest, SetSysUserFileStringResponse>
+    {
+        protected override void ExcuteInternal(SetSysUserFileStringRequest request, object state, SetSysUserFileStringResponse rslt)
+        {
+            if (request.empid == null)
+            {
+                rslt.ErrMsg = "参数错误,empid不能为null";
+                return;
+            }
+
+            if (request.dwname == null)
+            {
+                rslt.ErrMsg = "参数错误,dwname不能为null";
+                return;
+            }
+
+            if (request.itemname == null)
+            {
+                rslt.ErrMsg = "参数错误,itemname不能为null";
+                return;
+            }
+
+            if (request.itemvalue == null)
+            {
+                rslt.ErrMsg = "参数错误,itemvalue不能为null";
+                return;
+            }
+
+
+            var tokendata = BllHelper.GetToken(request.token);
+            if (tokendata == null)
+            {
+                rslt.ErrMsg = "会话已经中断";
+                return;
+            }
+            //if (string.IsNullOrEmpty(tokendata.ConStr))
+            //{
+            //    rslt.ErrMsg = "当前账套未设置数据库";
+            //    return;
+            //}
+
+            using (var con = new SqlConnection(GlobalVar.ConnectionString))
+            using (var cmd = con.CreateCommand())
+            {
+                con.Open();
+                using (cmd.Transaction = con.BeginTransaction())
+                {
+                    try
+                    {
+                        //var ufs = HelperBase.GetHelper<SysUserFileString>(cmd);
+
+                        var ifok = BllHelper.SetValue(cmd, request.empid.Value, request.dwname, request.itemname, request.itemvalue, request.ifcompress == 1 ? true : false);
+                        if (!ifok)
+                        {
+                            rslt.ErrMsg = "自定义值保存失败,可能数据库字段长度不足";
+                        }
+                        //if (request.empid == -1)
+                        //{
+                        //    BllHelper.delOtherLayout(cmd, request.dwname, request.itemname);
+                        //}
+                        cmd.Transaction.Commit();
+                    }
+                    catch (Exception e)
+                    {
+                        cmd.Transaction.Rollback();
+                        rslt.ErrMsg = e.ToString();
+                    }
+                }
+
+            }
+        }
+    }
+}

+ 10 - 1
JLHHJSvr/GlobalVar/GlobalVar.cs

@@ -18,7 +18,7 @@ using JLHHJSvr.LJLib.HttpServer;
 
 namespace JLHHJSvr
 {
-    internal static class GlobalVar
+    public static class GlobalVar
     {
         private static ExcutorManager excutorManager = null;
         private static Timer _timer = null;
@@ -104,6 +104,14 @@ namespace JLHHJSvr
                 excutorManager = new ExcutorManager();
                 // excutorManager.AddMap("HelloWord", typeof(HelloWordRequest), new HelloWordExcutor());
                 excutorManager.AddMap("Login", typeof(LoginRequest), new LoginExcutor());//登陆
+                //excutorManager.AddMap("GetUserInfo", typeof(GetUserInfoRequest), new GetUserInfoExcutor());
+                excutorManager.AddMap("GetSysUserFileString", typeof(GetSysUserFileStringRequest), new GetSysUserFileStringExcutor());
+                excutorManager.AddMap("SetSysUserFileString", typeof(SetSysUserFileStringRequest), new SetSysUserFileStringExcutor());
+
+                excutorManager.AddMap("GetPriceList", typeof(GetPriceListRequest), new GetPriceListExcutor());
+
+
+
                 excutorManager.AddMap("SavePermitList", typeof(SavePermitListRequest), new SavePermitListExcutor());//保存车位
                 excutorManager.AddMap("GetPermitList", typeof(GetPermitListRequest), new GetPermitListExcutor());//获取车位列表
                 excutorManager.AddMap("DelPermitList", typeof(DelPermitListRequest), new DelPermitListExcutor());//删除车位
@@ -134,6 +142,7 @@ namespace JLHHJSvr
                 excutorManager.AddMap("EditBill", typeof(EditBillRequest), new EditBillExcutor());//违停单处理/撤销
                 excutorManager.AddMap("TmpGetRoadList", typeof(TmpGetRoadListRequest), new TmpGetRoadListExcutor());//自主停车备案页面,获取路段列表
                 excutorManager.AddMap("TmpSavePermit", typeof(TmpSavePermitRequest), new TmpSavePermitExcutor());//自助停车备案保存
+
             }
             catch (Exception ex)
             {

+ 16 - 0
JLHHJSvr/JLHHJSvr.csproj

@@ -35,6 +35,9 @@
     <Prefer32Bit>false</Prefer32Bit>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+      <HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.configuration" />
     <Reference Include="System.Configuration.Install" />
@@ -50,6 +53,7 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="BLL\UserHelper.cs" />
     <Compile Include="BLL\BllHelper.cs" />
     <Compile Include="BLL\TokenData.cs" />
     <Compile Include="CMD\CMDHelper.cs" />
@@ -67,6 +71,10 @@
     <Compile Include="Com\GetCarList.cs" />
     <Compile Include="Com\GetDwLayout.cs" />
     <Compile Include="Com\GetFileByMd5.cs" />
+    <Compile Include="Com\GetPriceList.cs" />
+    <Compile Include="Com\Model\u_pricelist.cs" />
+    <Compile Include="Com\SetSysUserFileString.cs" />
+    <Compile Include="Com\GetUserInfo.cs" />
     <Compile Include="Com\GetOptionList.cs" />
     <Compile Include="Com\GetPermitList.cs" />
     <Compile Include="Com\GetRoadList.cs" />
@@ -90,6 +98,7 @@
     <Compile Include="Com\SaveRoadList.cs" />
     <Compile Include="Com\SaveUserList.cs" />
     <Compile Include="Com\SetDwLayout.cs" />
+    <Compile Include="Com\GetSysUserFileString.cs" />
     <Compile Include="Com\SetOption.cs" />
     <Compile Include="CRC64\CRC64.cs" />
     <Compile Include="DBA\DAL_SQLite\DbSqlHelper.cs" />
@@ -105,6 +114,7 @@
     <Compile Include="DBA\DBModle\st_option.cs" />
     <Compile Include="DBA\DBModle\st_permit.cs" />
     <Compile Include="DBA\DBModle\st_road.cs" />
+    <Compile Include="DBA\DBModle\u_user_jlhprice.cs" />
     <Compile Include="DBA\DBModle\st_user.cs" />
     <Compile Include="DBA\DBModle\st_user_power.cs" />
     <Compile Include="DBA\DBVersionSql\DBVersionSql.cs" />
@@ -127,6 +137,7 @@
     <Compile Include="Excutor\GetOptionListExcutor.cs" />
     <Compile Include="Excutor\GetPermitListExcutor.cs" />
     <Compile Include="Excutor\GetRoadListExcutor.cs" />
+    <Compile Include="Excutor\GetPriceListExcutor.cs" />
     <Compile Include="Excutor\GetUserListExcutor.cs" />
     <Compile Include="Excutor\GetUserPowerExcutor.cs" />
     <Compile Include="Excutor\HelloWordExcutor.cs" />
@@ -138,12 +149,16 @@
     <Compile Include="Excutor\SaveRoadListExcutor.cs" />
     <Compile Include="Excutor\SaveUserListExcutor.cs" />
     <Compile Include="Excutor\SetDwLayoutExcutor.cs" />
+    <Compile Include="Excutor\GetSysUserFileStringExcutor.cs" />
+    <Compile Include="Excutor\SetSysUserFileStringExcutor.cs" />
     <Compile Include="Excutor\SetOptionExcutor.cs" />
     <Compile Include="ImgHelper\ImgHelper.cs" />
+    <Compile Include="LJFrameWork\LJException\LJException.cs" />
     <Compile Include="LJLib.HttpServer\IFileDBModel.cs" />
     <Compile Include="LJLib.HttpServer\SimpleHttpServer.cs" />
     <Compile Include="LJLib.HttpServer\LJHttpProcessor.cs" />
     <Compile Include="LJLib.HttpServer\LJHttpServer.cs" />
+    <Compile Include="LJLib.Tools\psw_bczh3.cs" />
     <Compile Include="MIMEHelper\MIMEHelper.cs" />
     <Compile Include="JLHHJSvrConfig.cs">
       <SubType>Form</SubType>
@@ -287,6 +302,7 @@
       <DependentUpon>LJInstaller.cs</DependentUpon>
     </EmbeddedResource>
     <None Include="app.config" />
+    <None Include="packages.config" />
     <None Include="Properties\Settings.settings">
       <Generator>SettingsSingleFileGenerator</Generator>
       <LastGenOutput>Settings.Designer.cs</LastGenOutput>

+ 69 - 0
JLHHJSvr/LJFrameWork/LJException/LJException.cs

@@ -0,0 +1,69 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JLHHJSvr.LJException
+{
+    public class LJException : Exception
+    {
+        public LJException(string msg)
+            : base(msg)
+        {
+        }
+
+#if !DEBUG
+        // 非debug版本不返回堆栈
+        public override string ToString()
+        {
+            return Message;
+        }
+#endif
+    }
+
+    public class LJCommonException : LJException
+    {
+        public LJCommonException(string message)
+            : base(message)
+        {
+        }
+    }
+    public class LJNetworkException : LJException
+    {
+        public LJNetworkException(string message)
+            : base(message)
+        {
+        }
+    }
+    public class LJSearchResultNotFoundException : LJException
+    {
+        public LJSearchResultNotFoundException(string msg)
+            : base(string.Format("未查找到[{0}]的相关记录", msg))
+        {
+        }
+    }
+    public class PriceHelperException : LJException
+    {
+        public PriceHelperException(string message)
+            : base(message)
+        {
+        }
+    }
+
+    public class PBExpressionHelperException : LJException
+    {
+        public PBExpressionHelperException(string message)
+            : base(message)
+        {
+        }
+    }
+
+    public class LJPowerMissingExeption : LJException
+    {
+        public LJPowerMissingExeption(string message)
+            : base(message)
+        {
+        }
+    }
+}

+ 1 - 1
JLHHJSvr/LJLib.HttpServer/LJHttpProcessor.cs

@@ -22,7 +22,7 @@ namespace LJLib.HttpServer
         public string http_url;
         public string http_protocol_versionstring;
         private string querystr; //GET方式请求,路径后接的"?key=value……"
-        private Hashtable httpHeaders = new Hashtable();
+        private Dictionary<string, string> httpHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
 
         /// <summary>
         /// 显式参数列表

+ 235 - 0
JLHHJSvr/LJLib.Tools/psw_bczh3.cs

@@ -0,0 +1,235 @@
+using System;
+
+namespace LJLib.Tools.Encry
+{
+    public class psw_bczh3
+    {
+        //f_psw_BCzh2(STRING obj_string,INT add_expr,STRING keystr) 三倍变长加密,可以用于任意字符串
+        //obj_string 目标的处理字符串,不能为空
+        //add_expr 0 :加密,1:解密
+        //arg_keystr 密钥数字字符串
+        //private string obj_string;
+        //private int add_expr;
+        //private string arg_keystr;
+
+        public string GetEntrypt(string obj_string, int add_expr, string arg_keystr)
+        {
+            string RT_STRING = "";
+            if (obj_string == null || obj_string == "" || arg_keystr.Length == 0)
+            {
+                // add by lwl 20091217
+                if (RT_STRING == "")
+                {
+                    RT_STRING = "3003003003";
+                }
+            }
+
+            int LS_XX = 0;
+            int LS_YY = 0;
+            string ZH_STR = "";
+
+            int STR_LEN = obj_string.Length;
+            string FORMAT_STR = arg_keystr;
+
+            try
+            {
+                if (add_expr == 0)//ADD加密
+                {
+
+                    for (LS_YY = 0; LS_YY < (STR_LEN / FORMAT_STR.Length) + 1; LS_YY++)
+                        ZH_STR += FORMAT_STR;//67896789
+
+                    for (LS_XX = 0; LS_XX < STR_LEN; LS_XX++)
+                    {
+                        RT_STRING += (999 - (int)Math.Pow(int.Parse(ZH_STR.Substring(LS_XX, 1)), 2) * 9 - (int)obj_string.Substring(LS_XX, 1)[0]).ToString();
+                    }
+
+                    RT_STRING = ReverseString(RT_STRING);
+                    // add by lwl 20091217
+                    if (RT_STRING == "")
+                    {
+                        RT_STRING = "3003003003";
+                    }
+
+                }
+                else//EXPR解密
+                {
+                    // add by lwl 20091217
+                    if (obj_string == "3003003003")
+                    {
+                        return "";
+                    }
+                    else if (obj_string == "")
+                    {
+                        return "";
+                    }
+
+                    for (LS_YY = 0; LS_YY < ((STR_LEN / 3) / FORMAT_STR.Length) + 1; LS_YY++)
+                        ZH_STR += FORMAT_STR;
+
+
+                    obj_string = ReverseString(obj_string);
+
+                    for (LS_XX = 0; LS_XX < STR_LEN / 3; LS_XX++)
+                    {
+
+                        if (int.Parse(obj_string.Substring(LS_XX * 3, 3)) == 0)
+                        {
+                            //int1 = int.Parse(obj_string.Substring(LS_XX * 3, 3)) * 13;
+                            //RT_STRING += int1.ToString();
+
+                            RT_STRING += (int.Parse(obj_string.Substring(LS_XX * 3, 3)) * 13).ToString();
+                        }
+                        else
+                        {
+                            RT_STRING += Convert.ToChar(999 - (int)Math.Pow(int.Parse(ZH_STR.Substring(LS_XX, 1)), 2) * 9 - int.Parse(obj_string.Substring(LS_XX * 3, 3)));
+                        }
+                    }
+                }
+            }
+            catch
+            {
+                RT_STRING = "";
+            }
+
+
+            return RT_STRING;
+
+        }
+
+        public string GetEntrypt(string obj_string, int add_expr)
+        {
+            string arg_keystr = "182457512398663";
+            string RT_STRING = "";
+            //if (obj_string == null || obj_string == "" || arg_keystr.Length == 0)
+            if (obj_string == null)
+                return RT_STRING;
+
+            int LS_XX = 0;
+            int LS_YY = 0;
+            string ZH_STR = "";
+
+            int STR_LEN = obj_string.Length;
+            string FORMAT_STR = arg_keystr;
+
+            try
+            {
+                if (add_expr == 0)//ADD加密
+                {
+                    if (obj_string == "")
+                        return "3003003003";
+
+                    for (LS_YY = 0; LS_YY < (STR_LEN / FORMAT_STR.Length) + 1; LS_YY++)
+                        ZH_STR += FORMAT_STR;//67896789
+
+                    for (LS_XX = 0; LS_XX < STR_LEN; LS_XX++)
+                    {
+                        RT_STRING += (999 - (int)Math.Pow(int.Parse(ZH_STR.Substring(LS_XX, 1)), 2) * 9 - (int)obj_string.Substring(LS_XX, 1)[0]).ToString();
+                    }
+
+                    RT_STRING = ReverseString(RT_STRING);
+
+                }
+                else//EXPR解密
+                {
+                    if (obj_string == "3003003003")
+                        return "";
+
+                    for (LS_YY = 0; LS_YY < ((STR_LEN / 3) / FORMAT_STR.Length) + 1; LS_YY++)
+                        ZH_STR += FORMAT_STR;
+
+
+                    obj_string = ReverseString(obj_string);
+
+                    for (LS_XX = 0; LS_XX < STR_LEN / 3; LS_XX++)
+                    {
+
+                        if (int.Parse(obj_string.Substring(LS_XX * 3, 3)) == 0)
+                        {
+                            //int1 = int.Parse(obj_string.Substring(LS_XX * 3, 3)) * 13;
+                            //RT_STRING += int1.ToString();
+
+                            RT_STRING += (int.Parse(obj_string.Substring(LS_XX * 3, 3)) * 13).ToString();
+                        }
+                        else
+                        {
+                            RT_STRING += Convert.ToChar(999 - (int)Math.Pow(int.Parse(ZH_STR.Substring(LS_XX, 1)), 2) * 9 - int.Parse(obj_string.Substring(LS_XX * 3, 3)));
+                        }
+                    }
+                }
+            }
+            catch
+            {
+                RT_STRING = "";
+            }
+
+
+            return RT_STRING;
+
+        }
+
+        private string ReverseString(string S)
+        {
+            string tS = "";
+            for (int i = S.Length - 1; i >= 0; i--)
+                tS = tS + S.Substring(i, 1);
+            return tS;
+        }
+
+
+        public string dEncrypt(string obj_string, string obj_wkeystring, ref string obj_rkeystring)
+        {
+            string enstr = "";
+            string rtstr = "";
+
+            long key = 0;
+            key = long.Parse(obj_wkeystring);
+            key = (long)Math.Sqrt(key);
+            obj_rkeystring = key.ToString();
+
+            for (int i = 0; i < (obj_string.Length / obj_rkeystring.Length) + 1; i++)
+                enstr += obj_rkeystring;
+
+            enstr = ReverseString(enstr);
+
+            for (int i = 0; i < obj_string.Length; i++)
+                rtstr += (500 - (int)Math.Pow(int.Parse(enstr.Substring(i, 1)), 2) * 3 - (int)obj_string.Substring(i, 1)[0]).ToString();
+
+            return rtstr;
+
+
+        }
+
+        public string dUnencrypt(string obj_string, string obj_keystring)
+        {
+            string enstr = "";
+            string rtstr = "";
+
+            long key = 0;
+            key = long.Parse(obj_keystring);
+            key = (long)Math.Pow(key, 2);
+
+            for (int i = 0; i < ((obj_string.Length) / (obj_keystring.Length * 3)) + 1; i++)
+                enstr += obj_keystring;
+            enstr = ReverseString(enstr);
+
+            for (int i = 0; i < obj_string.Length / 3; i++)
+            {
+
+                if (int.Parse(obj_string.Substring(i * 3, 3)) == 0)
+                {
+                    rtstr += (int.Parse(obj_string.Substring(i * 3, 3)) * 9).ToString();
+                }
+                else
+                {
+                    rtstr += Convert.ToChar(500 - (int)Math.Pow(int.Parse(enstr.Substring(i, 1)), 2) * 3 - int.Parse(obj_string.Substring(i * 3, 3)));
+                }
+            }
+
+            return rtstr;
+
+        }
+
+
+    }
+}

+ 4 - 0
JLHHJSvr/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="Newtonsoft.Json" version="13.0.3" targetFramework="net45" />
+</packages>