Skip to content

Commit

Permalink
细节优化。
Browse files Browse the repository at this point in the history
  • Loading branch information
cyq1162 committed May 9, 2019
1 parent 8e870a4 commit e80f571
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 43 deletions.
5 changes: 4 additions & 1 deletion Action/AppConst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static class AppConst
internal const string Host = "cyqdata.com";
internal const string Host_Aries = "aries.cyqdata.com";
internal const string Host_Taurus = "taurus.cyqdata.com";

internal const string Host_Lic = "lic.cyqdata.com";
#endregion
#region License 常量

Expand All @@ -35,9 +35,11 @@ internal static class AppConst

#region 全局
internal const string FilePre = "file:";
internal const string Result = ".Result";
internal const string Global_NotImplemented = "The method or operation is not implemented.";
internal const string ACKey = "4pMxvlk1OlOv0K6z96T+mNDBdEkX6mPa7Yq27cWP/u0#=2";
internal const string ALKey = "YH/xArdNhygAvQ7NwJiq2HreAmphvcTP7Yq27cWP/u0#=2";

#endregion

#region 静态常量
Expand Down Expand Up @@ -92,6 +94,7 @@ internal static string NewLine
/// </summary>
internal static string _DLLFullName = string.Empty;
static string _RunfolderPath;
internal static string HNKey = LocalEnvironment.HostName;
/// <summary>
/// 框架的程序集所在的运行路径
/// </summary>
Expand Down
25 changes: 5 additions & 20 deletions Cache/LocalCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public override MDataTable CacheInfo

#endregion

allowCacheTableTime = DateTime.Now.AddSeconds(5);
allowCacheTableTime = DateTime.Now.AddSeconds(5);
cacheInfoTable = cacheTable;
}
return cacheInfoTable;
Expand All @@ -68,7 +68,7 @@ internal LocalCache()
ThreadBreak.AddGlobalThread(new ParameterizedThreadStart(ConnObject.CheckConnIsOk));//主从链接的检测机制。
//if (AppConfig.Cache.IsAutoCache) // 机制变更为Aop也可控制,所以这个参数还决定不了
//{
ThreadBreak.AddGlobalThread(new ParameterizedThreadStart(AutoCache.ClearCache));
ThreadBreak.AddGlobalThread(new ParameterizedThreadStart(AutoCache.ClearCache));
//}
}
catch (Exception err)
Expand Down Expand Up @@ -145,24 +145,9 @@ private void CheckIsSafe()
if (!isFirstCheck)
{
isFirstCheck = true;
string key = EncryptHelper.Decrypt(AppConst.ACKey, AppConst.Host);
key = AppConfig.GetConn(key);
if (!string.IsNullOrEmpty(key))
if (!EncryptHelper.HashKeyIsValid())
{
key = EncryptHelper.Decrypt(AppConst.ALKey, AppConst.Host);
if (!string.IsNullOrEmpty(key))
{
string code = AppConfig.GetApp(key);
if (!string.IsNullOrEmpty(code))
{
string[] items = EncryptHelper.Decrypt(code.Substring(4), code.Substring(0, 4)).Split(',');
DateTime d;
if (DateTime.TryParse(items[0], out d) && d > DateTime.Now)
{
AppConfig.SetApp(key + ".result", "1");
}
}
}
AppConfig.SetApp("Conn" + AppConst.Result, "false");
}
}
}
Expand Down Expand Up @@ -321,7 +306,7 @@ public override bool Set(string key, object value, double cacheMinutes, string f
}
return true;
}
catch(Exception err)
catch (Exception err)
{
Log.Write(err, LogType.Cache);
errorCount++;
Expand Down
9 changes: 6 additions & 3 deletions DAL/Conn/ConnBean.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,18 @@ public ConnBean Clone()
public bool TryTestConn()
{
//err = string.Empty;
if (!string.IsNullOrEmpty(ConnName))
if (!string.IsNullOrEmpty(ConnName) && AppConfig.GetAppBool("Conn.Result", true))
{
DalBase helper = DalCreate.CreateDal(ConnName);
try
{

helper.Con.Open();
Version = helper.Con.ServerVersion;
if (string.IsNullOrEmpty(Version)) { Version = helper.DataBaseType.ToString(); }
if (string.IsNullOrEmpty(Version))
{
Version = helper.DataBaseType.ToString();
}
helper.Con.Close();
IsOK = true;
ErrorMsg = string.Empty;
Expand Down Expand Up @@ -103,7 +106,7 @@ internal partial class ConnBean
private static MDictionary<int, ConnBean> connBeanDicCache = new MDictionary<int, ConnBean>();
public static void ClearCache(string key)
{
if(!string.IsNullOrEmpty(key))
if (!string.IsNullOrEmpty(key))
{
int hash = key.GetHashCode();
ConnBean cb = connBeanDicCache[hash];
Expand Down
18 changes: 0 additions & 18 deletions DAL/NoSql/NoSqlAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,36 +80,18 @@ private MDataTable Table
{
Error.Throw("MDataTable can't load data from file : " + _FileFullName);
}
//行修正,有可能json的某些列数据为Null
// foreach (MCellStruct rowST in _Row.Columns)
// {
// foreach (MCellStruct tableST in _Table.Columns)
//{

//}
// if (!_Table.Columns.Contains(cst.ColumnName))
// {
// _Table.Columns.Add(cst);
// }
// else if(cst.SqlType!=_Table.col
// {

// }
// }
DateTime _lastWriteTimeUtc = new IOInfo(_FileFullName).LastWriteTimeUtc;
if (!_lastWriteTimeList.ContainsKey(_FileFullName))
{
_lastWriteTimeList.Add(_FileFullName, _lastWriteTimeUtc);
}
if (_Table.Rows.Count > 0)
{
//lock (_lockTableListObj)
//{
if (!_tableList.ContainsKey(_FileFullName))
{
_tableList.Add(_FileFullName, _Table);
}
// }
}
return _Table;

Expand Down
27 changes: 26 additions & 1 deletion Tool/EncryptHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,32 @@ private static string Decrypt(string text, byte[] hashKey)
}
return result;
}

internal static bool HashKeyIsValid()
{
string acKey = Decrypt(AppConst.ACKey, AppConst.Host);
acKey = AppConfig.GetConn(acKey);
if (!string.IsNullOrEmpty(acKey))
{
string alKey = EncryptHelper.Decrypt(AppConst.ALKey, AppConst.Host);
if (!string.IsNullOrEmpty(alKey))
{
string code = AppConfig.GetApp(alKey);
if (!string.IsNullOrEmpty(code))
{
string[] items = EncryptHelper.Decrypt(code.Substring(4), code.Substring(0, 4)).Split(',');
DateTime d;
if ((DateTime.TryParse(items[0], out d) && d > DateTime.Now) || (items.Length > 1 && items[1] == AppConst.HNKey))
{
AppConfig.SetApp(alKey + AppConst.Result, "1");
return true;
}
}
}
AppConfig.SetApp(alKey + AppConst.Result, "0");
return false;
}
return true;
}
#endregion
}
}

0 comments on commit e80f571

Please sign in to comment.