コード例 #1
0
        /// <summary>
        /// 获取列所在的索引位置(若不存在返回-1)
        /// </summary>
        public int GetIndex(string columnName)
        {
            if (columnIndex.Count == 0 || IsColumnNameChanged || columnIndex.Count != Count)
            {
                columnIndex.Clear();
                for (int i = 0; i < Count; i++)
                {
                    columnIndex.Add(this[i].ColumnName.Replace("_", ""), i);
                }
                IsColumnNameChanged = false;
            }

            if (!string.IsNullOrEmpty(columnName))
            {
                if (columnName.IndexOf('_') > -1)
                {
                    columnName = columnName.Replace("_", "");//兼容映射处理
                }
                if (columnIndex.ContainsKey(columnName))
                {
                    return(columnIndex[columnName]);
                }
                //for (int i = 0; i < Count; i++)
                //{
                //    if (string.Compare(this[i].ColumnName.Replace("_", ""), columnName, StringComparison.OrdinalIgnoreCase) == 0)//第三个参数用StringComparison.OrdinalIgnoreCase比用true快。
                //    {
                //        return i;
                //    }
                //}
            }
            return(-1);
        }
コード例 #2
0
ファイル: MDataColumn.cs プロジェクト: zzgzzgok/cyqdata
        /// <summary>
        /// 获取列所在的索引位置(若不存在返回-1)
        /// </summary>
        public int GetIndex(string columnName)
        {
            columnName = columnName.Trim();
            if (columnIndex.Count == 0 || IsColumnNameChanged || columnIndex.Count != Count)
            {
                columnIndex.Clear();
                for (int i = 0; i < Count; i++)
                {
                    columnIndex.Add(this[i].ColumnName.Replace("_", ""), i);
                }
                IsColumnNameChanged = false;
            }

            if (!string.IsNullOrEmpty(columnName))
            {
                if (columnName.IndexOf('_') > -1)
                {
                    columnName = columnName.Replace("_", "");//兼容映射处理
                }
                if (columnIndex.ContainsKey(columnName))
                {
                    return(columnIndex[columnName]);
                }
                else
                {
                    //开启默认前缀检测
                    string[] items = AppConfig.UI.AutoPrefixs.Split(',');
                    if (items != null && items.Length > 0)
                    {
                        foreach (string item in items)
                        {
                            columnName = columnName.StartsWith(item) ? columnName.Substring(3) : item + columnName;
                            if (columnIndex.ContainsKey(columnName))
                            {
                                return(columnIndex[columnName]);
                            }
                        }
                    }
                }
                //for (int i = 0; i < Count; i++)
                //{
                //    if (string.Compare(this[i].ColumnName.Replace("_", ""), columnName, StringComparison.OrdinalIgnoreCase) == 0)//第三个参数用StringComparison.OrdinalIgnoreCase比用true快。
                //    {
                //        return i;
                //    }
                //}
            }
            return(-1);
        }
コード例 #3
0
ファイル: LocalCache.cs プロジェクト: zzgzzgok/cyqdata
        /// <summary>
        /// 清除所有缓存
        /// </summary>
        public override void Clear()
        {
            try
            {
                lock (lockObj)
                {
                    DBSchema.Clear();
                    TableSchema.Clear();

                    theCache.Clear();
                    theTime.Clear();
                    theFileName.Clear();
                    theKeyTime.Clear();
                    for (int i = 0; i < theFolderWatcher.Count; i++)
                    {
                        theFolderWatcher[i].Changed -= new FileSystemEventHandler(fsy_Changed);
                        theFolderWatcher[i]          = null;
                    }
                    theFolderWatcher.Clear();
                    theFolderKeys.Clear();
                }
            }
            catch
            {
                errorCount++;
            }
        }
コード例 #4
0
ファイル: LocalCache.cs プロジェクト: wangscript007/cyqdata
        /// <summary>
        /// 清除所有缓存
        /// </summary>
        public override void Clear()
        {
            try
            {
                lock (lockObj)
                {
                    DBSchema.Clear();
                    TableSchema.Clear();

                    theCache.Clear();
                    theTime.Clear();
                    theFileName.Clear();
                    theKeyTime.Clear();
                    for (int i = 0; i < theFolderWatcher.Count; i++)
                    {
                        theFolderWatcher[i].Changed -= new FileSystemEventHandler(fsy_Changed);
                        theFolderWatcher[i]          = null;
                    }
                    theFolderWatcher.Clear();
                    theFolderKeys.Clear();
                    if (!string.IsNullOrEmpty(AppConfig.DB.SchemaMapPath))
                    {
                        if (Directory.Exists(AppConfig.RunPath + AppConfig.DB.SchemaMapPath))
                        {
                            Directory.Delete(AppConfig.RunPath + AppConfig.DB.SchemaMapPath, true);
                        }
                    }
                }
            }
            catch
            {
                errorCount++;
            }
        }
コード例 #5
0
 /// <summary>
 /// 清除所有缓存
 /// </summary>
 public override void Clear()
 {
     try
     {
         if (theCache.Count > 0)
         {
             System.Collections.IDictionaryEnumerator e = theCache.GetEnumerator();
             while (e.MoveNext())
             {
                 theCache.Remove(Convert.ToString(e.Key));
             }
         }
         lock (lockObj)
         {
             try
             {
                 theState.Clear();
                 theState = null;
                 theState = new MDictionary <string, CacheDependencyInfo>(500, StringComparer.OrdinalIgnoreCase);
             }
             catch
             {
             }
         }
     }
     catch
     {
         errorCount++;
     }
 }
コード例 #6
0
 /// <summary>
 /// 清除所有缓存
 /// </summary>
 public override void Clear()
 {
     try
     {
         lock (lockObj)
         {
             TableSchema.tableCache.Clear();
             TableSchema.columnCache.Clear();
             theKey.Clear();
             theCache.Clear();
             theTime.Clear();
             theKeyTime.Clear();
             for (int i = 0; i < theFile.Count; i++)
             {
                 theFile[i].Changed -= new FileSystemEventHandler(fsy_Changed);
                 theFile[i]          = null;
             }
             theFile.Clear();
             theFileKeys.Clear();
         }
     }
     catch
     {
         errorCount++;
     }
 }
コード例 #7
0
ファイル: LogWorker.cs プロジェクト: zzgzzgok/cyqdata
        private static void DoWork(object p)
        {
            //检测文件夹
            string folder  = AppConfig.WebRootPath;
            string logPath = AppConfig.Log.LogPath;

            if (logPath.StartsWith("~/"))
            {
                logPath = logPath.Substring(2);
            }
            folder = folder + logPath;
            if (!System.IO.Directory.Exists(folder))
            {
                System.IO.Directory.CreateDirectory(folder);
            }
            int empty = 0;

            while (true)
            {
                empty++;
                while (_LogQueue.Count > 0)
                {
                    empty = 0;
                    SysLogs sys = _LogQueue.Dequeue();
                    if (sys == null)
                    {
                        continue;
                    }
                    if (!sys.IsWriteToTxt)
                    {
                        if (sys.Insert(InsertOp.None)) //直接写数据库。
                        {
                            sys.Dispose();
                            continue;
                        }
                    }

                    string todayKey = DateTime.Today.ToString("yyyyMMdd") + ".txt";

                    if (!string.IsNullOrEmpty(sys.LogType))
                    {
                        todayKey = sys.LogType.TrimEnd('_') + '_' + todayKey;
                    }
                    string filePath = folder + todayKey;
                    //检测数据库
                    //检测文件路径:
                    string body = sys.GetFormatterText();
                    IOHelper.Save(filePath, body, true, false);
                    sys.Dispose();
                }
                Thread.Sleep(5000);
                if (empty > 100)
                {
                    //超过10分钟没日志产生
                    hashObj.Clear();
                    threadIsWorking = false;
                    break;//结束线程。
                }
            }
        }
コード例 #8
0
 public static void Clear()
 {
     _ColumnCache.Clear();
 }
コード例 #9
0
            /// <summary>
            /// 清理服务主机。
            /// </summary>
            internal static void ClearServerTable()
            {
                while (true)
                {
                    try
                    {
                        lock (Const.tableLockObj)
                        {
                            if (Server._HostList != null && Server._HostList.Count > 0)
                            {
                                MDictionary <string, List <HostInfo> > keyValuePairs    = Server._HostList;//拿到引用
                                MDictionary <string, List <HostInfo> > newKeyValuePairs = new MDictionary <string, List <HostInfo> >(StringComparer.OrdinalIgnoreCase);
                                foreach (var item in keyValuePairs)
                                {
                                    List <HostInfo> newList = new List <HostInfo>();
                                    foreach (var info in item.Value)
                                    {
                                        if (info.RegTime < DateTime.Now.AddSeconds(-11) || info.Version < 0)
                                        {
                                            Server.IsChange = true;
                                        }
                                        else
                                        {
                                            newList.Add(info);
                                        }
                                    }
                                    if (newList.Count > 0)
                                    {
                                        newKeyValuePairs.Add(item.Key, newList);
                                    }
                                }

                                if (Server.IsChange)
                                {
                                    Server.IsChange = false;
                                    Server.Tick     = DateTime.Now.Ticks;
                                    if (newKeyValuePairs.Count > 0)
                                    {
                                        Server._HostListJson = JsonHelper.ToJson(newKeyValuePairs);
                                        IO.Write(Const.ServerHostListJsonPath, Server._HostListJson);
                                    }
                                    else
                                    {
                                        Server._HostListJson = String.Empty;
                                        IO.Delete(Const.ServerHostListJsonPath);
                                    }
                                    Server._HostList = newKeyValuePairs;
                                }
                                else
                                {
                                    newKeyValuePairs.Clear();
                                    newKeyValuePairs = null;
                                }
                            }
                        }
                    }
                    catch (Exception err)
                    {
                        LogWrite(err.Message, "MicroService.Run.ClearServerTable()", "", Config.ServerName);
                    }
                    Thread.Sleep(5000);//测试并发。
                }
            }
コード例 #10
0
ファイル: AppConfig.cs プロジェクト: jiszen/cyqdata
 internal static void Clear()
 {
     appConfigs.Clear();
     connConfigs.Clear();
 }
コード例 #11
0
 public override void Clear()
 {
     dic.Clear();
 }