Ejemplo n.º 1
0
        public List <ConfigPositions> GetConfigPositions(int configId)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString;
            List <ConfigPositions> configPositionList = new List <ConfigPositions>();
            SqlConnection          con = new SqlConnection(connectionString);
            string selectSQL           = String.Format("SELECT Activity.Activity, XPos, YPos FROM ActivityPosition INNER JOIN Activity ON ActivityPosition.ActivityId = Activity.ActivityId");

            try
            {
                con.Open();
                SqlCommand    cmd = new SqlCommand(selectSQL, con);
                SqlDataReader dr  = cmd.ExecuteReader();
                if (dr != null)
                {
                    while (dr.Read())
                    {
                        ConfigPositions configPosition = new ConfigPositions();

                        configPosition.Activity = Convert.ToString(dr["Activity"]);
                        configPosition.XPos     = Convert.ToDouble(dr["XPos"]);
                        configPosition.YPos     = Convert.ToDouble(dr["YPos"]);

                        configPositionList.Add(configPosition);
                    }
                }
                con.Close();
            }
            catch (Exception ex)
            {
                ActivityViewModel.ShowMessageBox(ex.ToString(), "Error!");
            }
            return(configPositionList);
        }
Ejemplo n.º 2
0
        //Method to connect locations and activities in the config list
        public void AddActivityLocations()
        {
            DatabaseHandler dbHandler    = new DatabaseHandler();
            List <string>   activityList = new List <string>();

            activityList = dbHandler.GetActivityList();
            for (int i = 0; i < activityList.Count; i++)
            {
                ConfigPositions configPosition = new ConfigPositions();
                configPosition.Activity = activityList[i];
                switch (activityList[i])
                {
                case "Sleeping":
                    configPosition.ActivityLocation = "Bed";
                    break;

                case "Toileting":
                    configPosition.ActivityLocation = "Toilet";
                    break;

                case "Showering":
                    configPosition.ActivityLocation = "ShowerArea";
                    break;

                case "Breakfast":
                    configPosition.ActivityLocation = "DiningTable";
                    break;

                case "Grooming":
                    configPosition.ActivityLocation = "Basin";
                    break;

                case "SpareTime/TV":
                    configPosition.ActivityLocation = "Sofa";
                    break;

                case "Leaving":
                    configPosition.ActivityLocation = "Entrance";
                    break;

                case "Lunch":
                    configPosition.ActivityLocation = "DiningTable";
                    break;

                case "Snack":
                    configPosition.ActivityLocation = "DiningTable";
                    break;
                }
                configPositionList.Add(configPosition);
            }
        }