public void Create(Configuration configuration)
        {
            this.config = configuration;

            if (UsingStoredProc == true)
            {
                storedProcParams = SQLHelpers.GetStoredProcParams(this.SQLServer, this.SQLUser, this.SQLUseSQLAuth, this.SQLPassword, this.SQLDatabase, this.StoredProc).ToList();
            }
            else
            {
                if (CreateTable == true)
                {
                    var newColumns = GetColumns(ParentOutputs);
                    using (SqlConnection connection = new SqlConnection(SQLHelpers.GetConnectionString(SQLServer, SQLUser, SQLPassword, SQLUseSQLAuth, SQLDatabase)))
                    {
                        SqlCommand command = new SqlCommand(String.Format(CreateTableSQL, RemoveSchemaName(SQLTable), SQLTable, newColumns), connection);
                        command.CommandType = CommandType.Text;
                        command.Connection.Open();
                        command.ExecuteNonQuery();
                    }
                }

                var adp = new SqlDataAdapter(String.Format("Select Top 0 * FROM {0}", SQLHelpers.AddTableQuotes(SQLTable)), SQLHelpers.GetConnectionString(SQLServer, SQLUser, SQLPassword, SQLUseSQLAuth, SQLDatabase));
                this.dt = new DataTable();
                adp.Fill(this.dt);
            }
        }
 public IEnumerable <XMIoT.Framework.Attribute> GetOutputAttributes(string endpoint, IDictionary <string, string> parameters)
 {
     this.config = new Configuration()
     {
         Parameters = parameters
     };
     if (UsingStoredProc)
     {
         return(SQLHelpers.GetStoredProcParams(this.SQLServer, this.SQLUser, this.SQLUseSQLAuth, this.SQLPassword, this.SQLDatabase, this.StoredProc)
                .Select(p => new XMIoT.Framework.Attribute(p.ParameterName.TrimStart(new char[] { '@' }), SQLHelpers.GetSystemType(p.DbType).GetIoTType())));
     }
     else if (CreateTable == false)
     {
         return(SQLHelpers.GetColumns(this.SQLServer, this.SQLUser, this.SQLUseSQLAuth, this.SQLPassword, this.SQLDatabase, this.SQLTable)
                .Select(col => new XMIoT.Framework.Attribute(col.ColumnName, col.DataType.GetIoTType())));
     }
     else
     {
         return(ParentOutputs);
     }
 }
예제 #3
0
        public IEnumerable <XMIoT.Framework.Attribute> GetOutputAttributes(string endpoint, IDictionary <string, string> parameters)
        {
            this.config = new Configuration()
            {
                Parameters = parameters
            };
            if (UsingStoredProc)
            {
                var outputs = SQLHelpers.GetStoredProcParams(this.SQLServer, this.SQLUser, this.SQLUseSQLAuth, this.SQLPassword, this.SQLDatabase, this.StoredProc)
                              .Where(p => p.Direction != ParameterDirection.Input)
                              .Select(p => new XMIoT.Framework.Attribute(p.ParameterName.TrimStart(new char[] { '@' }), SQLHelpers.GetSystemType(p.DbType).GetIoTType()));

                if (ReturnType == "Append")
                {
                    outputs = outputs.Union(ParentOutputs);
                }

                return(outputs);
            }
            else
            {
                return(ParentOutputs);
            }
        }