Exemplo n.º 1
0
        public static OmaEventWithDuration ToOmaEventWithDuration(OmaReaderResult OmaReaderResult)
        {
            OmaEventWithDuration OmaEvent        = default;
            OmaParameter         leftDesignName  = default;
            OmaParameter         rightDesignName = default;

            switch (OmaReaderResult)
            {
            case OmaReaderDoubleResult OmaReaderDoubleResult:
                leftDesignName  = OmaReaderDoubleResult.Left.ContainsKey(OmaParameter.LDNAM) ? OmaParameter.LDNAM : OmaParameter.LNAM;
                rightDesignName = OmaReaderDoubleResult.Left.ContainsKey(OmaParameter.LDNAM) ? OmaParameter.LDNAM : OmaParameter.LNAM;
                OmaEvent        = new OmaEventWithDuration(OmaReaderDoubleResult.Left[OmaParameter.JOB], OmaReaderDoubleResult.Left[leftDesignName], OmaReaderDoubleResult.Right[rightDesignName], StringConverter.ExtractBoolValue(OmaReaderDoubleResult.Left, OmaParameter._PRECALC), DateTime.Now);
                break;

            case OmaReaderLeftResult OmaReaderLeftResult:
                leftDesignName = OmaReaderLeftResult.Result.ContainsKey(OmaParameter.LDNAM) ? OmaParameter.LDNAM : OmaParameter.LNAM;
                OmaEvent       = new OmaEventWithDuration(OmaReaderLeftResult.Result[OmaParameter.JOB], OmaReaderLeftResult.Result[leftDesignName], default, StringConverter.ExtractBoolValue(OmaReaderLeftResult.Result, OmaParameter._PRECALC), DateTime.Now);
                break;

            case OmaReaderRightResult OmaReaderRightResult:
                rightDesignName = OmaReaderRightResult.Result.ContainsKey(OmaParameter.LDNAM) ? OmaParameter.LDNAM : OmaParameter.LNAM;
                OmaEvent        = new OmaEventWithDuration(OmaReaderRightResult.Result[OmaParameter.JOB], default, OmaReaderRightResult.Result[rightDesignName], StringConverter.ExtractBoolValue(OmaReaderRightResult.Result, OmaParameter._PRECALC), DateTime.Now);
                break;
            }
            return(OmaEvent);
        }
Exemplo n.º 2
0
 public static bool ExtractBoolValue(IDictionary <OmaParameter, string> parameters, OmaParameter parameter, bool defaultValue = false)
 {
     return(ExtractValue(parameters, parameter, value => "1".Equals(value), defaultValue));
 }
Exemplo n.º 3
0
 public static int ExtractIntValue(IDictionary <OmaParameter, string> parameters, OmaParameter parameter, int defaultValue = 0)
 {
     return(ExtractValue(parameters, parameter, value => int.Parse(value, CultureInfo.InvariantCulture), defaultValue));
 }
Exemplo n.º 4
0
 private static T ExtractValue <T>(IDictionary <OmaParameter, string> parameters, OmaParameter parameter, Func <string, T> parsingFunction, T defaultValue = default)
 {
     if (!parameters.ContainsKey(parameter) || string.Equals(parameters[parameter], "?"))
     {
         return(defaultValue);
     }
     else
     {
         try
         {
             return(parsingFunction.Invoke(parameters[parameter]));
         }
         catch (Exception e)
         {
             throw new Exception(parameter + ": " + e.Message, e);
         }
     }
 }
Exemplo n.º 5
0
 public static double ExtractDoubleValue(IDictionary <OmaParameter, string> parameters, OmaParameter parameter, double defaultValue = 0)
 {
     return(ExtractValue(parameters, parameter, value => double.Parse(value, CultureInfo.InvariantCulture), defaultValue));
 }