public override DeviceStateBase ChangeState()
        {
            if (controler.WebCamAnalyzeResult != null && controler.WebCamAnalyzeResult.IsSuccess())
            {
                var state = new WebCamSuccessState(controler);
                state.ErrorsList   = ErrorsList;
                state.ErrorMessage = ErrorMessage;
                return(state);
            }


            if (controler.CanCam())
            {
                var state = new WebCamErrorState(controler);
                state.ErrorsList.AddRange(ErrorsList);
                state.ErrorsList   = state.ErrorsList.Distinct().ToList();
                state.ErrorMessage = ErrorMessage;
                return(state);
            }
            else
            {
                var state = new WebCamExceededAttemptsState(controler);
                state.ErrorsList.AddRange(ErrorsList);
                state.ErrorsList   = state.ErrorsList.Distinct().ToList();
                state.ErrorMessage = ErrorMessage;
                return(state);
            }
        }
Exemplo n.º 2
0
        public override DeviceStateBase ChangeState()
        {
            if (controller.WebCamAnalyzeResult != null && controller.WebCamAnalyzeResult.IsSuccess())
            {
                var state = new WebCamSuccessState(controller);
                state.ErrorsList   = ErrorsList;
                state.ErrorMessage = ErrorMessage;
                return(state);
            }
            System.Configuration.ConfigurationManager.RefreshSection("appSettings");
            string LoadPath = string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["FolderForLoadingImages"]) ? "" : System.Configuration.ConfigurationManager.AppSettings["FolderForLoadingImages"];

            if (LoadPath != string.Empty)
            {
                System.IO.DirectoryInfo DI = new System.IO.DirectoryInfo(LoadPath);
                if (DI.GetFiles("*.jpg").Count() != 0)
                {
                    var state = new WebCamSuccessState(controller);
                    state.ErrorsList   = ErrorsList;
                    state.ErrorMessage = ErrorMessage;
                    return(state);
                }
                else
                {
                    var HDDstateError = new WebCamErrorState(controller);
                    HDDstateError.ErrorsList.AddRange(ErrorsList);
                    HDDstateError.ErrorsList   = HDDstateError.ErrorsList.Distinct().ToList();
                    HDDstateError.ErrorMessage = ErrorMessage;
                    return(HDDstateError);
                }
            }

            var stateError = new WebCamErrorState(controller);

            stateError.ErrorsList.AddRange(ErrorsList);
            stateError.ErrorsList   = stateError.ErrorsList.Distinct().ToList();
            stateError.ErrorMessage = ErrorMessage;
            return(stateError);

            //return this;
        }