コード例 #1
0
        private void FileWatchTimer_Tick(object state)
        {
            this.Stop();

            string pattern = "*.txt";

            List <FileInfo> files = new List <FileInfo>();

            PartyPokerParser.DiscoverHandHistoryFiles(this.WatchDirectory, pattern, files);

            List <FileInfo> changes = new List <FileInfo>();

            foreach (FileInfo file in files)
            {
                bool parseFile = false;

                DateTime create = file.CreationTime;
                DateTime write  = file.LastWriteTime;
                long     size   = file.Length;

                if (_fileSizes.ContainsKey(file.FullName))
                {
                    parseFile = size > _fileSizes[file.FullName];
                }
                else
                {
                    parseFile = create >= this.LastCheck;
                }

                _fileSizes[file.FullName] = file.Length;
                if (parseFile)
                {
                    changes.Add(file);
                }
            }

            if (changes.Count > 0)
            {
                foreach (FileInfo file in changes)
                {
                    FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Changed,
                                                                    file.DirectoryName, file.Name);
                    OnFileChanged(this, e);
                }
            }

            this.LastCheck = DateTime.Now;

            this.Start();
        }
コード例 #2
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            _store  = Data.SQLite.DataStore.Instance;
            _parser = new PartyPoker.PartyPokerParser(_store);
            _parser.HandImported += new EventHandler(parser_HandImported);

            string exe = Application.ExecutablePath;

            System.IO.FileInfo      exeInfo = new System.IO.FileInfo(exe);
            System.IO.DirectoryInfo dirInfo = exeInfo.Directory;
            string programDir = dirInfo.FullName;

            string appPath = System.IO.Path.Combine(programDir, "Http");
            int    port    = this.IISExpressPort;
            bool   sysTray = this.IISExpressSysTray;

            _iisExpress = new IISExpress(appPath, port, sysTray);

            string httpPath       = _iisExpress.Path;
            bool   httpPathExists = System.IO.Directory.Exists(httpPath);

            if (httpPathExists)
            {
                if (_iisExpress.IsRunning == false)
                {
                    this.StartIIS();
                }
            }
            else
            {
                Logger.Warn("Hand Analysis ASP.NET Applicaton not found at {0}", httpPath);
            }

            // Parse existing files
            this.DiscoverExistingFiles();

            this.UpdateStats();

            this.StartImport();

            _monitor              = new PartyPoker.HandHistoryMonitor(_parser.HandHistoryDir);
            _monitor.FileChanged += new FileSystemEventHandler(this._monitor_FileChanged);
            _monitor.Start();

            _statsRefreshTimer.Start();

            this.RefreshPlayers();
        }
コード例 #3
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            _store = Data.SQLite.DataStore.Instance;
            _parser = new PartyPoker.PartyPokerParser(_store);
            _parser.HandImported += new EventHandler(parser_HandImported);

            string exe = Application.ExecutablePath;
            System.IO.FileInfo exeInfo = new System.IO.FileInfo(exe);
            System.IO.DirectoryInfo dirInfo = exeInfo.Directory;
            string programDir = dirInfo.FullName;

            string appPath = System.IO.Path.Combine(programDir, "Http");
            int port = this.IISExpressPort;
            bool sysTray = this.IISExpressSysTray;
            _iisExpress = new IISExpress(appPath, port, sysTray);

            string httpPath = _iisExpress.Path;
            bool httpPathExists = System.IO.Directory.Exists(httpPath);

            if (httpPathExists)
            {
                if (_iisExpress.IsRunning == false)
                {
                    this.StartIIS();
                }
            }
            else
            {
                Logger.Warn("Hand Analysis ASP.NET Applicaton not found at {0}", httpPath);
            }

            // Parse existing files
            this.DiscoverExistingFiles();

            this.UpdateStats();

            this.StartImport();

            _monitor = new PartyPoker.HandHistoryMonitor(_parser.HandHistoryDir);
            _monitor.FileChanged += new FileSystemEventHandler(this._monitor_FileChanged);
            _monitor.Start();

            _statsRefreshTimer.Start();

            this.RefreshPlayers();
        }