You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
3.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/////////////////////////////////////////////////////////////////
//
// (C) Copyright 2013, Kenneth, Inc.
// All rights reserved. Confidential. Except as pursuant
// to a written agreement with Kenneth, this software may
// not be used or distributed. This software may be covered
// by one or more patents.
//
// 本软件为 ** 公司开发版权所有违者必究23810511@qq.com
//
/////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using System.IO;
using System.Reflection;
using System.Data;
using System.Data.SqlClient;
using QuiltingCommon;
namespace QuiltingBusiness
{
public class SysConfigurationPool : PoolInterface
{
private static List<SysConfigurationEntity> bufferPool = new List<SysConfigurationEntity>();
public static void InitializeResults()
{
DataTable dt = MysqlHelper.ExecuteDataTable("select * from sys_configuration where IsActive = 1");
var results = MysqlHelper.DataTableToIList<SysConfigurationEntity>(dt) as List<SysConfigurationEntity>;
lock (bufferPool)
{
bufferPool.Clear();
bufferPool.AddRange(results);
}
}
public static void Update(object obj)
{
lock (bufferPool)
{
SysConfigurationEntity key = obj as SysConfigurationEntity;
bufferPool.RemoveAll(q => q.RecId == key.RecId);
bufferPool.Add((SysConfigurationEntity)key.Clone());
}
}
public static void Delete(string recid)
{
lock (bufferPool)
{
bufferPool.RemoveAll(q => q.RecId == recid);
}
}
public static string LoadResultByKeyId(string currentUserId, string currentClientId, string currentSendParameter)
{
var send = JsonConvert.DeserializeObject(currentSendParameter, typeof(SysConfigurationEntity)) as SysConfigurationEntity;
var data = bufferPool.FirstOrDefault(t => t.KeyId == send.KeyId);
var rst = new SysConfigurationEntityExtension();
if (data != null)
{
rst.CreateBy = data.CreateBy;
rst.CreateTime = data.CreateTime;
rst.IsActive = data.IsActive;
rst.KeyId = data.KeyId;
rst.KeyValue = data.KeyValue;
rst.ModifyBy = data.ModifyBy;
rst.ModifyTime = data.ModifyTime;
rst.RecId = data.RecId;
rst.ReferenceId = data.ReferenceId;
var user = SysUserPool.BufferPool.Where(q => q.RecId == data.CreateBy).FirstOrDefault();
if (user != null)
{
rst.CreateByShow = user.UserName;
}
user = SysUserPool.BufferPool.Where(q => q.RecId == data.ModifyBy).FirstOrDefault();
if (user != null)
{
rst.ModifyByShow = user.UserName;
}
}
OutEntity oe = new OutEntity() { ErrorCode = ErrorCode.Success, ReturnObj = JsonConvert.SerializeObject(rst) };
return JsonConvert.SerializeObject(oe);
}
public static string GetValueByKey(string keyid)
{
var data = bufferPool.FirstOrDefault(t => t.KeyId == keyid);
if (data != null)
{
return data.KeyValue;
}
return string.Empty;
}
}
}