Exemplo n.º 1
0
        private void Search()
        {
            //refresh list
            List <DataItem> dataList = new List <DataItem>();

            foreach (ListViewItem lv in listViewData.Items)
            {
                DataCacheType type  = (DataCacheType)(lv.Tag);
                string        key   = lv.SubItems[1].Text;
                string        value = lv.SubItems[2].Text;
                dataList.Add(new DataItem {
                    Type  = type,
                    Key   = key,
                    Value = value
                });
            }

            formSearch.RefreshList(dataList);


            //show
            if (formSearch.ShowDialog() == DialogResult.OK)
            {
                DataItem item      = formSearch.SelectLine;
                var      checkItem = FindExistItem(item.Key, listViewWatch);
                if (checkItem == null)
                {
                    AddData(item.Key, item.Value, item.Type, DateTime.Now.ToString(), listViewWatch);
                }
            }
        }
Exemplo n.º 2
0
 public void OnDataChanged(string argKey,
                           string argValue,
                           DataCacheType argType,
                           string argDateTimestamp)
 {
     m_main.OnDataChanged(argKey, argValue, argType, argDateTimestamp);
 }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ct"></param>
        /// <param name="_dbRadis">只对Radis数据库有效</param>
        /// <param name="_conn">连接地址和端口,只对Radis数据库有效</param>
        /// <returns></returns>
        public static IDataCacheHelper GetCacheHelp(DataCacheType ct, int _dbRadis = -1, string conn = null)
        {
            var _conn = ct == DataCacheType.Redis?(conn ?? ConfigurationManager.AppSettings["RedisConfig"] ?? "127.0.0.1:6379"):"";
            var key   = ct.ToString() + "db" + _conn;

            lock (IClock)
            {
                if (dic.Count == 0 || dic[key] == null)
                {
                    IDataCacheHelper _IDataCacheHelper = null;
                    switch (ct)
                    {
                    case DataCacheType.Redis:
                        _IDataCacheHelper = Redis.RedisPool.GetPool(_conn, _dbRadis);
                        dic.Add(key, _IDataCacheHelper);
                        break;

                    case DataCacheType.Sysnet:
                        _IDataCacheHelper = Sysnet.SysnetPool.GetPool();
                        dic.Add(key, _IDataCacheHelper);
                        break;
                    }
                }
                return(dic[key]);
            }
        }
Exemplo n.º 4
0
        private Color QueryColorByDataCacheType(DataCacheType argType)
        {
            Color clr = Color.Black;

            switch (argType)
            {
            case DataCacheType.None:
            {
                clr = Color.Green;
            }
            break;

            case DataCacheType.Transaction:
            {
                clr = Color.Blue;
            }
            break;

            case DataCacheType.CardHolder:
            {
                clr = SystemColors.WindowText;
            }
            break;

            case DataCacheType.Terminal:
            {
                clr = Color.Fuchsia;
            }
            break;
            }

            return(clr);
        }
Exemplo n.º 5
0
        private void HandleDataDeleted(string argKey,
                                       DataCacheType argType,
                                       string argDateTime)
        {
            string typedes = argType.ToString();
            int    total   = listViewData.Items.Count;

            for (int i = 0; i < total;)
            {
                if ((DataCacheType)(listViewData.Items[i].Tag) == argType &&
                    string.Equals(argKey, (string)listViewData.Items[i].Tag, StringComparison.Ordinal))
                {
                    AddLogInfo(string.Format(s_deleteDataFormat,
                                             argDateTime,
                                             (string)listViewData.Items[i].SubItems[1].Tag,
                                             typedes));
                    listViewData.Items.RemoveAt(i);
                    --total;
                }
                else
                {
                    ++i;
                }
            }
        }
Exemplo n.º 6
0
        private void UpdateData(string argkey,
                                string argValue,
                                DataCacheType type,
                                string argDatetimeStamp)
        {
            if (type == DataCacheType.None)
            {
                UpdateStatusPanel(argkey, argValue);
                RaiseNodeChangeEvent(argkey, argValue);
                return;
            }

            ListViewItem item = FindExistItem(argkey, listViewData);

            if (null != item)
            {
                UpdateData(item, argValue, argDatetimeStamp);
            }
            else
            {
                AddData(argkey,
                        argValue,
                        type,
                        argDatetimeStamp, listViewData);
            }

            //add by wjw to update the watchList
            ListViewItem itemWatch = FindExistItem(argkey, listViewWatch);

            if (null != itemWatch)
            {
                UpdateData(itemWatch, argValue, argDatetimeStamp);
            }
        }
Exemplo n.º 7
0
        private void HandleDataClear(DataCacheType argType,
                                     string argDateTime)
        {
            string typedes = argType.ToString();

            AddLogInfo(string.Format(s_clearDataFormat,
                                     argDateTime,
                                     typedes));

            int total = listViewData.Items.Count;

            for (int i = 0; i < total;)
            {
                if ((DataCacheType)(listViewData.Items[i].Tag) == argType)
                {
                    AddLogInfo(string.Format(s_deleteDataFormat,
                                             argDateTime,
                                             (string)listViewData.Items[i].SubItems[1].Tag,
                                             typedes));
                    listViewData.Items.RemoveAt(i);
                    --total;
                }
                else
                {
                    ++i;
                }
            }
        }
Exemplo n.º 8
0
 public void OnDataCacheClear(DataCacheType argType,
                              string argDateTimestamp)
 {
     this.BeginInvoke(m_dataClearHandler,
                      argType,
                      argDateTimestamp);
 }
Exemplo n.º 9
0
 public void OnDataDeleted(string argKey,
                           DataCacheType argType,
                           string argDateTimeStamp)
 {
     this.BeginInvoke(m_dataDeletedHandler,
                      argKey,
                      argType,
                      argDateTimeStamp);
 }
        //Clear
        public void Clear(DataCacheType type)
        {
            DataCache dc = GetDataCache(type.ToString());

            foreach (string regionName in dc.GetSystemRegions())
            {
                dc.ClearRegion(regionName);
            }
        }
        //Clear
        public void Clear(DataCacheType type, out List <string> keys)
        {
            keys = new List <string>();
            DataCache dc = GetDataCache(type.ToString());

            foreach (string regionName in dc.GetSystemRegions())
            {
                keys.AddRange(dc.GetObjectsInRegion(regionName).ToList().Select(a => a.Key));
                dc.ClearRegion(regionName);
            }
        }
Exemplo n.º 12
0
 public void OnDataChanged(string argkey,
                           string argValue,
                           DataCacheType type,
                           string argDatetimeStamp)
 {
     this.BeginInvoke(m_updateDataHandler,
                      argkey,
                      argValue,
                      type,
                      argDatetimeStamp);
 }
        private IEnumerable <DataCacheObject> GetAllCache(DataCacheType dct)
        {
            List <DataCacheObject> result = new List <DataCacheObject>();
            DataCache     dc = GetDataCache(dct.ToString());
            DataCacheItem dci;

            foreach (string region in dc.GetSystemRegions())
            {
                foreach (var obj in dc.GetObjectsInRegion(region))
                {
                    dci = dc.GetCacheItem(obj.Key);
                    result.Add(new DataCacheObject(dct, region, obj.Key, null, (int)dci.Timeout.TotalSeconds, dci.Value));
                }
            }
            return(result);
        }
Exemplo n.º 14
0
        private void addToWatchListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listViewData.SelectedItems.Count < 1)
            {
                return;
            }
            ListViewItem  lv    = listViewData.SelectedItems[0];
            DataCacheType type  = (DataCacheType)(lv.Tag);
            string        key   = lv.SubItems[1].Text;
            string        value = lv.SubItems[2].Text;
            ListViewItem  lvi   = FindExistItem(key, listViewWatch);

            if (lvi == null)
            {
                AddData(key, value, type, DateTime.Now.ToString(), listViewWatch);
            }
        }
Exemplo n.º 15
0
        private void AddData(string argkey,
                             string argValue,
                             DataCacheType type,
                             string argDatetimeStamp,
                             ListView lv)
        {
            ListViewItem item = lv.Items.Add(type.ToString());

            ListViewItem.ListViewSubItem keyItem = item.SubItems.Add(argkey);
            keyItem.Tag = argkey;
            ListViewItem.ListViewSubItem valueItem = item.SubItems.Add(argValue);
            item.Tag       = type;
            item.ForeColor = QueryColorByDataCacheType(type);

            //log
            AddLogInfo(string.Format(s_AddDataFormat,
                                     argDatetimeStamp,
                                     argkey,
                                     argValue));
        }
        public override void Read(BlamLib.IO.EndianReader s)
        {
            DataCacheFile cache = s.Owner as DataCacheFile;

            type = (DataCacheType)s.ReadInt32();
            tagNamesTableOffset     = s.ReadInt32();
            tagInstancesTableOffset = s.ReadInt32();
            tagCount = s.ReadInt32();
            items    = new DataItem[tagCount];

            TagInterface.TagGroup tgroup = null;
            switch (type)
            {
            case DataCacheType.Bitmap: tgroup = TagGroups.bitm; break;

            case DataCacheType.Sound: tgroup = TagGroups.snd_; break;

            case DataCacheType.Loc:
                break;
            }

            s.Seek(TagNamesTableOffset, System.IO.SeekOrigin.Begin);
            DataItem item = null;

            for (int x = 0; x < TagCount; x++)
            {
                item               = new DataItem();
                items[x]           = item;
                item.GroupTag      = tgroup;
                item.ReferenceName = cache.References.AddOptimized(item.GroupTag, s.ReadCString());
            }

            s.Seek(tagInstancesTableOffset, System.IO.SeekOrigin.Begin);
            for (int x = 0; x < TagCount; x++)
            {
                items[x].Read(s);
            }
        }
Exemplo n.º 17
0
		public override void Read(BlamLib.IO.EndianReader s)
		{
			DataCacheFile cache = s.Owner as DataCacheFile;

			type = (DataCacheType)s.ReadInt32();
			tagNamesTableOffset = s.ReadInt32();
			tagInstancesTableOffset = s.ReadInt32();
			tagCount = s.ReadInt32();
			items = new DataItem[tagCount];

			TagInterface.TagGroup tgroup = null;
			switch(type)
			{
				case DataCacheType.Bitmap: tgroup = TagGroups.bitm; break;
				case DataCacheType.Sound: tgroup = TagGroups.snd_; break;
				case DataCacheType.Loc:
					break;
			}

			s.Seek(TagNamesTableOffset, System.IO.SeekOrigin.Begin);
			DataItem item = null;
			for (int x = 0; x < TagCount; x++)
			{
				item = new DataItem();
				items[x] = item;
				item.GroupTag = tgroup;
				item.ReferenceName = cache.References.AddOptimized(item.GroupTag, s.ReadCString());
			}

			s.Seek(tagInstancesTableOffset, System.IO.SeekOrigin.Begin);
			for (int x = 0; x < TagCount; x++)
				items[x].Read(s);
		}
Exemplo n.º 18
0
 public DataCacheObject(DataCacheType type, string region, string method, object[] prms, int timetolive, object data)
     : this(type, region, method, prms, timetolive)
 {
     Data = data;
 }
Exemplo n.º 19
0
 public DataCacheObject(DataCacheType type, string region, string method, object[] prms, int timetolive)
     : this(type, region, method, prms)
 {
     CacheTime = timetolive;
 }
Exemplo n.º 20
0
 public DataCacheObject(DataCacheType type, string region, string method, object[] prms)
     : this(type, region, method)
 {
     Params = (prms != null) ? prms.ToArray() : null;
 }
Exemplo n.º 21
0
 public DataCacheObject(DataCacheType type, string region, string method)
 {
     Type = type;
       Region = region;
       Method = method;
 }
Exemplo n.º 22
0
 public DataCacheObject(DataCacheType type, string region, string method, object[] prms, int timetolive, object data)
     : this(type, region, method, prms, timetolive)
 {
     Data = data;
 }
Exemplo n.º 23
0
 private IEnumerable<DataCacheObject> GetAllCache(DataCacheType dct)
 {
   try
   {
     List<DataCacheObject> result = new List<DataCacheObject>();
     DataCache dc = GetDataCache(dct.ToString());
     DataCacheItem dci;
     foreach (string region in dc.GetSystemRegions())
     {
       foreach (var obj in dc.GetObjectsInRegion(region))
       {
         dci = dc.GetCacheItem(obj.Key, region);
         result.Add(new DataCacheObject(dct, region, obj.Key, null, (int)dci.Timeout.TotalSeconds, dci.Value));
       }
     }
     return result;
   }
   catch (Exception ex)
   {
     Logger.LogException(dct.ToString(), ex);
   }
   return null;
 }
Exemplo n.º 24
0
 public DataCacheObject(DataCacheType type, string region, string method, object[] prms) : this(type, region, method)
 {
     Params = (prms != null) ? prms.ToArray() : null;
 }
Exemplo n.º 25
0
 public DataCacheObject(DataCacheType type, string region, string method, object[] prms, int timetolive)
     : this(type, region, method, prms)
 {
     CacheTime = timetolive;
 }
Exemplo n.º 26
0
 public DataCacheObject(DataCacheType type, string region, string method)
 {
     Type   = type;
     Region = region;
     Method = method;
 }
 //Clear
 public void Clear(DataCacheType type, out List<string> keys)
 {
     keys = new List<string>();
       DataCache dc = GetDataCache(type.ToString());
       foreach (string regionName in dc.GetSystemRegions())
       {
     keys.AddRange(dc.GetObjectsInRegion(regionName).ToList().Select(a => a.Key));
     dc.ClearRegion(regionName);
       }
 }
 //Clear
 public void Clear(DataCacheType type)
 {
     DataCache dc = GetDataCache(type.ToString());
       foreach (string regionName in dc.GetSystemRegions())
     dc.ClearRegion(regionName);
 }
Exemplo n.º 29
0
 public void OnDataCacheClear(DataCacheType argType,
                              string argDateTimestamp)
 {
     m_main.OnDataCacheClear(argType, argDateTimestamp);
 }
Exemplo n.º 30
0
 public void OnDataDeleted(string argKey,
                           DataCacheType argType,
                           string argDateTimestamp)
 {
     m_main.OnDataDeleted(argKey, argType, argDateTimestamp);
 }