예제 #1
0
파일: Audit.cs 프로젝트: ifidakov/trunk
 //-------------------------------------------------------------------------
 public Audit(string filePath, out Exception exception)
 {
     exception = null;
     var serializer = new SerializerHelper();
     var audit = serializer.GetAuditFromFile(filePath, out exception);
     if (audit != null)
     {
         this.fileName = audit.fileName;
         this.SHA1Hash = audit.SHA1Hash;
         this.type = audit.type;
         this.error = audit.error;
         this.dataFileName = audit.dataFileName;
         this.dataFileSHA1Hash = audit.dataFileSHA1Hash;
         this.sourceFilePath = audit.sourceFilePath;
         this.sourceFileName = audit.sourceFileName;
         this.sourceSHA1Hash = audit.sourceSHA1Hash;
         this.archiveFileName = audit.archiveFileName;
         this.sourcePage = audit.sourcePage;
     }
 }
예제 #2
0
파일: Audit.cs 프로젝트: ifidakov/trunk
 //-------------------------------------------------------------------------
 public void Save(string filePath)
 {
     var serializer = new SerializerHelper();
     serializer.SaveToFile(this, filePath, Encoding.ASCII);
 }
예제 #3
0
 //-------------------------------------------------------------------------
 private Batches GetAppConfig()
 {
     Exception ex;
     var serializer = new SerializerHelper();
     return serializer.GetBatchesFromFile(OcrAppConfig.AppConfigFileName, out ex);
 }
예제 #4
0
        public OcrAppConfig(string appConfigFileName)
        {
            if (!File.Exists(appConfigFileName))
            {
                CreateDefaultAppConfig();
                appConfigFileName = OcrAppConfig.AppConfigFileName;
                var Message = "Error in " + appConfigFileName + " This file does not exist. Default AppConfig was created.";
                log.LogMessage(Message);
            }

            this.appConfigDateTime = File.GetLastWriteTime(appConfigFileName).ToString();

            var serializer = new SerializerHelper();
            Batches currentAppConfig = serializer.GetBatchesFromFile(appConfigFileName, out exception);
            if (currentAppConfig == null)
            {
                log.LogMessage(exception);
                var Message = "Error in " + OcrAppConfig.AppConfigFileName + ". The program will be closed";
                log.LogMessage(Message);
                exception = new Exception("Error in " + OcrAppConfig.AppConfigFileName + "\r\n" + exception.Message + "\r\nThe program will be closed");
                return;
            }

            bool active = false;
            foreach (var item in currentAppConfig.batches)
            {
                if (!item.active)
                {
                    continue;
                }
                active = true;
                useStudentId = item.useStudentId;
                recQRCode = item.recQRCode;
                InputFolder = item.inPath;
                ManualInputFolder = item.manualInPath;
                ErrorFolder = item.outPathError;
                ManualErrorFolder = item.manualErrorsFolder;
                ConfigsFolder = item.configsFolder;
                ManualConfigsFolder = item.manuaConfigsFolder;
                ArchiveFolder = item.outPathArchive;
                ManualArchiveFolder = item.manualOutPathArchive;
                NotConfidentFolder = item.outPathNotConfident;
                ManualNotConfidentFolder = item.manualOutPathNotConfident;
                SuccessFolder = item.outPathSuccess;
                OutputFolder_Success = item.outputFolder_Success;
                ManualSuccessFolder = item.manualSuccessFolder;
                ManualNextProccessingFolder = item.manualNextProccessingFolder;
                DualControl = item.dual_control_bar_codes;
                AutoRunEditorOnError = item.autoRunEditorOnError;
                if (!string.IsNullOrEmpty(item.serverName))
                    ServerName = item.serverName;
                else
                    ServerName = Environment.MachineName;

                if (!string.IsNullOrEmpty(item.updateServerName))
                    UpdateServerName = item.updateServerName;

                if (!string.IsNullOrEmpty(item.outputMode))
                    OutputMode = item.outputMode;

                if (!string.IsNullOrEmpty(item.baseTempFolder))
                {
                    BaseTempFolder = item.baseTempFolder;
                    TempFolder = Path.Combine(BaseTempFolder, "Temp\\");
                    TempFramesFolder = Path.Combine(BaseTempFolder, "TempFrames\\");
                    TempEdFolder = Path.Combine(BaseTempFolder, "TempEd\\");
                    LogsFolder = Path.Combine(BaseTempFolder, "Logs\\");
                }

                SmartResize = (item.smartResize == true) ? true : false;
                DoNotProcess = (item.doNotProcess == true) ? true : false;

                RemoveEmptyScans = (item.removeEmptyScans == true) ? true : false;

                PercentConfidentText = (item.percent_confident_text != null) ? (double)item.percent_confident_text : PercentConfidentTextDefault;
                FontName = (String.IsNullOrEmpty(item.fontName)) ? FontNameDefault : item.fontName;
                SupportedExtensions = (String.IsNullOrEmpty(item.fileMask)) ? SupportedExtensionsDefault : item.fileMask;
                MoveToNextProccessingFolderOnSheetIdentifierError = (item.moveToNextProccessingFolderOnSheetIdentifierError == true) ? true : false;

                EmptyScanDarknessPercent = (item.emptyScanDarknessPercent != null) ? (double)item.emptyScanDarknessPercent : EmptyScanDarknessPercentDefault;
                EmptyScansFolder = (String.IsNullOrEmpty(item.emptyScansPath)) ? ErrorFolder : item.emptyScansPath;

                NotSupportedSheetFolder = (String.IsNullOrEmpty(item.notSupportedSheetPath)) ? ErrorFolder : item.notSupportedSheetPath;
                NotSupportedSheets = (!String.IsNullOrEmpty(item.notSupportedSheets))
                    ? Regex.Split(item.notSupportedSheets, "\\s+").ToList() : (!String.IsNullOrEmpty(NotSupportedSheetsDefault))
                        ? Regex.Split(NotSupportedSheetsDefault, "\\s+").ToList() : new List<string>();

                OutputFileValue = new Dictionary<int, string>();
                foreach (Batches.OutputFileValue itm in item.outputFileValues)
                {
                    OutputFileValue.Add(itm.position, itm.value.ToString());
                }
                SheetIdEnum = new Dictionary<int, string>();
                if (item.sheetIdEnum != null)
                {
                    foreach (Batches.SheetIdEnum itm in item.sheetIdEnum)
                    {
                        SheetIdEnum.Add(itm.position, itm.value);
                    }
                }
                //ManualProcessingFlag = new KeyValuePair<int, string>
                //    (item.manualProcessingFlag.position, item.manualProcessingFlag.value as string);

                if (configsFolderDefault != ConfigsFolder)
                    CopyConfigsFile(ConfigsFolder);
                if (configsFolderDefault != ManualConfigsFolder)
                    CopyConfigsFile(ManualConfigsFolder);
                break;
            }
            if (!active)
            {
                exception = new Exception("Active batches not found. The program will be closed.");
                log.LogMessage(exception);
                return;
            }

            this.AutoStart = currentAppConfig.autoStart;
            this.LogLength = currentAppConfig.logLength;
        }
예제 #5
0
        public Batches CreateDefaultAppConfig()
        {
            Batches batches = new Batches();
            batches.autoStart = AutoStartDefault;
            batches.logLength = LogLengthDefault;
            batches.email = new Batches.Email()
            {
                host = "//smtp.gmail.com",
                port = 587,
                from = "*****@*****.**",
                password = "******",
                emails = @"[email protected]
                        //[email protected]
                        //[email protected]",
                caption = "Bad answers sheet",
                message = "Test"
            };
            Batches.Batch[] b = new Batches.Batch[1];
            b[0] = new Batches.Batch
            {
                inPath = InputFolder,
                configsFolder = ConfigsFolder,
                outPathSuccess = SuccessFolder,
                outPathError = ErrorFolder,
                outPathNotConfident = NotConfidentFolder,
                outPathArchive = ArchiveFolder,
                manualInPath = ManualInputFolder,
                manualErrorsFolder = ManualErrorFolder,
                manualSuccessFolder = ManualSuccessFolder,
                manuaConfigsFolder = ManualConfigsFolder,
                manualOutPathArchive = ManualArchiveFolder,
                manualOutPathNotConfident = ManualNotConfidentFolder,
                manualNextProccessingFolder = ManualNextProccessingFolder,
                notSupportedSheetPath = NotSupportedSheetFolder,
                emptyScansPath = EmptyScansFolder,

                active = ActiveDefault,
                autoRunEditorOnError = AutoRunEditorOnErrorDefault,
                smartResize = SmartResizeDefault,
                dual_control_bar_codes = DualControlDefault,
                fileMask = SupportedExtensionsDefault,
                percent_confident_text = PercentConfidentTextDefault,
                fontName = FontNameDefault,

                notSupportedSheets = NotSupportedSheetsDefault,
                removeEmptyScans = RemoveEmptyScansDefault,
                emptyScanDarknessPercent = EmptyScanDarknessPercentDefault,
            };
            b[0].outputFileValues = new Batches.OutputFileValue[2];
            b[0].outputFileValues[0].position = 7;
            b[0].outputFileValues[0].value = "EDOCOCR";
            b[0].outputFileValues[1].position = 8;
            b[0].outputFileValues[1].value = 1;

            batches.batches = b;
            var serializer = new SerializerHelper();
            serializer.SaveToFile(batches, OcrAppConfig.AppConfigFileName, Encoding.Unicode);
            return batches;
        }
예제 #6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void restartToolStripMenuItem_Click(object sender, EventArgs e)
 {
     //запустить экзешник для рестарта редактора и
      //ProcessStartInfo psi = new ProcessStartInfo();
      //psi.Arguments =new string[1] { Application.ExecutablePath };
      //psi.FileName = "startApp.exe";
      //Process.Start(psi);
     try
     {
         log.LogMessage("Manual restart");
         SaveSettings();
         if (testUids.Test.Count > 0)
         {
             var serializer = new SerializerHelper();
             serializer.SaveToFile(testUids, Path.Combine(OcrAppConfigDefaults.BaseTempFolder, "testUids.json"), Encoding.Unicode);
         }
     }
     catch (Exception)
     {
     }
     Process.Start("startApp.exe", Application.ExecutablePath);// + " a b c"
     Environment.Exit(0);
     //try
     //{
     //    Application.Restart();
     //}
     //catch (Exception)
     //{
     //}
 }
예제 #7
0
 //-------------------------------------------------------------------------
 private void EditorForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     log.LogMessage("Closing");
     SaveSettings();
     ioHelper.ReDelete();
     var serializer = new SerializerHelper();
     serializer.SaveToFile(testUids, Path.Combine(OcrAppConfigDefaults.BaseTempFolder, "testUids.json"), Encoding.Unicode);
     if (ioHelper.ReDeleteList.Count > 0)
     {
         string message = "ioHelper.ReDeleteList.Count = " + ioHelper.ReDeleteList.Count;
         log.LogMessage(message);
         new ErrorRestart(KeyProgram.eDoctrinaOcrEd).SendErrorMail(message);
     }
 }