public static void UpdatePermanentVariable(EpiInfo.Plugin.IVariable variable) { Configuration config = Configuration.GetNewInstance(); DataRow[] result = config.PermanentVariables.Select("Name='" + variable.Name + "'"); if (result.Length < 1) { config.PermanentVariables.AddPermanentVariableRow( variable.Name, variable.Expression ?? "", (int)variable.DataType, config.ParentRowPermanentVariables); } else if (result.Length == 1) { ((DataSets.Config.PermanentVariableRow)result[0]).DataValue = variable.Expression ?? ""; ((DataSets.Config.PermanentVariableRow)result[0]).DataType = (int)variable.DataType; } else { throw new ConfigurationException(ConfigurationException.ConfigurationIssue.ContentsInvalid, "Duplicate permanent variable rows encountered."); } Configuration.Save(config); }
/// <summary> /// peforms an assign rule by assigning an expression to a variable. return the variable that was assigned /// </summary> /// <returns>object</returns> public override object Execute() { object result = this.value.Execute(); EpiInfo.Plugin.IVariable var; //DataType dataType = DataType.Unknown; string dataValue = string.Empty; var = this.Context.CurrentScope.resolve(this.QualifiedId, this.Namespace); if (var != null) { if (var.VariableScope == EpiInfo.Plugin.VariableScope.DataSource) { //IVariable fieldVar = new DataSourceVariableRedefined(var.Name, var.DataType); //fieldVar.PromptText = var.PromptText; var.Expression = result.ToString(); //var.DataType = //this.Context.CurrentScope.undefine(var.Name); //this.Context.CurrentScope.define((EpiInfo.Plugin.IVariable) fieldVar); } else { if (result != null) { var.Expression = result.ToString(); } else { var.Expression = "Null"; } if (var.VariableScope == EpiInfo.Plugin.VariableScope.Permanent) { //Rule_Context.UpdatePermanentVariable(var); } } } else { if (result != null) { EpiInfo.Plugin.IVariable v = this.Context.CurrentScope.resolve(this.QualifiedId); if (result != null) { v.Expression = result.ToString(); } else { v.Expression = ""; } } } return(result); }
public bool TryGetVariable(string p, out EpiInfo.Plugin.IVariable var) { bool result = false; var = null; Epi.IVariable V = null; result = this.mContext.MemoryRegion.TryGetVariable(p, out V); var = (EpiInfo.Plugin.IVariable)V; return(result); }
public List <EpiInfo.Plugin.IVariable> GetVariablesInScope() { List <EpiInfo.Plugin.IVariable> result = new List <EpiInfo.Plugin.IVariable>(); foreach (Epi.IVariable var in this.mContext.MemoryRegion.GetVariablesInScope()) { EpiInfo.Plugin.IVariable temp = (EpiInfo.Plugin.IVariable)var; result.Add(temp); } return(result); }
public bool TryGetVariable(string p, out EpiInfo.Plugin.IVariable var) { bool result = false; var = null; var = this.currentScope.resolve(p); if (var != null) { result = true; } return(result); }
public List <EpiInfo.Plugin.IVariable> GetVariablesInScope(VariableScope scopeCombination) { List <EpiInfo.Plugin.IVariable> result = new List <EpiInfo.Plugin.IVariable>(); Epi.VariableType VT = (Epi.VariableType)scopeCombination; foreach (Epi.IVariable var in this.mContext.MemoryRegion.GetVariablesInScope(VT)) { EpiInfo.Plugin.IVariable temp = (EpiInfo.Plugin.IVariable)var; result.Add(temp); } return(result); }
public void OpenViewHandler(object sender, OpenViewEventArgs e) { if (this.mView.GetProject().CollectedData.TableExists(mView.TableName) == false) { this.mView.GetProject().CollectedData.CreateDataTableForView(mView, 1); } this.mView.MustRefreshFieldCollection = true; if (this.mView.IsRelatedView) { this.mView.ForeignKeyField.CurrentRecordValueString = this.ParentGlobalRecordId; } this.mCurrentPage = this.mView.Pages[0]; // access fields to be sure available in the checkcode Epi.Collections.FieldCollectionMaster Fields = this.mView.Fields; // push after_view onto stack this.AfterStack.Push(new KeyValuePair <EventActionEnum, StackCommand>(EventActionEnum.CloseView, new StackCommand(this.EpiInterpreter, "view", "after", ""))); // execute before_view //this.RunCheckCodeCommands(this.mView.CheckCodeVariableDefinitions); // will run the variable definitions and setup compiled context foreach (Field field in this.View.Fields) { if (field is IDataField) { EpiInfo.Plugin.IVariable definedVar = (EpiInfo.Plugin.IVariable)field; this.mEpiInterpreter.Context.DefineVariable(definedVar); } } this.RunCheckCodeCommands(this.mView.CheckCode); this.ExecuteCheckCode("view", "before", ""); this.recordCount = this.View.GetRecordCount(); }
public void DefineVariable(EpiInfo.Plugin.IVariable variable) { this.Context.MemoryRegion.DefineVariable((Epi.IVariable)variable); }
/// <summary> /// peforms the Define rule uses the MemoryRegion and this.Context.DataSet to hold variable definitions /// </summary> /// <returns>object</returns> public override object Execute() { try { EpiInfo.Plugin.IVariable var = null; var = Context.CurrentScope.Resolve(Identifier); if (var != null) { if (var.VariableScope != VariableScope.Permanent && var.VariableScope != VariableScope.Global) { this.Context.EnterCheckCodeInterface.Dialog("Duplicate variable: " + Identifier, "Define"); return(null); } if (var.VariableScope == VariableScope.Permanent) { return(var); } } string dataTypeName = VariableTypeIndicator.Trim().ToUpperInvariant(); EpiInfo.Plugin.DataType type = GetDataType(dataTypeName); string variableScope = Variable_Scope.Trim().ToUpperInvariant(); EpiInfo.Plugin.VariableScope vt = EpiInfo.Plugin.VariableScope.Standard; //if(variableScope.Equals("PERMANENT", StringComparison.OrdinalIgnoreCase)) //{ // vt = EpiInfo.Plugin.VariableScope.Permanent; //} //else if(variableScope.Equals("GLOBAL", StringComparison.OrdinalIgnoreCase)) //{ // vt = EpiInfo.Plugin.VariableScope.Global; //} //else //{ // vt = EpiInfo.Plugin.VariableScope.Standard; //} if (!string.IsNullOrEmpty(variableScope)) { vt = this.GetVariableScopeIdByName(variableScope); } string promptString = Define_Prompt.Trim().Replace("\"", string.Empty); if (!string.IsNullOrEmpty(promptString)) { promptString = promptString.Replace("(", string.Empty).Replace(")", string.Empty); promptString.Replace("\"", string.Empty); } var = new PluginVariable(Identifier, type, vt, null, promptString); //var.PromptText = promptString; //this.Context.MemoryRegion.DefineVariable(var); EpiInfo.Plugin.IVariable temp = (EpiInfo.Plugin.IVariable)var; this.Context.CurrentScope.Define(temp); return(var); } catch (Exception ex) { Epi.Diagnostics.Debugger.Break(); Epi.Diagnostics.Debugger.LogException(ex); throw ex; } }
public BuiltInTypeSymbol(EpiInfo.Plugin.IVariable pVariable) : base(pVariable.Name, pVariable.DataType) { }
public cSymbol(EpiInfo.Plugin.IVariable pVariable) { this.Name = pVariable.Name; this.Type = pVariable.DataType; }
public void DefineVariable(EpiInfo.Plugin.IVariable variable) { this.currentScope.define(variable); }