提交 e5970666 编写于 作者: cdy816's avatar cdy816

完成历史数据查询接口

上级 f8d9aa03
...@@ -43,6 +43,8 @@ namespace Cdy.Tag ...@@ -43,6 +43,8 @@ namespace Cdy.Tag
public static byte[] zoreData = new byte[1024 * 10]; public static byte[] zoreData = new byte[1024 * 10];
private int mSize;
#endregion ...Variables... #endregion ...Variables...
#region ... Events ... #region ... Events ...
...@@ -60,21 +62,21 @@ namespace Cdy.Tag ...@@ -60,21 +62,21 @@ namespace Cdy.Tag
Init(count); Init(count);
} }
/// <summary> ///// <summary>
/// /////
/// </summary> ///// </summary>
/// <param name="handle"></param> ///// <param name="handle"></param>
/// <param name="count"></param> ///// <param name="count"></param>
public HisQueryResult(IntPtr handle,int count) //public HisQueryResult(IntPtr handle,int count)
{ //{
this.handle = handle; // this.handle = handle;
mCount = count; // mCount = count;
mTimeAddr = count * mDataSize; // mTimeAddr = count * mDataSize;
mQulityAddr = count * (mDataSize + 8); // mQulityAddr = count * (mDataSize + 8);
mLenght = count; // mLenght = count;
mLimite = count; // mLimite = count;
mPosition = 0; // mPosition = 0;
} //}
#endregion ...Constructor... #endregion ...Constructor...
...@@ -101,6 +103,10 @@ namespace Cdy.Tag ...@@ -101,6 +103,10 @@ namespace Cdy.Tag
{ {
return mCount; return mCount;
} }
set
{
mCount = value;
}
} }
/// <summary> /// <summary>
...@@ -123,14 +129,41 @@ namespace Cdy.Tag ...@@ -123,14 +129,41 @@ namespace Cdy.Tag
{ {
return mPosition; return mPosition;
} }
set
{
mPosition = value;
}
}
public int Size
{
get
{
return mSize;
}
} }
#endregion ...Properties... #endregion ...Properties...
#region ... Methods ... #region ... Methods ...
/// <summary>
///
/// </summary>
/// <returns></returns>
public HisQueryResult<T> Contracts()
{
HisQueryResult<T> re = new HisQueryResult<T>(this.Count);
Buffer.MemoryCopy((void*)this.handle, (void*)re.handle, re.Size, mDataSize * Count);
Buffer.MemoryCopy((void*)(this.handle+ mTimeAddr), (void*)(re.handle+ re.mTimeAddr), re.Size, 8 * Count);
Buffer.MemoryCopy((void*)(this.handle + mQulityAddr), (void*)(re.handle + re.mQulityAddr), re.Size, Count);
re.mCount = this.mCount;
return re;
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
...@@ -156,6 +189,7 @@ namespace Cdy.Tag ...@@ -156,6 +189,7 @@ namespace Cdy.Tag
handle = Marshal.AllocHGlobal(csize); handle = Marshal.AllocHGlobal(csize);
// handle = (void*)System.Runtime.InteropServices.Marshal.UnsafeAddrOfPinnedArrayElement(mDataBuffer, 0); // handle = (void*)System.Runtime.InteropServices.Marshal.UnsafeAddrOfPinnedArrayElement(mDataBuffer, 0);
mLimite = count; mLimite = count;
mSize = csize;
} }
/// <summary> /// <summary>
......
...@@ -33,6 +33,11 @@ namespace Cdy.Tag ...@@ -33,6 +33,11 @@ namespace Cdy.Tag
/// </summary> /// </summary>
public string Name { get; set; } = "local"; public string Name { get; set; } = "local";
/// <summary>
/// 最后生成时间
/// </summary>
public string UpdateTime { get; set; } = "";
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
......
...@@ -74,6 +74,8 @@ namespace Cdy.Tag ...@@ -74,6 +74,8 @@ namespace Cdy.Tag
RealDatabase db = new RealDatabase(); RealDatabase db = new RealDatabase();
if (System.IO.File.Exists(path)) if (System.IO.File.Exists(path))
{ {
db.UpdateTime = new System.IO.FileInfo(path).LastWriteTimeUtc.ToString();
XElement xe = XElement.Load(path); XElement xe = XElement.Load(path);
db.Name = xe.Attribute("Name").Value; db.Name = xe.Attribute("Name").Value;
......
...@@ -126,8 +126,6 @@ namespace Cdy.Tag ...@@ -126,8 +126,6 @@ namespace Cdy.Tag
/// </summary> /// </summary>
public async Task Int() public async Task Int()
{ {
string datapath = GetPrimaryHisDataPath(); string datapath = GetPrimaryHisDataPath();
await Scan(datapath); await Scan(datapath);
if (System.IO.Directory.Exists(datapath)) if (System.IO.Directory.Exists(datapath))
......
...@@ -180,17 +180,25 @@ namespace Cdy.Tag ...@@ -180,17 +180,25 @@ namespace Cdy.Tag
/// <param name="result"></param> /// <param name="result"></param>
public void ReadAllValue<T>(int id, DateTime startTime, DateTime endTime, HisQueryResult<T> result) public void ReadAllValue<T>(int id, DateTime startTime, DateTime endTime, HisQueryResult<T> result)
{ {
Tuple<DateTime, DateTime> mLogFileTimes; try
var vfiles = GetFileManager().GetDataFiles(startTime, endTime, out mLogFileTimes, id); {
vfiles.ForEach(e => { Tuple<DateTime, DateTime> mLogFileTimes;
DateTime sstart = e.StartTime > startTime ? e.StartTime : startTime; var vfiles = GetFileManager().GetDataFiles(startTime, endTime, out mLogFileTimes, id);
DateTime eend = e.EndTime > endTime ? endTime : endTime; vfiles.ForEach(e =>
e.ReadAllValue(id, sstart, eend, result); {
}); DateTime sstart = e.StartTime > startTime ? e.StartTime : startTime;
DateTime eend = e.EndTime > endTime ? endTime : endTime;
e.ReadAllValue(id, sstart, eend, result);
});
if (mLogFileTimes.Item1 != DateTime.MinValue) if (mLogFileTimes.Item1 != DateTime.MinValue)
{
ReadLogFileAllValue(id, mLogFileTimes.Item1, mLogFileTimes.Item2, result);
}
}
catch(Exception ex)
{ {
ReadLogFileAllValue(id, mLogFileTimes.Item1, mLogFileTimes.Item2, result); LoggerService.Service.Erro("QueryService", ex.StackTrace);
} }
} }
......
...@@ -252,13 +252,17 @@ namespace DBRunTime.ServiceApi ...@@ -252,13 +252,17 @@ namespace DBRunTime.ServiceApi
mb.WriteString(loginid); mb.WriteString(loginid);
infoRequreEvent.Reset(); infoRequreEvent.Reset();
Send(mb); Send(mb);
try
if (infoRequreEvent.WaitOne(timeout))
{ {
return mInfoRequreData.ReadString(); if (infoRequreEvent.WaitOne(timeout))
{
return mInfoRequreData.ReadString();
}
}
finally
{
mInfoRequreData?.ReleaseBuffer();
} }
mInfoRequreData?.ReleaseBuffer();
return string.Empty; return string.Empty;
} }
...@@ -281,12 +285,17 @@ namespace DBRunTime.ServiceApi ...@@ -281,12 +285,17 @@ namespace DBRunTime.ServiceApi
mb.WriteInt(maxid); mb.WriteInt(maxid);
this.realRequreEvent.Reset(); this.realRequreEvent.Reset();
Send(mb); Send(mb);
try
if (realRequreEvent.WaitOne(timeout))
{ {
return mRealRequreData.ReadByte() > 0; if (realRequreEvent.WaitOne(timeout))
{
return mRealRequreData.ReadByte() > 0;
}
}
finally
{
mRealRequreData?.ReleaseBuffer();
} }
mRealRequreData?.ReleaseBuffer();
return true; return true;
} }
...@@ -303,11 +312,17 @@ namespace DBRunTime.ServiceApi ...@@ -303,11 +312,17 @@ namespace DBRunTime.ServiceApi
realRequreEvent.Reset(); realRequreEvent.Reset();
Send(mb); Send(mb);
if (realRequreEvent.WaitOne(timeout)) try
{ {
return mRealRequreData.ReadByte() > 0; if (realRequreEvent.WaitOne(timeout))
{
return mRealRequreData.ReadByte() > 0;
}
}
finally
{
mRealRequreData?.ReleaseBuffer();
} }
mRealRequreData?.ReleaseBuffer();
return true; return true;
} }
...@@ -328,11 +343,18 @@ namespace DBRunTime.ServiceApi ...@@ -328,11 +343,18 @@ namespace DBRunTime.ServiceApi
realRequreEvent.Reset(); realRequreEvent.Reset();
Send(mb); Send(mb);
if (realRequreEvent.WaitOne(timeout)) try
{ {
return mRealRequreData; if (realRequreEvent.WaitOne(timeout))
{
return mRealRequreData;
}
} }
mRealRequreData?.Release(); finally
{
mRealRequreData?.ReleaseBuffer();
}
return null; return null;
} }
...@@ -352,7 +374,7 @@ namespace DBRunTime.ServiceApi ...@@ -352,7 +374,7 @@ namespace DBRunTime.ServiceApi
{ {
return mRealRequreData; return mRealRequreData;
} }
mRealRequreData?.Release(); mRealRequreData?.ReleaseBuffer();
return null; return null;
} }
...@@ -448,10 +470,16 @@ namespace DBRunTime.ServiceApi ...@@ -448,10 +470,16 @@ namespace DBRunTime.ServiceApi
} }
realRequreEvent.Reset(); realRequreEvent.Reset();
Send(mb); Send(mb);
try
if (realRequreEvent.WaitOne(timeout))
{ {
return mRealRequreData.ReadByte()>0; if (realRequreEvent.WaitOne(timeout))
{
return mRealRequreData.ReadByte() > 0;
}
}
finally
{
mRealRequreData?.ReleaseBuffer();
} }
return false; return false;
} }
...@@ -551,10 +579,16 @@ namespace DBRunTime.ServiceApi ...@@ -551,10 +579,16 @@ namespace DBRunTime.ServiceApi
} }
realRequreEvent.Reset(); realRequreEvent.Reset();
Send(mb); Send(mb);
try
if (realRequreEvent.WaitOne(timeout))
{ {
return mRealRequreData.ReadByte() > 0; if (realRequreEvent.WaitOne(timeout))
{
return mRealRequreData.ReadByte() > 0;
}
}
finally
{
mRealRequreData?.ReleaseBuffer();
} }
return false; return false;
} }
...@@ -582,12 +616,17 @@ namespace DBRunTime.ServiceApi ...@@ -582,12 +616,17 @@ namespace DBRunTime.ServiceApi
this.hisRequreEvent.Reset(); this.hisRequreEvent.Reset();
Send(mb); Send(mb);
try
if (hisRequreEvent.WaitOne(timeout) && mHisRequreData.ReadableBytes>1)
{ {
return mHisRequreData; if (hisRequreEvent.WaitOne(timeout) && mHisRequreData.ReadableBytes > 1)
{
return mHisRequreData;
}
}
finally
{
mHisRequreData?.ReleaseBuffer();
} }
mHisRequreData?.ReleaseBuffer();
return null; return null;
} }
...@@ -613,12 +652,17 @@ namespace DBRunTime.ServiceApi ...@@ -613,12 +652,17 @@ namespace DBRunTime.ServiceApi
this.hisRequreEvent.Reset(); this.hisRequreEvent.Reset();
Send(mb); Send(mb);
try
if (hisRequreEvent.WaitOne(timeout) && mHisRequreData.ReadableBytes > 1)
{ {
return mHisRequreData; if (hisRequreEvent.WaitOne(timeout) && mHisRequreData.ReadableBytes > 1)
{
return mHisRequreData;
}
}
finally
{
mHisRequreData?.ReleaseBuffer();
} }
mHisRequreData?.ReleaseBuffer();
return null; return null;
} }
...@@ -643,12 +687,17 @@ namespace DBRunTime.ServiceApi ...@@ -643,12 +687,17 @@ namespace DBRunTime.ServiceApi
mb.WriteLong(span.Ticks); mb.WriteLong(span.Ticks);
this.hisRequreEvent.Reset(); this.hisRequreEvent.Reset();
Send(mb); Send(mb);
try
if (hisRequreEvent.WaitOne(timeout) && mHisRequreData.ReadableBytes > 1) {
if (hisRequreEvent.WaitOne(timeout) && mHisRequreData.ReadableBytes > 1)
{
return mHisRequreData;
}
}
finally
{ {
return mHisRequreData; mHisRequreData?.ReleaseBuffer();
} }
mHisRequreData?.ReleaseBuffer();
return null; return null;
} }
......
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<Config Ip="127.0.0.1" Port="14330" LoginUser="Admin" LoginPassword="Admin" > <Config>
<ProxyClient Ip="127.0.0.1" Port="14330" LoginUser="Admin" LoginPassword="Admin" WorkMode="0" PollCircle="1000" />
</Config> </Config>
\ No newline at end of file
...@@ -46,6 +46,10 @@ namespace DBRuntime.Proxy ...@@ -46,6 +46,10 @@ namespace DBRuntime.Proxy
private bool mIsClosed = false; private bool mIsClosed = false;
private NetTransformWorkMode mWorkMode = NetTransformWorkMode.Poll;
private int mPollCircle = 1000;
#endregion ...Variables... #endregion ...Variables...
#region ... Events ... #region ... Events ...
...@@ -54,6 +58,12 @@ namespace DBRuntime.Proxy ...@@ -54,6 +58,12 @@ namespace DBRuntime.Proxy
#region ... Constructor... #region ... Constructor...
static DatabaseRunner()
{
//注册日志
ServiceLocator.Locator.Registor<ILog>(new ConsoleLogger());
}
#endregion ...Constructor... #endregion ...Constructor...
#region ... Properties ... #region ... Properties ...
...@@ -89,6 +99,9 @@ namespace DBRuntime.Proxy ...@@ -89,6 +99,9 @@ namespace DBRuntime.Proxy
if(System.IO.File.Exists(sfileName)) if(System.IO.File.Exists(sfileName))
{ {
XElement xe = XElement.Load(sfileName); XElement xe = XElement.Load(sfileName);
if (xe.Element("ProxyClient") == null)
return;
xe = xe.Element("ProxyClient");
if(xe.Attribute("Ip")!=null) if(xe.Attribute("Ip")!=null)
{ {
mIp = xe.Attribute("Ip").Value; mIp = xe.Attribute("Ip").Value;
...@@ -108,6 +121,16 @@ namespace DBRuntime.Proxy ...@@ -108,6 +121,16 @@ namespace DBRuntime.Proxy
{ {
mPassword = xe.Attribute("LoginPassword").Value; mPassword = xe.Attribute("LoginPassword").Value;
} }
if (xe.Attribute("WorkMode") != null)
{
mWorkMode = (NetTransformWorkMode) int.Parse(xe.Attribute("WorkMode").Value);
}
if (xe.Attribute("PollCircle") != null)
{
mPollCircle = int.Parse(xe.Attribute("PollCircle").Value);
}
} }
} }
...@@ -174,7 +197,7 @@ namespace DBRuntime.Proxy ...@@ -174,7 +197,7 @@ namespace DBRuntime.Proxy
string sname = mProxy.GetRunnerDatabase(); string sname = mProxy.GetRunnerDatabase();
if(!string.IsNullOrEmpty(sname)) if(!string.IsNullOrEmpty(sname))
{ {
Load(sname); CheckAndLoadDatabase(sname);
break; break;
} }
} }
...@@ -184,11 +207,20 @@ namespace DBRuntime.Proxy ...@@ -184,11 +207,20 @@ namespace DBRuntime.Proxy
} }
} }
/// <summary>
///
/// </summary>
private void CheckAndLoadDatabase(string database)
{
string[] sbase = database.Split(new char[] { ',' });
Load(sbase[0], sbase[1] + sbase[2]);
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="database"></param> /// <param name="database"></param>
public void Load(string database) public void Load(string database,string checkKey)
{ {
if (database == mDatabaseName) return; if (database == mDatabaseName) return;
...@@ -207,6 +239,14 @@ namespace DBRuntime.Proxy ...@@ -207,6 +239,14 @@ namespace DBRuntime.Proxy
if (CheckDatabaseExist(mDatabaseName)) if (CheckDatabaseExist(mDatabaseName))
{ {
var mDatabase = new DatabaseSerise().Load(mDatabaseName); var mDatabase = new DatabaseSerise().Load(mDatabaseName);
string skey = mDatabase.RealDatabase.Version + mDatabase.RealDatabase.UpdateTime;
if(skey!=checkKey)
{
LoggerService.Service.Warn("Proxy","代理使用的数据库和服务器使用的数据库不一致.");
}
this.mRealDatabase = mDatabase.RealDatabase; this.mRealDatabase = mDatabase.RealDatabase;
mSecurityRunner = new SecurityRunner() { Document = mDatabase.Security }; mSecurityRunner = new SecurityRunner() { Document = mDatabase.Security };
} }
...@@ -216,7 +256,7 @@ namespace DBRuntime.Proxy ...@@ -216,7 +256,7 @@ namespace DBRuntime.Proxy
RegistorInterface(); RegistorInterface();
IsReady = true; IsReady = true;
mDriver = new NetTransformDriver() { Client = mProxy.NetworkClient }; mDriver = new NetTransformDriver() { Client = mProxy.NetworkClient ,WorkMode=mWorkMode,PollCircle=mPollCircle};
mDriver.Start(realEnginer); mDriver.Start(realEnginer);
} }
......
此差异已折叠。
...@@ -12,6 +12,14 @@ using System.Threading.Tasks; ...@@ -12,6 +12,14 @@ using System.Threading.Tasks;
namespace DBRuntime.Proxy namespace DBRuntime.Proxy
{ {
public enum NetTransformWorkMode
{
//主动获取模式
Poll,
//服务器主动推送
Push
}
public class NetTransformDriver : Cdy.Tag.Driver.IProducterDriver public class NetTransformDriver : Cdy.Tag.Driver.IProducterDriver
{ {
...@@ -27,6 +35,8 @@ namespace DBRuntime.Proxy ...@@ -27,6 +35,8 @@ namespace DBRuntime.Proxy
private Thread mScanThread; private Thread mScanThread;
#endregion ...Variables... #endregion ...Variables...
#region ... Events ... #region ... Events ...
...@@ -44,6 +54,17 @@ namespace DBRuntime.Proxy ...@@ -44,6 +54,17 @@ namespace DBRuntime.Proxy
/// </summary> /// </summary>
public ApiClient Client { get; set; } public ApiClient Client { get; set; }
/// <summary>
///
/// </summary>
public NetTransformWorkMode WorkMode { get; set; }
/// <summary>
/// 查询周期
/// </summary>
public int PollCircle { get; set; } = 1000;
#endregion ...Properties... #endregion ...Properties...
#region ... Methods ... #region ... Methods ...
...@@ -72,12 +93,23 @@ namespace DBRuntime.Proxy ...@@ -72,12 +93,23 @@ namespace DBRuntime.Proxy
{ {
while(!mIsClosed) while(!mIsClosed)
{ {
resetEvent.WaitOne(); if (WorkMode == NetTransformWorkMode.Push)
if (mIsClosed) break; {
resetEvent.Reset(); resetEvent.WaitOne();
while(mCachDatas.Count>0) if (mIsClosed) break;
resetEvent.Reset();
while (mCachDatas.Count > 0)
{
ProcessSingleBufferData(mCachDatas.Dequeue());
}
}
else
{ {
ProcessSingleBufferData(mCachDatas.Dequeue()); DateTime stime = DateTime.Now;
ReadAllData();
double span = (DateTime.Now - stime).TotalMilliseconds;
int sleeptime = span > PollCircle ? 1 : (int)(PollCircle - span);
Thread.Sleep(sleeptime);
} }
} }
} }
...@@ -218,7 +250,10 @@ namespace DBRuntime.Proxy ...@@ -218,7 +250,10 @@ namespace DBRuntime.Proxy
ServiceLocator.Locator.Resolve<IRealDataNotifyForProducter>().SubscribeProducter("NetTransformDriver", ProcessValueChanged, ServiceLocator.Locator.Resolve<IRealDataNotifyForProducter>().SubscribeProducter("NetTransformDriver", ProcessValueChanged,
new Func<List<int>>(() => { return new List<int>() { -1 }; }) new Func<List<int>>(() => { return new List<int>() { -1 }; })
); );
RegistorTag();
if (WorkMode == NetTransformWorkMode.Push)
RegistorTag();
ReadAllData(); ReadAllData();
mScanThread = new Thread(RemoteDataudpatePro); mScanThread = new Thread(RemoteDataudpatePro);
mScanThread.IsBackground = true; mScanThread.IsBackground = true;
......
...@@ -103,7 +103,7 @@ namespace DBRuntime.Api ...@@ -103,7 +103,7 @@ namespace DBRuntime.Api
loginId = data.ReadString(); loginId = data.ReadString();
if (Cdy.Tag.ServiceLocator.Locator.Resolve<IRuntimeSecurity>().CheckLogin(loginId)) if (Cdy.Tag.ServiceLocator.Locator.Resolve<IRuntimeSecurity>().CheckLogin(loginId))
{ {
Parent.AsyncCallback(client, ToByteBuffer(ApiFunConst.TagInfoRequest, Runner.mCurrentDatabase)); Parent.AsyncCallback(client, ToByteBuffer(ApiFunConst.TagInfoRequest, Runner.CurrentDatabase+","+Runner.CurrentDatabaseVersion+","+Runner.CurrentDatabaseLastUpdateTime));
} }
break; break;
......
...@@ -21,7 +21,11 @@ namespace Cdy.Tag ...@@ -21,7 +21,11 @@ namespace Cdy.Tag
#region ... Variables ... #region ... Variables ...
public static string mCurrentDatabase = ""; public static string CurrentDatabase = "";
public static string CurrentDatabaseVersion = "";
public static string CurrentDatabaseLastUpdateTime = "";
/// <summary> /// <summary>
/// ///
...@@ -124,10 +128,12 @@ namespace Cdy.Tag ...@@ -124,10 +128,12 @@ namespace Cdy.Tag
/// </summary> /// </summary>
private void LoadDatabase() private void LoadDatabase()
{ {
this.mDatabase = new DatabaseSerise().Load(mDatabaseName); this.mDatabase = new DatabaseSerise().Load(mDatabaseName);
this.mRealDatabase = this.mDatabase.RealDatabase; this.mRealDatabase = this.mDatabase.RealDatabase;
this.mHisDatabase = this.mDatabase.HisDatabase; this.mHisDatabase = this.mDatabase.HisDatabase;
CurrentDatabaseVersion = this.mRealDatabase.Version;
CurrentDatabase = mRealDatabase.Name;
CurrentDatabaseLastUpdateTime = mRealDatabase.UpdateTime;
} }
/// <summary> /// <summary>
...@@ -182,6 +188,8 @@ namespace Cdy.Tag ...@@ -182,6 +188,8 @@ namespace Cdy.Tag
DriverManager.Manager.Init(realEnginer); DriverManager.Manager.Init(realEnginer);
HisQueryManager.Instance.Registor(mDatabaseName);
await task; await task;
return true; return true;
...@@ -253,8 +261,6 @@ namespace Cdy.Tag ...@@ -253,8 +261,6 @@ namespace Cdy.Tag
hisEnginer.Start(); hisEnginer.Start();
mSecurityRunner.Start(); mSecurityRunner.Start();
DriverManager.Manager.Start(); DriverManager.Manager.Start();
mCurrentDatabase = database;
mIsStarted = true; mIsStarted = true;
LoggerService.Service.Info("Runner", " 数据库 " + database + " 启动完成"); LoggerService.Service.Info("Runner", " 数据库 " + database + " 启动完成");
......
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<Config Ip="127.0.0.1" Port="14330" LoginUser="Admin" LoginPassword="Admin" > <Config>
<ProxyClient Ip="127.0.0.1" Port="14330" LoginUser="Admin" LoginPassword="Admin" WorkMode="0" PollCircle="1000" />
</Config> </Config>
\ No newline at end of file
...@@ -7,17 +7,14 @@ using Microsoft.AspNetCore.Mvc; ...@@ -7,17 +7,14 @@ using Microsoft.AspNetCore.Mvc;
namespace DbWebApiProxy.Controllers namespace DbWebApiProxy.Controllers
{ {
[Route("[controller]")]
[ApiController] public class HomeController : Controller
public class HomeController : ControllerBase
{ {
// GET: api/Home // GET: api/Home
[HttpGet] [HttpGet]
public string Index() public string Index()
{ {
return "welcome to mar realtime datase web api."; return Res.Get("WelcomeMsg");
} }
} }
} }
...@@ -17,6 +17,25 @@ ...@@ -17,6 +17,25 @@
<ProjectReference Include="..\DBRuntime.Proxy\DBRuntime.Proxy.csproj" /> <ProjectReference Include="..\DBRuntime.Proxy\DBRuntime.Proxy.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.zh-CN.resx">
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<Generator>ResXFileCodeGenerator</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="Config\DbWebApiProxy.cfg"> <None Update="Config\DbWebApiProxy.cfg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
......
...@@ -79,7 +79,7 @@ namespace DbInRunWebApi.Model ...@@ -79,7 +79,7 @@ namespace DbInRunWebApi.Model
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public Dictionary<DateTime,object> Datas { get; set; } public List<ValueItem> Values { get; set; }
#endregion ...Properties... #endregion ...Properties...
#region ... Methods ... #region ... Methods ...
...@@ -91,6 +91,47 @@ namespace DbInRunWebApi.Model ...@@ -91,6 +91,47 @@ namespace DbInRunWebApi.Model
#endregion ...Interfaces... #endregion ...Interfaces...
} }
public class ValueItem
{
#region ... Variables ...
#endregion ...Variables...
#region ... Events ...
#endregion ...Events...
#region ... Constructor...
#endregion ...Constructor...
#region ... Properties ...
/// <summary>
///
/// </summary>
public DateTime Time { get; set; }
/// <summary>
///
/// </summary>
public string Value { get; set; }
/// <summary>
///
/// </summary>
public byte Quality { get; set; }
#endregion ...Properties...
#region ... Methods ...
#endregion ...Methods...
#region ... Interfaces ...
#endregion ...Interfaces...
}
/// <summary> /// <summary>
/// ///
...@@ -180,7 +221,7 @@ namespace DbInRunWebApi.Model ...@@ -180,7 +221,7 @@ namespace DbInRunWebApi.Model
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public List<HisValue> Datas { get; set; } public HisValue Datas { get; set; }
#endregion ...Properties... #endregion ...Properties...
#region ... Methods ... #region ... Methods ...
......
...@@ -217,7 +217,7 @@ namespace DbInRunWebApi.Model ...@@ -217,7 +217,7 @@ namespace DbInRunWebApi.Model
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public List<DateTime> Times { get; set; } public List<string> Times { get; set; }
#endregion ...Properties... #endregion ...Properties...
...@@ -263,13 +263,18 @@ namespace DbInRunWebApi.Model ...@@ -263,13 +263,18 @@ namespace DbInRunWebApi.Model
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public DateTime StartTime { get; set; } public string StartTime { get; set; }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public DateTime EndTime { get; set; } public string EndTime { get; set; }
/// <summary>
///
/// </summary>
public string Duration { get; set; }
#endregion ...Properties... #endregion ...Properties...
...@@ -308,13 +313,13 @@ namespace DbInRunWebApi.Model ...@@ -308,13 +313,13 @@ namespace DbInRunWebApi.Model
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public DateTime StartTime { get; set; } public string StartTime { get; set; }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public DateTime EndTime { get; set; } public string EndTime { get; set; }
#endregion ...Properties... #endregion ...Properties...
......
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace DbWebApiProxy.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DbWebApiProxy.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性
/// 重写当前线程的 CurrentUICulture 属性。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// 查找类似 Welcome to Web Api of Mars high performance realtime iot database 的本地化字符串。
/// </summary>
internal static string WelcomeMsg {
get {
return ResourceManager.GetString("WelcomeMsg", resourceCulture);
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="WelcomeMsg" xml:space="preserve">
<value>Welcome to Web Api of Mars high performance realtime iot database</value>
</data>
</root>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="WelcomeMsg" xml:space="preserve">
<value>欢迎来到Mars高性能实时物联数据库 Web Api</value>
</data>
</root>
\ No newline at end of file
//==============================================================
// Copyright (C) 2020 Inc. All rights reserved.
//
//==============================================================
// Create by 种道洋 at 2020/3/29 11:05:05.
// Version 1.0
// 种道洋
//==============================================================
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace DbWebApiProxy
{
public class Res
{
public static string Get(string name)
{
return Properties.Resources.ResourceManager.GetString(name, Thread.CurrentThread.CurrentCulture);
}
}
}
...@@ -40,8 +40,10 @@ namespace DbInRunWebApi ...@@ -40,8 +40,10 @@ namespace DbInRunWebApi
app.UseEndpoints(endpoints => app.UseEndpoints(endpoints =>
{ {
endpoints.MapControllers(); endpoints.MapControllers();
endpoints.MapDefaultControllerRoute(); endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
}); });
DatabaseRunner.Manager.Load(); DatabaseRunner.Manager.Load();
DatabaseRunner.Manager.Start(); DatabaseRunner.Manager.Start();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册