Exemple #1
0
        public EpiInfo.Plugin.IVariable Resolve(string pName, string pNamespace = null)
        {
            EpiInfo.Plugin.IVariable result = null;

            if (!string.IsNullOrEmpty(pNamespace) && (!string.IsNullOrEmpty(_name) && !_name.Equals(pNamespace, StringComparison.OrdinalIgnoreCase)))
            {
                if (_parent != null)
                {
                    result = _parent.Resolve(pName, pNamespace);
                }
            }
            else if (_symbolList.ContainsKey(pName))
            {
                result = _symbolList[pName];
            }
            else
            {
                if (_parent != null)
                {
                    result = _parent.Resolve(pName, pNamespace);
                }
            }

            return(result);
        }
Exemple #2
0
        public static Dictionary <string, string> GetContextDetailList(Epi.Core.EnterInterpreter.EnterRule FunctionObject)
        {
            Dictionary <string, string> ContextDetailList = new Dictionary <string, string>();


            if (FunctionObject != null && !FunctionObject.IsNull())
            {
                foreach (KeyValuePair <string, EpiInfo.Plugin.IVariable> kvp in FunctionObject.Context.CurrentScope.SymbolList)
                {
                    EpiInfo.Plugin.IVariable field = kvp.Value;

                    if (!string.IsNullOrEmpty(field.Expression))
                    {
                        if (field.DataType == EpiInfo.Plugin.DataType.Date)
                        {
                            var      datetemp = string.Format("{0:MM/dd/yyyy}", field.Expression);
                            DateTime date     = new DateTime();
                            date = Convert.ToDateTime(datetemp);
                            ContextDetailList[kvp.Key] = date.Date.ToString("MM/dd/yyyy");
                        }
                        else
                        {
                            ContextDetailList[kvp.Key] = field.Expression;
                        }
                    }
                }
            }


            return(ContextDetailList);
        }
        /// <summary>
        /// performs execution of retrieving the value of a variable or expression
        /// </summary>
        /// <returns>object</returns>
        public override object Execute()
        {
            object result = null;

            if (this.Id != null)
            {
                EpiInfo.Plugin.IVariable var;
                EpiInfo.Plugin.DataType  dataType = EpiInfo.Plugin.DataType.Unknown;
                string dataValue = string.Empty;

                var = Context.CurrentScope.Resolve(this.Id, this.Namespace);

                if (var != null && !(var.VariableScope == EpiInfo.Plugin.VariableScope.DataSource))
                {
                    dataType  = var.DataType;
                    dataValue = var.Expression;
                }
                else
                {
                    if (this.Context.EnterCheckCodeInterface != null)
                    {
                        EpiInfo.Plugin.DataType dt = EpiInfo.Plugin.DataType.Unknown;

                        if (this.Index0 == -1)
                        {
                            this.Context.EnterCheckCodeInterface.TryGetFieldInfo(this.Id, out dt, out dataValue);
                            dataType = (EpiInfo.Plugin.DataType)dt;
                        }
                        else
                        {
                            if (this.Index1 is Rule_Value)
                            {
                                this.Index1 = ((Rule_Value)this.Index1).Execute();
                            }

                            EpiInfo.Plugin.IVariable iv = this.Context.EnterCheckCodeInterface.GetGridValue(this.Id, this.Index0, this.Index1);
                            dataValue = iv.Expression;
                            dataType  = iv.DataType;
                        }
                    }
                }
                result = ConvertEpiDataTypeToSystemObject(dataType, dataValue);
            }
            else
            {
                if (value is EnterRule)
                {
                    result = ((EnterRule)value).Execute();
                }
                else
                {
                    result = value;
                }
            }
            return(result);
        }
        public override object Execute()
        {
            if (base.Context.EnterCheckCodeInterface.GetValue(address_field_name) != null)
            {
                string address = base.Context.EnterCheckCodeInterface.GetValue(address_field_name).Trim();
                base.Context.EnterCheckCodeInterface.Geocode(address, latitude_field_name, longitude_field_name);
            }
            else
            {
                EpiInfo.Plugin.IVariable var = Context.CurrentScope.Resolve(address_field_name, null);

                if (var.VariableScope == EpiInfo.Plugin.VariableScope.Standard)
                {
                    base.Context.EnterCheckCodeInterface.Geocode(var.Expression, latitude_field_name, longitude_field_name);
                }
            }

            return(null);
        }
 public void define(EpiInfo.Plugin.IVariable pSymbol)
 {
     // ensure that Permanent and Global variables are placed in global scope
     if
     (
         (pSymbol.VariableScope == EpiInfo.Plugin.VariableScope.Permanent | pSymbol.VariableScope == EpiInfo.Plugin.VariableScope.Global) && !this._name.Equals("global", StringComparison.OrdinalIgnoreCase) ||
         !string.IsNullOrEmpty(pSymbol.Namespace) && (!string.IsNullOrEmpty(this._name) && !this._name.Equals(pSymbol.Namespace, StringComparison.OrdinalIgnoreCase))
     )
     {
         if (this._parent != null)
         {
             this._parent.define(pSymbol);
         }
     }
     else if (!string.IsNullOrEmpty(pSymbol.Namespace) && !this._name.Equals(pSymbol.Namespace))
     {
         if (this._parent != null)
         {
             this._parent.define(pSymbol);
         }
     }
     else
     {
         if (this._SymbolList.ContainsKey(pSymbol.Name))
         {
             // maybe throw error duplicate symbol in scope?
             // instead of error redefining
             this._SymbolList[pSymbol.Name] = pSymbol;
         }
         else
         {
             this._SymbolList.Add(pSymbol.Name, pSymbol);
             if (pSymbol.VariableScope == EpiInfo.Plugin.VariableScope.Permanent)
             {
                 //PermanentVariable pv = new PermanentVariable(pSymbol.Name, (Epi.DataType) pSymbol.DataType);
                 //pv.Expression = pSymbol.Expression;
                 //Epi.MemoryRegion.UpdatePermanentVariable(pv);
             }
         }
     }
 }
        public override object Execute()
        {
            if (base.Context.EnterCheckCodeInterface.GetValue(industry_field_name) != null)
            {
                string iinput = base.Context.EnterCheckCodeInterface.GetValue(industry_field_name).Trim();
                string oinput = base.Context.EnterCheckCodeInterface.GetValue(occupation_field_name).Trim();
                base.Context.EnterCheckCodeInterface.IOCode(iinput, oinput, industry_field_name, occupation_field_name, icode_field_name, ocode_field_name, ititle_field_name, otitle_field_name, scheme_field_name);
            }
            else
            {
                EpiInfo.Plugin.IVariable varI = Context.CurrentScope.Resolve(industry_field_name, null);
                EpiInfo.Plugin.IVariable varO = Context.CurrentScope.Resolve(occupation_field_name, null);

                if (varI.VariableScope == EpiInfo.Plugin.VariableScope.Standard && varO.VariableScope == EpiInfo.Plugin.VariableScope.Standard)
                {
                    base.Context.EnterCheckCodeInterface.IOCode(varI.Expression, varI.Expression, industry_field_name, occupation_field_name, icode_field_name, ocode_field_name, ititle_field_name, otitle_field_name, scheme_field_name);
                }
            }

            return(null);
        }
Exemple #7
0
        public void Define(EpiInfo.Plugin.IVariable symbol)
        {
            if
            (
                (symbol.VariableScope == EpiInfo.Plugin.VariableScope.Permanent | symbol.VariableScope == EpiInfo.Plugin.VariableScope.Global) && !_name.Equals("global", StringComparison.OrdinalIgnoreCase) ||
                !string.IsNullOrEmpty(symbol.Namespace) && (!string.IsNullOrEmpty(_name) && !_name.Equals(symbol.Namespace, StringComparison.OrdinalIgnoreCase))
            )
            {
                if (_parent != null)
                {
                    _parent.Define(symbol);
                }
            }
            else if (!string.IsNullOrEmpty(symbol.Namespace) && !_name.Equals(symbol.Namespace))
            {
                if (_parent != null)
                {
                    _parent.Define(symbol);
                }
            }
            else
            {
                if (_symbolList.ContainsKey(symbol.Name))
                {
                    _symbolList[symbol.Name] = symbol;
                }
                else
                {
                    _symbolList.Add(symbol.Name, symbol);

                    if (symbol.VariableScope == EpiInfo.Plugin.VariableScope.Permanent)
                    {
                        PermanentVariable permanentVariable = new PermanentVariable(symbol.Name, (Epi.DataType)symbol.DataType);
                        permanentVariable.Expression = symbol.Expression;
                        Epi.MemoryRegion.UpdatePermanentVariable(permanentVariable);
                    }
                }
            }
        }
Exemple #8
0
        public void CloseViewHandler(object returnHome, EventArgs e)
        {
            this.canvas.UnsubscribeControlEventHandlers();
            this.SetFieldData();

            if (SaveRecord() == false)
            {
                return;
            }

            RunTimeView RTV = this.EnterCheckCodeEngine.CurrentView;

            this.IsClosingRelatedView = RTV.View.IsRelatedView;
            EpiInfo.Plugin.IScope scope = RTV.EpiInterpreter.Context.Scope.GetEnclosingScope();
            this.EnterCheckCodeEngine.CheckCodeHandler(this, new RunCheckCodeEventArgs(EventActionEnum.CloseView, ""));

            if (returnHome is Boolean && (bool)returnHome)
            {
                while (this.EnterCheckCodeEngine.CurrentView.View.IsRelatedView)
                {
                    this.EnterCheckCodeEngine.CheckCodeHandler(this, new RunCheckCodeEventArgs(EventActionEnum.CloseView, ""));
                }
            }

            if (this.EnterCheckCodeEngine.CurrentView != null)
            {
                view = this.EnterCheckCodeEngine.CurrentView.View;

                this.Reset();
                this.canvas.CurrentView = this.view;
                this.mainForm.OpenView(this.view);

                this.viewExplorer.LoadView(this.EnterCheckCodeEngine.CurrentView, this.EnterCheckCodeEngine.CurrentView.CurrentPage);

                // *** populate view data with any changes from child - begin
                if (scope != null && this.view.Name.Equals(scope.Name, StringComparison.OrdinalIgnoreCase))
                {
                    foreach (Epi.Fields.Field field in this.view.Fields)
                    {
                        if (field is EpiInfo.Plugin.IVariable)
                        {
                            EpiInfo.Plugin.IVariable iVariable = scope.Resolve(field.Name, this.view.Name);

                            if (iVariable != null && (field is Epi.Fields.ImageField == false))
                            {
                                if (field is Epi.Fields.CheckBoxField || field is Epi.Fields.YesNoField)
                                {
                                    if (((Epi.Fields.IDataField)field).CurrentRecordValueString == "true" || ((Epi.Fields.IDataField)field).CurrentRecordValueString == "1")
                                    {
                                        //v.Expression = "true";
                                        ((Epi.Fields.IDataField)field).CurrentRecordValueString = "1";
                                    }
                                    else if (((Epi.Fields.IDataField)field).CurrentRecordValueString == "false" || ((Epi.Fields.IDataField)field).CurrentRecordValueString == "0")
                                    {
                                        //v.Expression = "false";
                                        ((Epi.Fields.IDataField)field).CurrentRecordValueString = "0";
                                    }
                                    else
                                    {
                                        ((Epi.Fields.IDataField)field).CurrentRecordValueString = null;
                                    }
                                }
                                else
                                {
                                    string value = iVariable.Expression;

                                    if (value != ((EpiInfo.Plugin.IVariable)field).Expression)
                                    {
                                        ((Epi.Fields.IDataField)field).CurrentRecordValueString = value;
                                    }
                                }
                            }
                        }
                    }
                }
                // *** populate view data with any changes from child - end

                this.Render();
                this.IsClosingRelatedView = false;
            }
            else
            {
                this.view              = null;
                this.currentPage       = null;
                this.mainForm.View     = this.view;
                this.viewExplorer.View = this.EnterCheckCodeEngine.CurrentView;
                this.Reset();
                this.Render();
                this.canvas.CurrentView = this.view;
            }
        }
Exemple #9
0
 public BuiltInTypeSymbol(EpiInfo.Plugin.IVariable pVariable) : base(pVariable.Name, pVariable.DataType)
 {
 }
Exemple #10
0
 public cSymbol(EpiInfo.Plugin.IVariable pVariable)
 {
     this.Name = pVariable.Name;
     this.Type = pVariable.DataType;
 }