示例#1
0
        public void RemoveVariablesInScope(EpiInfo.Plugin.VariableScope scopeCombination, string variableNamespace = null)
        {
            if (!string.IsNullOrEmpty(variableNamespace) && (!string.IsNullOrEmpty(_name) && !_name.Equals(variableNamespace, StringComparison.OrdinalIgnoreCase)))
            {
                if (_parent != null)
                {
                    _parent.RemoveVariablesInScope(scopeCombination);
                }
            }
            else
            {
                List <string> kvplist = new List <string>();
                for (int i = 0; i < _symbolList.Count; i++)
                {
                    KeyValuePair <string, EpiInfo.Plugin.IVariable> kvp = _symbolList.ElementAt(i);

                    if ((kvp.Value.VariableScope & scopeCombination) > 0)
                    {
                        kvplist.Add(kvp.Key);
                    }
                }
                foreach (string kvpkey in kvplist)
                {
                    Undefine(kvpkey, variableNamespace);
                }

                if (_parent != null)
                {
                    _parent.RemoveVariablesInScope(scopeCombination, variableNamespace);
                }
            }
        }
示例#2
0
        public List <EpiInfo.Plugin.IVariable> FindVariables(EpiInfo.Plugin.VariableScope pScopeCombination, string pNamespace = null)
        {
            List <EpiInfo.Plugin.IVariable> result = new List <EpiInfo.Plugin.IVariable>();

            if (!string.IsNullOrEmpty(pNamespace) && (!string.IsNullOrEmpty(_name) && !_name.Equals(pNamespace, StringComparison.OrdinalIgnoreCase)))
            {
                if (_parent != null)
                {
                    result.AddRange(_parent.FindVariables(pScopeCombination, pNamespace));
                }
            }
            else
            {
                foreach (KeyValuePair <string, EpiInfo.Plugin.IVariable> kvp in _symbolList)
                {
                    if ((kvp.Value.VariableScope & pScopeCombination) > 0)
                    {
                        result.Add(kvp.Value);
                    }
                }

                if (_parent != null)
                {
                    result.AddRange(_parent.FindVariables(pScopeCombination, pNamespace));
                }
            }

            return(result);
        }
        public void RemoveVariablesInScope(EpiInfo.Plugin.VariableScope pScopeCombination, string pNamespace = null)
        {
            if (!string.IsNullOrEmpty(pNamespace) && (!string.IsNullOrEmpty(this._name) && !this._name.Equals(pNamespace, StringComparison.OrdinalIgnoreCase)))
            {
                if (this._parent != null)
                {
                    this._parent.RemoveVariablesInScope(pScopeCombination);
                }
            }
            else
            {
                for (int i = 0; i < _SymbolList.Count; i++)
                {
                    KeyValuePair <string, EpiInfo.Plugin.IVariable> kvp = _SymbolList.ElementAt(i);
                    if ((kvp.Value.VariableScope & pScopeCombination) > 0)
                    {
                        this.undefine(kvp.Key, pNamespace);
                    }
                }

                if (this._parent != null)
                {
                    this._parent.RemoveVariablesInScope(pScopeCombination, pNamespace);
                }
            }
        }
示例#4
0
 public PluginVariable(string pName, EpiInfo.Plugin.DataType pDataType, EpiInfo.Plugin.VariableScope pVariableScope, string pExpression, string pNamespace = null)
 {
     this.name          = pName;
     this.dataType      = pDataType;
     this.variableScope = pVariableScope;
     this.expression    = pExpression;
     this._Namespace    = pNamespace;
 }
 public PluginVariable(string name, EpiInfo.Plugin.DataType dataType, EpiInfo.Plugin.VariableScope variableScope, string expression, string variableNamespace = null, string prompt = null)
 {
     _name              = name;
     _dataType          = dataType;
     _variableScope     = variableScope;
     _expression        = expression;
     _variableNamespace = variableNamespace;
     _prompt            = prompt;
 }
示例#6
0
        private void viewSelect_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (viewSelect.SelectedItem == null)
            {
                return;
            }

            if (project.Views.Contains((string)viewSelect.SelectedItem))
            {
                view = project.Views[(string)viewSelect.SelectedItem];

                displayTable = this.view.Project.Metadata.GetDataDictionary(this.view);

                foreach (DataColumn column in displayTable.Columns)
                {
                    column.AllowDBNull = true;
                }

                foreach (DataRow dr in displayTable.Rows)
                {
                    if (dr["Special Info"] is string)
                    {
                        string info = (string)dr["Special Info"];

                        if (info.Contains("||"))
                        {
                            int index = info.IndexOf("||");
                            dr["Special Info"] = info.Substring(0, index);
                        }
                        else
                        {
                            dr["Special Info"] = info;
                        }
                    }

                    if (dr["Variable Type"].ToString().ToLowerInvariant() == "unknown")
                    {
                        dr["Variable Type"] = "Text";
                    }

                    if (dr["Field Type"].ToString().ToLowerInvariant() == "option")
                    {
                        dr["Variable Type"] = "Number";
                    }
                    else if (dr["Field Type"].ToString().ToLowerInvariant() == "grid")
                    {
                        dr["Variable Type"] = "Data Table";
                    }

                    if (dr["Field Type"].ToString().ToLowerInvariant() == "image")
                    {
                        dr["Variable Type"] = "Image";
                        //--2365
                        Boolean bshouldretainImage = (Boolean)dr[Constants.SHOULDRETAINIMAGESIZE];
                        if (bshouldretainImage == true)
                        {
                            dr[Constants.SPECIALINFO] = dr[Constants.SPECIALINFO].ToString() + Constants.VARRETAINIMAGESIZE;
                        }
                        //--
                    }
                    //--2365
                    Boolean bshouldRepeatLast = false;
                    if (dr[ColumnNames.SHOULD_REPEAT_LAST] != DBNull.Value)
                    {
                        bshouldRepeatLast = (Boolean)dr[ColumnNames.SHOULD_REPEAT_LAST];
                        if (bshouldRepeatLast == true)
                        {
                            dr[Constants.SPECIALINFO] = dr[Constants.SPECIALINFO].ToString() + Constants.VARREPEATLAST;
                        }
                    }

                    Boolean bIsRequired = false;
                    if (dr[ColumnNames.IS_REQUIRED] != DBNull.Value)
                    {
                        bIsRequired = (Boolean)dr[ColumnNames.IS_REQUIRED];
                        if (bIsRequired == true)
                        {
                            dr[Constants.SPECIALINFO] = dr[Constants.SPECIALINFO].ToString() + Constants.VARREQUIRED;
                        }
                    }

                    Boolean bIsReadOnly = false;
                    if (dr[ColumnNames.IS_READ_ONLY] != DBNull.Value)
                    {
                        bIsReadOnly = (Boolean)dr[ColumnNames.IS_READ_ONLY];
                        if (bIsReadOnly == true)
                        {
                            dr[Constants.SPECIALINFO] = dr[Constants.SPECIALINFO] + Constants.VARREADONLY;
                        }
                    }

                    if (dr[ColumnNames.UPPER] != DBNull.Value && dr[ColumnNames.LOWER] != DBNull.Value)
                    {
                        if (dr[ColumnNames.UPPER].ToString().Length > 0 && dr[ColumnNames.LOWER].ToString().Length > 0)
                        {
                            dr[Constants.SPECIALINFO] = dr[Constants.SPECIALINFO] + Constants.VARRANGE + CharLiterals.LEFT_SQUARE_BRACKET + dr[ColumnNames.LOWER].ToString() + CharLiterals.COMMA + dr[ColumnNames.UPPER].ToString() + CharLiterals.RIGHT_SQUARE_BRACKET;
                        }
                    }
                    //----
                }
                //-- 2365
                displayTable.Columns.Remove(ColumnNames.IS_REQUIRED);
                displayTable.Columns.Remove(ColumnNames.SHOULD_REPEAT_LAST);
                displayTable.Columns.Remove(ColumnNames.IS_READ_ONLY);
                displayTable.Columns.Remove(Constants.SHOULDRETAINIMAGESIZE);
                displayTable.Columns.Remove(ColumnNames.UPPER);
                displayTable.Columns.Remove(ColumnNames.LOWER);


                //--
                ((EnterMainForm)this.mainForm).RunTimeView.EpiInterpreter.Context.ClearState();
                ((EnterMainForm)this.mainForm).RunTimeView.EpiInterpreter.Execute(this.view.CheckCode);

                EpiInfo.Plugin.VariableScope variableScope =
                    EpiInfo.Plugin.VariableScope.Global |
                    EpiInfo.Plugin.VariableScope.Standard |
                    EpiInfo.Plugin.VariableScope.Permanent;


                List <EpiInfo.Plugin.IVariable> vars = new List <EpiInfo.Plugin.IVariable>();
                if (((EnterMainForm)this.mainForm).RunTimeView.EpiInterpreter != null)
                {
                    vars = ((EnterMainForm)this.mainForm).RunTimeView.EpiInterpreter.Context.GetVariablesInScope(variableScope);
                }

                DataRow row;

                foreach (EpiInfo.Plugin.IVariable var in vars)
                {
                    if (!(var is Epi.Fields.PredefinedDataField))
                    {
                        row                  = displayTable.NewRow();
                        row["Name"]          = var.Name.ToString();
                        row["Field Type"]    = var.VariableScope.ToString();
                        row["Variable Type"] = var.DataType.ToString();
                        displayTable.Rows.Add(row);
                    }
                }

                BindingSource source = new BindingSource();
                source.DataSource            = displayTable;
                source.Sort                  = sortExp;
                this.dataGridView.DataSource = source;
            }
            else
            {
                displayTable = this.view.Project.GetCodeTableData((string)viewSelect.SelectedItem);

                foreach (DataColumn column in displayTable.Columns)
                {
                    column.AllowDBNull = true;
                }

                BindingSource source = new BindingSource();
                source.DataSource            = displayTable;
                this.dataGridView.DataSource = source;
            }
        }