示例#1
0
        public Inference GetInference(int customerID, decimal monthlyPayment, bool isTryout, GetInferenceMode mode)
        {
            Log.Debug("Engine.GetInference({0}, {1}) started...", customerID, mode);

            Inference result = null;

            switch (mode)
            {
            case GetInferenceMode.CacheOnly:
                result = GetInference(customerID, Now, isTryout, monthlyPayment);
                break;

            case GetInferenceMode.DownloadIfOld:
                Inference           cachedInference = GetInference(customerID, Now, isTryout, monthlyPayment);
                ModuleConfiguration cfg             = Keeper.LoadModuleConfiguration();

                if (cachedInference.IsUpToDate(Now, cfg.CacheAcceptanceDays))
                {
                    Log.Debug(
                        "Engine.GetInference({0}, {1}): returning cached inference with ResponseID = {2}.",
                        customerID,
                        mode,
                        cachedInference.ResponseID
                        );

                    result = cachedInference;
                    break;
                }                                         // if

                goto case GetInferenceMode.ForceDownload; // !!! fall through !!!

            case GetInferenceMode.ForceDownload:
                result = DownloadAndSave(customerID, monthlyPayment, isTryout);
                break;

            default:
                throw new EngineAlert(
                          Log,
                          new ArgumentOutOfRangeException("mode"),
                          "Failed to get customer {0} inference at mode {1}.",
                          customerID,
                          mode
                          );
            }             // switch

            Log.Debug("Engine.GetInference({0}, {1}) complete.", customerID, mode);

            return(result);
        }         // GetInference (standard, by actual data)