public override DeviceStateBase ChangeState() { System.Configuration.ConfigurationManager.RefreshSection("appSettings"); string LoadPath = string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["ScanJpgPath"]) ? "" : System.Configuration.ConfigurationManager.AppSettings["ScanJpgPath"]; if (LoadPath != string.Empty) { System.IO.DirectoryInfo DI = new System.IO.DirectoryInfo(LoadPath); if (DI.GetFiles("*.jpg").Count() != 0 && controller.ScannerAnalyzeResult != null) { var state = new ScanSuccessState(controller); state.ErrorsList = ErrorsList; state.ErrorMessage = ErrorMessage; return(state); } else { var HDDstateError = new ScanErrorState(controller); HDDstateError.ErrorsList = new List <Contracts.AnalyzeImageResultType>(); HDDstateError.ErrorsList.AddRange(ErrorsList); HDDstateError.ErrorMessage = ErrorMessage; return(HDDstateError); } } return(this); }
public override DeviceStateBase ChangeState() { if (controler.ScannerAnalyzeResult != null && controler.ScannerAnalyzeResult.IsSuccess()) { var state = new ScanSuccessState(controler); state.ErrorsList = ErrorsList; state.ErrorMessage = ErrorMessage; return(state); } if (controler.CanScan()) { var state = new ScanErrorState(controler); state.ErrorsList = ErrorsList; state.ErrorMessage = ErrorMessage; return(state); } else { var state = new ScanExceededAttemptsState(controler); state.ErrorsList = ErrorsList; state.ErrorMessage = ErrorMessage; return(state); } }