/// <summary>
        /// Get the connection string name when given a GUID
        /// </summary>
        /// <param name="conn_guid_str"></param>
        /// <returns></returns>
        public static string GetConnectionStringPrefix(string conn_guid_str)
        {
            SsisObject connobj = SsisObject.GetObjectByGuid(Guid.Parse(conn_guid_str));

            if (connobj == null)
            {
                return("Sql");
            }
            string objecttype = connobj.Properties["CreationName"];

            if (objecttype.StartsWith("OLEDB"))
            {
                return("OleDb");
            }
            else if (objecttype.StartsWith("ADO.NET:System.Data.SqlClient.SqlConnection"))
            {
                return("Sql");
            }
            else
            {
                SourceWriter.Help(null, "I don't understand the database connection type " + objecttype);
            }
            return("");
        }
        public ProgramVariable(SsisObject o, bool as_global)
        {
            // Figure out what type of a variable we are
            DtsType      = o.GetChildByType("DTS:VariableValue").Attributes["DTS:DataType"];
            CSharpType   = null;
            DefaultValue = o.GetChildByType("DTS:VariableValue").ContentValue;
            Comment      = o.Description;
            Namespace    = o.Properties["Namespace"];
            IsGlobal     = as_global;
            VariableName = o.DtsObjectName;

            // Here are the DTS type codes I know
            if (DtsType == "3")
            {
                CSharpType = "int";
            }
            else if (DtsType == "8")
            {
                CSharpType = "string";
                if (!String.IsNullOrEmpty(DefaultValue))
                {
                    DefaultValue = "\"" + DefaultValue.Replace("\\", "\\\\").Replace("\"", "\\\"") + "\"";
                }
            }
            else if (DtsType == "13")
            {
                CSharpType   = "DataTable";
                DefaultValue = "new DataTable()";
            }
            else if (DtsType == "2")
            {
                CSharpType = "short";
            }
            else if (DtsType == "11")
            {
                CSharpType = "bool";
                if (DefaultValue == "1")
                {
                    DefaultValue = "true";
                }
                else
                {
                    DefaultValue = "false";
                }
            }
            else if (DtsType == "20")
            {
                CSharpType = "long";
            }
            else if (DtsType == "7")
            {
                CSharpType = "DateTime";
                if (!String.IsNullOrEmpty(DefaultValue))
                {
                    DefaultValue = "DateTime.Parse(\"" + DefaultValue + "\")";
                }
            }
            else
            {
                SourceWriter.Help(o, "I don't understand DTS type " + DtsType);
            }
        }
Example #3
0
        public Token ConsumeToken(ref string s)
        {
            // Get the first character
            char c = s[0];

            // Is it whitespace?  Just consume this character and move on
            if (c == ' ' || c == '\r' || c == '\n' || c == '\t')
            {
                s = s.Substring(1);
                return(null);

                // Is this a lineage column reference?
            }
            else if (c == '#')
            {
                return(new LineageToken(ref s, this));

                // Is this a global variable reference?
            }
            else if (c == '@')
            {
                return(new VariableToken(ref s, this));

                // Is this a type conversion?  If so, we need one more token
            }
            else if (c == '(')
            {
                return(new ConversionToken(ref s, this));

                // Is this a math operation?
            }
            else if (c == '+' || c == '-' || c == '*' || c == '/')
            {
                s = s.Substring(1);
                return(new OperationToken()
                {
                    Op = c.ToString()
                });

                // Check for solo negation or not-equals
            }
            else if (c == '!')
            {
                if (s[1] == '=')
                {
                    s = s.Substring(2);
                    return(new OperationToken()
                    {
                        Op = "!="
                    });
                }
                s = s.Substring(1);
                return(new OperationToken()
                {
                    Op = "!"
                });

                // This could be either assignment or equality
            }
            else if (c == '=')
            {
                if (s[1] == '=')
                {
                    s = s.Substring(2);
                    return(new OperationToken()
                    {
                        Op = "=="
                    });
                }
                s = s.Substring(1);
                return(new OperationToken()
                {
                    Op = "="
                });

                // Is this a string constant?
            }
            else if (c == '"')
            {
                Match m = STRING_REGEX.Match(s);
                if (m.Success)
                {
                    s = s.Substring(m.Index + m.Length);
                    return(new ConstantToken()
                    {
                        Value = m.Captures[0].Value, TypeRef = "System.String"
                    });
                }

                // Is this a numeric constant?
            }
            else if (c >= '0' && c <= '9')
            {
                Match m = NUMBER_REGEX.Match(s);
                if (m.Success)
                {
                    s = s.Substring(m.Index + m.Length);
                    return(new ConstantToken()
                    {
                        Value = m.Captures[0].Value, TypeRef = "System.Int32"
                    });
                }

                // Is this boolean true or false?
            }
            else if (s.StartsWith("true", StringComparison.CurrentCultureIgnoreCase))
            {
                s = s.Substring(4);
                return(new ConstantToken()
                {
                    Value = "true", TypeRef = "System.Boolean"
                });
            }
            else if (s.StartsWith("false", StringComparison.CurrentCultureIgnoreCase))
            {
                s = s.Substring(5);
                return(new ConstantToken()
                {
                    Value = "false", TypeRef = "System.Boolean"
                });
            }

            // Did we fail to process this token?  Fail out
            SourceWriter.Help(null, "Unable to parse expression '" + _expression + "'");
            s = "";
            return(null);
        }