コード例 #1
0
        private void WriteMarket()
        {
            ConcurrentDictionary <string, List <MarketData> > dicMarket = new ConcurrentDictionary <string, List <MarketData> >();
            const int MaxCacheCount     = 500;
            int       currentCacheCount = 0;

            while (true)
            {
                try
                {
                    //LogHelper.Instance.Info("1");
                    ZMessage msg;
                    if (marketWriteCache.Count > 0 && marketWriteCache.TryDequeue(out msg))
                    {
                        //LogHelper.Instance.Info("1");
                        if (msg == null || msg.Count != 2)
                        {
                            continue;
                        }
                        var marketItem = BaseCommon.DeserializeMessage <MarketData>(msg);
                        if (dicMarket.ContainsKey(marketItem.Code))
                        {
                            dicMarket[marketItem.Code].Add(marketItem);
                        }
                        else
                        {
                            dicMarket.TryAdd(marketItem.Code, new List <MarketData> {
                                marketItem
                            });
                        }
                        currentCacheCount = currentCacheCount + 1;
                        marketDt          = DateTime.Now;
                    }
                    else
                    {
                        Thread.Sleep(10);
                    }
                    TimeSpan marketPlus = DateTime.Now - marketDt;
                    if (dicMarket.Count > 0 && (currentCacheCount > MaxCacheCount || marketPlus.Minutes != 0 || marketPlus.Seconds > 30))
                    {
                        foreach (string code in dicMarket.Keys)
                        {
                            List <MarketData> lstMarket;
                            dicMarket.TryRemove(code, out lstMarket);
                            BaseCommon.WriteMarketTxt(code, lstMarket);
                        }
                    }
                }

                catch (System.Exception ex)
                {
                    LogHelper.Instance.Info("异常:" + ex.ToString());
                    continue;
                }
            }
        }
コード例 #2
0
        private void WriteTran()
        {
            ConcurrentDictionary <string, List <MarketTransaction> > dicTran = new ConcurrentDictionary <string, List <MarketTransaction> >();
            const int MaxCacheCount     = 500;
            int       currentCacheCount = 0;

            while (true)
            {
                try
                {
                    ZMessage msg;
                    if (tranWriteCache.Count > 0 && tranWriteCache.TryDequeue(out msg))
                    {
                        //LogHelper.Instance.Info("1");
                        if (msg == null || msg.Count != 2)
                        {
                            continue;
                        }
                        var tranItem = BaseCommon.DeserializeMessage <MarketTransaction>(msg);
                        if (dicTran.ContainsKey(tranItem.Code))
                        {
                            dicTran[tranItem.Code].Add(tranItem);
                        }
                        else
                        {
                            dicTran.TryAdd(tranItem.Code, new List <MarketTransaction> {
                                tranItem
                            });
                        }
                        currentCacheCount = currentCacheCount + 1;
                        tranDt            = DateTime.Now;
                    }
                    else
                    {
                        Thread.Sleep(10);
                    }
                    TimeSpan tranPlus = DateTime.Now - tranDt;
                    if (dicTran.Count > 0 && (currentCacheCount > MaxCacheCount || tranPlus.Minutes != 0 || tranPlus.Seconds > 30))
                    {
                        foreach (string code in dicTran.Keys)
                        {
                            List <MarketTransaction> lstTran;
                            dicTran.TryRemove(code, out lstTran);
                            BaseCommon.WriteTranTxt(code, lstTran);
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    LogHelper.Instance.Info("异常:" + ex.ToString());
                    continue;
                }
            }
        }
コード例 #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            // 将图片显示到控件
            string filepath = BaseCommon.SelectFile();

            if (String.IsNullOrEmpty(filepath))
            {
                return;
            }

            if (_imageOr != null)
            {
                _imageOr.Dispose();
            }
            _imageOr          = new Bitmap(filepath);
            pictureBox1.Image = new Bitmap(_imageOr, pictureBox1.Width, pictureBox1.Height);
        }
コード例 #4
0
        public BaseRenderer(BaseCommon common)
        {
            MenuConfig            = common.MenuConfig;
            ComboMenu             = MenuConfig.ComboMenu;
            WithMuteMenu          = MenuConfig.ComboMenu.WithMuteMenu;
            UnitComboMenu         = MenuConfig.UnitMenu.UnitComboMenu;
            UnitControlMenu       = MenuConfig.UnitMenu.UnitControlMenu;
            UnitFarmMenu          = MenuConfig.UnitMenu.UnitFarmMenu;
            SettingsMenu          = MenuConfig.SettingsMenu;
            DamageCalculationMenu = SettingsMenu.DrawingMenu.DamageCalculationMenu;
            TextPanelMenu         = common.MenuConfig.SettingsMenu.DrawingMenu.TextPanelMenu;

            TargetSelector = common.TargetSelector;

            PanelMove = new PanelMove(TextPanelMenu.Position.Value);

            if (!SettingsMenu.DisableDrawingItem)
            {
                RendererManager.TextureManager.LoadFromDivine(@"others\green_arrow.png");

                if (TextPanelMenu.ComboPanelItem)
                {
                    Size.Y += 60;
                }

                if (TextPanelMenu.UnitComboPanelItem)
                {
                    Size.Y += 90;
                }

                PanelMove.Size = Size;

                RendererManager.OnDraw += RendererOnDraw;
                Drawing.OnDraw         += OnDraw;

                TextPanelMenu.MoveItem.Changed += MoveChanged;
                PanelMove.ValueChanged         += PanelMoveChanged;

                TextPanelMenu.ComboPanelItem.Changed     += ComboPanelChanged;
                TextPanelMenu.UnitComboPanelItem.Changed += UnitComboPanelChanged;
            }

            SettingsMenu.DisableDrawingItem.Changed += DisableChanged;
        }
コード例 #5
0
        private void VideoImgSearch_Load(object sender, EventArgs e)
        {
            this.lstSearch.ThumbnailSize = new Size(130, 138);
            this.lstSearch.SetRenderer(new ImageListViewRenderers.XPRenderer());

            this.txtScore.Text    = _AlertScore.ToString();
            this.btnSearch.Click += delegate
            {
                if (m_searchCondition != null)
                {
                    m_searchCondition.Dispose();
                }

                Image searchImg = (Image)this.pictureBox1.Image.Clone();
                m_searchCondition = new SearchCondition("FaceTest", searchImg);

                this.lstSearch.SuspendLayout();
                this.lstSearch.Items.Clear();
                // Resume layout logic.
                this.lstSearch.ResumeLayout(true);

                int lret = SearchImage();
                if (lret == -1)
                {
                    MessageBox.Show("人脸图像搜索出现异常!", "提示");
                }
                else if (lret == -2)
                {
                    MessageBox.Show("人脸图像检测出现异常!", "提示");
                }
                else if (lret == -3)
                {
                    MessageBox.Show("人脸图像没有人脸!", "提示");
                }
                else if (lret == -4)
                {
                    MessageBox.Show("没有符合结果!", "提示");
                }
            };

            this.btnSelect.Click += delegate
            {
                string selFile = BaseCommon.SelectFile();
                if (string.IsNullOrEmpty(selFile))
                {
                    return;
                }

                if (this.pictureBox1.Image != null)
                {
                    this.pictureBox1.Image.Dispose();
                }

                Image img = Image.FromFile(selFile);
                this.pictureBox1.Image = img;
            };

            this.btnAddLibrary.Click += delegate
            {
                string number     = ConvertHelper.DateTimeToStamp().ToString();
                byte[] imgdisplay = ImageHelper.BitmapToByteArray(this.pictureBox1.Image);

                PersonManager frm = new PersonManager(imgdisplay, number);
                frm.ShowDialog();
            };
        }
コード例 #6
0
        public void StartWatch(string directoryPath)
        {
            if (m_bIsWatching)
            {
                return;
            }

            StartFileTask();

            m_bIsWatching    = true;
            m_Watcher        = new System.IO.FileSystemWatcher();
            m_Watcher.Filter = "*.*";
            m_Watcher.IncludeSubdirectories = true;
            if (!directoryPath.EndsWith("\\"))
            {
                m_Watcher.Path = directoryPath + "\\";
            }
            else
            {
                m_Watcher.Path = directoryPath;
            }

            m_Watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size
                                     | NotifyFilters.FileName | NotifyFilters.DirectoryName;
            m_Watcher.Changed            += new FileSystemEventHandler(WatcherOnChanged);
            m_Watcher.Created            += new FileSystemEventHandler(WatcherOnChanged);
            m_Watcher.Deleted            += new FileSystemEventHandler(WatcherOnChanged);
            m_Watcher.Renamed            += new RenamedEventHandler(WatcherOnRenamed);
            m_Watcher.EnableRaisingEvents = true;


            _taskDeleteOld = Task.Run(() =>
            {
                while (true)
                {
                    try
                    {
                        // 取消任务判断
                        if (_tokenDeleteOld.IsCancellationRequested)
                        {
                            break;
                        }

                        // select all file
                        List <string> waitfordel = new List <string>();
                        List <string> allfiles   = BaseCommon.GetDirectory(directoryPath);
                        if (allfiles != null && allfiles.Count > 0)
                        {
                            foreach (string sFile in allfiles)
                            {
                                if (File.Exists(sFile))
                                {
                                    FileInfo fi = new FileInfo(sFile);
                                    if (fi.CreationTime < DateTime.Today.AddDays(-2))
                                    {
                                        waitfordel.Add(sFile);
                                    }
                                }
                            }

                            // delete file
                            if (waitfordel != null && waitfordel.Count > 0)
                            {
                                foreach (string delfile in waitfordel)
                                {
                                    File.Delete(delfile);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Log4NetHelper.Instance.Error("删除FTP目录旧的文件数据错误:" + (ex.InnerException != null ? ex.InnerException.Message : ex.Message));
                    }

                    Thread.Sleep(2 * 60 * 60 * 1000);
                }
            }, _tokenDeleteOld.Token);
        }