コード例 #1
0
 public WebEndPoint_ScanDocs(ScanDocHandler scanDocHandler)
 {
     _scanDocHandler = scanDocHandler;
     Action = ScanDocs;
     Name = "scandocs";
     Description = "scandocs actions";
 }
コード例 #2
0
 public QuickNewDocType(ScanDocHandler scanDocHandler, DocTypesMatcher docTypesMatcher, string curDocUniqName, int curDocPageNum)
 {
     InitializeComponent();
     _scanDocHandler = scanDocHandler;
     _docTypesMatcher = docTypesMatcher;
     _curDocPageNum = curDocPageNum;
     _curDocUniqName = curDocUniqName;
     txtDocTypeName.Focus();
 }
コード例 #3
0
        public ScanDocInfoCache(ScanDocHandler scanDocHandler)
        {
            _scanDocHandler = scanDocHandler;

            // List update thread
            _bwUnfiledListUpdateThread = new BackgroundWorker();
            _bwUnfiledListUpdateThread.DoWork += new DoWorkEventHandler(UnfiledListUpdateThread_DoWork);

            // Run background thread to get unfiled list
            _bwUnfiledListUpdateThread.RunWorkerAsync();
        }
コード例 #4
0
        public ScanFileMonitor(ReportStatus reportStatusFn, ScanDocHandler scanDocHandler)
        {
            _reportStatusFn = reportStatusFn;
            _scanDocHandler = scanDocHandler;

            // Monitor thread
            _bwFileMonitorThread = new BackgroundWorker();
            _bwFileMonitorThread.WorkerSupportsCancellation = true;
            _bwFileMonitorThread.WorkerReportsProgress = true;
            _bwFileMonitorThread.DoWork += new DoWorkEventHandler(FileMonitorThread_DoWork);
        }
コード例 #5
0
        public ScanDocLikelyDocType(ScanDocHandler scanDocHandler, DocTypesMatcher docTypesMatcher)
        {
            _scanDocHandler = scanDocHandler;
            _docTypesMatcher = docTypesMatcher;

            // List update thread
            _bwDocTypeListUpdateThread = new BackgroundWorker();
            _bwDocTypeListUpdateThread.DoWork += new DoWorkEventHandler(DocTypeListUpdateThread_DoWork);

            // Run background thread to get unfiled list
            _bwDocTypeListUpdateThread.RunWorkerAsync();
        }
コード例 #6
0
        public AuditView(ScanDocHandler scanDocHandler, DocTypesMatcher docTypesMatcher)
        {
            InitializeComponent();
            _scanDocHandler = scanDocHandler;
            _docTypesMatcher = docTypesMatcher;

            // List view for comparisons
            auditListView.ItemsSource = _auditDataColl;

            // Populate list thread
            _bwThreadForPopulateList = new BackgroundWorker();
            _bwThreadForPopulateList.WorkerSupportsCancellation = true;
            _bwThreadForPopulateList.WorkerReportsProgress = true;
            _bwThreadForPopulateList.DoWork += new DoWorkEventHandler(PopulateList_DoWork);
            _bwThreadForPopulateList.ProgressChanged += new ProgressChangedEventHandler(PopulateList_ProgressChanged);
            _bwThreadForPopulateList.RunWorkerCompleted += new RunWorkerCompletedEventHandler(PopulateList_RunWorkerCompleted);
        }
コード例 #7
0
        public DocFilingView(ScanDocHandler scanDocHandler, DocTypesMatcher docTypesMatcher)
        {
            InitializeComponent();
            _scanDocHandler = scanDocHandler;
            _docTypesMatcher = docTypesMatcher;
            popupDocTypePickerThumbs.ItemsSource = _thumbnailsOfDocTypes;
            popupDocTypeResultList.ItemsSource = _listOfPossibleDocMatches;
            ShowDocToBeFiled(0);

            // Image filler thread
            _bwThreadForImagesPopup = new BackgroundWorker();
            _bwThreadForImagesPopup.WorkerSupportsCancellation = true;
            _bwThreadForImagesPopup.WorkerReportsProgress = true;
            _bwThreadForImagesPopup.DoWork += new DoWorkEventHandler(AddImages_DoWork);

            // Timer to display latest doc
            _timerForNewDocumentCheck = new System.Windows.Threading.DispatcherTimer();
            _timerForNewDocumentCheck.Tick += new EventHandler(NewDocumentTimer_Tick);
            _timerForNewDocumentCheck.Interval = new TimeSpan(0, 0, 2);
            _timerForNewDocumentCheck.Start();

            // Current document display thread
            _bwThreadForCurDocDisplay = new BackgroundWorker();
            _bwThreadForCurDocDisplay.WorkerSupportsCancellation = true;
            _bwThreadForCurDocDisplay.WorkerReportsProgress = false;
            _bwThreadForCurDocDisplay.DoWork += new DoWorkEventHandler(CurDocDisplay_DoWork);

            // DocType display thread
            _bwThreadForDocTypeDisplay = new BackgroundWorker();
            _bwThreadForDocTypeDisplay.WorkerSupportsCancellation = true;
            _bwThreadForDocTypeDisplay.WorkerReportsProgress = false;
            _bwThreadForDocTypeDisplay.DoWork += new DoWorkEventHandler(DocTypeChanged_DoWork);

            // Use a background worker to populate
            _bwThreadForImagesPopup.RunWorkerAsync();

            // Use a background worker to populate
            _bwThreadForCurDocDisplay.RunWorkerAsync();
            _bwThreadForDocTypeDisplay.RunWorkerAsync();
        }
コード例 #8
0
        public DocTypeView(ScanDocHandler scanDocHandler, DocTypesMatcher docTypesMatcher)
        {
            InitializeComponent();
            _scanDocHandler = scanDocHandler;
            _docTypesMatcher = docTypesMatcher;

            // List view for comparisons
            listMatchResults.ItemsSource = _docCompareRslts;
            listMatchResults.Items.SortDescriptions.Add(new SortDescription("matchStatus", ListSortDirection.Ascending));

            // Location rectangle handler
            locRectHandler = new LocationRectangleHandler(exampleFileImage, docOverlayCanvas, tooltipCallback_MouseMove, tooptipCallback_MouseLeave, docRectChangesComplete);
            locRectHandler.SelectionEnable(false);

            // Matcher thread
            _bwThread = new BackgroundWorker();
            _bwThread.WorkerSupportsCancellation = true;
            _bwThread.WorkerReportsProgress = true;
            _bwThread.DoWork += new DoWorkEventHandler(FindMatchingDocs_DoWork);
            _bwThread.ProgressChanged += new ProgressChangedEventHandler(FindMatchingDocs_ProgressChanged);
            _bwThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(FindMatchingDocs_RunWorkerCompleted);
        }
コード例 #9
0
        public static void LoadAuditFileToDb(string fileName, ScanDocHandler scanDocHandler)
        {
            bool TEST_ON_LOCAL_DATA = false;
            bool PROCESS_PDF_FILE = true;
            bool CREATE_RECORD_IN_DB = true;
            Dictionary<string, bool> uniqNamesTest = new Dictionary<string, bool>();

            // Read file
            using (StreamReader sr = new StreamReader(fileName))
            {
                while (sr.Peek() >= 0)
                {
                    string line = sr.ReadLine();
                    string[] fields = line.Split('\t');
                    if ((fields[6] != "OK") || ((fields[5] == "TEST") || (fields[5] == "DELETED")))
                        continue;
                    NewAuditData ad = new NewAuditData();
                    string uniqName = ScanDocInfo.GetUniqNameForFile(fields[4], fields[0]);
                    if (uniqNamesTest.ContainsKey(uniqName))
                    {
                        Console.WriteLine("File {0} UNIQNAME IS NOT UNIQUE", uniqName);
                        continue;
                    }
                    uniqNamesTest.Add(uniqName, true);
                    ad.ProcDateAndTime = fields[0];
                    ad.DocType = fields[1];
                    if (ad.DocType == "")
                    {
                        Console.WriteLine("File {0} BLANK DOC TYPE", uniqName);
                    }
                    ad.OrigFileName = fields[2];
                    ad.UniqName = uniqName;
                    ad.DestFile = fields[3];
                    ad.ArchiveFile = fields[4];
                    if (TEST_ON_LOCAL_DATA)
                        ad.ArchiveFile = ad.ArchiveFile.Replace(@"\\N7700PRO\Archive\ScanAdmin\ScanBackups\", @"C:\Users\Rob\Dropbox\20140227 Train\ScanBackups\");
                    ad.ProcMessage = fields[5];
                    ad.ProcStatus = fields[6];
                    ad.DestOk = File.Exists(ad.DestFile) ? "" : "NO";
                    bool arcvExists = File.Exists(ad.ArchiveFile);
                    if (!arcvExists)
                    {
                        Console.WriteLine("File {0} ARCHIVE FILE missing {1}", uniqName, ad.ArchiveFile);
                        continue;
                    }
                    ad.ArcvOk = arcvExists ? "" : "NO";

                    // Process file
                    if (PROCESS_PDF_FILE)
                    {
                        if (scanDocHandler.ProcessPdfFile(ad.ArchiveFile, uniqName, true, true, true, false, true, true))
                        {
                            // Create filed info record
                            if (CREATE_RECORD_IN_DB)
                            {
                                DateTime docDateFiled = DateTime.ParseExact(ad.ProcDateAndTime, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
                                FiledDocInfo fdi = new FiledDocInfo(ad.UniqName);
                                fdi.SetDocFilingInfo(ad.DocType, ad.DestFile.Replace('\\', '/'), docDateFiled, "", "", "", "", DateTime.MinValue, new TimeSpan(), "", "", "");
                                fdi.SetFiledAtInfo(true, docDateFiled, ad.ProcStatus + ", " + ad.ProcMessage, FiledDocInfo.DocFinalStatus.STATUS_FILED);
                                scanDocHandler.AddFiledDocRecToMongo(fdi);
                            }
                        }
                    }
                }
            }

            logger.Info("Finished loading from old log");

            //// Sort to find duplicates
            //bool sortIt = false;
            //if (sortIt)
            //{
            //    var sortedAd = from item in _auditDataColl
            //                   orderby item.UniqName
            //                   select item;

            //    string lastuniq = "";
            //    foreach (AuditData ad in sortedAd)
            //    {
            //        if (lastuniq == ad.UniqName)
            //        {
            //            Console.WriteLine("Duplicate name " + ad.UniqName);
            //        }
            //        lastuniq = ad.UniqName;
            //    }
            //}
            //// Check validity
            //for (int rowidx = 0; rowidx < auditListView.Items.Count; rowidx++)
            //{
            //    AuditData audData = (AuditData)(auditListView.Items[rowidx]);
            //    string destFile = audData.DestFile;
            //    if (File.Exists(destFile))
            //        auditListView.
            //}
        }
コード例 #10
0
        public MainWindow()
        {
            InitializeComponent();
            InitNotifyIcon();
            logger.Info("App Started");

            // Document matcher
            _docTypesMatcher = new DocTypesMatcher();
            if (!_docTypesMatcher.Setup(_dbConnectionStr))
            {
                MessageBoxButton btnMessageBox = MessageBoxButton.OK;
                MessageBoxImage icnMessageBox = MessageBoxImage.Error;
                MessageBoxResult rsltMessageBox = System.Windows.MessageBox.Show("Database may not be started - cannot continue", "Database problem", btnMessageBox, icnMessageBox);
                System.Windows.Application.Current.Shutdown();
                return;
            }

            // Scanned document handler
            _scanDocHandler = new ScanDocHandler(AddToStatusText, _docTypesMatcher, _scanDocHandlerConfig, _dbConnectionStr);

            // Scan folder watcher
            statusRunningMonitor.Content = "This PC is " + System.Environment.MachineName;
            if (Properties.Settings.Default.PCtoRunMonitorOn.Trim() == System.Environment.MachineName.Trim())
            {
                _scanFileMonitor = new ScanFileMonitor(AddToStatusText, _scanDocHandler);
                string[] foldersToMonitorArray = _foldersToMonitor.Split(';');
                List<string> foldersToMonitor = new List<string>();
                foreach (string folder in foldersToMonitorArray)
                {
                    try
                    {
                        if (System.IO.Directory.Exists(folder))
                        {
                            foldersToMonitor.Add(folder);
                            continue;
                        }
                    }
                    catch (Exception excp)
                    {
                        logger.Error("Watch folder {0} exception {1}", folder, excp);
                    }
                    AddToStatusText("Watch folder not found " + folder);
                }
                _scanFileMonitor.Start(foldersToMonitor, TEST_MODE);
                statusRunningMonitor.Content += " and is Running Folder Monitor";
            }

            // Start the web server
            /*            WebServer ws = new WebServer("http://localhost:8080");
            ws.RegisterEndPoint(new WebEndPoint_ScanDocs(_scanDocHandler));
            ws.RegisterEndPoint(new WebEndPoint_DocTypes(_docTypesMatcher));
            ws.Run();  */
        }