예제 #1
0
        public static CourseSectionSchedule[,,] GenerateTimeTableMatrix2(this TimetableModel source)
        {
            if (source == null)
                throw new ArgumentException("source");

            int dayOfWeek = Commons.Constants.DAY_OF_WEEK;
            var timeTableMatrix = new CourseSectionSchedule[dayOfWeek, source.ShiftPerDay, source.SlotPerShift];

            for (int k = 0; k < dayOfWeek; k++)
            {
                for (int i = 0; i < source.ShiftPerDay ; i++)
                {
                    for (int j = 0; j < source.SlotPerShift; j++)
                    {
                        CourseSectionSchedule cs = new CourseSectionSchedule();
                        cs.Id = Guid.Empty;
                        cs.Day = (DayOfWeek)k;
                        cs.Shift = (SHIFT)(i);
                        cs.Slot = (short)(j);
                        cs.Stage = COURSE_SECTION_STAGE.OPEN;
                        timeTableMatrix[k, i, j] = cs;

                    }
                }
            }

            foreach (CourseSectionSchedule cs in source.CourseSections)
            {
                timeTableMatrix[(int)cs.Day, (int)cs.Shift, cs.Slot] = cs;
            }

            return timeTableMatrix;
        }
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            // Get a deferral, to prevent the task from closing prematurely
            // while asynchronous code is still running.
            BackgroundTaskDeferral deferral = taskInstance.GetDeferral();

            // update live tile
            try {
                // Load the item.
                XmlDocument tileXml = await TimetableModel.GetNextLessonXml();

                if (tileXml == null)
                {
                    throw new Exception("Timetable is empty.");
                }
                // Update the live tile with the item.
                TimetableModel.UpdateTile(tileXml);
            }
            catch {
                Debug.WriteLine("Missing timetable item. First load the timetable.");
            }

            // Inform the system that the task is finished.
            deferral.Complete();
        }
예제 #3
0
        public static TimetableModel Join(this TimetableModel source, TimetableModel target)
        {
            if (source == null)
                throw new ArgumentException("source");

            if (target == null)
                throw new ArgumentException("target");

            if (source.ShiftPerDay != target.ShiftPerDay)
                throw new InvalidOperationException("Cannot join Timetable with different Shift.");

            for(int i = 0; i < source.ShiftPerDay * source.SlotPerShift; i ++)
                for(int j = 0; j < Commons.Constants.DAY_OF_WEEK; j ++)
                {
                    CourseSectionSchedule s = source.TimeTableMatrix[i, j];
                    CourseSectionSchedule t = target.TimeTableMatrix[i, j];

                    if(s.ClassCourse == t.ClassCourse && t.ClassCourse == null)
                    {
                        if(t.Stage == Schedule.Models.COURSE_SECTION_STAGE.CLOSED)
                        {
                            s.Stage = t.Stage;
                        }
                    }
                }

            return source;
        }
예제 #4
0
        public EditClassDialog(TimetableModel timetable, ClassModel model = null)
        {
            _timetable = timetable;
            InitializeComponent();

            if (!string.IsNullOrEmpty(_timetable.Name))
            {
                TxtSubject.Text      = _timetable.Name;
                TxtSubject.IsEnabled = false;
            }

            ComboType.ItemsSource   = Enum.GetValues(typeof(ClassType)).Cast <ClassType>();
            ComboType.SelectedIndex = 0;

            ComboDay.ItemsSource       = ClassModel.Days;
            ComboTimeStart.ItemsSource = ClassModel.TimeSegments;
            UpdateComboDuration();

            if (model != null)
            {
                TxtTeacher.Text              = model.TeacherName;
                ComboType.SelectedItem       = model.ClassType;
                ComboDay.SelectedIndex       = model.DayIndex;
                ComboTimeStart.SelectedIndex = model.TimeSegmentStart;
                ComboDuration.SelectedIndex  = model.TimeSegmentCount - 1;
            }

            var firstTextBox = TxtSubject.IsEnabled ? TxtSubject : TxtTeacher;

            firstTextBox.Focus();
            firstTextBox.SelectAll();
        }
예제 #5
0
        public TimetableModel GetTimetable(TimetableModel model)
        {
            TimetableModel ttModel = null;

            switch (model.Type)
            {
            case TIMETABLE_TYPE.SEMESTER:
                ttModel = this.GetSemesterTimetable(model.ReferenceObjectId);
                break;

            case TIMETABLE_TYPE.PROGRAM:
                ttModel = this.GetProgramTimetable(model.ReferenceObjectId);
                break;

            case TIMETABLE_TYPE.SUBJECT:
                ttModel = this.GetSubjectTimetable(model.ReferenceObjectId);
                break;

            case TIMETABLE_TYPE.COURSE:
                ttModel = this.GetCourseTimetable(model.ReferenceObjectId);
                break;

            case TIMETABLE_TYPE.TEACHER:
                ttModel = this.GetTeacherTimetable(model.ReferenceObjectId);
                break;

            case TIMETABLE_TYPE.CLASS:
                ttModel = this.GetClassTimetable(model.ReferenceObjectId);
                break;
            }
            ;
            return(ttModel);
        }
예제 #6
0
        public TimetableModel GetTeacherTimetable(Guid teacherId)
        {
            if (teacherId == null)
            {
                throw new ArgumentNullException("teacherId");
            }

            TeacherDivision teacherDivision = this.UnitOfWork.TeacherDivisionRepository.GetByTeacherId(teacherId);

            if (teacherDivision == null)
            {
                throw new InvalidOperationException("Teacher has not assigned to this semester.");
            }

            Timetable tt = null;

            if (teacherDivision.Timetable != null)
            {
                tt = teacherDivision.Timetable;
            }
            else
            {
                tt = this.UnitOfWork.TeacherDivisionRepository.CreateTeacherTimetable(teacherDivision.Id, ShiftPerDay, SlotPerShift);
                this.UnitOfWork.SaveChanges();
            }

            TimetableModel ttModel = Mapper.Map <Schedule.Models.Timetable, StoneCastle.Scheduler.Models.TimetableModel>(tt);

            ttModel = this.CreateTimetableMatrix(ttModel);

            return(ttModel);
        }
예제 #7
0
        public static CourseSectionSchedule[,] GenerateTimeTableMatrix(this TimetableModel source)
        {
            if (source == null)
                throw new ArgumentException("source");

            int dayOfWeek = Commons.Constants.DAY_OF_WEEK;
            var timeTableMatrix = new CourseSectionSchedule[source.ShiftPerDay * source.SlotPerShift, dayOfWeek];

            /*for (int i = 0; i < source.ShiftPerDay * source.SlotPerShift; i++)
            {
                for (int j = 0; j < dayOfWeek; j++)
                {
                    CourseSectionSchedule cs = new CourseSectionSchedule();
                    cs.Id = Guid.Empty;
                    cs.Day = (DayOfWeek)j;
                    cs.Shift = (SHIFT)(i / source.ShiftPerDay);
                    cs.Slot = (short)(i % source.SlotPerShift);
                    cs.Stage = COURSE_SECTION_STAGE.OPEN;
                    timeTable[i, j] = cs;
                }
            }*/

            foreach (CourseSectionSchedule cs in source.CourseSections)
            {
                timeTableMatrix[(int)cs.Shift * source.SlotPerShift + cs.Slot, (int)cs.Day] = cs;
            }

            return timeTableMatrix;
        }
예제 #8
0
        public void SaveTimetable()
        {
            var newTimetable = new TimetableModel();

            newTimetable.TimetableDescription  = TimetableDescription;
            newTimetable.TimetableName         = TimetableName;
            newTimetable.TimetableAbbreviation = TimetableAbbreviation;
            newTimetable.RouteId          = RouteId;
            newTimetable.IsMultiDirection = IsMultiDirection;
            if (IsMultiDirection)
            {
                newTimetable.ServiceDirectionId = -1;
            }
            else
            {
                newTimetable.ServiceDirectionId = ServiceDirectionId;
            }
            if (TimetableId <= 0)
            {
                TimetableDataAccess.InsertTimetableForRoute(newTimetable);
            }
            else
            {
                newTimetable.Id = TimetableId;
                TimetableDataAccess.UpdateTimetable(newTimetable);
            }
            ClearTimetable();
            TimetablesUI.TimetableList = new BindableCollection <TimetableModel>(TimetableDataAccess.GetAllTimetablesPerRoute(RouteId));
            NotifyOfPropertyChange(() => TimetablesUI);
        }
예제 #9
0
 public TimetableViewModel()
 {
     this.Context = new TimetableCourseProject();
     context.Timetable.Load();
     TimetableDatabase = Context.Timetable.Local;
     Timetable         = new ObservableCollection <Timetable>(TimetableDatabase);
     timetableModel    = new TimetableModel();
 }
예제 #10
0
        /// <summary>
        /// TimetableModel típust konvertál Timetable típusra (entitás)
        /// </summary>
        /// <param name="timetable">Átkonvertálandó TimetableModel</param>
        /// <returns>Timetable-é konvertált TimetableModel</returns>
        public static Timetable ModelToEntity(TimetableModel timetable)
        {
            Timetable newTimetable = new Timetable();

            newTimetable.Id        = timetable.Id;
            newTimetable.Course_Id = timetable.CourseId;
            newTimetable.User_Id   = timetable.UserId;
            //newTimetable.Course = CourseMapper.ModelToEntity(timetable.Course);
            //newTimetable.User = UserMapper.ModelToEntity(timetable.User);
            return(newTimetable);
        }
예제 #11
0
        private TimetableModel MapTimetable(TimetableInfo parsedTimetable)
        {
            var timetable = new TimetableModel();

            timetable.Key        = CreateTimetableId(parsedTimetable.Groups);
            timetable.SheetTitle = parsedTimetable.SheetTitle;
            timetable.Groups     = parsedTimetable.Groups;
            timetable.Subjects   = MapSubjects(parsedTimetable.Subjects);

            return(timetable);
        }
예제 #12
0
        public TimetableModel GetTimeTable(int shifts)
        {
            TimetableModel timetable = new TimetableModel();

            CourseSectionSchedule[,] timeTableMatrix = this.GenerateTimeTableMatrix(shifts, 5, COURSE_SECTION_STAGE.OPEN);

            timetable.TimeTableMatrix = timeTableMatrix;
            timetable.ShiftPerDay     = shifts;

            return(timetable);
        }
예제 #13
0
        /// <summary>
        /// Timetable típust (entitás) konvertál TimetableModel típusra
        /// </summary>
        /// <param name="timetable">Átkonvertálandó Timetable (entitás)</param>
        /// <returns>TimetableModel-é konvertált Timetable</returns>
        public static TimetableModel EntityToModel(Timetable timetable)
        {
            TimetableModel newModelTimetable = new TimetableModel();

            newModelTimetable.Id       = timetable.Id;
            newModelTimetable.CourseId = timetable.Course_Id;
            newModelTimetable.UserId   = timetable.User_Id;
            newModelTimetable.Course   = CourseMapper.EntityToModel(timetable.Course);
            newModelTimetable.User     = UserMapper.EntityToModel(timetable.User);
            return(newModelTimetable);
        }
예제 #14
0
        public List <TimetableModel> Map(List <TimetableInfo> parsedTimetables)
        {
            var timetables = new List <TimetableModel>();

            foreach (TimetableInfo parsedTimetable in parsedTimetables)
            {
                TimetableModel timetable = MapTimetable(parsedTimetable);
                timetables.Add(timetable);
            }

            return(timetables);
        }
예제 #15
0
 public void timetableAdd_Method(object paramert)
 {
     if (IsValid(ValidatesAddProperties, out AddErrors))
     {
         MessageBox.Show(timetableModel.Add(TimetableModel.getTimetableObject(AddAudienceNumber, AddGroupId, AddSubgroup,
                                                                              AddTeacherId, AddShortPairtypeName, int.Parse(AddPairNumber), AddWeekNumber, AddShortSubjectName, AddDayNumber.Id)), "Результат добавления");
         FilterTimetable();
     }
     else
     {
         MessageBox.Show("Заполните поля корректно!", "Результат добавления");
     }
 }
예제 #16
0
        public static int InsertTimetableForRoute(TimetableModel timetable)
        {
            string sql = @"INSERT OR IGNORE INTO Timetables 
                   (TimetableName, TimetableAbbreviation, TimetableDescription, 
                    ServiceDirectionId, IsMultiDirection, RouteId) 
                    VALUES(@TimetableName, @TimetableAbbreviation, @TimetableDescription, 
                    @ServiceDirectionId, @IsMultiDirection, @RouteId);SELECT last_insert_rowid();";

            return(SQLiteData.SaveData <dynamic>(sql, new { timetable.TimetableName, timetable.TimetableAbbreviation,
                                                            timetable.TimetableDescription, timetable.ServiceDirectionId,
                                                            timetable.IsMultiDirection, timetable.RouteId },
                                                 SQLiteData.GetConnectionString()));
        }
예제 #17
0
        public Guid SaveTimetable(TimetableModel timetable)
        {
            if (timetable == null)
            {
                throw new ArgumentNullException("timetable");
            }

            if (timetable.Id == null)
            {
                throw new ArgumentNullException("timetable.Id");
            }

            Timetable tt = this.UnitOfWork.TimetableRepository.GetById(timetable.Id);

            if (tt == null)
            {
                throw new InvalidOperationException($"Timetable ({timetable.Id}) does not exist.");
            }


            for (int i = 0; i < timetable.ShiftPerDay * timetable.SlotPerShift; i++)
            {
                for (int j = 0; j < Commons.Constants.DAY_OF_WEEK; j++)
                {
                    CourseSectionSchedule cs = timetable.TimeTableMatrix[i, j];
                    if (cs.Checked && (cs.Id == null || cs.Id == Guid.Empty))
                    {// Added
                        //CourseSection courseSection = Mapper.Map<CourseSectionSchedule, CourseSection>(cs);
                        CourseSection courseSection = new CourseSection();
                        courseSection.Day         = (DayOfWeek)j;
                        courseSection.Id          = Guid.NewGuid();
                        courseSection.TimetableId = timetable.Id;
                        courseSection.Stage       = COURSE_SECTION_STAGE.OPEN;
                        courseSection.Shift       = cs.Shift;
                        courseSection.Slot        = cs.Slot;

                        this.UnitOfWork.CourseSectionRepository.Insert(courseSection);
                    }
                    else if (!cs.Checked && (cs.Id != Guid.Empty))
                    {// Remove
                        //CourseSection courseSection = Mapper.Map<CourseSectionSchedule, CourseSection>(cs);
                        this.UnitOfWork.CourseSectionRepository.DeleteCourseSection(cs.Id);
                    }
                }
            }

            this.UnitOfWork.SaveChanges();

            return(tt.Id);
        }
예제 #18
0
        public TimetableEntity MapTimetable(TimetableModel timetableModel)
        {
            string jsonTimetable = TimetableSerializer.SerializeToJson(timetableModel);
            string hashTimetable = HashCoder.GetSha256Hash(jsonTimetable);

            var entity = new TimetableEntity
            {
                Key      = timetableModel.Key,
                Groups   = MapGroups(timetableModel.Groups),
                Subjects = MapSubjects(timetableModel.Subjects),
                Hash     = hashTimetable
            };

            return(entity);
        }
예제 #19
0
        public static void UpdateTimetable(TimetableModel timetable)
        {
            string sql = @"UPDATE OR IGNORE Timetables 
                          SET 
                                  TimetableName=@TimetableName, 
                                  TimetableAbbreviation=@TimetableAbbreviation, 
                                  TimetableDescription=@TimetableDescription, 
                                  ServiceDirectionId=@ServiceDirectionId,
                                  IsMultiDirection=@IsMultiDirection,
                                  RouteId=@RouteId WHERE Id=@Id";

            SQLiteData.SaveData <dynamic>(sql, new { timetable.TimetableName, timetable.TimetableAbbreviation,
                                                     timetable.TimetableDescription, timetable.ServiceDirectionId,
                                                     timetable.IsMultiDirection, timetable.RouteId, timetable.Id },
                                          SQLiteData.GetConnectionString());
        }
예제 #20
0
        public static bool AddToTimetable(int courseId)
        {
            using (var context = new Classmaister5000Entities())
            {
                var course = context.Courses.Find(courseId);
                ICollection <Timetable> records = context.Timetables.ToList();
                ICollection <Course>    courses = new List <Course>();
                foreach (var item in records)
                {
                    courses.Add(context.Courses.Where(c => c.Id == item.Course_Id).First());
                }

                bool   exists     = false;
                Course changeThis = null;
                foreach (var item in courses)
                {
                    if (item.Subject_Id == course.Subject_Id)
                    {
                        exists     = true;
                        changeThis = item;
                    }
                }
                if (!exists)
                {
                    int?id = context.Timetables.Max(i => (int?)i.Id) + 1;
                    if (id == null)
                    {
                        id = 0;
                    }
                    TimetableModel record = new TimetableModel();
                    record.UserId   = GetUserId;
                    record.CourseId = courseId;
                    record.Id       = (int)id + 1;

                    context.Timetables.Add(TimetableMapper.ModelToEntity(record));
                    context.SaveChanges();
                }
                else
                {
                    var changeThisPlease = context.Timetables.Where(t => t.Course_Id == changeThis.Id).First();
                    changeThisPlease.Course_Id            = courseId;
                    context.Entry(changeThisPlease).State = System.Data.Entity.EntityState.Modified;
                    context.SaveChanges();
                }
            }
            return(true);
        }
예제 #21
0
        // update the live tile
        private static async Task UpdateLiveTile()
        {
            try {
                // Load the item.
                XmlDocument tileXml = await TimetableModel.GetNextLessonXml();

                if (tileXml == null)
                {
                    throw new Exception("Timetable is empty.");
                }
                // Update the live tile with the item.
                TimetableModel.UpdateTile(tileXml);
            }
            catch {
                Debug.WriteLine("Missing timteable item. First load the timetable.");
            }
        }
예제 #22
0
        protected async void AddClaim()
        {
            MyDB DB = new MyDB();

            if (CrossConnectivity.Current.IsConnected)
            {
                try
                {
                    App_activity_indicator.IsVisible = true;
                    App_activity_indicator.IsRunning = true;
                    TimetableModel TT = new TimetableModel();
                    TT = (TimetableModel)txtclass.SelectedItem;

                    string webaddress = Libraries.MobileConfig.GetWebAddress(Application.Current.Properties["campus"].ToString()) +
                                        string.Format("DataFinder.aspx?dataFormat=newclaim&empcode={0}&acad={1}&sem={2}&SID={3}",
                                                      Application.Current.Properties["userno"], acad_year, semester, TT.SID);
                    _client.Timeout = TimeSpan.Parse("00:00:15");
                    var content = await _client.GetStringAsync(webaddress);

                    if (content.Contains("Created"))
                    {
                        await DisplayAlert("IUIU Mobile", content, "OK");

                        await Navigation.PushAsync(new ClaimingCentre());
                    }
                    else
                    {
                        await DisplayAlert("IUIU Mobile", "An Error Occurred. Try again", "OK");
                    }
                    App_activity_indicator.IsVisible = false;
                    App_activity_indicator.IsRunning = false;
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Error!", "" + ex.Message, "OK");

                    App_activity_indicator.IsVisible = false;
                    App_activity_indicator.IsRunning = false;
                }
            }
            else
            {
                await DisplayAlert("Warning", "No Internet Connection", "OK");
            }
        }
예제 #23
0
        private TimetableModel CreateTimetableMatrix(TimetableModel ttModel)
        {
            int totalShift   = 2;
            int slotPerShift = 5;

            CourseSectionSchedule[,] timeTableMatrix = this.GenerateTimeTableMatrix(totalShift, slotPerShift, COURSE_SECTION_STAGE.CLOSED);
            ttModel.ShiftPerDay     = totalShift;
            ttModel.SlotPerShift    = slotPerShift;
            ttModel.TimeTableMatrix = timeTableMatrix;

            foreach (CourseSectionSchedule cs in ttModel.CourseSections)
            {
                cs.Stage = COURSE_SECTION_STAGE.OPEN;
                int shift = (int)cs.Shift;
                timeTableMatrix[shift * ttModel.SlotPerShift + cs.Slot, (int)cs.Day] = cs;
                cs.Checked = true;
            }

            return(ttModel);
        }
        private void ImportTimetable(string[] fields)
        {
            //return $"\"Timetables\"{sep}\"Id\"{sep}\"TimetableName\"{sep}\"TimetableAbbreviation\"{sep}" +
            //      $"\"TimetableDescription\"{sep}\"IsMultiDirection\"{sep}\"ServiceDirectionId\"{sep}\"RouteId\"\r\n";
            var timetable = new TimetableModel();

            timetable.Id                    = int.Parse(fields[1]);
            timetable.TimetableName         = fields[2];
            timetable.TimetableAbbreviation = fields[3];
            timetable.TimetableDescription  = fields[4];
            timetable.IsMultiDirection      = bool.Parse(fields[5]);
            var oldServiceDirectionId = int.Parse(fields[6]);

            timetable.ServiceDirectionId =
                ServiceDirectionKeys.GetValueOrDefault(oldServiceDirectionId, 0);
            timetable.RouteId = newRouteId;
            var newTimetableId = TimetableDataAccess.InsertTimetableForRoute(timetable);

            TimetableKeys.Add(timetable.Id, newTimetableId);
        }
예제 #25
0
 private void timetableRemove_Method(object parametr)
 {
     if (editButtonContent.Equals("Изменить"))
     {
         if (IsValid(ValidatesChangeProperties, out ChangeErrors))
         {
             MessageBox.Show(timetableModel.Remove(TimetableModel.getTimetableObject(changeAudienceNumber,
                                                                                     changeGroupId, changeSubgroup, changeTeacherId, changeShortPairtypeName, int.Parse(changePairNumber), changeWeekNumber, changeShortSubjectName, changeDayNumber.Id)), "Результат удаления");
             FilterTimetable();
         }
         else
         {
             MessageBox.Show("Заполните корректно поля!", "Результат удаления");
         }
     }
     else
     {
         MessageBox.Show("Для удаления отмените операцию \"Изменение\" нажав на кнопку\"Отмена\"", "", MessageBoxButton.OK, MessageBoxImage.Exclamation);
     }
 }
예제 #26
0
 private void timetableChange_Method(object parametr)
 {
     if (editButtonContent.Equals("Изменить"))
     {
         if (IsValid(ValidatesChangeProperties, out ChangeErrors))
         {
             if (timetableModel.IsExist(TimetableModel.getTimetableObject(changeAudienceNumber, changeGroupId, changeSubgroup,
                                                                          changeTeacherId, changeShortPairtypeName, int.Parse(changePairNumber), changeWeekNumber, changeShortSubjectName, changeDayNumber.Id)))
             {
                 EditButtonContent = "Сохранить";
                 CancelVisibility  = Visibility.Visible;
                 changedTimetable  = TimetableModel.getTimetableObject(changeAudienceNumber, changeGroupId, changeSubgroup,
                                                                       changeTeacherId, changeShortPairtypeName, int.Parse(changePairNumber), changeWeekNumber, changeShortSubjectName, changeDayNumber.Id);
                 return;
             }
             else
             {
                 MessageBox.Show("Изменяемого объекта не существует", "Результат изменения");
             }
         }
         else
         {
             MessageBox.Show("Заполните корректно поля!", "Результат Изменения");
         }
     }
     else if (editButtonContent.Equals("Сохранить"))
     {
         if (IsValid(ValidatesChangeProperties, out ChangeErrors))
         {
             MessageBox.Show(timetableModel.Change(changedTimetable, TimetableModel.getTimetableObject(changeAudienceNumber, changeGroupId,
                                                                                                       changeSubgroup, changeTeacherId, changeShortPairtypeName, int.Parse(changePairNumber), changeWeekNumber, changeShortSubjectName, changeDayNumber.Id)), "Результат изменения");
             EditButtonContent = "Изменить";
             CancelVisibility  = Visibility.Collapsed;
             FilterTimetable();
         }
         else
         {
             MessageBox.Show("Заполните корректно поля!", "Результат изменения");
         }
     }
 }
예제 #27
0
        public TimetableModel GetCourseTimetable(Guid courseId)
        {
            if (courseId == null)
            {
                throw new ArgumentNullException("courseId");
            }

            Timetable tt = this.UnitOfWork.ClassCourseRepository.GetTimetable(courseId);

            if (tt == null)
            {
                tt = this.UnitOfWork.ClassCourseRepository.CreateTimetable(courseId, ShiftPerDay, SlotPerShift);
                this.UnitOfWork.SaveChanges();
            }

            TimetableModel ttModel = Mapper.Map <Schedule.Models.Timetable, StoneCastle.Scheduler.Models.TimetableModel>(tt);

            ttModel = this.CreateTimetableMatrix(ttModel);

            return(ttModel);
        }
예제 #28
0
        protected async void AddClaim()
        {
            MyDB DB = new MyDB();

            if (CrossConnectivity.Current.IsConnected)
            {
                try
                {
                    App_activity_indicator.IsVisible = true;
                    App_activity_indicator.IsRunning = true;
                    TimetableModel TT = new TimetableModel();
                    TT = (TimetableModel)txtclass.SelectedItem;
                    string webaddress = Libraries.MobileConfig.GetWebAddress(Application.Current.Properties["campus"].ToString()) +
                                        string.Format("DataFinder.aspx?dataFormat=newlecture&SID={0}&day={1}&date={2}&claimID={3}&empcode={4}",
                                                      TT.SID, TT.lecture_day, txtDate.Date.ToString("yyyy-MM-dd"), _claimID, Application.Current.Properties["userno"]);
                    _client.Timeout = TimeSpan.Parse("00:00:15");
                    var content = await _client.GetStringAsync(webaddress);
                    await DisplayAlert("IUIU Mobile", content, "OK");


                    App_activity_indicator.IsVisible = false;
                    App_activity_indicator.IsRunning = false;
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Error!", "" + ex.Message, "OK");

                    App_activity_indicator.IsVisible = false;
                    App_activity_indicator.IsRunning = false;
                }
            }
            else
            {
                await DisplayAlert("Warning", "No Internet Connection", "OK");
            }
        }
예제 #29
0
        protected async void RefreshTimetables(int Sem)
        {
            MyDB DB = new MyDB();

            if (CrossConnectivity.Current.IsConnected)
            {
                try
                {
                    App_activity_indicator.IsVisible = true;
                    App_activity_indicator.IsRunning = true;

                    string webaddress = Libraries.MobileConfig.GetWebAddress(Application.Current.Properties["campus"].ToString()) +
                                        string.Format("DataFinder.aspx?dataFormat=personaltimetable&code={0}&acad={1}&sem={2}&system={3}",
                                                      Application.Current.Properties["userno"], acad_year, Sem, study_sys);
                    _client.Timeout = TimeSpan.Parse("00:00:15");
                    var content = await _client.GetStringAsync(webaddress);

                    //await DisplayAlert("Error!", ""+ content, "OK");
                    var n = JsonConvert.DeserializeObject <List <Model.TimetableModel> >(content);
                    List <Model.TimetableModel> TT_data = new List <Model.TimetableModel>(n);
                    if (TT_data.Count > 0)
                    {
                        DB.resetTimetables(acad_year, semester);
                        DB.AddTimetables(content, acad_year, semester);
                    }
                    else
                    {
                        DB.resetTimetables(acad_year, semester);
                        txtclass.ItemsSource = null;
                    }

                    App_activity_indicator.IsVisible = false;
                    App_activity_indicator.IsRunning = false;
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Error!", "" + ex.Message, "OK");

                    DB.resetTimetables(acad_year, semester);
                    txtclass.ItemsSource             = null;
                    App_activity_indicator.IsVisible = false;
                    App_activity_indicator.IsRunning = false;
                }
            }
            else
            {
                await DisplayAlert("Warning", "No Internet Connection", "OK");
            }

            var list = JsonConvert.DeserializeObject <List <TimetableModel> >(DB.GetAllTimetables(acad_year, semester));
            List <TimetableModel> display_data = new List <TimetableModel>(list);
            List <TimetableModel> combo_data   = new List <TimetableModel>();

            foreach (TimetableModel item in display_data)
            {
                TimetableModel a = new TimetableModel();
                a.SID         = item.SID;
                a.duration    = string.Format("{0} - {2} {1}", item.course_name, item.duration, item.lecture_day);
                a.lecture_day = item.lecture_day;
                combo_data.Add(a);
            }
            txtclass.ItemsSource = combo_data;
        }
예제 #30
0
        public ClassScheduleBoard LoadClassScheduleBoard(Guid scheduleId)
        {
            Logger.Debug($"Start loading class schedule-board: {scheduleId}");

            if (scheduleId == null || scheduleId == Guid.Empty)
            {
                Logger.Error($"ScheduleId is empty.");
                throw new ArgumentNullException("scheduleId");
            }

            Schedule.Models.SchedulingTable schedule = this.UnitOfWork.SchedulingTableRepository.GetById(scheduleId);

            if (schedule == null)
            {
                Logger.Error($"Schedule ({scheduleId}) does not exist.");
                throw new InvalidOperationException($"Schedule ({scheduleId}) does not exist.");
            }

            Guid semesterId = schedule.SemesterId;

            if (semesterId == null || semesterId == Guid.Empty)
            {
                Logger.Error($"Schedule ({scheduleId}) does not content SemesterId.");
                throw new InvalidOperationException($"Schedule ({scheduleId}) does not content SemesterId.");
            }

            ClassScheduleBoard board = new ClassScheduleBoard();

            board.Id           = scheduleId;
            board.WorkingDays  = (int)Commons.Constants.DAY_OF_WEEK;
            board.ShiftPerDay  = 2;
            board.SlotPerShift = 5;

            Logger.Debug($"Start loading schedule-board for semester: {semesterId}");

            // Get Class Groups
            List <ClassGroup> classGroups = this.UnitOfWork.ClassGroupRepository.GetSemesterClassGroups(semesterId).ToList();

            Logger.Debug($"Found {classGroups.Count} class-groups");

            var mapper = config.CreateMapper();

            List <ClassGroupSchedule> cgs = mapper.Map <List <ClassGroup>, List <ClassGroupSchedule> >(classGroups);

            foreach (ClassGroupSchedule cg in cgs)
            {
                Logger.Debug($"Loading group: {cg.Name}");
                board.ClassGroups.Add(cg);

                foreach (ClassRoomSchedule cr in cg.ClassRooms)
                {
                    Timetable tt = this.UnitOfWork.ClassTimetableRepository.GetTimetable(board.Id, cr.Id);
                    if (tt != null)
                    {
                        TimetableModel ttm = mapper.Map <Timetable, TimetableModel>(tt);

                        cr.Timetable = ttm;
                        cr.Timetable.TimeTableMatrix = ttm.GenerateTimeTableMatrix();
                    }

                    List <ClassCourse> courses = this.UnitOfWork.ClassCourseRepository.GetCoursesByClassRoom(cr.Id).ToList();
                    cr.Courses = mapper.Map <List <ClassCourse>, List <ClassCourseSchedule> >(courses);
                }

                Logger.Debug($"Complete loading group: {cg.Name}");
            }

            Logger.Debug($"Complete loading semester: {semesterId}");

            return(board);
        }