Esempio n. 1
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);
                }
            }
        }