Ejemplo n.º 1
0
        private GenericReply GetBrowserData()
        {
            GenericReply reply = new GenericReply();

            var fields = new List <string>()
            {
                "ROOMS.ID",
                "ROOMS.NAME",
                "ROOMS.BUILDINGID",
                "ROOMS.BUILDINGID_BUILDINGS_NAME",
                "ROOMS.BUILDINGID_BUILDINGS_ADDRESS",
                "ROOMS.ALTERNATEBUILDINGID",
                "ROOMS.ALTERNATEBUILDINGID_BUILDINGS_NAME",
                "ROOMS.ALTERNATEBUILDINGID_BUILDINGS_ADDRESS"
            };

            D.Models.Interfaces.NavigableDbContext navigableDbContext = new Models.Interfaces.NavigableDbContext(db);

            D.Models.Interfaces.DatabaseGossiper databaseGossiper = new Models.Interfaces.DatabaseGossiper(navigableDbContext);

            D.Models.Interfaces.QueryBuilder qb = new D.Models.Interfaces.QueryBuilder(databaseGossiper);

            var q = qb.BuildBasicQuery(fields);

            D.Models.Interfaces.DatabaseCommander dc = new Models.Interfaces.DatabaseCommander();

            db.Database.SqlQuery <object>(q);

            var o = dc.ExecuteSql(q);

            reply.data = o;

            return(reply);
        }
Ejemplo n.º 2
0
        private object test(IEnumerable <string> fields)
        {
            System.Text.StringBuilder sbSelect = new System.Text.StringBuilder();
            System.Text.StringBuilder sbFrom   = new System.Text.StringBuilder();

            sbSelect.Append(" SELECT ");
            sbFrom.Append(" FROM ");

            fields = new List <string>()
            {
                "ROOMS.ID",
                "ROOMS.NAME",
                "ROOMS.BUILDINGID",
                "ROOMS.BUILDINGID_BUILDINGS_NAME",
                "ROOMS.BUILDINGID_BUILDINGS_ADDRESS",
                "ROOMS.ALTERNATEBUILDINGID",
                "ROOMS.ALTERNATEBUILDINGID_BUILDINGS_NAME",
                "ROOMS.ALTERNATEBUILDINGID_BUILDINGS_ADDRESS"
            };

            D.Models.Interfaces.NavigableDbContext navigableDbContext = new Models.Interfaces.NavigableDbContext(db);

            D.Models.Interfaces.DatabaseGossiper databaseGossiper = new Models.Interfaces.DatabaseGossiper(navigableDbContext);

            D.Models.Interfaces.QueryBuilder qb = new D.Models.Interfaces.QueryBuilder(databaseGossiper);

            var q = qb.BuildBasicQuery(fields);

            D.Models.Interfaces.DatabaseCommander dc = new Models.Interfaces.DatabaseCommander();

            db.Database.SqlQuery <object>(q);

            var o = dc.ExecuteSql(q);

            return(o);
        }
Ejemplo n.º 3
0
        private GenericReply GetViewerData()
        {
            // You can specify the Catalog, Schema, Table Name, Table Type to get
            // the specified table(s).
            // You can use four restrictions for Table, so you should create a 4 members array.
            String[] tableRestrictions = new String[4];

            // For the array, 0-member represents Catalog; 1-member represents Schema;
            // 2-member represents Table Name; 3-member represents Table Type.
            // Now we specify the Table Name of the table what we want to get schema information.
            tableRestrictions[2] = "Rooms";

            using (var conn = new System.Data.SqlClient.SqlConnection(@"Data Source=.\SQLEXPRESS; Initial Catalog=D;User Id=sa;password=prosvasis;"))
            {
                conn.Open();

                try
                {
                    System.Data.DataTable courseTableSchemaTable = conn.GetSchema("Tables", tableRestrictions);

                    System.Diagnostics.Debug.WriteLine("Schema Information of Course Tables:");
                    ShowDataTable(courseTableSchemaTable, 20);
                    System.Diagnostics.Debug.WriteLine("");
                } catch (Exception x)
                {
                }
            }

            using (var conn = new System.Data.SqlClient.SqlConnection(@"Data Source=.\SQLEXPRESS; Initial Catalog=D;User Id=sa;password=prosvasis;"))
            {
                string[] restrictions = new string[4] {
                    null, null, "rooms", null
                };
                conn.Open();
                try
                {
                    var columnList = conn.GetSchema("Columns", restrictions).AsEnumerable().Select(s => s.Field <String>("Column_Name")).ToList();
                }
                catch (Exception exc)
                {
                }
            }



            GenericReply reply = new GenericReply();

            var fields = new List <string>()
            {
                "ROOMS.ID",
                "ROOMS.NAME",
                "ROOMS.BUILDINGID",
                "ROOMS.BUILDINGID_BUILDINGS_NAME",
                "ROOMS.BUILDINGID_BUILDINGS_ADDRESS",
                "ROOMS.ALTERNATEBUILDINGID",
                "ROOMS.ALTERNATEBUILDINGID_BUILDINGS_NAME",
                "ROOMS.ALTERNATEBUILDINGID_BUILDINGS_ADDRESS"
            };

            D.Models.Interfaces.NavigableDbContext navigableDbContext = new Models.Interfaces.NavigableDbContext(db);

            D.Models.Interfaces.DatabaseGossiper databaseGossiper = new Models.Interfaces.DatabaseGossiper(navigableDbContext);

            D.Models.Interfaces.QueryBuilder qb = new D.Models.Interfaces.QueryBuilder(databaseGossiper);

            var q = qb.BuildBasicQuery(fields);

            q = q + " where ROOMS.ID = 1";

            D.Models.Interfaces.DatabaseCommander dc = new Models.Interfaces.DatabaseCommander();

            var o = dc.ExecuteSql(q);

            reply.data = o;

            var data = new ViewerData();

            data.Data = new Dictionary <string, List <Dictionary <string, object> > >();

            data.Data.Add("ROOMS", new List <Dictionary <string, object> >()
            {
                new Dictionary <string, object>()
                {
                    {
                        "ID",
                        "1"
                    },
                    {
                        "NAME",
                        "AAAAAAAA"
                    }
                }
            });

            reply.data = data.Data;

            return(reply);
        }