public Polskaya(PolskaParams polskaParams, IDBInterfaceAdapter nameInterface, IFormulaArchivesPrecalculator formulaArchivesPrecalculator, Dictionary <string, Variable> variablesDict) { _polskaParams = polskaParams; NameInterface = nameInterface; _operationStack = new List <PolskayaVariable>(MemoryAllockStep_bytes); OutString = new List <PolskayaVariable>(); Expression = new StringBuilder(); _variablesDict = variablesDict; #region Ф-ии CreateFunction(new MinFunction()); CreateFunction(new MaxFunction()); CreateFunction(new SinFunction()); CreateFunction(new CosFunction()); CreateFunction(new PowFunction()); CreateFunction(new ExpFunction()); CreateFunction(new LogFunction()); CreateFunction(new IfFunction()); CreateFunction(new MacroIfFunction()); CreateFunction(new RoundFunction()); CreateFunction(new ValueStatusCodeContains()); CreateFunction(new ValueStatusCodeContainsAllAlarmStatuses()); #endregion // Добавляем возможность использовать пользовательский функции CreateFunction(new GetHalfHourIndex()); CreateFunction(new UserDefinedSQLFunction(nameInterface)); CreateFunction(new UserDefinedCSharpFunction()); CreateFunction(new GetHalfHourDateTime()); CreateFunction(new AbsFunction()); #region Добавление ф-ий которые требуют предварительной подгрузки данных _precalculatedFunctionDict = new Dictionary <string, PrecalculatedFunctionVariable>(); foreach (var precalculatedFormulasFunction in Enum.GetNames(typeof(EnumFormulasFunction)) .Select(s => (EnumFormulasFunction)Enum.Parse(typeof(EnumFormulasFunction), s)).Select( formulasFunction => formulasFunction.CreatePrecalculatedFormulasFunctionDescription(formulaArchivesPrecalculator))) { _precalculatedFunctionDict[precalculatedFormulasFunction.Id] = precalculatedFormulasFunction; } _precalculatedFunctionBooleanDict = new Dictionary <string, Function>(); var f = new IfEnabledFunction(); _precalculatedFunctionBooleanDict[f.id] = f; #endregion }
public UserDefinedSQLFunction(IDBInterfaceAdapter dbInterfaceAdapter) { _dbInterfaceAdapter = dbInterfaceAdapter; id = "ПользовательскаяФункцияSql"; FuncArgsCount = int.MaxValue; FuncDlgt = DoSql; //Создадим временную таблицу для результатов // _connection.Open(); // createTemporyResultTable(_connection, _tempTablePrefix); }
//string timeZoneId, bool isReadCalculatedValues, // DateTime dtServerStart, DateTime dtServerEnd, EnumDataSourceType? dataSourceType, public FormulaInterpreterDB(FORMULAS_EXPRESSIONS fExpr, IDBInterfaceAdapter nameInterface , InterpretatorParams interpretatorParams , IMyListConverters myListConverters, IGetNotWorkedPeriodService IGetNotWorkedPeriodService, IDateTimeExtensions dateTimeExtensions) { _fExpr = fExpr; InterpretatorParams = interpretatorParams; //this.SubFormulas = new System.Collections.Hashtable(); _recursionCallStack = new HashSet <string>(); _variablesDict = new Dictionary <string, Variable>(); //_variablesDict.Add("myVar", new Variable("myVar", 0, 1440, new TFormulaConstant() { ArchiveValues = new List<TVALUES_DB>() { new TVALUES_DB(VALUES_FLAG_DB.DataCorrect, 20010) } }, "1666")); _nameInterface = nameInterface; _dateTimeExtensions = dateTimeExtensions; _formulaArchivesPrecalculator = new FormulaArchivesPrecalculator(interpretatorParams.TimeZoneId , interpretatorParams.IsReadCalculatedValues, interpretatorParams.ServerStartDateTime, interpretatorParams.ServerEndDateTime , interpretatorParams.DataSourceType, myListConverters, IGetNotWorkedPeriodService, _dateTimeExtensions); }