Ejemplo n.º 1
0
 public WebEndPoint_DocTypes(DocTypesMatcher docTypesMatcher)
 {
     _docTypesMatcher = docTypesMatcher;
     Action = DocTypes;
     Name = "doctypes";
     Description = "doctypes actions";
 }
Ejemplo n.º 2
0
        //        private ObservableCollection<SubstText> pathSubstObs = new ObservableCollection<SubstTexts>();
        public PathSubstView(DocTypesMatcher docTypesMatcher)
        {
            InitializeComponent();
            _docTypesMatcher = docTypesMatcher;

            PopulateGrid();

            SetInitialFieldEnables();
        }
Ejemplo n.º 3
0
 public QuickNewDocType(ScanDocHandler scanDocHandler, DocTypesMatcher docTypesMatcher, string curDocUniqName, int curDocPageNum)
 {
     InitializeComponent();
     _scanDocHandler = scanDocHandler;
     _docTypesMatcher = docTypesMatcher;
     _curDocPageNum = curDocPageNum;
     _curDocUniqName = curDocUniqName;
     txtDocTypeName.Focus();
 }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        public ScanDocHandler(ReportStatus reportStatusFn, DocTypesMatcher docTypesMatcher, ScanDocHandlerConfig scanConfig, string dbConnectionStr)
        {
            // Setup
            _reportStatusFn = reportStatusFn;
            _docTypesMatcher = docTypesMatcher;
            _scanConfig = scanConfig;

            // Init db
            InitDatabase(dbConnectionStr);

            // Create info cache etc
            _scanDocInfoCache = new ScanDocInfoCache(this);
            _scanDocLikelyDocType = new ScanDocLikelyDocType(this, _docTypesMatcher);

            // Init the background worker used for processing docs
            _fileProcessBkgndWorker.WorkerSupportsCancellation = true;
            _fileProcessBkgndWorker.WorkerReportsProgress = true;
            _fileProcessBkgndWorker.DoWork += new DoWorkEventHandler(FileProcessDoWork);
            _fileProcessBkgndWorker.ProgressChanged += new ProgressChangedEventHandler(FileProcessProgressChanged);
            _fileProcessBkgndWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(FileProcessRunWorkerCompleted);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 9
0
        // Test code
        public static void AddOldDocTypes(string filename, DocTypesMatcher docTypesMatcher)
        {
            ScanMan.OldXmlRulesManager xmlRulesManager = new ScanMan.OldXmlRulesManager(filename);
            List<ScanMan.OldXmlRulesManager.DocType> oldDocTypeList = xmlRulesManager.GetAllDocTypes();

            // Handle match expression
            foreach (ScanMan.OldXmlRulesManager.DocType oldDocType in oldDocTypeList)
            {
                DocType newDocType = new DocType();
                newDocType.docTypeName = oldDocType.dtName;
                if (oldDocType.goodStrings.Count > 0)
                {
                    newDocType.matchExpression = "";
                    foreach (ScanMan.OldXmlRulesManager.CheckItem chkItem in oldDocType.goodStrings)
                    {
                        if (newDocType.matchExpression != "")
                            newDocType.matchExpression += " & ";
                        chkItem.checkString = chkItem.checkString.Replace(",", "&");
                        if (chkItem.checkString.Contains('|'))
                            newDocType.matchExpression += "( " + chkItem.checkString + " )";
                        else
                            newDocType.matchExpression += chkItem.checkString;
                    }
                }
                string notStr = "";
                if (oldDocType.badStrings.Count > 0)
                {
                    notStr = "( ";
                    foreach (ScanMan.OldXmlRulesManager.CheckItem chkItem in oldDocType.badStrings)
                    {
                        if (notStr != "( ")
                            notStr += " & ";
                        chkItem.checkString = chkItem.checkString.Replace(",", "&");
                        if (chkItem.checkString.Contains('|'))
                            notStr += "( " + chkItem.checkString + " )";
                        else
                            notStr += chkItem.checkString;
                    }
                    notStr += " )";
                }
                if (notStr != "")
                    newDocType.matchExpression = "( " + newDocType.matchExpression + " ) & !" + notStr;

                // Handle thumbnail
                if (oldDocType.thumbFileNames.Count > 0)
                {
                    string thumbFile = oldDocType.thumbFileNames[0].Replace('\\', '/');
                    if (File.Exists(thumbFile))
                    {
                        DateTime fileDateTime = File.GetCreationTime(thumbFile);
                        string uniqName = ScanDocInfo.GetUniqNameForFile(thumbFile, fileDateTime);
                        newDocType.thumbnailForDocType = uniqName;
                    }
                    else
                    {
                        newDocType.thumbnailForDocType = "";
                    }
                }
                else
                {
                    newDocType.thumbnailForDocType = "";
                }

                // Handle paths
                string newPath = oldDocType.moveTo;
                newDocType.moveFileToPath = docTypesMatcher.ComputeMinimalPath(newPath);

                // Handle rename
                string newName = oldDocType.renameTo;
                newDocType.renameFileTo = newName;

                // Update DB
                if (!docTypesMatcher.AddOrUpdateDocTypeRecInDb(newDocType))
                    logger.Info("Failed to add doc type record {0}", newDocType.docTypeName);
            }

            logger.Info("Finished loading legacy doc types");
        }
Ejemplo n.º 10
0
 public static void ReplaceDocTypeThumbnailStrs(DocTypesMatcher docTypesMatcher)
 {
     foreach (DocType dt in docTypesMatcher.ListDocTypes())
     {
         if (dt.thumbnailForDocType != "")
         {
             DateTime fileDateTime = File.GetCreationTime(dt.thumbnailForDocType);
             string uniqName = ScanDocInfo.GetUniqNameForFile(dt.thumbnailForDocType, fileDateTime);
             dt.thumbnailForDocType = uniqName;
             if (!docTypesMatcher.AddOrUpdateDocTypeRecInDb(dt))
                 logger.Info("Failed to update doc type record {0}", dt.docTypeName);
         }
     }
 }
Ejemplo n.º 11
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();  */
        }