コード例 #1
0
        public bool isBatchEnd()
        {
            int i = 0;//控制一下,不去判断最后一个状态
            if (string.IsNullOrEmpty(_strStateFilePath))
            {
                return false;
            }
            if (_batchState == null)
            {
                _batchState = BatchState.Load(_strStateFilePath);
            }
            foreach (FileState fs in _batchState.FilesState)
            {
                i++;
                if (fs.State == FileState.Undone && i < _batchState.FilesState.Count)
                {
                    return false;
                }

            }
            return true;
        }
コード例 #2
0
 /// <summary>
 /// 如果手动的把一张图片移到proofer失败的情况,需要把其在BatchState.xml中的记录清楚
 /// 好像用不上,先留着,以后考虑
 /// </summary>
 /// <param name="strFileName">要删除的文件名,.csv的,或者没有扩展名</param>
 /// <returns></returns>
 public bool deleteOneFile(string strFileName)
 {
     if (string.IsNullOrEmpty(_strStateFilePath))
     {
         return false;
     }
     if (_batchState == null)
     {
         _batchState = BatchState.Load(_strStateFilePath);
     }
     foreach (FileState fs in _batchState.FilesState)
     {
         if (fs.FilePath.Contains(strFileName))
         {
             _batchState.FilesState.Remove(fs);
             _batchState.Save(_strStateFilePath);
             return true;
         }
     }
     return false;
 }
コード例 #3
0
 public int GetFileState(string strFilePath)
 {
     strFilePath = Path.GetFullPath(strFilePath);
     strFilePath = strFilePath.Replace(".ocr.", ".");
     _batchState = BatchState.Load(_strStateFilePath);
     if (_batchState.FilesState.Count <= 0)
     {
         return -1;
     }
     foreach (FileState fs in _batchState.FilesState)
     {
         if (fs.FilePath.ToUpper().Equals(strFilePath.ToUpper()))
         {
             return fs.State;
         }
     }
     return -1;
 }
コード例 #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="strDir"></param>
        /// <param name="nReBatch">重新加载一遍当前文件夹中的图像文件文件,原来记录清空</param>
        public BatchEngine(string strDir, bool nReBatch)
        {
            ArrayList fileList = new ArrayList();
            _strStateFilePath = strDir + "\\BatchState.xml";
            fileList = DirectoryReader.GetFiles(strDir, DataEntryForm.strImageConfig, false);

            if (nReBatch)
            {
                if (File.Exists(_strStateFilePath))
                {
                    try
                    {
                        File.Delete(_strStateFilePath);
                    }
                    catch (System.Exception ex)
                    {
                        Console.WriteLine(_strStateFilePath + ": is opened by another program.");
                    }

                    _batchState = new BatchState();
                    foreach (string s in fileList)
                    {
                        FileState fs = new FileState();
                        fs.FilePath = s;
                        fs.State = FileState.Undone;
                        _batchState.FilesState.Add(fs);
                    }

                    _batchState.Save(_strStateFilePath);
                }
            }
            else
            {
                if (fileList.Count <= 0)
                {
                    return;
                }
                else if (File.Exists(_strStateFilePath))
                {
                    _batchState = BatchState.Load(_strStateFilePath);
                }
                else
                {
                    _batchState = new BatchState();
                    foreach (string s in fileList)
                    {
                        FileState fs = new FileState();
                        fs.FilePath = s;
                        fs.State = FileState.Undone;
                        _batchState.FilesState.Add(fs);
                    }

                    _batchState.Save(_strStateFilePath);
                }
            }
        }