Example #1
0
        public void InitTestScriptEngine()
        {
            var lgf = LoggerFactory.Create(f =>
            {
                f.AddConsole();
            });


            _js_engine = new JavaScriptEngine(lgf.CreateLogger <JavaScriptEngine>(), Options.Create(new Interpreter.EngineSetting()
            {
                Timeout = 4
            }));
            _python_engine = new PythonScriptEngine(lgf.CreateLogger <PythonScriptEngine>(), Options.Create(new Interpreter.EngineSetting()
            {
                Timeout = 4
            }));
            _lua_engine = new  LuaScriptEngine(lgf.CreateLogger <LuaScriptEngine>(), Options.Create(new Interpreter.EngineSetting()
            {
                Timeout = 4
            }));
            _c_engine = new CScriptEngine(lgf.CreateLogger <CScriptEngine>(), Options.Create(new Interpreter.EngineSetting()
            {
                Timeout = 4
            }));
            _sql_engine = new SQLEngine(lgf.CreateLogger <SQLEngine>(), Options.Create(new Interpreter.EngineSetting()
            {
                Timeout = 4
            }));
            _csharp_engine = new  CSharpScriptEngine(lgf.CreateLogger <CSharpScriptEngine>(), Options.Create(new Interpreter.EngineSetting()
            {
                Timeout = 4
            }));
        }
Example #2
0
        public static void Next()
        {
            ++ScriptPosition;
            if (ScriptPosition <= ScriptLength)
            {
                ActionType = int.Parse(SQLEngine.GetValue("SELECT CmdID FROm ScnScript WHERE ID =" + ScriptPosition.ToString()));
                switch (ActionType)
                {
                case 1:
                    TryHard.This(() => SQLEngine.ImagePath());
                    GraphicEngine.SetBackground();
                    //MessageBox.Show(text: ScriptPosition.ToString());
                    break;

                case 2:
                    break;

                case 3:
                    break;
                }
            }

            else
            {
                MessageBox.Show(text: "End of Script.");
            }
        }
Example #3
0
 internal StormConnection(SchemaNavigator navigator, IDbConnection connection, SQLEngine engine)
 {
     isOpen            = false;
     this.navigator    = navigator;
     this.connection   = connection;
     this.engine       = engine;
     this.connectionId = Util.UCode();
 }
Example #4
0
        static void FillScenarioListBox(ListBox x)
        {
            SQLiteDataReader r    = SQLEngine.ThrowQuery("SELECT scr.ID, ScnCommands.Description, img.path FROM ScnScript scr left outer join ResImages img on scr.cmdAction = img.id left outer join ScnCommands on scr.cmdID = ScnCommands.ID");
            string           line = String.Empty;

            while (r.Read())
            {
                line = r["ID"].ToString() + " " + r["Description"].ToString() + " " + r["Path"].ToString();
                x.Items.Add(line);
            }
            r.Close();
        }
Example #5
0
        public static void FillScenarioList(ListBox x)
        {
            SQLiteDataReader r    = SQLEngine.ThrowQuery("SELECT Name FROM Scenarios");
            string           line = String.Empty;

            while (r.Read())
            {
                line = r["Name"].ToString();
                x.Items.Add(line);
            }
            r.Close();
            SQLiteConnection.ClearAllPools();
        }
Example #6
0
 private void checkBoxOptions_toggleDominantColor_CheckedChanged(object sender, EventArgs e)
 {
     if (checkBoxOptions_toggleDominantColor.Checked)
     {
         SQLEngine.Update("Update GameOptions Set value = 1 where id = 1");
         GraphicEngine.UseDominantColor = true;
     }
     else
     {
         SQLEngine.Update("Update GameOptions Set value = 0 where id = 1");
         GraphicEngine.UseDominantColor = false;
     }
 }
Example #7
0
        public static void GameInit()
        {
            ActionType = int.Parse(SQLEngine.GetValue("SELECT CmdID FROm ScnScript WHERE ID =" + ScriptPosition.ToString()));
            switch (ActionType)
            {
            case 1:
                TryHard.This(() => SQLEngine.ImagePath());
                GraphicEngine.SetBackground();
                break;

            case 2:
                break;

            case 3:
                break;
            }
        }
Example #8
0
        private void GameWindow_Load(object sender, EventArgs e)
        {
            //<--Maximize window
            this.WindowState     = FormWindowState.Normal;
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.Bounds          = Screen.PrimaryScreen.Bounds;
            this.WindowState     = FormWindowState.Maximized;
            GraphicEngine.GetResolution(); //sets resolution for rendering
                                           //-->

            this.panelOptions.AllowDrop = true;
            foreach (Control c in this.panelOptions.Controls)
            {
                c.MouseDown += new MouseEventHandler(c_MouseDown);
            }
            this.panelOptions.DragOver += new DragEventHandler(panelOptions_DragOver);
            this.panelOptions.DragDrop += new DragEventHandler(panelOptions_DragDrop);

            //<--Resize/Move components according to resolution
            button1.Location = new Point(GraphicEngine.X(button1.Location.X), GraphicEngine.Y(button1.Location.Y));
            button1.Size     = new Size(GraphicEngine.X(button1.Size.Width), GraphicEngine.Y(button1.Size.Height));

            //-->

            //<--sets hidable Text are to visible state by default
            this.TextAreaVisible = true;
            //-->

            // this.LoadBackground(@"G:\Temp\Images\13.jpg");


            ScriptEngine.GameInit();
            int Value = int.Parse(SQLEngine.GetValue("Select Value from GameOptions where ID=1"));

            if (Value == 1)
            {
                checkBoxOptions_toggleDominantColor.Checked = true; GraphicEngine.UseDominantColor = true;
            }
            else
            {
                checkBoxOptions_toggleDominantColor.Checked = false; GraphicEngine.UseDominantColor = false;
            }
        }
Example #9
0
        private string TransSQL(string sql)
        {
            bool   flag = string.IsNullOrEmpty(sql);
            string result;

            if (flag)
            {
                result = "";
            }
            else
            {
                string rtn = "";
                try
                {
                    rtn = SQLEngine.TransSQL(this.m_database.DriverName, sql);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                result = rtn;
            }
            return(result);
        }
Example #10
0
        public static void ScenarioSelected(ListBox x, Label y)
        {
            String r = SQLEngine.GetValue("SELECT Description FROM Scenarios WHERE Name ='" + x.Text + "'");

            y.Text = r;
        }
    private void GetNames()
    {
        SQLEngine sql = new SQLEngine(ConnectionString);

        _names = sql.GetDataTable("SELECT * FROM Names").ToList <string>();
    }
Example #12
0
 public Storm(SQLEngine engine)
 {
     this.schema = new Schema.Schema();
     this.engine = engine;
 }
Example #13
0
 public Storm()
 {
     this.schema = new Schema.Schema();
     this.engine = SQLEngine.MSSQLServer;
 }
Example #14
0
 public BaseDAO()
 {
     db     = new SQLEngine();
     logger = new LogEngine();
 }
        public MainWindow()
        {
            InitializeComponent();

            bool IsMySQLDB = true;

            DataSet busDataSet      = AccessEngine.Get("SELECT DISTINCT(bus_id) FROM [IntervalData2014-2015]");
            DataSet intervalDataSet = AccessEngine.Get("SELECT * FROM [IntervalData2014-2015]");
            DataSet routeDataSet    = AccessEngine.Get("SELECT * FROM [Route ID]");
            DataSet stopDataSet     = AccessEngine.Get("SELECT * FROM [Stop ID]");
            DataSet weatherDataSet  = AccessEngine.Get("SELECT * FROM [Weather Data]");

            List <Bus> buses = new List <Bus>();

            foreach (DataRow row in busDataSet.Tables[0].Rows)
            {
                Bus bus = new Bus();
                bus.ID          = SQLUtil.ParseID(row[0]);
                bus.Description = string.Empty;
                buses.Add(bus);
            }

            List <Route> routes = new List <Route>();

            foreach (DataRow row in routeDataSet.Tables[0].Rows)
            {
                Route route = new Route();
                route.ID = SQLUtil.ParseID(row["ID"]);
                string   info      = SQLUtil.ParseString(row["Route ID"]);
                string[] infoArray = info.Split(' ');
                if (infoArray.Length > 1 && infoArray[0].Length == 1)
                {
                    route.Name = infoArray[0];
                }
                else
                {
                    route.Name = info;
                }

                route.RouteDetail = info;

                if (route.RouteDetail.Contains("M-R"))
                {
                    route.IsMtoR = true;
                }
                else
                {
                    route.IsMtoR = false;
                }

                routes.Add(route);
            }

            List <RouteDetail> routeDetails = new List <RouteDetail>();
            List <string>      lines        = new List <string>();

            //Build each route.
            lines = CSVUtil.ReadCSV("A.csv");
            int ARouteID = routes.First(o => o.Name == lines[0].Substring(0, 1) && o.IsMtoR == true).ID.Value;

            for (int i = 2; i < lines.Count; i++) // Line 0 is route name and Line 1 is header
            {
                string[]    line = lines[i].Split(',');
                RouteDetail rd   = new RouteDetail();
                rd.RouteID       = ARouteID;
                rd.Sequence      = i - 1;
                rd.FromBusStopID = int.Parse(line[0]);
                rd.ToBusStopID   = int.Parse(line[1]);
                if (rd.FromBusStopID == rd.ToBusStopID)
                {
                    rd.IsStationary = true;
                }
                else
                {
                    rd.IsStationary = false;
                }

                rd.Distance            = double.Parse(line[2]);
                rd.IdealTravelTime     = int.Parse(line[3]);
                rd.ScheduledTravelTime = int.Parse(line[3]);
                if (rd.IsStationary)
                {
                    rd.ScheduledStopTime = int.Parse(line[3]);
                }

                routeDetails.Add(rd);
            }

            lines.Clear();
            lines = CSVUtil.ReadCSV("B.csv");
            int BRouteID = routes.First(o => o.Name == lines[0].Substring(0, 1) && o.IsMtoR == true).ID.Value;

            for (int i = 2; i < lines.Count; i++) // Line 0 is route name and Line 1 is header
            {
                string[]    line = lines[i].Split(',');
                RouteDetail rd   = new RouteDetail();
                rd.RouteID       = BRouteID;
                rd.Sequence      = i - 1;
                rd.FromBusStopID = int.Parse(line[0]);
                rd.ToBusStopID   = int.Parse(line[1]);
                if (rd.FromBusStopID == rd.ToBusStopID)
                {
                    rd.IsStationary = true;
                }
                else
                {
                    rd.IsStationary = false;
                }

                rd.Distance            = double.Parse(line[2]);
                rd.IdealTravelTime     = int.Parse(line[3]);
                rd.ScheduledTravelTime = int.Parse(line[3]);
                if (rd.IsStationary)
                {
                    rd.ScheduledStopTime = int.Parse(line[3]);
                }

                routeDetails.Add(rd);
            }

            lines.Clear();
            lines = CSVUtil.ReadCSV("E.csv");
            int ERouteID = routes.First(o => o.Name == lines[0].Substring(0, 1) && o.IsMtoR == true).ID.Value;

            for (int i = 2; i < lines.Count; i++) // Line 0 is route name and Line 1 is header
            {
                string[]    line = lines[i].Split(',');
                RouteDetail rd   = new RouteDetail();
                rd.RouteID       = ERouteID;
                rd.Sequence      = i - 1;
                rd.FromBusStopID = int.Parse(line[0]);
                rd.ToBusStopID   = int.Parse(line[1]);
                if (rd.FromBusStopID == rd.ToBusStopID)
                {
                    rd.IsStationary = true;
                }
                else
                {
                    rd.IsStationary = false;
                }

                rd.Distance            = double.Parse(line[2]);
                rd.IdealTravelTime     = int.Parse(line[3]);
                rd.ScheduledTravelTime = int.Parse(line[3]);
                if (rd.IsStationary)
                {
                    rd.ScheduledStopTime = int.Parse(line[3]);
                }

                routeDetails.Add(rd);
            }

            lines.Clear();
            lines = CSVUtil.ReadCSV("X.csv");
            int XRouteID = routes.First(o => o.Name == lines[0].Substring(0, 1) && o.IsMtoR == true).ID.Value;

            for (int i = 2; i < lines.Count; i++) // Line 0 is route name and Line 1 is header
            {
                string[]    line = lines[i].Split(',');
                RouteDetail rd   = new RouteDetail();
                rd.RouteID       = ERouteID;
                rd.Sequence      = i - 1;
                rd.FromBusStopID = int.Parse(line[0]);
                rd.ToBusStopID   = int.Parse(line[1]);
                if (rd.FromBusStopID == rd.ToBusStopID)
                {
                    rd.IsStationary = true;
                }
                else
                {
                    rd.IsStationary = false;
                }

                rd.Distance            = double.Parse(line[2]);
                rd.IdealTravelTime     = int.Parse(line[3]);
                rd.ScheduledTravelTime = int.Parse(line[3]);
                if (rd.IsStationary)
                {
                    rd.ScheduledStopTime = int.Parse(line[3]);
                }

                routeDetails.Add(rd);
            }

            List <BusStop> busStops = new List <BusStop>();

            //foreach (DataRow row in stopDataSet.Tables[0].Rows)
            //{
            //    BusStop busStop = new BusStop();
            //    busStop.ID = SQLUtil.ParseID(row["ID"]);
            //    busStop.Name = SQLUtil.ParseString(row["Stop"]);
            //    busStop.IsMajorStop = false;

            //    busStops.Add(busStop);
            //}

            lines.Clear();
            lines = CSVUtil.ReadCSV("Combined GPS Data.csv");
            for (int i = 1; i < lines.Count; i++) // Line 0 is header
            {
                string[] line    = lines[i].Split(',');
                BusStop  busStop = new BusStop();
                busStop.ID        = int.Parse(line[0]);
                busStop.Name      = line[1];
                busStop.Latitude  = double.Parse(line[2]);
                busStop.Longitude = double.Parse(line[3]);
                busStop.Buddy     = line[4];
                if (line[5].ToLower() == "yes")
                {
                    busStop.Visible = true;
                }
                else
                {
                    busStop.Visible = false;
                }

                if (line[6].ToLower() == "yes")
                {
                    busStop.Announce = true;
                }
                else
                {
                    busStop.Announce = false;
                }

                busStops.Add(busStop);
            }


            List <Weather> weathers = new List <Weather>();

            foreach (DataRow row in weatherDataSet.Tables[0].Rows)
            {
                Weather weather = new Weather();
                weather.ID            = SQLUtil.ParseID(row["ID"]);
                weather.Date          = SQLUtil.ParseDateTime(row["EDT"]);
                weather.MinTemp       = SQLUtil.ParseInt(row["MinTemp"]);
                weather.Precipitation = SQLUtil.ParseString(row["Precipitation"]);
                weather.Events        = SQLUtil.ParseString(row["Events"]);

                weathers.Add(weather);
            }

            List <Interval> intervals = new List <Interval>();

            foreach (DataRow row in intervalDataSet.Tables[0].Rows)
            {
                Interval interval = new Interval();
                //interval.ID = SQLUtil.ParseID(row["ID1"]);
                interval.BusID = SQLUtil.ParseInt(row["bus_id"]);
                string routeName = SQLUtil.ParseString(row["route_id"]);
                if (routeName == "354")
                {
                    routeName = "A";
                }
                interval.RouteObj      = routes.First(o => o.Name == routeName && o.IsMtoR == true);
                interval.FromBusStopID = SQLUtil.ParseInt(row["from"]);
                string toBusStop = SQLUtil.ParseString(row["to"]);
                interval.ToBusStopID = busStops.First(o => o.Name.ToLower().Contains(toBusStop.ToLower())).ID.Value;

                if (interval.FromBusStopID == interval.ToBusStopID)
                {
                    interval.IsStationary = true;
                }
                else
                {
                    interval.IsStationary = false;
                }

                interval.TimeInterval = SQLUtil.ParseInt(row["time"]);
                interval.Timestamp    = SQLUtil.ParseDateTime(row["when"]);

                Weather temp = weathers.FirstOrDefault(o => o.DateString == interval.Timestamp.ToShortDateString());
                if (temp != null)
                {
                    interval.MinTemp       = temp.MinTemp;
                    interval.Precipitation = temp.Precipitation;
                    interval.Events        = temp.Events;
                }

                intervals.Add(interval);
            }

            DataTable rdDataTable;

            if (IsMySQLDB)
            {
                MySQLEngine.OpenDBConnection();
                MySqlCommand myCmd = new MySqlCommand();

                foreach (Bus bus in buses)
                {
                    myCmd.CommandText = "INSERT INTO TBL_Bus(ID, Description) VALUES (" + bus.ID + ", '" + bus.Description + "')";

                    MySQLEngine.ExecuteCommandText(myCmd);
                }

                foreach (Bus bus in buses)
                {
                    myCmd.CommandText = "INSERT INTO TBL_Bus(ID, Description) VALUES (" + bus.ID + ", '" + bus.Description + "')";

                    MySQLEngine.ExecuteCommandText(myCmd);
                }

                foreach (BusStop busStop in busStops)
                {
                    myCmd.CommandText = "INSERT INTO TBL_BusStop(ID, Name, IsMajorStop, Latitude, Longitude, Buddy, Visible, Announce) VALUES ("
                                        + busStop.ID + ", '" + busStop.Name.Replace("'", "''") + "', '" + busStop.IsMajorStop + "', "
                                        + busStop.Latitude + ", " + busStop.Longitude + ", '" + busStop.Buddy + "', '"
                                        + busStop.Visible + "', '" + busStop.Announce + "')";

                    MySQLEngine.ExecuteCommandText(myCmd);
                }

                foreach (Route route in routes)
                {
                    myCmd.CommandText = "INSERT INTO TBL_Route(ID, Name, RouteDetail, IsMtoR) VALUES (" + route.ID + ", '"
                                        + route.Name + "', '" + route.RouteDetail + "', '" + route.IsMtoR.ToString() + "')";

                    MySQLEngine.ExecuteCommandText(myCmd);
                }

                foreach (RouteDetail rd in routeDetails)
                {
                    myCmd.CommandText = "INSERT INTO TBL_RouteDetail(RouteID, Sequence, FromBusStopID, ToBusStopID, IsStationary, "
                                        + "Distance, IdealTravelTime, ScheduleStopTime, ScheduleTravelTime) VALUES ("
                                        + rd.RouteID + ", " + rd.Sequence + ", " + rd.FromBusStopID + ", " + rd.ToBusStopID
                                        + ", '" + rd.IsStationary + "', " + rd.Distance + ", " + rd.IdealTravelTime
                                        + ", " + rd.ScheduledStopTime + ", " + rd.ScheduledTravelTime + ")";

                    MySQLEngine.ExecuteCommandText(myCmd);
                    myCmd.CommandText = "SELECT MAX(ID) FROM TBL_RouteDetail";
                    rdDataTable       = MySQLEngine.GetDataTableCommandText(myCmd);
                    rd.ID             = SQLUtil.ParseID(rdDataTable.Rows[0][0]);
                }

                foreach (Interval interval in intervals)
                {
                    interval.RouteDetailObj = routeDetails.FirstOrDefault(o => o.FromBusStopID == interval.FromBusStopID &&
                                                                          o.ToBusStopID == interval.ToBusStopID && o.RouteID == interval.RouteID);
                    myCmd.CommandText = "INSERT INTO TBL_Interval(BusID, RouteID, RouteDetailID, FromBusStopID, ToBusStopID, "
                                        + "IsStationary, TimeInterval, Timestamp, Day, MinTemp, Precipitation, Events) VALUES ("
                                        + interval.BusID + ", " + interval.RouteID + ", " + interval.RouteDetailID + ", "
                                        + interval.FromBusStopID + ", " + interval.ToBusStopID + ", '" + interval.IsStationary + "', "
                                        + interval.TimeInterval + ", '" + interval.Timestamp.ToString() + "', '" + interval.Day + "', "
                                        + interval.MinTemp + ", '" + interval.Precipitation + "', '" + interval.Events + "')";
                    MySQLEngine.ExecuteCommandText(myCmd);
                }

                MySQLEngine.CloseDBConnection();
            }
            else
            {
                SQLEngine.OpenDBConnection();
                SqlCommand cmd = new SqlCommand();

                foreach (Bus bus in buses)
                {
                    cmd.CommandText = "INSERT INTO TBL_Bus(ID, Description) VALUES (" + bus.ID + ", '" + bus.Description + "')";

                    SQLEngine.ExecuteCommandText(cmd);
                }

                foreach (Bus bus in buses)
                {
                    cmd.CommandText = "INSERT INTO TBL_Bus(ID, Description) VALUES (" + bus.ID + ", '" + bus.Description + "')";

                    SQLEngine.ExecuteCommandText(cmd);
                }

                foreach (BusStop busStop in busStops)
                {
                    cmd.CommandText = "INSERT INTO TBL_BusStop(ID, Name, IsMajorStop, Latitude, Longitude, Buddy, Visible, Announce) VALUES ("
                                      + busStop.ID + ", '" + busStop.Name.Replace("'", "''") + "', '" + busStop.IsMajorStop + "', "
                                      + busStop.Latitude + ", " + busStop.Longitude + ", '" + busStop.Buddy + "', '"
                                      + busStop.Visible + "', '" + busStop.Announce + "')";

                    SQLEngine.ExecuteCommandText(cmd);
                }

                foreach (Route route in routes)
                {
                    cmd.CommandText = "INSERT INTO TBL_Route(ID, Name, RouteDetail, IsMtoR) VALUES (" + route.ID + ", '"
                                      + route.Name + "', '" + route.RouteDetail + "', '" + route.IsMtoR.ToString() + "')";

                    SQLEngine.ExecuteCommandText(cmd);
                }

                foreach (RouteDetail rd in routeDetails)
                {
                    cmd.CommandText = "INSERT INTO TBL_RouteDetail(RouteID, Sequence, FromBusStopID, ToBusStopID, IsStationary, "
                                      + "Distance, IdealTravelTime, ScheduleStopTime, ScheduleTravelTime) VALUES ("
                                      + rd.RouteID + ", " + rd.Sequence + ", " + rd.FromBusStopID + ", " + rd.ToBusStopID
                                      + ", '" + rd.IsStationary + "', " + rd.Distance + ", " + rd.IdealTravelTime
                                      + ", " + rd.ScheduledStopTime + ", " + rd.ScheduledTravelTime + ")";

                    SQLEngine.ExecuteCommandText(cmd);
                    cmd.CommandText = "SELECT MAX(ID) FROM TBL_RouteDetail";
                    rdDataTable     = SQLEngine.GetDataTableCommandText(cmd);
                    rd.ID           = SQLUtil.ParseID(rdDataTable.Rows[0][0]);
                }

                foreach (Interval interval in intervals)
                {
                    interval.RouteDetailObj = routeDetails.FirstOrDefault(o => o.FromBusStopID == interval.FromBusStopID &&
                                                                          o.ToBusStopID == interval.ToBusStopID && o.RouteID == interval.RouteID);
                    cmd.CommandText = "INSERT INTO TBL_Interval(BusID, RouteID, RouteDetailID, FromBusStopID, ToBusStopID, "
                                      + "IsStationary, TimeInterval, Timestamp, Day, MinTemp, Precipitation, Events) VALUES ("
                                      + interval.BusID + ", " + interval.RouteID + ", " + interval.RouteDetailID + ", "
                                      + interval.FromBusStopID + ", " + interval.ToBusStopID + ", '" + interval.IsStationary + "', "
                                      + interval.TimeInterval + ", '" + interval.Timestamp.ToString() + "', '" + interval.Day + "', "
                                      + interval.MinTemp + ", '" + interval.Precipitation + "', '" + interval.Events + "')";
                    SQLEngine.ExecuteCommandText(cmd);
                }

                SQLEngine.CloseDBConnection();
            }
        }