예제 #1
0
        public ValidationResult IsFormulaValid(
            string formula,
            ThresholdLevel level,
            ThresholdOperatorEnum thresholdOperator)
        {
            if (this.get_Log().get_IsDebugEnabled())
            {
                this.get_Log().DebugFormat("Validating formula: {0} ...", (object)formula);
            }
            ValidationResult validationResult;

            try
            {
                validationResult = this._preProcessor.PreValidateFormula(formula, level, thresholdOperator);
                if (validationResult.get_IsValid())
                {
                    formula         = this._preProcessor.PreProcessFormula(formula, level, thresholdOperator);
                    this._variables = CoreThresholdProcessor.CreateVariables(CoreThresholdProcessor.CreateDefaultBaselineValues());
                    this.TryParse(formula, true);
                    validationResult = ValidationResult.CreateValid();
                }
            }
            catch (InvalidInputException ex)
            {
                validationResult = !ex.get_HasError() ? new ValidationResult(false, ((Exception)ex).Message) : new ValidationResult(false, (IEnumerable <string>)((IEnumerable <ExprEvalErrorDescription>)ex.get_Errors()).Select <ExprEvalErrorDescription, string>((Func <ExprEvalErrorDescription, string>)(er => CoreThresholdProcessor.GetErrorMessage(er))).ToArray <string>());
            }
            catch (Exception ex)
            {
                this.get_Log().Error((object)string.Format("Unexpected error when validating formula: {0} ", (object)formula), ex);
                validationResult = new ValidationResult(false, ex.Message);
            }
            return(validationResult);
        }
예제 #2
0
 // Token: 0x060004C5 RID: 1221 RVA: 0x0001E130 File Offset: 0x0001C330
 public ValidationResult PreValidateFormula(string formula, ThresholdLevel level, ThresholdOperatorEnum thresholdOperator)
 {
     if (string.IsNullOrEmpty(formula))
     {
         return(new ValidationResult(false, string.Format(Resources.LIBCODE_PC0_01, Array.Empty <object>())));
     }
     if (this.IsUseBaselineMacro(formula))
     {
         if (thresholdOperator == ThresholdOperatorEnum.Equal || thresholdOperator == ThresholdOperatorEnum.NotEqual)
         {
             return(new ValidationResult(false, string.Format(Resources.LIBCODE_ZT0_11, formula)));
         }
     }
     else
     {
         if (this.ContainsMacro(BusinessLayerSettings.Instance.ThresholdsUseBaselineCalculationMacro, formula))
         {
             return(new ValidationResult(false, string.Format(Resources.LIBCODE_ZT0_17, BusinessLayerSettings.Instance.ThresholdsUseBaselineCalculationMacro)));
         }
         if (this.ContainsMacro(BusinessLayerSettings.Instance.ThresholdsUseBaselineWarningCalculationMacro, formula))
         {
             return(new ValidationResult(false, string.Format(Resources.LIBCODE_ZT0_17, BusinessLayerSettings.Instance.ThresholdsUseBaselineWarningCalculationMacro)));
         }
         if (this.ContainsMacro(BusinessLayerSettings.Instance.ThresholdsUseBaselineCriticalCalculationMacro, formula))
         {
             return(new ValidationResult(false, string.Format(Resources.LIBCODE_ZT0_17, BusinessLayerSettings.Instance.ThresholdsUseBaselineCriticalCalculationMacro)));
         }
     }
     return(ValidationResult.CreateValid());
 }
예제 #3
0
 public void LogMessage(DateTime date, ThresholdLevel level, string message)
 {
     foreach (var appender in this.Appenders)
     {
         appender.Append(date, level, message);
     }
 }
예제 #4
0
 // Token: 0x060004C4 RID: 1220 RVA: 0x0001E0A4 File Offset: 0x0001C2A4
 public string PreProcessFormula(string formula, ThresholdLevel level, ThresholdOperatorEnum thresholdOperator)
 {
     if (string.IsNullOrEmpty(formula))
     {
         return(formula);
     }
     if (!this.IsUseBaselineMacro(formula))
     {
         return(formula);
     }
     if (this.IsMacro(BusinessLayerSettings.Instance.ThresholdsUseBaselineCriticalCalculationMacro, formula))
     {
         level = ThresholdLevel.Critical;
     }
     if (this.IsMacro(BusinessLayerSettings.Instance.ThresholdsUseBaselineWarningCalculationMacro, formula))
     {
         level = ThresholdLevel.Warning;
     }
     if (CoreThresholdPreProcessor.IsGreaterOperator(thresholdOperator))
     {
         if (level != ThresholdLevel.Critical)
         {
             return(BusinessLayerSettings.Instance.ThresholdsDefaultWarningFormulaForGreater);
         }
         return(BusinessLayerSettings.Instance.ThresholdsDefaultCriticalFormulaForGreater);
     }
     else
     {
         if (level != ThresholdLevel.Critical)
         {
             return(BusinessLayerSettings.Instance.ThresholdsDefaultWarningFormulaForLess);
         }
         return(BusinessLayerSettings.Instance.ThresholdsDefaultCriticalFormulaForLess);
     }
 }
예제 #5
0
 /// <summary>
 /// Handling user voice threshold exceeded
 /// </summary>
 /// <param name="voiceLevel"></param>
 void OnUserVoiceThresholdExceeded(ThresholdLevel voiceLevel)
 {
     foreach (ObjectTrigger voiceObjTrigger in voiceActionObjs)
     {
         if (voiceObjTrigger.actionTrigger.details == voiceLevel.ToString())
         {
             voiceObjTrigger.holdingTime += Time.deltaTime;
             if (voiceObjTrigger.holdingTime >= voiceObjTrigger.holdingTimeThreshold && !voiceObjTrigger.isSolved)
             {
                 Debug.Log("Voice input action solved, nice");
                 voiceObjTrigger.isSolved = true;
                 StartCoroutine(voiceObjTrigger.TriggerAction(CompleteAction));
                 voiceObjTrigger.holdingTime = 0.0f;
                 VoiceAudioSource.PlayOneShot(VoiceAudioClip);
             }
         }
         else
         {
             if (!voiceObjTrigger.isSolved)
             {
                 voiceObjTrigger.holdingTime = 0;
                 TriggerFailAttempt();
             }
         }
     }
 }
예제 #6
0
        public override string Format(DateTime date, ThresholdLevel level, string message)
        {
            var builder = new StringBuilder();

            builder.Append($"{date} - {level} - {message}");

            return(builder.ToString());
        }
예제 #7
0
        public override void Append(DateTime date, ThresholdLevel level, string message)
        {
            base.Append(date, level, message);
            if (this.Level > level)
            {
                return;
            }

            var format = base.Layout.Format(date, level, message);

            Console.WriteLine(format);
        }
예제 #8
0
        public override string Format(DateTime date, ThresholdLevel level, string message)
        {
            var builder = new StringBuilder();

            builder.Append("<log>").AppendLine();
            builder.Append("    <date>").Append(date).Append("</date>").AppendLine();
            builder.Append("    <level>").Append(level).Append("</level>").AppendLine();
            builder.Append("    <message>").Append(message).Append("</message>").AppendLine();
            builder.Append("</log>").AppendLine();

            return(builder.ToString());
        }
 public string PreProcessFormula(
   string formula,
   ThresholdLevel level,
   ThresholdOperatorEnum thresholdOperator)
 {
   if (string.IsNullOrEmpty(formula) || !this.IsUseBaselineMacro(formula))
     return formula;
   if (this.IsMacro(BusinessLayerSettings.Instance.ThresholdsUseBaselineCriticalCalculationMacro, formula))
     level = (ThresholdLevel) 2;
   if (this.IsMacro(BusinessLayerSettings.Instance.ThresholdsUseBaselineWarningCalculationMacro, formula))
     level = (ThresholdLevel) 1;
   return CoreThresholdPreProcessor.IsGreaterOperator(thresholdOperator) ? (level != 2 ? BusinessLayerSettings.Instance.ThresholdsDefaultWarningFormulaForGreater : BusinessLayerSettings.Instance.ThresholdsDefaultCriticalFormulaForGreater) : (level != 2 ? BusinessLayerSettings.Instance.ThresholdsDefaultWarningFormulaForLess : BusinessLayerSettings.Instance.ThresholdsDefaultCriticalFormulaForLess);
 }
예제 #10
0
        /// <summary>
        /// Handling user Push (Acceleration)
        /// </summary>
        /// <param name="shakeThreshold"></param>
        void OnUserPush(ThresholdLevel shakeThreshold)
        {
            Vector2       shakeLoc   = gyroCam.pixelRect.center;
            GameObject    hitObj     = MobileInput.instance.CastRayHitFromCam(shakeLoc, gyroCam);
            ObjectTrigger objTrigger = TryGetObjectTrigger(hitObj);

            if (objTrigger != null)
            {
                PlayAudio(AssetManager.instance.push);

                TryTriggerInteraction(objTrigger, TriggerTypes.push);
            }
        }
예제 #11
0
        public override void Append(DateTime date, ThresholdLevel level, string message)
        {
            base.Append(date, level, message);

            if (this.Level > level)
            {
                return;
            }

            using (var fs = new StreamWriter(this.pathFile))
            {
                var format = base.Layout.Format(date, level, message);
                foreach (var letter in format)
                {
                    this.fileSize += letter;
                }

                fs.Write(format);
            }
        }
예제 #12
0
 public double ComputeThreshold(
     string formula,
     BaselineValues baselineValues,
     ThresholdLevel level,
     ThresholdOperatorEnum thresholdOperator)
 {
     if (this.get_Log().get_IsVerboseEnabled())
     {
         this.get_Log().VerboseFormat("Computing formula: {0}, values: [{1}]", new object[2]
         {
             (object)formula,
             (object)baselineValues
         });
     }
     if (string.IsNullOrEmpty(formula))
     {
         return(0.0);
     }
     try
     {
         formula         = this._preProcessor.PreProcessFormula(formula, level, thresholdOperator);
         this._variables = CoreThresholdProcessor.CreateVariables(baselineValues);
         return(this.EvaluateDynamic(formula, (IDictionary <string, Variable>) this._variables, (object)null));
     }
     catch (InvalidInputException ex)
     {
         string message = !ex.get_HasError() ? ((Exception)ex).Message : string.Join(" ", ((IEnumerable <ExprEvalErrorDescription>)ex.get_Errors()).Select <ExprEvalErrorDescription, string>(new Func <ExprEvalErrorDescription, string>(CoreThresholdProcessor.GetErrorMessage)).ToArray <string>());
         if (this.get_Log().get_IsInfoEnabled())
         {
             this.get_Log().Info((object)string.Format("Parsing error: {0} when evaluating formula: {1}, values: {2}", (object)message, (object)formula, (object)baselineValues), (Exception)ex);
         }
         throw new Exception(message, (Exception)ex);
     }
     catch (Exception ex)
     {
         this.get_Log().Error((object)string.Format("Unexpected error when evaluating formula: {0}, values: {1}", (object)formula, (object)baselineValues), ex);
         throw;
     }
 }
        // Token: 0x060004CE RID: 1230 RVA: 0x0001E2F0 File Offset: 0x0001C4F0
        public ValidationResult IsFormulaValid(string formula, ThresholdLevel level, ThresholdOperatorEnum thresholdOperator)
        {
            if (base.Log.IsDebugEnabled)
            {
                base.Log.DebugFormat("Validating formula: {0} ...", formula);
            }
            ValidationResult validationResult;

            try
            {
                validationResult = this._preProcessor.PreValidateFormula(formula, level, thresholdOperator);
                if (validationResult.IsValid)
                {
                    formula         = this._preProcessor.PreProcessFormula(formula, level, thresholdOperator);
                    this._variables = CoreThresholdProcessor.CreateVariables(CoreThresholdProcessor.CreateDefaultBaselineValues());
                    base.TryParse(formula, true);
                    validationResult = ValidationResult.CreateValid();
                }
            }
            catch (InvalidInputException ex)
            {
                if (ex.HasError)
                {
                    validationResult = new ValidationResult(false, (from er in ex.Errors
                                                                    select CoreThresholdProcessor.GetErrorMessage(er)).ToArray <string>());
                }
                else
                {
                    validationResult = new ValidationResult(false, ex.Message);
                }
            }
            catch (Exception ex2)
            {
                base.Log.Error(string.Format("Unexpected error when validating formula: {0} ", formula), ex2);
                validationResult = new ValidationResult(false, ex2.Message);
            }
            return(validationResult);
        }
 public ValidationResult PreValidateFormula(
   string formula,
   ThresholdLevel level,
   ThresholdOperatorEnum thresholdOperator)
 {
   if (string.IsNullOrEmpty(formula))
     return new ValidationResult(false, string.Format(Resources.get_LIBCODE_PC0_01()));
   if (this.IsUseBaselineMacro(formula))
   {
     if (thresholdOperator == 2 || thresholdOperator == 5)
       return new ValidationResult(false, string.Format(Resources.get_LIBCODE_ZT0_11(), (object) formula));
   }
   else
   {
     if (this.ContainsMacro(BusinessLayerSettings.Instance.ThresholdsUseBaselineCalculationMacro, formula))
       return new ValidationResult(false, string.Format(Resources.get_LIBCODE_ZT0_17(), (object) BusinessLayerSettings.Instance.ThresholdsUseBaselineCalculationMacro));
     if (this.ContainsMacro(BusinessLayerSettings.Instance.ThresholdsUseBaselineWarningCalculationMacro, formula))
       return new ValidationResult(false, string.Format(Resources.get_LIBCODE_ZT0_17(), (object) BusinessLayerSettings.Instance.ThresholdsUseBaselineWarningCalculationMacro));
     if (this.ContainsMacro(BusinessLayerSettings.Instance.ThresholdsUseBaselineCriticalCalculationMacro, formula))
       return new ValidationResult(false, string.Format(Resources.get_LIBCODE_ZT0_17(), (object) BusinessLayerSettings.Instance.ThresholdsUseBaselineCriticalCalculationMacro));
   }
   return ValidationResult.CreateValid();
 }
예제 #15
0
 public virtual void Append(DateTime date, ThresholdLevel level, string message)
 {
     this.MessageCount++;
 }
예제 #16
0
 protected Appender(ILayout layout, ThresholdLevel level)
 {
     this.Layout = layout;
     this.Level  = level;
 }
        // Token: 0x060004CF RID: 1231 RVA: 0x0001E3F8 File Offset: 0x0001C5F8
        public double ComputeThreshold(string formula, BaselineValues baselineValues, ThresholdLevel level, ThresholdOperatorEnum thresholdOperator)
        {
            if (base.Log.IsVerboseEnabled)
            {
                base.Log.VerboseFormat("Computing formula: {0}, values: [{1}]", new object[]
                {
                    formula,
                    baselineValues
                });
            }
            if (string.IsNullOrEmpty(formula))
            {
                return(0.0);
            }
            double result;

            try
            {
                formula         = this._preProcessor.PreProcessFormula(formula, level, thresholdOperator);
                this._variables = CoreThresholdProcessor.CreateVariables(baselineValues);
                result          = base.EvaluateDynamic(formula, this._variables, null);
            }
            catch (InvalidInputException ex)
            {
                string text;
                if (ex.HasError)
                {
                    text = string.Join(" ", ex.Errors.Select(new Func <ExprEvalErrorDescription, string>(CoreThresholdProcessor.GetErrorMessage)).ToArray <string>());
                }
                else
                {
                    text = ex.Message;
                }
                if (base.Log.IsInfoEnabled)
                {
                    base.Log.Info(string.Format("Parsing error: {0} when evaluating formula: {1}, values: {2}", text, formula, baselineValues), ex);
                }
                throw new Exception(text, ex);
            }
            catch (Exception ex2)
            {
                base.Log.Error(string.Format("Unexpected error when evaluating formula: {0}, values: {1}", formula, baselineValues), ex2);
                throw;
            }
            return(result);
        }
예제 #18
0
 public FileAppender(ILayout layout, ThresholdLevel level, string path)
     : base(layout, level)
 {
     this.pathFile = path;
 }
예제 #19
0
 public FileAppender(ILayout layout, ThresholdLevel level)
     : base(layout, level)
 {
     this.pathFile = DefaultPathFile;
 }
예제 #20
0
 public abstract string Format(DateTime date, ThresholdLevel level, string message);
예제 #21
0
 public ConsoleAppender(ILayout layout, ThresholdLevel level)
     : base(layout, level)
 {
 }