特种设备修改,车辆管理人员管理合并,考试接口创建试卷和答题使用redis
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using EmitMapper;
|
||||
using EmitMapper.MappingConfiguration;
|
||||
using Model;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
@@ -253,7 +254,9 @@ namespace BLL
|
||||
};
|
||||
|
||||
db.Training_TestRecordItem.InsertAllOnSubmit(getItems);
|
||||
db.SubmitChanges();
|
||||
db.SubmitChanges();
|
||||
BLL.RedisHelper redis = new BLL.RedisHelper();
|
||||
redis.SetObjString(testRecordId, getItems);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -615,33 +618,40 @@ namespace BLL
|
||||
/// <returns>考试人员</returns>
|
||||
public static List<Model.TestRecordItemItem> geTestRecordItemListByTestRecordId(string testRecordId)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
BLL.RedisHelper redis = new BLL.RedisHelper();
|
||||
var getDataLists= redis.GetObjString<List<TestRecordItemItem>>(testRecordId); //先从redis取数据,不存在再从数据库取
|
||||
if (getDataLists.Count==0)
|
||||
{
|
||||
var getDataLists = (from x in db.Training_TestRecordItem
|
||||
where x.TestRecordId == testRecordId
|
||||
orderby x.TestType, x.TrainingItemCode
|
||||
select new Model.TestRecordItemItem
|
||||
{
|
||||
TestRecordItemId = x.TestRecordItemId,
|
||||
TestRecordId = x.TestRecordId,
|
||||
TrainingItemCode = x.TrainingItemCode,
|
||||
TrainingItemName = x.TrainingItemName,
|
||||
Abstracts = x.Abstracts,
|
||||
AttachUrl = x.AttachUrl.Replace("\\", "/") ?? "",
|
||||
TestType = x.TestType,
|
||||
TestTypeName = x.TestType == "1" ? "单选题" : (x.TestType == "2" ? "多选题" : "判断题"),
|
||||
AItem = x.AItem ?? "",
|
||||
BItem = x.BItem ?? "",
|
||||
CItem = x.CItem ?? "",
|
||||
DItem = x.DItem ?? "",
|
||||
EItem = x.EItem ?? "",
|
||||
AnswerItems = x.AnswerItems ?? "",
|
||||
Score = x.Score ?? 0,
|
||||
SubjectScore = x.SubjectScore ?? 0,
|
||||
SelectedItem = x.SelectedItem ?? "",
|
||||
}).ToList();
|
||||
return getDataLists;
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
getDataLists = (from x in db.Training_TestRecordItem
|
||||
where x.TestRecordId == testRecordId
|
||||
orderby x.TestType, x.TrainingItemCode
|
||||
select new Model.TestRecordItemItem
|
||||
{
|
||||
TestRecordItemId = x.TestRecordItemId,
|
||||
TestRecordId = x.TestRecordId,
|
||||
TrainingItemCode = x.TrainingItemCode,
|
||||
TrainingItemName = x.TrainingItemName,
|
||||
Abstracts = x.Abstracts,
|
||||
AttachUrl = x.AttachUrl.Replace("\\", "/") ?? "",
|
||||
TestType = x.TestType,
|
||||
TestTypeName = x.TestType == "1" ? "单选题" : (x.TestType == "2" ? "多选题" : "判断题"),
|
||||
AItem = x.AItem ?? "",
|
||||
BItem = x.BItem ?? "",
|
||||
CItem = x.CItem ?? "",
|
||||
DItem = x.DItem ?? "",
|
||||
EItem = x.EItem ?? "",
|
||||
AnswerItems = x.AnswerItems ?? "",
|
||||
Score = x.Score ?? 0,
|
||||
SubjectScore = x.SubjectScore ?? 0,
|
||||
SelectedItem = x.SelectedItem ?? "",
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return getDataLists;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
+42
-4
@@ -21,6 +21,8 @@
|
||||
<SccProvider>
|
||||
</SccProvider>
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -55,11 +57,14 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\FineUIPro\FineUIPro.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\netstandard2.0\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
<Reference Include="Fleck, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Fleck.1.2.0\lib\net45\Fleck.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.2.1.1\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\lib\net461\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.QualityTools.Testing.Fakes, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
@@ -83,12 +88,18 @@
|
||||
<Reference Include="NPOI.OpenXmlFormats, Version=2.5.5.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NPOI.2.5.5\lib\net45\NPOI.OpenXmlFormats.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Pipelines.Sockets.Unofficial, Version=1.0.0.0, Culture=neutral, PublicKeyToken=42ea0a778e13fbe2, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Pipelines.Sockets.Unofficial.2.2.8\lib\net461\Pipelines.Sockets.Unofficial.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Quartz, Version=3.7.0.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Quartz.3.7.0\lib\netstandard2.0\Quartz.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp, Version=106.15.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\RestSharp.106.15.0\lib\net452\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="StackExchange.Redis, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c219ff1ca8c2ce46, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\StackExchange.Redis.2.7.33\lib\net461\StackExchange.Redis.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
@@ -105,6 +116,14 @@
|
||||
</Reference>
|
||||
<Reference Include="System.DirectoryServices" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.IO.Pipelines, Version=5.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.IO.Pipelines.5.0.1\lib\net461\System.IO.Pipelines.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
|
||||
@@ -117,6 +136,11 @@
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
@@ -136,6 +160,9 @@
|
||||
<Reference Include="System.Text.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Json.7.0.2\lib\netstandard2.0\System.Text.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Channels, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Channels.5.0.0\lib\net461\System.Threading.Channels.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -255,6 +282,9 @@
|
||||
<Compile Include="Common\NPOIHelper.cs" />
|
||||
<Compile Include="Common\PrinterDocService.cs" />
|
||||
<Compile Include="Common\ProjectDataFlowSetService.cs" />
|
||||
<Compile Include="Common\Redis\ICache.cs" />
|
||||
<Compile Include="Common\Redis\Redis.cs" />
|
||||
<Compile Include="Common\Redis\RedisHelper.cs" />
|
||||
<Compile Include="Common\UploadFileService.cs" />
|
||||
<Compile Include="Common\UpLoadImageService.cs" />
|
||||
<Compile Include="Common\UserShowColumnsService.cs" />
|
||||
@@ -1044,7 +1074,15 @@
|
||||
<ItemGroup>
|
||||
<WCFMetadataStorage Include="Service References\CNCECHSSEService\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\build\Microsoft.Extensions.Logging.Abstractions.targets" Condition="Exists('..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\build\Microsoft.Extensions.Logging.Abstractions.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\build\Microsoft.Extensions.Logging.Abstractions.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\build\Microsoft.Extensions.Logging.Abstractions.targets'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
using System;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 接口
|
||||
/// </summary>
|
||||
public interface ICache
|
||||
{
|
||||
/// <summary>
|
||||
/// 缓存过期时间
|
||||
/// </summary>
|
||||
int TimeOut { set; get; }
|
||||
/// <summary>
|
||||
/// 获得指定键的缓存值
|
||||
/// </summary>
|
||||
/// <param name="key">缓存键</param>
|
||||
/// <returns>缓存值</returns>
|
||||
object Get(string key);
|
||||
/// <summary>
|
||||
/// 获得指定键的缓存值
|
||||
/// </summary>
|
||||
T Get<T>(string key);
|
||||
/// <summary>
|
||||
/// 从缓存中移除指定键的缓存值
|
||||
/// </summary>
|
||||
/// <param name="key">缓存键</param>
|
||||
void Remove(string key);
|
||||
/// <summary>
|
||||
/// 清空所有缓存对象
|
||||
/// </summary>
|
||||
//void Clear();
|
||||
/// <summary>
|
||||
/// 将指定键的对象添加到缓存中
|
||||
/// </summary>
|
||||
/// <param name="key">缓存键</param>
|
||||
/// <param name="data">缓存值</param>
|
||||
void Insert(string key, object data);
|
||||
/// <summary>
|
||||
/// 将指定键的对象添加到缓存中
|
||||
/// </summary>
|
||||
/// <param name="key">缓存键</param>
|
||||
/// <param name="data">缓存值</param>
|
||||
void Insert<T>(string key, T data);
|
||||
/// <summary>
|
||||
/// 将指定键的对象添加到缓存中,并指定过期时间
|
||||
/// </summary>
|
||||
/// <param name="key">缓存键</param>
|
||||
/// <param name="data">缓存值</param>
|
||||
/// <param name="cacheTime">缓存过期时间(秒钟)</param>
|
||||
void Insert(string key, object data, int cacheTime);
|
||||
|
||||
/// <summary>
|
||||
/// 将指定键的对象添加到缓存中,并指定过期时间
|
||||
/// </summary>
|
||||
/// <param name="key">缓存键</param>
|
||||
/// <param name="data">缓存值</param>
|
||||
/// <param name="cacheTime">缓存过期时间(秒钟)</param>
|
||||
void Insert<T>(string key, T data, int cacheTime);
|
||||
/// <summary>
|
||||
/// 将指定键的对象添加到缓存中,并指定过期时间
|
||||
/// </summary>
|
||||
/// <param name="key">缓存键</param>
|
||||
/// <param name="data">缓存值</param>
|
||||
/// <param name="cacheTime">缓存过期时间</param>
|
||||
void Insert(string key, object data, DateTime cacheTime);
|
||||
/// <summary>
|
||||
/// 将指定键的对象添加到缓存中,并指定过期时间
|
||||
/// </summary>
|
||||
/// <param name="key">缓存键</param>
|
||||
/// <param name="data">缓存值</param>
|
||||
/// <param name="cacheTime">缓存过期时间</param>
|
||||
void Insert<T>(string key, T data, DateTime cacheTime);
|
||||
/// <summary>
|
||||
/// 判断key是否存在
|
||||
/// </summary>
|
||||
bool Exists(string key);
|
||||
/// <summary>
|
||||
/// 右侧入队
|
||||
/// </summary>
|
||||
/// <param name="queueName"></param>
|
||||
/// <param name="redisValue"></param>
|
||||
/// <returns></returns>
|
||||
long EnqueueListRightPush(RedisKey queueName, RedisValue redisValue);
|
||||
/// <summary>
|
||||
/// 左侧入队
|
||||
/// </summary>
|
||||
/// <param name="queueName"></param>
|
||||
/// <param name="redisvalue"></param>
|
||||
/// <returns></returns>
|
||||
long EnqueueListLeftPush(RedisKey queueName, RedisValue redisvalue);
|
||||
/// <summary>
|
||||
/// 获取队列长度
|
||||
/// </summary>
|
||||
/// <param name="queueName"></param>
|
||||
/// <returns></returns>
|
||||
long EnqueueListLength(RedisKey queueName);
|
||||
/// <summary>
|
||||
/// 左侧出队
|
||||
/// </summary>
|
||||
/// <param name="queueName"></param>
|
||||
/// <returns></returns>
|
||||
string DequeueListPopLeft(RedisKey queueName);
|
||||
/// <summary>
|
||||
/// 右侧出队
|
||||
/// </summary>
|
||||
/// <param name="queueName"></param>
|
||||
/// <returns></returns>
|
||||
string DequeueListPopRight(RedisKey queueName);
|
||||
/// <summary>
|
||||
/// 分布式加锁
|
||||
/// </summary>
|
||||
/// <param name="key">键</param>
|
||||
/// <param name="data">值</param>
|
||||
/// <param name="seconds">过期时间</param>
|
||||
/// <returns></returns>
|
||||
bool LockTake(string key, string data, TimeSpan seconds, int db = 0);
|
||||
/// <summary>
|
||||
/// 解锁
|
||||
/// </summary>
|
||||
/// <param name="key">键</param>
|
||||
/// <param name="data">值</param>
|
||||
/// <returns></returns>
|
||||
bool LockRelease(string key, string data, int db = -1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,308 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class Redis : ICache
|
||||
{
|
||||
int Default_Timeout = 600;//默认超时时间(单位秒)
|
||||
string address;
|
||||
JsonSerializerSettings jsonConfig = new JsonSerializerSettings() { ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore, NullValueHandling = NullValueHandling.Ignore };
|
||||
ConnectionMultiplexer connectionMultiplexer;
|
||||
IDatabase database;
|
||||
|
||||
class CacheObject<T>
|
||||
{
|
||||
public int ExpireTime { get; set; }
|
||||
public bool ForceOutofDate { get; set; }
|
||||
public T Value { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="dbbase"></param>
|
||||
public Redis(int dbbase = 0)
|
||||
{
|
||||
this.address = this.address = ConfigurationManager.AppSettings["RedisHosts"];
|
||||
|
||||
if (this.address == null || string.IsNullOrWhiteSpace(this.address.ToString()))
|
||||
throw new ApplicationException("配置文件中未找到RedisServer的有效配置");
|
||||
connectionMultiplexer = ConnectionMultiplexer.Connect(address);
|
||||
database = connectionMultiplexer.GetDatabase(dbbase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 连接超时设置
|
||||
/// </summary>
|
||||
public int TimeOut
|
||||
{
|
||||
get
|
||||
{
|
||||
return Default_Timeout;
|
||||
}
|
||||
set
|
||||
{
|
||||
Default_Timeout = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public object Get(string key)
|
||||
{
|
||||
return Get<object>(key);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public T Get<T>(string key)
|
||||
{
|
||||
|
||||
DateTime begin = DateTime.Now;
|
||||
var cacheValue = database.StringGet(key);
|
||||
DateTime endCache = DateTime.Now;
|
||||
var value = default(T);
|
||||
if (!cacheValue.IsNull)
|
||||
{
|
||||
var cacheObject = JsonConvert.DeserializeObject<CacheObject<T>>(cacheValue, jsonConfig);
|
||||
if (!cacheObject.ForceOutofDate)
|
||||
database.KeyExpire(key, new TimeSpan(0, 0, cacheObject.ExpireTime));
|
||||
value = cacheObject.Value;
|
||||
}
|
||||
DateTime endJson = DateTime.Now;
|
||||
return value;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="data"></param>
|
||||
public void Insert(string key, object data)
|
||||
{
|
||||
var jsonData = GetJsonData(data, TimeOut, false);
|
||||
database.StringSet(key, jsonData);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="cacheTime"></param>
|
||||
public void Insert(string key, object data, int cacheTime)
|
||||
{
|
||||
var timeSpan = TimeSpan.FromSeconds(cacheTime);
|
||||
var jsonData = GetJsonData(data, TimeOut, true);
|
||||
database.StringSet(key, jsonData, timeSpan);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="cacheTime"></param>
|
||||
public void Insert(string key, object data, DateTime cacheTime)
|
||||
{
|
||||
var timeSpan = cacheTime - DateTime.Now;
|
||||
var jsonData = GetJsonData(data, TimeOut, true);
|
||||
database.StringSet(key, jsonData, timeSpan);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="data"></param>
|
||||
public void Insert<T>(string key, T data)
|
||||
{
|
||||
var jsonData = GetJsonData<T>(data, TimeOut, false);
|
||||
database.StringSet(key, jsonData);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="cacheTime"></param>
|
||||
public void Insert<T>(string key, T data, int cacheTime)
|
||||
{
|
||||
var timeSpan = TimeSpan.FromSeconds(cacheTime);
|
||||
var jsonData = GetJsonData<T>(data, TimeOut, true);
|
||||
database.StringSet(key, jsonData, timeSpan);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="cacheTime"></param>
|
||||
public void Insert<T>(string key, T data, DateTime cacheTime)
|
||||
{
|
||||
var timeSpan = cacheTime - DateTime.Now;
|
||||
var jsonData = GetJsonData<T>(data, TimeOut, true);
|
||||
database.StringSet(key, jsonData, timeSpan);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="cacheTime"></param>
|
||||
/// <param name="forceOutOfDate"></param>
|
||||
/// <returns></returns>
|
||||
string GetJsonData(object data, int cacheTime, bool forceOutOfDate)
|
||||
{
|
||||
var cacheObject = new CacheObject<object>() { Value = data, ExpireTime = cacheTime, ForceOutofDate = forceOutOfDate };
|
||||
return JsonConvert.SerializeObject(cacheObject, jsonConfig);//序列化对象
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="cacheTime"></param>
|
||||
/// <param name="forceOutOfDate"></param>
|
||||
/// <returns></returns>
|
||||
string GetJsonData<T>(T data, int cacheTime, bool forceOutOfDate)
|
||||
{
|
||||
var cacheObject = new CacheObject<T>() { Value = data, ExpireTime = cacheTime, ForceOutofDate = forceOutOfDate };
|
||||
return JsonConvert.SerializeObject(cacheObject, jsonConfig);//序列化对象
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
public void Remove(string key)
|
||||
{
|
||||
database.KeyDelete(key, CommandFlags.HighPriority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断key是否存在
|
||||
/// </summary>
|
||||
public bool Exists(string key)
|
||||
{
|
||||
return database.KeyExists(key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 右侧入队
|
||||
/// </summary>
|
||||
/// <param name="queueName">队列名称</param>
|
||||
/// <param name="redisValue">值</param>
|
||||
/// <returns></returns>
|
||||
public long EnqueueListRightPush(RedisKey queueName, RedisValue redisValue)
|
||||
{
|
||||
return database.ListRightPush(queueName, redisValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 左侧入队
|
||||
/// </summary>
|
||||
/// <param name="queueName">队列名称</param>
|
||||
/// <param name="redisvalue">队列值</param>
|
||||
/// <returns></returns>
|
||||
public long EnqueueListLeftPush(RedisKey queueName, RedisValue redisvalue)
|
||||
{
|
||||
return database.ListLeftPush(queueName, redisvalue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取队列长度
|
||||
/// </summary>
|
||||
/// <param name="queueName">队列名称</param>
|
||||
/// <returns></returns>
|
||||
public long EnqueueListLength(RedisKey queueName)
|
||||
{
|
||||
if (database.KeyExists(queueName))
|
||||
{
|
||||
return database.ListLength(queueName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 左侧出队
|
||||
/// </summary>
|
||||
/// <param name="queueName"></param>
|
||||
/// <returns></returns>
|
||||
public string DequeueListPopLeft(RedisKey queueName)
|
||||
{
|
||||
int count = database.ListRange(queueName).Length;
|
||||
if (count > 0)
|
||||
{
|
||||
string redisValue = database.ListLeftPop(queueName);
|
||||
if (!string.IsNullOrEmpty(redisValue))
|
||||
return redisValue;
|
||||
else
|
||||
return string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "-1";
|
||||
throw new Exception($"队列{queueName}数据为零");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 右侧出队
|
||||
/// </summary>
|
||||
public string DequeueListPopRight(RedisKey queueName)
|
||||
{
|
||||
int count = database.ListRange(queueName).Length;
|
||||
if (count > 0)
|
||||
{
|
||||
string redisValue = database.ListRightPop(queueName);
|
||||
if (!string.IsNullOrEmpty(redisValue))
|
||||
return redisValue;
|
||||
else
|
||||
return string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "-1";
|
||||
throw new Exception($"队列{queueName}数据为零");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分布式加锁
|
||||
/// </summary>
|
||||
/// <param name="key">键</param>
|
||||
/// <param name="data">值</param>
|
||||
/// <param name="seconds">过期时间</param>
|
||||
/// <returns></returns>
|
||||
public bool LockTake(string key, string data, TimeSpan seconds, int db = 0)
|
||||
{
|
||||
return database.LockTake(key, data, seconds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解锁
|
||||
/// </summary>
|
||||
/// <param name="key">键</param>
|
||||
/// <param name="data">值</param>
|
||||
/// <returns></returns>
|
||||
public bool LockRelease(string key, string data, int db = -1)
|
||||
{
|
||||
return database.LockRelease(key, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -360,7 +360,29 @@
|
||||
lis[2] = new ListItem("仪表安装工程", "3");
|
||||
return lis;
|
||||
}
|
||||
|
||||
public static ListItem[] Sys_Menu_Type()
|
||||
{
|
||||
ListItem[] lis = new ListItem[18];
|
||||
lis[0] = new ListItem("项目清单", "Menu_Project");
|
||||
lis[1] = new ListItem("大数据中心", "Menu_DigData");
|
||||
lis[2] = new ListItem("总部检查", "Menu_Server");
|
||||
lis[3] = new ListItem("通知管理", "Menu_Notice");
|
||||
lis[4] = new ListItem("员工菜单", "Menu_Person");
|
||||
lis[5] = new ListItem("综合管理", "Menu_ZHGL");
|
||||
lis[6] = new ListItem("系统设置", "Menu_SysSet");
|
||||
lis[7] = new ListItem("施工管理", "Menu_PZHGL");
|
||||
lis[8] = new ListItem("进度/计划", "Menu_JDGL");
|
||||
lis[9] = new ListItem("质量", "Menu_CQMS");
|
||||
lis[10] = new ListItem("HSE", "Menu_HSSE");
|
||||
lis[11] = new ListItem("焊接管理", "Menu_HJGL");
|
||||
lis[12] = new ListItem("变更管理", "Menu_Change");
|
||||
lis[13] = new ListItem("文控管理", "Menu_DocControl");
|
||||
lis[14] = new ListItem("现场考勤", "Menu_Attendance");
|
||||
lis[15] = new ListItem("视频监控", "Menu_Video");
|
||||
lis[16] = new ListItem("试车管理", "Menu_TestRun");
|
||||
lis[17] = new ListItem("项目设置", "Menu_ProjectSet");
|
||||
return lis;
|
||||
}
|
||||
// 定义允许上传的文件类型列表
|
||||
public static List<string> allowExtensions = new List<string>
|
||||
{
|
||||
|
||||
@@ -40,7 +40,10 @@ namespace BLL
|
||||
Remark = carManager.Remark,
|
||||
CompileMan = carManager.CompileMan,
|
||||
CompileDate = carManager.CompileDate,
|
||||
States = carManager.States
|
||||
States = carManager.States,
|
||||
DriverName = carManager.DriverName,
|
||||
DriverCode = carManager.DriverCode,
|
||||
DrivingDate= carManager.DrivingDate,
|
||||
};
|
||||
Funs.DB.Administrative_CarManager.InsertOnSubmit(newCarManager);
|
||||
Funs.DB.SubmitChanges();
|
||||
@@ -67,6 +70,9 @@ namespace BLL
|
||||
newCarManager.CompileMan = carManager.CompileMan;
|
||||
newCarManager.CompileDate = carManager.CompileDate;
|
||||
newCarManager.States = carManager.States;
|
||||
newCarManager.DriverName = carManager.DriverName;
|
||||
newCarManager.DriverCode = carManager.DriverCode;
|
||||
newCarManager.DrivingDate = carManager.DrivingDate;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Quartz.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -54,7 +55,15 @@ namespace BLL
|
||||
InsuranceNum = equipmentInItem.InsuranceNum,
|
||||
CommercialInsuranceNum = equipmentInItem.CommercialInsuranceNum,
|
||||
IsUsed = equipmentInItem.IsUsed,
|
||||
IsIn = equipmentInItem.IsIn
|
||||
IsIn = equipmentInItem.IsIn,
|
||||
InDate = equipmentInItem.InDate,
|
||||
EququalityExpireDate= equipmentInItem.EququalityExpireDate,
|
||||
InsuredAmount= equipmentInItem.InsuredAmount,
|
||||
OperatorName= equipmentInItem.OperatorName,
|
||||
OperatorIdentityCard= equipmentInItem.OperatorIdentityCard,
|
||||
OperatorQualityExpireDate= equipmentInItem.OperatorQualityExpireDate,
|
||||
CertificationDepartment= equipmentInItem.CertificationDepartment,
|
||||
|
||||
};
|
||||
db.InApproveManager_EquipmentInItem.InsertOnSubmit(newEquipmentItem);
|
||||
db.SubmitChanges();
|
||||
@@ -83,6 +92,14 @@ namespace BLL
|
||||
newEquipmentItem.CommercialInsuranceNum = equipmentInItem.CommercialInsuranceNum;
|
||||
newEquipmentItem.IsUsed = equipmentInItem.IsUsed;
|
||||
newEquipmentItem.IsIn = equipmentInItem.IsIn;
|
||||
newEquipmentItem.InDate = equipmentInItem.InDate;
|
||||
newEquipmentItem.EququalityExpireDate = equipmentInItem.EququalityExpireDate;
|
||||
newEquipmentItem.InsuredAmount = equipmentInItem.InsuredAmount;
|
||||
newEquipmentItem.OperatorName = equipmentInItem.OperatorName;
|
||||
newEquipmentItem.OperatorIdentityCard = equipmentInItem.OperatorIdentityCard;
|
||||
newEquipmentItem.OperatorQualityExpireDate = equipmentInItem.OperatorQualityExpireDate;
|
||||
newEquipmentItem.CertificationDepartment = equipmentInItem.CertificationDepartment;
|
||||
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using FineUIPro;
|
||||
using Model;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
@@ -23,7 +25,7 @@ namespace BLL
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public static List<Model.Sys_HttpLog> GetSys_HttpLogByModle(Model.Sys_HttpLog table)
|
||||
public static IQueryable<Model.Sys_HttpLog> GetSys_HttpLogByModle(Model.Sys_HttpLog table)
|
||||
{
|
||||
var q = from x in db.Sys_HttpLog
|
||||
where
|
||||
@@ -32,15 +34,15 @@ namespace BLL
|
||||
(string.IsNullOrEmpty(table.HttpUrl) || x.HttpUrl.Contains(table.HttpUrl)) &&
|
||||
(string.IsNullOrEmpty(table.LogTxt) || x.LogTxt.Contains(table.LogTxt)) &&
|
||||
(string.IsNullOrEmpty(table.MeThod) || x.MeThod.Contains(table.MeThod)) //&&
|
||||
// (!table.LogTime.HasValue || (x.LogTime.HasValue && x.LogTime.Value.Date == table.LogTime.Value.Date))
|
||||
// (!table.LogTime.HasValue || (x.LogTime.HasValue && x.LogTime.Value.Date == table.LogTime.Value.Date))
|
||||
|
||||
select x
|
||||
select x
|
||||
;
|
||||
if (table.LogTime.HasValue)
|
||||
{
|
||||
q=q.Where(x=> x.LogTime.Value.Date.CompareTo(table.LogTime.Value.Date) == 0);
|
||||
q = q.Where(x => x.LogTime.Value.Date.CompareTo(table.LogTime.Value.Date) == 0);
|
||||
}
|
||||
return q.OrderByDescending(x=>x.LogTime ).ToList();
|
||||
return q;
|
||||
}
|
||||
|
||||
/// 获取分页列表
|
||||
@@ -48,7 +50,7 @@ namespace BLL
|
||||
/// <param name="PageIndex">页码</param>
|
||||
/// <param name="PageSize">每页数量</param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable getListData(Model.Sys_HttpLog table, Grid Grid1)
|
||||
public static List<Sys_HttpLog> getListData(Model.Sys_HttpLog table, Grid Grid1)
|
||||
{
|
||||
var q = GetSys_HttpLogByModle(table);
|
||||
count = q.Count();
|
||||
@@ -56,19 +58,10 @@ namespace BLL
|
||||
{
|
||||
return null;
|
||||
}
|
||||
q= q.Skip(Grid1.PageSize * (Grid1.PageIndex)).Take(Grid1.PageSize).ToList();
|
||||
q = q.OrderByDescending(x => x.LogTime).Skip(Grid1.PageSize * (Grid1.PageIndex)).Take(Grid1.PageSize);
|
||||
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
||||
return from x in q
|
||||
select new
|
||||
{
|
||||
x.HttpLogId,
|
||||
x.LogTime,
|
||||
x.UserName,
|
||||
x.HttpUrl,
|
||||
x.LogTxt,
|
||||
x.MeThod,
|
||||
|
||||
};
|
||||
return (from x in q
|
||||
select x).ToList();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -76,7 +69,10 @@ namespace BLL
|
||||
{
|
||||
return db.Sys_HttpLog.FirstOrDefault(x => x.HttpLogId == HttpLogId);
|
||||
}
|
||||
|
||||
public static DateTime? GetSys_HttpLogMaxDate()
|
||||
{
|
||||
return db.Sys_HttpLog.Max(x => x.LogTime);
|
||||
}
|
||||
|
||||
public static void AddSys_HttpLog(Model.Sys_HttpLog newtable)
|
||||
{
|
||||
@@ -139,5 +135,12 @@ namespace BLL
|
||||
}
|
||||
}
|
||||
|
||||
public static void aa()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,13 +20,17 @@ namespace BLL
|
||||
var list = (from x in Funs.DB.Sys_Menu where x.SuperMenu == superMenu orderby x.SortIndex select x).ToList();
|
||||
return list;
|
||||
}
|
||||
public static Model.Sys_Menu GetSys_MenuById(string MenuId)
|
||||
|
||||
/// <summary>
|
||||
/// 根据MenuId获取菜单名称项
|
||||
/// </summary>
|
||||
/// <param name="menuId"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.Sys_Menu GetSupMenuBySuperMenu(string superMenu)
|
||||
{
|
||||
return Funs.DB.Sys_Menu.FirstOrDefault(e => e.MenuId == MenuId);
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据MenuId获取菜单名称项
|
||||
/// </summary>
|
||||
/// <param name="menuId"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.Sys_Menu GetSupMenuBySuperMenu(string superMenu)
|
||||
{
|
||||
return Funs.DB.Sys_Menu.FirstOrDefault(x => x.SuperMenu == superMenu);
|
||||
}
|
||||
@@ -91,6 +95,37 @@ namespace BLL
|
||||
}
|
||||
|
||||
return lists;
|
||||
}
|
||||
}
|
||||
public static void UpdateSys_Menu(Model.Sys_Menu newtable)
|
||||
{
|
||||
Model.Sys_Menu table = Funs.DB.Sys_Menu.FirstOrDefault(e => e.MenuId == newtable.MenuId);
|
||||
|
||||
if (table != null)
|
||||
{
|
||||
table.MenuId = newtable.MenuId;
|
||||
table.IsUsed = newtable.IsUsed;
|
||||
table.MenuName = newtable.MenuName;
|
||||
table.Icon = newtable.Icon;
|
||||
table.Url = newtable.Url;
|
||||
table.SortIndex = newtable.SortIndex;
|
||||
table.SuperMenu = newtable.SuperMenu;
|
||||
table.MenuType = newtable.MenuType;
|
||||
table.IsOffice = newtable.IsOffice;
|
||||
table.IsEnd = newtable.IsEnd;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
}
|
||||
public static void SetAllIsUsed(string MenuType)
|
||||
{
|
||||
var q = from x in Funs.DB.Sys_Menu
|
||||
where x.MenuType == MenuType
|
||||
select x;
|
||||
foreach (var p in q)
|
||||
{
|
||||
p.IsUsed = false;
|
||||
}
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user