Exemple #1
0
        /// <summary>
        /// peforms the Define rule uses the MemoryRegion and this.Context.DataSet to hold variable definitions
        /// </summary>
        /// <returns>object</returns>
        public override object Execute()
        {
            PluginVariable result = new PluginVariable();

            try
            {
                result.Name = this.Identifier;
                string dataTypeName             = VariableTypeIndicator.Trim().ToUpper();
                EpiInfo.Plugin.DataType type    = GetDataType(dataTypeName);
                string variableScope            = Variable_Scope.Trim().ToUpper();
                EpiInfo.Plugin.VariableScope vt = EpiInfo.Plugin.VariableScope.Standard;

                if (!string.IsNullOrEmpty(variableScope))
                {
                    vt = this.GetVariableScopeIdByName(variableScope);
                }

                result.VariableScope = vt;
                result.DataType      = type;
                result.ControlType   = "hidden";
                this.Context.CurrentScope.define(result);

                return(result);
            }
            catch (Exception ex)
            {
                //Epi.Diagnostics.Debugger.Break();
                //Epi.Diagnostics.Debugger.LogException(ex);
                throw ex;
            }
        }
 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;
 }
 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;
 }
Exemple #4
0
        ///// <summary>
        ///// peforms the Define rule uses the MemoryRegion and this.Context.DataSet to hold variable definitions
        ///// </summary>
        ///// <returns>object</returns>
        //public override object Execute_Old()
        //{
        //    try
        //    {
        //        EpiInfo.Plugin.IVariable var = null;

        //        var = this.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;
        //                }
        //        }


        //        string dataTypeName = VariableTypeIndicator.Trim().ToUpper();
        //        EpiInfo.Plugin.DataType type = GetDataType(dataTypeName);
        //        string variableScope = Variable_Scope.Trim().ToUpper();
        //        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);
        //        }

        //        //var = new PluginVariable(Identifier, type, vt, null);
        //        var = null;
        //        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.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 override void ToJavaScript(StringBuilder pJavaScriptBuilder)
        {
            string defineFormat       = "cce_Context.define(\"{0}\", \"{1}\", \"{2}\", \"{3}\");";
            string defineNumberFormat = "cce_Context.define(\"{0}\", \"{1}\", \"{2}\", new Number({3}));";

            PluginVariable var = (PluginVariable)this.Context.CurrentScope.resolve(this.Identifier);

            if (var == null)
            {
                //foreach (PluginVariable var in this.Context.CurrentScope.FindVariables( VariableScope.DataSource | VariableScope.Global | VariableScope.Permanent))
                var = new PluginVariable();

                var.Name = this.Identifier;
                string dataTypeName             = VariableTypeIndicator.Trim().ToUpper();
                EpiInfo.Plugin.DataType type    = GetDataType(dataTypeName);
                string variableScope            = Variable_Scope.Trim().ToUpper();
                EpiInfo.Plugin.VariableScope vt = EpiInfo.Plugin.VariableScope.Standard;

                if (!string.IsNullOrEmpty(variableScope))
                {
                    vt = this.GetVariableScopeIdByName(variableScope);
                }

                var.VariableScope = vt;
                var.DataType      = type;
            }
            switch (var.ControlType)
            {
            case "checkbox":
            case "yesno":
                pJavaScriptBuilder.AppendLine(string.Format(defineFormat, var.Name, var.ControlType, "datasource", var.Expression));
                break;

            case "numeric":
                pJavaScriptBuilder.AppendLine(string.Format(defineNumberFormat, var.Name, var.ControlType, "datasource", var.Expression));
                break;

            case "commentlegal":
            case  "codes":
            case "legalvalues":
            case "datepicker":
            case "multiline":
            case "textbox":
            default:
                pJavaScriptBuilder.AppendLine(string.Format(defineFormat, var.Name, var.ControlType, "datasource", var.Expression));
                break;
            }
        }
Exemple #5
0
        /// <summary>
        /// Returns the DataType enumeration for the data type name passed
        /// </summary>
        /// <param name="typeName"></param>
        /// <returns>DataType</returns>
        protected EpiInfo.Plugin.DataType GetDataType(string typeName)
        {
            EpiInfo.Plugin.DataType type = EpiInfo.Plugin.DataType.Unknown;
            try
            {
                foreach (Epi.DataSets.AppDataSet.DataTypesRow row in AppData.Instance.DataTypesDataTable.Rows)
                {
                    // save a dereference
                    string expression = row.Expression;

                    if (!string.IsNullOrEmpty(expression) && (string.Compare(typeName, expression, true) == 0))
                    {
                        return(type = ((EpiInfo.Plugin.DataType)row.DataTypeId));
                    }
                }
            }
            catch (Exception)
            {
            }
            return(type);
        }
Exemple #6
0
        /// <summary>
        /// Returns the DataType enumeration for the data type name passed
        /// </summary>
        /// <param name="typeName"></param>
        /// <returns>DataType</returns>
        protected EpiInfo.Plugin.DataType GetDataType(string typeName)
        {
            EpiInfo.Plugin.DataType type = EpiInfo.Plugin.DataType.Unknown;

            if (!string.IsNullOrWhiteSpace(typeName))
            {
                switch (typeName.ToUpper())
                {
                case "NUMERIC":
                case "NUMBER":
                    type = EpiInfo.Plugin.DataType.Number;
                    break;

                case "TEXT":
                case "TEXTINPUT":
                    type = EpiInfo.Plugin.DataType.Text;
                    break;

                case "DATE":
                case "DATEFORMAT":
                    type = EpiInfo.Plugin.DataType.Date;
                    break;

                case "TIME":
                case "TIMEFORMAT":
                    type = EpiInfo.Plugin.DataType.Time;
                    break;

                case "DATETIME":
                case "DATETIMEFORMAT":
                    type = EpiInfo.Plugin.DataType.DateTime;
                    break;

                case "PHONENUMBER":
                    type = EpiInfo.Plugin.DataType.PhoneNumber;
                    break;

                case "BOOLEAN":
                case "YESNO":
                case "YN":
                    type = EpiInfo.Plugin.DataType.Boolean;
                    break;

                case "GUID":
                    type = EpiInfo.Plugin.DataType.GUID;
                    break;

                case "DLLOBJECT":
                case "OBJECT":
                    type = EpiInfo.Plugin.DataType.Object;
                    break;

                case "UNKNOWN":
                default:
                    type = EpiInfo.Plugin.DataType.Unknown;
                    break;
                }
            }

            return(type);
        }
Exemple #7
0
 public cSymbol(EpiInfo.Plugin.IVariable pVariable)
 {
     this.Name = pVariable.Name;
     this.Type = pVariable.DataType;
 }
        /// <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;
            }
        }
Exemple #9
0
 public cSymbol(string pName, EpiInfo.Plugin.DataType pType)
 {
     this.Name = pName;
     this.Type = pType;
 }
 public BuiltInTypeSymbol(EpiInfo.Plugin.DataType pType) : base(pType.ToString(), pType)
 {
 }
 public VariableSymbol(string pName, EpiInfo.Plugin.DataType pType) : base(pName, pType)
 {
 }
 public cSymbol(EpiInfo.Plugin.IVariable pVariable)
 {
     this.Name = pVariable.Name;
     this.Type = pVariable.DataType;
 }
 public cSymbol(string pName, EpiInfo.Plugin.DataType pType)
 {
     this.Name = pName;
     this.Type = pType;
 }