Ejemplo n.º 1
0
        /// <summary>
        /// Choose a specific room and view its information.
        /// </summary>
        /// <param name="selectedRoom">The room's data</param>
        private void UseSelectedRoom(RoomData selectedRoom)
        {
            // Cleanup previous selections
            SelectedClass         = NO_ASSIGNED_CLASS;
            RoomName              = string.Empty;
            LessonsInSelectedRoom = new ObservableCollection <LessonsInRoom>();

            // Remove the previous room choice's class from the available classes list (as it is already assigned to that room)
            if (_previousRoomClass != null)
            {
                AvailableClasses.Remove(_previousRoomClass.Value);
            }

            // Update the properties per the selected room
            if (selectedRoom != null)
            {
                RoomName = selectedRoom.Name;

                // If the room has an homeroom, add it first to the available classes list
                if (selectedRoom.HomeroomClassID != null)
                {
                    AvailableClasses.Add(selectedRoom.HomeroomClassID.Value, selectedRoom.HomeroomClassName);
                    SelectedClass = selectedRoom.HomeroomClassID.Value;
                }

                // Save this room class ID so it can be removed from the available classes when we select another room
                _previousRoomClass = selectedRoom.HomeroomClassID;

                // Create the list of lessons in the current room
                if (selectedRoom.LessonsInThisRoom != null)
                {
                    LessonsInSelectedRoom = new ObservableCollection <LessonsInRoom>(selectedRoom.LessonsInThisRoom);
                }
            }
        }
Ejemplo n.º 2
0
        public void Initialize(Person connectedPerson)
        {
            ConnectedPerson = connectedPerson;

            ResetAll();

            if (HasRequiredPermissions)
            {
                // Get the school data and use to it to populate this View Model's data
                SchoolEntities schoolData = new SchoolEntities();

                // Create a list of all the classes in the school
                schoolData.Classes.ToList().ForEach(currClass => AvailableClasses.Add(currClass.classID, currClass.className));

                AvailableHomeroomClasses.Add(FIELD_NOT_SET, "לא מוגדר");
                schoolData.Classes.Where(currClass => currClass.Teachers.Count() == 0).ToList()
                .ForEach(currClass => AvailableHomeroomClasses.Add(currClass.classID, currClass.className));

                // Create a list of all the parents in the school
                AvailableParents.Add(FIELD_NOT_SET, "לא מוגדר");
                schoolData.Persons.Where(p => p.isParent).ToList()
                .ForEach(parent => AvailableParents.Add(parent.personID, parent.firstName + " " + parent.lastName));

                // Create a list of all the students in the school
                schoolData.Persons.Where(p => p.isStudent).ToList()
                .ForEach(student => AvailableStudents.Add(student.personID, student.firstName + " " + student.lastName));

                // Create a list of all the courses in the school
                schoolData.Courses.Where(course => course.isHomeroomTeacherOnly == false).ToList()
                .ForEach(course => AvailableCoursesMustChoose.Add(course.courseID, course.courseName));
                AvailableCourses.Add(FIELD_NOT_SET, "לא מוגדר");
                AvailableCoursesMustChoose.ToList().ForEach(course => AvailableCourses.Add(course.Key, course.Value));
            }
        }
Ejemplo n.º 3
0
        public void Initialize(Person connectedPerson)
        {
            // Reset all information
            ConnectedPerson = connectedPerson;
            AvailableUserTypes.Clear();
            AvailableUsers.Clear();
            AvailableClasses.Clear();
            AvailableParents.Clear();
            AvailableStudents.Clear();
            AvailableCourses.Clear();
            AvailableCoursesMustChoose.Clear();
            AvailableHomeroomClasses.Clear();

            if (HasRequiredPermissions)
            {
                _schoolData = new SchoolEntities();

                // Create a list of all the editable user types
                if (!CanEditManagement)
                {
                    AvailableUserTypes.AddRange(new List <string>()
                    {
                        Globals.USER_TYPE_STUDENT, Globals.USER_TYPE_TEACHERS, Globals.USER_TYPE_PARENTS
                    });
                }
                else
                {
                    AvailableUserTypes.AddRange(new List <string>()
                    {
                        Globals.USER_TYPE_STUDENT, Globals.USER_TYPE_TEACHERS, Globals.USER_TYPE_PARENTS,
                        Globals.USER_TYPE_SECRETARIES, Globals.USER_TYPE_PRINCIPAL
                    });
                }
                SelectedUserType = AvailableUserTypes[0];

                // Create a list of all the classes in the school
                _schoolData.Classes.ToList().ForEach(currClass => AvailableClasses.Add(currClass.classID, currClass.className));

                AvailableHomeroomClasses.Add(FIELD_NOT_SET, "לא מוגדר");
                _schoolData.Classes.Where(currClass => currClass.Teachers.Count() == 0).ToList()
                .ForEach(currClass => AvailableHomeroomClasses.Add(currClass.classID, currClass.className));

                // Create a list of all the parents in the school
                AvailableParents.Add(FIELD_NOT_SET, "לא מוגדר");
                _schoolData.Persons.Where(p => p.isParent).ToList()
                .ForEach(parent => AvailableParents.Add(parent.personID, parent.firstName + " " + parent.lastName));

                // Create a list of all the students in the school
                _schoolData.Persons.Where(p => p.isStudent).ToList()
                .ForEach(student => AvailableStudents.Add(student.personID, student.firstName + " " + student.lastName));

                // Create a list of all the courses in the school
                _schoolData.Courses.Where(course => course.isHomeroomTeacherOnly == false).ToList()
                .ForEach(course => AvailableCoursesMustChoose.Add(course.courseID, course.courseName));
                AvailableCourses.Add(FIELD_NOT_SET, "לא מוגדר");
                AvailableCoursesMustChoose.ToList().ForEach(course => AvailableCourses.Add(course.Key, course.Value));
            }
        }
Ejemplo n.º 4
0
        private async void PostRequest()
        {
            try
            {
                var content = new StringContent(JsonConvert.SerializeObject(imageDirectory), Encoding.UTF8, "application/json");
                HttpResponseMessage httpResponse;
                try
                {
                    httpResponse = await client.PostAsync(url, content, cts.Token);
                }
                catch (HttpRequestException)
                {
                    await disp.BeginInvoke(new Action(() =>
                    {
                        MessageBox.Show("NO CONNECTION", "Warning");
                        Stop();
                    }));

                    return;
                }

                if (httpResponse.IsSuccessStatusCode)
                {
                    var items = JsonConvert.DeserializeObject <List <RecognitionInfo> >(httpResponse.Content.ReadAsStringAsync().Result);
                    foreach (var item in items)
                    {
                        await disp.BeginInvoke(new Action(() =>  //await ???
                        {
                            ClassesImages.Add(item);
                            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("ClassesImages"));
                            Pair <string, int> p;
                            try
                            {
                                p = AvailableClasses.Single(i => i.Item1 == item.Class);
                                p.Item2 += 1;
                            }
                            catch (InvalidOperationException)
                            {
                                AvailableClasses.Add(new Pair <string, int>(item.Class, 1));
                                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("AvailableClasses"));
                            }
                        }));
                    }
                    isRunning = false;
                }
            }
            catch (OperationCanceledException)
            {
                await disp.BeginInvoke(new Action(() =>
                {
                    MessageBox.Show("RECOGNITION STOPPED", "Warning");
                }));
            }
        }
Ejemplo n.º 5
0
        internal void DeliverClass(IContext context, IMailSender sender, ClassDeliveryPlan classDeliveryPlan)
        {
            classDeliveryPlan.DeliveryDate = DateTime.Now;
            AvailableClasses.Add(classDeliveryPlan);

            context.GetList <Notice>().Add(new Notice
            {
                Text =
                    $@"New <a href='Class/Watch/{classDeliveryPlan.ClassId}'>{Resource.ClassName} {classDeliveryPlan.Class.Name}</a> available! <br />
                               <a href='Class/Index/{classDeliveryPlan.Class.Course.Id}'>{Resource.CourseName} {classDeliveryPlan.Class.Course.Name}</a> <br />",
                DateTime     = DateTime.Now,
                DeliveryPlan = this
            });
            context.Save();
            SendDeliveringClassEmail(context, sender, classDeliveryPlan.Class, Students);
        }
Ejemplo n.º 6
0
        private void AddPrediction(PredictionResult pr)
        {
            dispatcher.BeginInvoke(new Action(() =>
            {
                ObservableModelPrediction.Add(new ModelPrediction(pr));
                var buf = AvailableClasses.Where(x => x.Item1 == pr.ClassName).FirstOrDefault();

                if (buf != null)
                {
                    AvailableClasses[AvailableClasses.IndexOf(buf)] = new Tuple <string, int>(buf.Item1, buf.Item2 + 1);
                }
                else
                {
                    AvailableClasses.Add(new Tuple <string, int>(pr.ClassName, 1));
                }
            }));
        }
Ejemplo n.º 7
0
        public void Initialize(Person connectedPerson)
        {
            ConnectedPerson = connectedPerson;

            // Get the list of existing rooms
            RoomsTableData = new ObservableCollection <RoomData>(_schoolData.Rooms.AsEnumerable().Select(room => ModelRoomToRoomData(room)).ToList());

            // Create the basic list of available classes
            AvailableClasses.Clear();

            // Add a 'No class' option, as not all rooms are assigned to a specific class
            AvailableClasses.Add(NO_ASSIGNED_CLASS, "אין כיתה משויכת");

            // Create the list of classes that don't have an homeroom already
            _schoolData.Classes.Where(schoolClass => schoolClass.roomID == null).ToList()
            .ForEach(schoolClass => AvailableClasses.Add(schoolClass.classID, schoolClass.className));

            SelectedClass = NO_ASSIGNED_CLASS;

            // For some reason, after re-initializing this view, the SelectedClass is not updated properly in the view unless called again
            OnPropertyChanged("SelectedClass");
        }
        public void Initialize(Person connectedPerson)
        {
            ConnectedPerson = connectedPerson;
            ResetData();

            // Create the lists of possible classes, courses, teachers
            _schoolData.Classes.ToList().ForEach(schoolClass => AvailableClasses.Add(schoolClass.classID, schoolClass.className));
            _schoolData.Courses.ToList().ForEach(course => AvailableCourses.Add(course.courseID, course.courseName));
            _schoolData.Teachers.Where(teacher => !teacher.Person.User.isDisabled).ToList()
            .ForEach(teacher => AvailableTeachers.Add(teacher.teacherID, teacher.Person.firstName + " " + teacher.Person.lastName));

            // Initialize the rooms list. Note that a room is optional and therefore has a NOT_ASSIGNED option
            AvailableRooms.Add(NOT_ASSIGNED, "ללא");
            _schoolData.Rooms.ToList().ForEach(room => AvailableRooms.Add(room.roomID, room.roomName));

            SearchingByClass = true;

            // For some reason, after re-initializing this view, the selections are not updated properly in the view unless called again
            OnPropertyChanged("SelectedClass");
            OnPropertyChanged("SelectedCourse");
            OnPropertyChanged("SelectedTeacher");
            OnPropertyChanged("SelectedRoom");
        }
Ejemplo n.º 9
0
    private static void DefineTypes()
    {
        var watch = Stopwatch.StartNew();

        var assembly = Assembly.GetExecutingAssembly();

        IEnumerable <Type> types;

        try
        {
            types = assembly.GetTypes();
        }
        catch (ReflectionTypeLoadException e)
        {
            types = e.Types.Where(x => x is not null) !;
        }

        var engineRelatedTypes = types.Where(t =>
                                             t?.IsClass == true &&
                                             t.Namespace?.StartsWith("GBX.NET.Engines") == true);

        var availableClassesByType = new Dictionary <Type, uint>();

        foreach (var type in engineRelatedTypes)
        {
            if (!type.IsSubclassOf(typeof(CMwNod)) && type != typeof(CMwNod)) // Engine types
            {
                continue;
            }

            var id = type.GetCustomAttribute <NodeAttribute>()?.ID;

            if (!id.HasValue)
            {
                throw new Exception($"{type.Name} misses NodeAttribute.");
            }

            AvailableClasses.Add(id.Value, type);
            availableClassesByType.Add(type, id.Value);
        }

        foreach (var typePair in AvailableClasses)
        {
            var id   = typePair.Key;
            var type = typePair.Value;

            var classes = new List <uint>();

            Type currentType = type.BaseType !;

            while (currentType != typeof(object))
            {
                classes.Add(availableClassesByType[currentType]);

                currentType = currentType.BaseType !;
            }

            AvailableInheritanceClasses[type] = classes;

            var chunks = type.GetNestedTypes().Where(x => x.IsSubclassOf(typeof(Chunk)));

            var baseType = type.BaseType !;

            while (baseType !.IsSubclassOf(typeof(CMwNod)))
            {
                chunks = chunks.Concat(baseType.GetNestedTypes().Where(x => x.IsSubclassOf(typeof(Chunk))));

                baseType = baseType.BaseType;
            }

            var availableChunkClasses       = new Dictionary <uint, Type>();
            var availableHeaderChunkClasses = new Dictionary <uint, Type>();

            foreach (var chunk in chunks)
            {
                var chunkAttribute = chunk.GetCustomAttribute <ChunkAttribute>();

                if (chunkAttribute == null)
                {
                    throw new Exception($"Chunk {chunk.FullName} doesn't have ChunkAttribute.");
                }

                if (chunk.GetInterface(nameof(IHeaderChunk)) == null)
                {
                    availableChunkClasses.Add(chunkAttribute.ID, chunk);
                }
                else
                {
                    availableHeaderChunkClasses.Add(chunkAttribute.ID, chunk);
                }
            }

            AvailableChunkClasses.Add(type, availableChunkClasses);
            AvailableHeaderChunkClasses.Add(type, availableHeaderChunkClasses);
        }

        foreach (var idClassPair in AvailableClasses)
        {
            var id        = idClassPair.Key;
            var classType = idClassPair.Value;

            AvailableClassAttributes.Add(classType, classType.GetCustomAttributes());
        }

        foreach (var classChunksPair in AvailableHeaderChunkClasses.Concat(AvailableChunkClasses))
        {
            var attributeDictionary = new Dictionary <uint, IEnumerable <Attribute> >();

            foreach (var chunkClassIdTypePair in classChunksPair.Value)
            {
                var id         = chunkClassIdTypePair.Key;
                var chunkClass = chunkClassIdTypePair.Value;

                var attributes = chunkClass.GetCustomAttributes();

                attributeDictionary[id] = attributes;

                AvailableChunkAttributesByType[chunkClass] = attributes;
            }

            AvailableChunkAttributes[classChunksPair.Key] = attributeDictionary;
        }

        foreach (var idClassPair in AvailableClasses)
        {
            var id        = idClassPair.Key;
            var classType = idClassPair.Value;

            var privateConstructor = classType.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, Array.Empty <Type>(), null);

            if (privateConstructor is null)
            {
                throw new PrivateConstructorNotFoundException(classType);
            }

            var newExp   = Expression.New(privateConstructor);
            var lambda   = Expression.Lambda <Func <CMwNod> >(newExp);
            var compiled = lambda.Compile();

            AvailableClassConstructors.Add(id, compiled);
        }

        foreach (var classChunksPair in AvailableChunkClasses)
        {
            var constructors = GetChunkConstructors(classChunksPair);
            if (constructors != null)
            {
                AvailableChunkConstructors[classChunksPair.Key] = constructors;
            }
        }

        foreach (var classChunksPair in AvailableHeaderChunkClasses)
        {
            var constructors = GetChunkConstructors(classChunksPair);
            if (constructors != null)
            {
                AvailableHeaderChunkConstructors[classChunksPair.Key] = constructors;
            }
        }

        Debug.WriteLine("Types defined in " + watch.Elapsed.TotalMilliseconds + "ms");
    }
Ejemplo n.º 10
0
        public static List <FitnessClass> GetClassList()
        {
            //creating and adding our classes

            Strength_Class StrengthClass1 = new Strength_Class
            {
                Name       = "Pump",
                Duration   = 60,
                Level      = "Intermediate",
                WeightType = "Barbells, Bar"
            };

            Strength_Class StrengthClass2 = new Strength_Class()
            {
                Name       = "Combat",
                Duration   = 45,
                Level      = "Beginner",
                WeightType = "Body Weight",
            };

            Cardio_Class CardioClass1 = new Cardio_Class
            {
                Name                 = "Attack",
                Duration             = 60,
                Level                = "Intermediate",
                FitnessLevelRequired = "High fitness Level Required"
            };

            Cardio_Class CardioClass2 = new Cardio_Class
            {
                Name                 = "Zumba",
                Duration             = 45,
                Level                = "Beginner",
                FitnessLevelRequired = "No fitness Level Required"
            };

            Balance_Class BalanceClass1 = new Balance_Class
            {
                Name     = "Easy Yoga",
                Duration = 30,
                Level    = "Beginner",
                Type     = "Yoga"
            };

            Balance_Class BalanceClass2 = new Balance_Class
            {
                Name     = "Master Pilates",
                Duration = 90,
                Level    = "Advanced",
                Type     = "Pilates"
            };

            Balance_Class BalanceClass3 = new Balance_Class
            {
                Name     = "Zen",
                Duration = 60,
                Level    = "Intermediate",
                Type     = "Thai Chi"
            };

            if (AvailableClasses.Count == 0)
            {
                AvailableClasses.Add(StrengthClass1);
                AvailableClasses.Add(StrengthClass2);
                AvailableClasses.Add(CardioClass1);
                AvailableClasses.Add(CardioClass2);
                AvailableClasses.Add(BalanceClass1);
                AvailableClasses.Add(BalanceClass2);
                AvailableClasses.Add(BalanceClass3);
            }
            //returning our class list
            return(AvailableClasses);
        }
Ejemplo n.º 11
0
        private async void PostRequest()
        {
            try
            {
                //MessageBox.Show(imageDirectory);
                var images = from file in Directory.GetFiles(imageDirectory) // пустой путь - throw exception
                             where file.Contains(".jpg") ||
                             file.Contains(".jpeg") ||
                             file.Contains(".png")
                             select file;
                Dictionary <string, string> ToServer = new Dictionary <string, string>();
                foreach (var i in images)
                {
                    ToServer.Add(i, Convert.ToBase64String(File.ReadAllBytes(i)));
                }

                var content = new StringContent(JsonConvert.SerializeObject(ToServer), Encoding.UTF8, "application/json");
                HttpResponseMessage httpResponse;
                try
                {
                    httpResponse = await client.PostAsync(url, content, cts.Token);
                }
                catch (HttpRequestException)
                {
                    await disp.BeginInvoke(new Action(() =>
                    {
                        MessageBox.Show("NO CONNECTION", "Warning");
                        Stop();
                    }));

                    return;
                }

                if (httpResponse.IsSuccessStatusCode)
                {
                    var items = JsonConvert.DeserializeObject <List <RecognitionContract> >(httpResponse.Content.ReadAsStringAsync().Result);
                    foreach (var item in items)
                    {
                        await disp.BeginInvoke(new Action(() =>  //await ???
                        {
                            ClassesImages.Add(item);
                            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("ClassesImages"));
                            Pair <string, int> p;
                            try
                            {
                                p = AvailableClasses.Single(i => i.Item1 == item.Class);
                                p.Item2 += 1;
                            }
                            catch (InvalidOperationException)
                            {
                                AvailableClasses.Add(new Pair <string, int>(item.Class, 1));
                                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("AvailableClasses"));
                            }
                        }));
                    }
                    isRunning = false;
                }
            }
            catch (OperationCanceledException)
            {
                await disp.BeginInvoke(new Action(() =>
                {
                    MessageBox.Show("RECOGNITION STOPPED", "Warning");
                }));
            }
        }
Ejemplo n.º 12
0
        private static void DefineTypes()
        {
            var watch = Stopwatch.StartNew();

            var assembly = Assembly.GetExecutingAssembly();

            IEnumerable <Type> types;

            try
            {
                types = assembly.GetTypes();
            }
            catch (ReflectionTypeLoadException e)
            {
                types = e.Types;
            }

            var engineRelatedTypes = types.Where(t =>
                                                 t?.IsClass == true &&
                                                 t.Namespace?.StartsWith("GBX.NET.Engines") == true);

            var availableClassesByType = new Dictionary <Type, uint>();

            foreach (var type in engineRelatedTypes)
            {
                if (type.IsSubclassOf(typeof(CMwNod)) || type == typeof(CMwNod)) // Engine types
                {
                    var id = type.GetCustomAttribute <NodeAttribute>()?.ID;

                    if (id.HasValue)
                    {
                        AvailableClasses.Add(id.Value, type);
                        availableClassesByType.Add(type, id.Value);
                    }
                    else
                    {
                        throw new Exception($"{type.Name} misses NodeAttribute.");
                    }
                }
            }

            var availableInheritanceTypes = new Dictionary <Type, List <Type> >();

            foreach (var typePair in AvailableClasses)
            {
                var id   = typePair.Key;
                var type = typePair.Value;

                List <uint> classes        = new List <uint>();
                List <Type> inheritedTypes = new List <Type>();

                Type currentType = type.BaseType;

                while (currentType != typeof(object))
                {
                    classes.Add(availableClassesByType[currentType]);
                    inheritedTypes.Add(currentType);

                    currentType = currentType.BaseType;
                }

                AvailableInheritanceClasses[type] = classes;
                availableInheritanceTypes[type]   = inheritedTypes;

                var chunks = type.GetNestedTypes().Where(x => x.IsSubclassOf(typeof(Chunk)));

                var availableChunkClasses       = new Dictionary <uint, Type>();
                var availableHeaderChunkClasses = new Dictionary <uint, Type>();

                foreach (var chunk in chunks)
                {
                    var chunkAttribute = chunk.GetCustomAttribute <ChunkAttribute>();

                    if (chunkAttribute == null)
                    {
                        throw new Exception($"Chunk {chunk.FullName} doesn't have ChunkAttribute.");
                    }

                    if (chunk.GetInterface(nameof(IHeaderChunk)) == null)
                    {
                        availableChunkClasses.Add(chunkAttribute.ID, chunk);
                    }
                    else
                    {
                        availableHeaderChunkClasses.Add(chunkAttribute.ID, chunk);
                    }
                }

                AvailableChunkClasses.Add(type, availableChunkClasses);
                AvailableHeaderChunkClasses.Add(type, availableHeaderChunkClasses);
            }

            foreach (var typePair in availableInheritanceTypes)
            {
                var mainType = typePair.Key;

                foreach (var type in typePair.Value)
                {
                    foreach (var chunkType in AvailableChunkClasses[type])
                    {
                        AvailableChunkClasses[mainType][chunkType.Key] = chunkType.Value;
                    }
                }
            }

            Debug.WriteLine("Types defined in " + watch.Elapsed.TotalMilliseconds + "ms");
        }