Exemplo n.º 1
0
        internal static void Parse(string PackageName, PackageRepository mifRepo, ClassRepository repo)
        {
            // Find the package that contains the class we want
            Package pkg = mifRepo.Find(p => p.PackageLocation.ToString(MifCompiler.NAME_FORMAT) == PackageName) as Package;
            
            if (pkg == null) // Check if package was found
            {
                System.Diagnostics.Trace.WriteLine(string.Format("Could not find static model '{0}'. Any dependent models may not be rendered correctly!", PackageName), "warn");
                return;
            }

            // Process the package
            IPackageCompiler comp = null;
            if (pkg is GlobalStaticModel)
                comp = new StaticModelCompiler();
            else if (pkg is SerializedStaticModel)
                comp = new SerializedStaticModelCompiler();
            else
            {
                System.Diagnostics.Trace.WriteLine(String.Format("Can't find an appropriate compiler for package '{0}'... Package will not be parsed", PackageName), "error");
                return;
            }
            comp.ClassRepository = repo;
            comp.Package = pkg;
            comp.PackageRepository = pkg.MemberOfRepository;
            comp.Compile();
        }
Exemplo n.º 2
0
 private void CompileMif(MohawkCollege.EHR.HL7v3.MIF.MIF20.Repository.PackageRepository pkr, ClassRepository rep)
 {
     
     MohawkCollege.EHR.gpmr.Pipeline.Compiler.Mif20.Compilers.RepositoryCompiler util = new MohawkCollege.EHR.gpmr.Pipeline.Compiler.Mif20.Compilers.RepositoryCompiler(pkr);
     util.ClassRepository = rep;
     util.Compile();
 }
Exemplo n.º 3
0
 public HomeController()
 {
     if (studentService == null)
     {
         studentService = new StudentService();
     }
     if (classRepository == null)
     {
         classRepository = new ClassRepository();
     }
 }
Exemplo n.º 4
0
        public void Unroll(StudentRepository studentRepository, ClassRepository classRepository,
                           StudentArchiveRepository studentArchiveRepository, StudentUnrollCommand command)
        {
            var student        = studentRepository.GetById(command.StudentId);
            var @class         = classRepository.GetById(command.ClassId);
            var studentArchive = studentArchiveRepository.GetById(command.StudentId);

            student.Unroll(@class);
            @class.Unroll(student);
            studentArchive.AddToPassedEnrollements(student.LastUnrolled, command.Reason);
        }
Exemplo n.º 5
0
 public TeacherController()
 {
     if (teacherService == null)
     {
         teacherService = new TeacherService();
     }
     if (classRepository == null)
     {
         classRepository = new ClassRepository();
     }
 }
Exemplo n.º 6
0
        public void Add_new_student_test()
        {
            var repo      = new StudentRepository(this.context);
            var classRepo = new ClassRepository(context);
            var clazz     = new ClassEntity("GR1");

            classRepo.AddNew(clazz);
            var model = new StudentEntity("Aneta", "Dams", clazz, true);

            repo.AddNew(model);
        }
Exemplo n.º 7
0
        public IList <CompetitionClass> GetClasses()
        {
            using (var connection = new MySqlConnection(_databaseConfiguration.GetConnectionString()))
            {
                var classRepository = new ClassRepository(connection);

                return(classRepository
                       .GetByEventRaceIdAndEventId(_eventRaceId, _eventId)
                       .ToContracts());
            }
        }
Exemplo n.º 8
0
 public ChangePasswordModel(
     UserManager <ApplicationUser> userManager,
     SignInManager <ApplicationUser> signInManager,
     ILogger <ChangePasswordModel> logger,
     ClassRepository <ApplicationUser> classRepository)
 {
     _userManager     = userManager;
     _signInManager   = signInManager;
     _logger          = logger;
     _classRepository = classRepository;
 }
Exemplo n.º 9
0
        public JsonResult Add(ClassModel classModel)
        {
            using (var classRepository = new ClassRepository())
            {
                classRepository.Add(new ClassDTO {
                    Name = classModel.Name, Username = HttpContext.User.Identity.Name
                });
            }

            return(Json("ok"));
        }
Exemplo n.º 10
0
        public void Enroll(StudentRepository studentRepository, ClassRepository classRepository,
                           StudentEnrollCommand command)
        {
            var student = studentRepository.GetById(command.StudentId);
            var @class  = classRepository.GetById(command.ClassId);

            student.TryEnrollIn(@class);
            @class.TryEnroll(student);

            student.Enroll(@class);
            @class.Enroll(student);
        }
Exemplo n.º 11
0
        private void initializeObjects()
        {
            getDbConnection   = () => new NpgsqlConnection("Server=localhost;Port=5433;User ID=teddy;Password=teddy;");
            studentLoggerMoq  = new Mock <ILogger <StudentRepository> >();
            classLoggerMoq    = new Mock <ILogger <ClassRepository> >();
            courseLoggerMoq   = new Mock <ILogger <CourseRepository> >();
            psqlString        = () => string.Empty;
            classRepository   = new ClassRepository(getDbConnection, classLoggerMoq.Object, psqlString);
            studentRepository = new StudentRepository(getDbConnection, studentLoggerMoq.Object);

            courseRepository = new CourseRepository(getDbConnection, courseLoggerMoq.Object);
        }
Exemplo n.º 12
0
        internal static CommonTypeReference Parse(CommonModelElement cme, ClassRepository memberOf)
        {
            CommonTypeReference retVal = new CommonTypeReference();

            retVal.Name    = cme.Name;
            retVal.SortKey = cme.SortKey;

            // Annotations
            if (cme.Annotations != null)
            {
                retVal.Documentation = DocumentationParser.Parse(cme.Annotations.Documentation);
            }

            retVal.DerivedFrom = cme;

            // Create a type reference
            retVal.Class = new TypeReference();

            // Entry Class specified?
            if (cme.EntryClass == null)
            {
                // Need to find it
                Package p = (Package)cme.Container.MemberOfRepository.Find(cme.BoundStaticModel);
                if (p is GlobalStaticModel && (p as GlobalStaticModel).OwnedEntryPoint.Count > 0)
                {
                    cme.EntryClass      = new SpecializationClass();
                    cme.EntryClass.Name = (p as GlobalStaticModel).OwnedEntryPoint[0].ClassName;
                }
                else if (p != null)
                {
                    throw new InvalidOperationException(string.Format("Can't determine the entry point for '{0}'!", p.PackageLocation.ToString(MifCompiler.NAME_FORMAT)));
                }
                else
                {
                    return(null); // Can't find the package
                }
            }

            retVal.Class.Name = string.Format("{0}.{1}", cme.BoundStaticModel.ToString(MifCompiler.NAME_FORMAT), cme.EntryClass.Name);

            // Pseudo Heiarchy to get back to the class repository
            retVal.MemberOf       = memberOf;
            retVal.Class.MemberOf = memberOf;

            // Classifier code
            retVal.ClassifierCode = cme.SupplierStructuralDomain.Code.Code;

            // Notify complete
            retVal.FireParsed();

            // Now return
            return(retVal);
        }
Exemplo n.º 13
0
        public static void Import(string path, ClassRepository classRepository, LessonRepository lessonRepository, ScheduleRepository scheduleRepository, TeacherRepository teacherRepository)
        {
            List <Lesson>   lessons   = null;
            List <Teacher>  teachers  = null;
            List <Class>    classes   = null;
            List <Schedule> schedules = null;

            IWorkbook workbook = null;

            var fs = File.OpenRead(path);

            if (path.IndexOf(".xlsx") > 0) // 2007版本
            {
                workbook = new XSSFWorkbook(fs);
            }
            else if (path.IndexOf(".xls") > 0) // 2003版本
            {
                workbook = new HSSFWorkbook(fs);
            }

            var courses = GetCourses(workbook.GetSheet("科目"));

            // TODO: 导入Lesson
            lessons = GetLessons(workbook.GetSheet("课程表"));

            // TODO: 导入Class
            teachers = new List <Teacher>();
            classes  = GetClasses(workbook.GetSheet("班级"), courses, teachers);

            // TODO: 导入Schedule
            schedules = new List <Schedule>();

            lessons.ForEach(lesson =>
            {
                lessonRepository.Add(lesson);
            });

            teachers.ForEach(teacher =>
            {
                teacherRepository.Add(teacher);
            });

            classes.ForEach(@class =>
            {
                classRepository.Add(@class);
            });

            schedules.ForEach(schedule =>
            {
                scheduleRepository.Add(schedule);
            });
        }
Exemplo n.º 14
0
        public HttpResponseMessage Scrape(int week)
        {
            var context             = new TimeTableContext(WebConfigurationManager.AppSettings["DbConnectionString"]);
            var scraperRepository   = new ScraperRepository(context);
            var classroomRepository = new ClassroomRepository(context);
            var bookingRepository   = new BookingRepository(context);
            var classRepository     = new ClassRepository(context);
            var scraperService      = new ScraperService(scraperRepository, classroomRepository, classRepository, bookingRepository);

            Task.Run(() => scraperService.Scrape(week));

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Exemplo n.º 15
0
        public void Get_class_by_id_test()
        {
            var repo   = new ClassRepository(context);
            var model  = new ClassEntity("GR2");
            var model2 = new ClassEntity("GR1");

            repo.AddNew(model);
            repo.AddNew(model2);
            var result = repo.GetById(model2.Id);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.Id, model2.Id);
        }
Exemplo n.º 16
0
        protected void GridviewPaylasimlar_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Presentation k = (Presentation)e.Row.DataItem;

                if (k.IsActive == true)
                {
                    (e.Row.FindControl("LinkbuttonAktif") as LinkButton).CssClass      = "btn btn-danger btn-mini";
                    (e.Row.FindControl("LinkbuttonAktif") as LinkButton).OnClientClick = "return confirm('Sunum Pasif Edilecek');";
                }
                else
                {
                    (e.Row.FindControl("LinkbuttonAktif") as LinkButton).CssClass      = "btn btn-success btn-mini";
                    (e.Row.FindControl("LinkbuttonAktif") as LinkButton).OnClientClick = "return confirm('Sunum Aktif Edilecek');";
                }

                (e.Row.FindControl("LinkbuttonKaydet") as LinkButton).CssClass = "btn btn-info btn-mini";
                int id;

                Label        lblgelenid   = (Label)e.Row.FindControl("lblID");
                Label        lblsecid     = (Label)e.Row.FindControl("Label1");
                Label        lbltrgelenid = (Label)e.Row.FindControl("lbltr");
                DropDownList ddl1         = (DropDownList)e.Row.FindControl("dropDownKonu");
                DropDownList ddl2         = (DropDownList)e.Row.FindControl("dropDownSinif");
                Label        lbldurum     = (Label)e.Row.FindControl("lbldurum");

                SubjectRepository konu  = new SubjectRepository();
                ClassRepository   sinif = new ClassRepository();
                int subjectid           = Convert.ToInt32(lblsecid.Text);
                if (subjectid > 0)
                {
                    Subject sec = new Subject();
                    sec                 = konu.TekGetir(subjectid);
                    ddl1.DataSource     = konu.HepsiniGetir();
                    ddl1.DataTextField  = "Name";
                    ddl1.DataValueField = "Id";
                    ddl1.SelectedValue  = sec.Id.ToString();
                    ddl1.DataBind();
                }

                int       classid = Convert.ToInt32(lbltrgelenid.Text);
                Classroom tid     = new Classroom();
                tid = sinif.TekGetir(classid);
                ddl2.SelectedValue  = tid.Id.ToString();
                ddl2.DataSource     = sinif.HepsiniGetir();
                ddl2.DataTextField  = "Name";
                ddl2.DataValueField = "Id";
                ddl2.DataBind();
            }
        }
Exemplo n.º 17
0
 public UnitOfWork(Model1 dbContext)
 {
     _dbContext                 = dbContext;
     StudentRepository          = new StudentRepository(_dbContext);
     TeacherRepository          = new TeacherRepository(_dbContext);
     PrincipalRepository        = new PrincipalRepository(_dbContext);
     UserRepository             = new UserRepository(_dbContext);
     School_SubjectsRepository  = new School_SubjectsRepository(_dbContext);
     SessionRepository          = new SessionRepository(_dbContext);
     Teachers_ClassesRepository = new Teachers_ClassesRepository(_dbContext);
     dClassRepository           = new ClassRepository(_dbContext);
     SubjectsRepository         = new SubjectsRepository(_dbContext);
     //add other repositories here
 }
Exemplo n.º 18
0
        public CompetitionClass GetClass(int competitionClassId)
        {
            using (var connection = new MySqlConnection(_databaseConfiguration.GetConnectionString()))
            {
                var classRepository  = new ClassRepository(connection);
                var resultRepository = new ResultRepository(connection);

                var classEntity = classRepository.GetWithSplitControls(_eventId, _eventRaceId, competitionClassId);

                var classContract = classEntity.ToContract();
                classContract.Results = GetResults(classEntity, resultRepository);
                return(classContract);
            }
        }
Exemplo n.º 19
0
        public void UpdateClass()
        {
            ClassRepository repo = new ClassRepository(new ClassSQLContext());
            Class           c    = repo.GetById(2);

            c.PhysDamage += 20;
            int damage = c.PhysDamage;

            repo.Update(c);
            c = repo.GetById(2);
            Assert.AreEqual(c.PhysDamage, damage, "Class wasn't updated.");
            c.PhysDamage -= 20;
            repo.Update(c);
        }
Exemplo n.º 20
0
        public ActionResult ListComments(Guid classId, int page = 1)
        {
            var classRepository = new ClassRepository(_context);
            var classInfo       = classRepository.GetClass(classId, _loggedUser.Id, GetUserRole(_loggedUser));
            var humanizer       = new DefaultDateTimeHumanizeStrategy();
            var comments        = classInfo.Class.Comments
                                  .OrderByDescending(x => x.DateTime)
                                  .Skip((page - 1) * 10)
                                  .Take(10)
                                  .ToList();

            return(Json(CommentViewModel.FromEntityList(comments, humanizer, _loggedUser.Id),
                        JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 21
0
        public void DeactivateCommandShouldDeactivateItem()
        {
            var dispatcher = new Dispatcher <ICommand>();

            var studentRepository = new StudentRepository();
            var classRepository   = new ClassRepository();

            var sh = new StudentEnrollmentHandlers();
            Action <StudentEnrollCommand> studentEnrollPipeline = c => sh.Enroll(studentRepository, classRepository, c);

            dispatcher.Subscribe(studentEnrollPipeline);

            dispatcher.Dispatch(new StudentEnrollCommand(1, 2, DateTime.Now, DateTime.Now.AddMonths(6)));
        }
Exemplo n.º 22
0
        public ActionResult Edit(Guid id, ClassViewModel viewModel)
        {
            var userRole         = GetUserRole(_loggedUser);
            var courseRepository = new CourseRepository(_context);
            var course           = courseRepository.GetById(viewModel.CourseId);

            if ((Role.Teacher != userRole ||
                 viewModel.TeacherId != _loggedUser.Id && course.TeacherInCharge.Id != _loggedUser.Id) &&
                userRole != Role.Admin)
            {
                return(RedirectToAction("Index", "Home"));
            }

            var userRepository = new UserRepository(_context);

            if (ModelState.IsValid)
            {
                try
                {
                    var teacher         = (Teacher)userRepository.GetById(viewModel.TeacherId);
                    var classRepository = new ClassRepository(_context);
                    classRepository.Update(ClassViewModel.ToEntity(viewModel, course, teacher));
                    _context.Save(_loggedUser);
                    TempData["MessageType"]  = "success";
                    TempData["MessageTitle"] = Resource.ContentManagementToastrTitle;
                    TempData["Message"]      = "Class updated";

                    return(Redirect(TempData["BackURL"].ToString()));
                }
                catch (Exception ex)
                {
                    TempData["MessageType"]  = "error";
                    TempData["MessageTitle"] = Resource.ContentManagementToastrTitle;
                    TempData["Message"]      = ex.Message;
                }
            }

            var activeCourses = courseRepository.ListActiveCourses();

            ViewBag.Courses = new SelectList(activeCourses, "Id", "Name");

            var activeTeachers = userRepository.ListActiveTeachers();

            ViewBag.Teachers = new SelectList(activeTeachers, "Id", "Name");
            const ContentType contetTypes = ContentType.Vimeo;

            ViewBag.ContentTypes = new SelectList(contetTypes.ToDataSource <ContentType>(), "Key", "Value");

            return(View(viewModel));
        }
Exemplo n.º 23
0
        protected void GridviewOgrenciler_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Student k = (Student)e.Row.DataItem;

                if (k.IsActive == true)
                {
                    //(e.Row.FindControl("LinkbuttonAktif") as LinkButton).ToolTip = "Pasif Et";
                    //(e.Row.FindControl("LinkbuttonAktif") as LinkButton).Text = "Pasif Et";
                    (e.Row.FindControl("LinkbuttonAktif") as LinkButton).CssClass      = "btn btn-danger btn-mini";
                    (e.Row.FindControl("LinkbuttonAktif") as LinkButton).OnClientClick = "return confirm('Kullanıcı Pasif Edilecek');";
                }
                else
                {
                    //(e.Row.FindControl("LinkbuttonAktif") as LinkButton).ToolTip = "Aktif Et";
                    //(e.Row.FindControl("LinkbuttonAktif") as LinkButton).Text = "Aktif Et";
                    (e.Row.FindControl("LinkbuttonAktif") as LinkButton).CssClass      = "btn btn-success btn-mini";
                    (e.Row.FindControl("LinkbuttonAktif") as LinkButton).OnClientClick = "return confirm('Kullanıcı Aktif Edilecek');";
                }
                int id;

                Label        lblgelenid = (Label)e.Row.FindControl("lblID");
                Label        lblsecid   = (Label)e.Row.FindControl("Label1");
                Label        lblsinifid = (Label)e.Row.FindControl("lbltr");
                DropDownList ddl1       = (DropDownList)e.Row.FindControl("dropdownBolum");
                DropDownList ddl2       = (DropDownList)e.Row.FindControl("dropdownSinif");
                Label        lbldurum   = (Label)e.Row.FindControl("lbldurum");

                SectionsRepository bolum     = new SectionsRepository();
                ClassRepository    sinifRepo = new ClassRepository();
                int     sectionid            = Convert.ToInt32(lblsecid.Text);
                Section sec = new Section();
                sec                 = bolum.TekGetir(sectionid);
                ddl1.DataSource     = bolum.HepsiniGetir();
                ddl1.DataTextField  = "Name";
                ddl1.DataValueField = "Id";
                ddl1.SelectedValue  = sec.Id.ToString();
                ddl1.DataBind();
                int       traineridd = Convert.ToInt32(lblsinifid.Text);
                Classroom tid        = new Classroom();
                tid                 = sinifRepo.TekGetir(traineridd);
                ddl2.DataSource     = sinifRepo.HepsiniGetir();
                ddl2.DataTextField  = "Name";
                ddl2.DataValueField = "Id";
                ddl2.SelectedValue  = tid.Id.ToString();
                ddl2.DataBind();
            }
        }
Exemplo n.º 24
0
        public static void Main()
        {
            using (var connection = new SqliteConnection("DataSource=:memory:"))
            {
                connection.Open();

                var context = StudentDbContext.Create(connection);

                var classes = new ClassRepository(context);
                classes.Create(new Class {
                    Id = 1, Name = "Math"
                });
                classes.Create(new Class {
                    Id = 2, Name = "History"
                });

                var students = new StudentRepository(context);

                var math    = classes.Get(1);
                var history = classes.Get(2);

                var jim = new Student
                {
                    Id      = 1,
                    Name    = "Jim Doe",
                    Classes = new List <Class> {
                        math, history
                    }
                };
                students.Create(jim);

                var nextOfKins = students.Get(1);
                nextOfKins.NextOfKins =
                    new List <NextOfKin> {
                    NextOfKin.Create("John Doe"), NextOfKin.Create("Jane Doe")
                };
                students.Update(nextOfKins);

                var residence = students.Get(1);
                nextOfKins.Hometown = City.Create("Oslo");
                students.Update(nextOfKins);

                new StudentReport(connection, 1).Write();
                new ClassesReport(connection).Write();

                Console.Out.WriteLine("Classes: " + context.Classes.Count());
                Console.Out.WriteLine("Students: " + context.Students.Count());
            }
        }
Exemplo n.º 25
0
 public UnitOfWork(CuriousDriveContext context)
 {
     _context        = context;
     Roles           = new RoleRepository(_context);
     Messages        = new MessageRepository(_context);
     Users           = new UserRepository(_context);
     Questions       = new QuestionRepository(_context);
     Classes         = new ClassRepository(_context);
     QuestionAnswers = new QuestionAnswerRepository(_context);
     QuestionClasses = new QuestionClassRepository(_context);
     Comments        = new CommentRepository(_context);
     Tags            = new TagRepository(_context);
     TagDetails      = new TagDetailRepository(_context);
     Feedback        = new FeedbackRepository(_context);
 }
Exemplo n.º 26
0
        public void Get_all_classes_test()
        {
            var repo   = new ClassRepository(context);
            var model  = new ClassEntity("GR2");
            var model2 = new ClassEntity("GR1");

            repo.AddNew(model);
            repo.AddNew(model2);
            var result = repo.GetAll();

            Assert.IsNotNull(result);
            Assert.AreEqual(result.Count, 2);
            Assert.AreEqual(model.Id, result[1].Id);
            Assert.AreEqual(model2.Id, result[0].Id);
        }
Exemplo n.º 27
0
        public void Add_new_timetable_test()
        {
            var         repo        = new TimeTableRepository(context);
            var         classRepo   = new ClassRepository(context);
            var         subjectRepo = new SubjectRepository(context);
            ClassEntity clazz       = new ClassEntity("GR1");

            classRepo.AddNew(clazz);
            SubjectEntity subject = new SubjectEntity("AM", "Analiza");

            subjectRepo.AddNew(subject);
            TimeTableEntity model = new TimeTableEntity("poniedziałek", clazz, subject);

            repo.AddNew(model);
        }
Exemplo n.º 28
0
 public RegisterModel(
     RoleManager <ApplicationRole> roleManager,
     UserManager <ApplicationUser> userManager,
     SignInManager <ApplicationUser> signInManager,
     ClassRepository <ApplicationUser> classRepository,
     ILogger <RegisterModel> logger,
     IEmailSender emailSender)
 {
     _roleManager     = roleManager;
     _userManager     = userManager;
     _signInManager   = signInManager;
     _classRepository = classRepository;
     _logger          = logger;
     _emailSender     = emailSender;
 }
Exemplo n.º 29
0
        public async Task Setup()
        {
            studentLoggingMoq = new Mock <ILogger <StudentRepository> >();
            Func <IDbConnection> getDbConnection = () =>
                                                   new NpgsqlConnection("Server=localhost;Port=5433;User ID=teddy;Password=teddy;");

            classLoggerMoq   = new Mock <ILogger <ClassRepository> >();
            courseLoggerMoq  = new Mock <ILogger <CourseRepository> >();
            psqlString       = () => string.Empty;
            classRepository  = new ClassRepository(getDbConnection, classLoggerMoq.Object, psqlString);
            courseRepository = new CourseRepository(getDbConnection, courseLoggerMoq.Object);

            studentRepository = new StudentRepository(getDbConnection, studentLoggingMoq.Object);

            await seedDatbase();
        }
Exemplo n.º 30
0
        private async Task showClasses()
        {
            if (!(thisApp.AllClasses?.Count > 0))
            {
                ClassRepository c = new ClassRepository();
                try
                {
                    classes.Add(new Class {
                        ID = 0, Name = "All Classes"
                    });
                    thisApp.AllClasses = await c.GetClasses();

                    foreach (Class item in thisApp.AllClasses.OrderBy(cl => cl.Name))
                    {
                        classes.Add(item);
                    }

                    pickerClasses.ItemsSource   = classes;
                    pickerClasses.SelectedIndex = 0;
                }
                catch (Exception ex)
                {
                    if (ex.InnerException != null)
                    {
                        if (ex.GetBaseException().Message.Contains("connection with the server"))
                        {
                            await DisplayAlert("Error", "No connection with the server. Check that the Web Service is running and available and then click the Refresh button.", "Ok");
                        }
                        else
                        {
                            await DisplayAlert("Error", "If the problem persists, please call your system administrator.", "Ok");
                        }
                    }
                    else
                    {
                        if (ex.Message.Contains("NameResolutionFailure"))
                        {
                            await DisplayAlert("Internet Access Error ", "Cannot resolve the Uri: " + Jeeves.DBUri.ToString(), "Ok");
                        }
                        else
                        {
                            await DisplayAlert("General Error ", ex.Message, "Ok");
                        }
                    }
                }
            }
        }
Exemplo n.º 31
0
        async void DeleteClicked(object sender, EventArgs e)
        {
            var answer = await DisplayAlert("Confirm Delete", "Are you certain that you want to delete " + theClass.Name + "?", "Yes", "No");

            if (answer == true)
            {
                try
                {
                    ClassRepository cl = new ClassRepository();
                    await cl.DeleteClass(theClass);

                    thisApp.needClassRefresh = true;
                    await Navigation.PopAsync();
                }
                catch (AggregateException ex)
                {
                    string errMsg = "";
                    foreach (var exception in ex.InnerExceptions)
                    {
                        errMsg += Environment.NewLine + exception.Message;
                    }
                    await DisplayAlert("One or more exceptions has occurred:", errMsg, "Ok");
                }
                catch (ApiException apiEx)
                {
                    var sb = new StringBuilder();
                    sb.AppendLine("Errors:");
                    foreach (var error in apiEx.Errors)
                    {
                        sb.AppendLine("-" + error);
                    }
                    await DisplayAlert("Problem Deleting the Class:", sb.ToString(), "Ok");
                }
                catch (Exception ex)
                {
                    if (ex.GetBaseException().Message.Contains("connection with the server"))
                    {
                        await DisplayAlert("Error", "No connection with the server.", "Ok");
                    }
                    else
                    {
                        await DisplayAlert("Error", "Could not complete operation.", "Ok");
                    }
                }
            }
        }
Exemplo n.º 32
0
        internal static CommonTypeReference Parse(CommonModelElement cme, ClassRepository memberOf)
        {
            CommonTypeReference retVal = new CommonTypeReference();
            retVal.Name = cme.Name;
            retVal.SortKey = cme.SortKey;

            // Annotations
            if (cme.Annotations != null)
                retVal.Documentation = DocumentationParser.Parse(cme.Annotations.Documentation);

            retVal.DerivedFrom = cme;
            
            // Create a type reference
            retVal.Class = new TypeReference();

            // Entry Class specified?
            if (cme.EntryClass == null)
            {
                // Need to find it
                Package p = (Package)cme.Container.MemberOfRepository.Find(cme.BoundStaticModel);
                if (p is GlobalStaticModel && (p as GlobalStaticModel).OwnedEntryPoint.Count > 0)
                {
                    cme.EntryClass = new SpecializationClass();
                    cme.EntryClass.Name = (p as GlobalStaticModel).OwnedEntryPoint[0].ClassName;
                }
                else if (p != null)
                    throw new InvalidOperationException(string.Format("Can't determine the entry point for '{0}'!", p.PackageLocation.ToString(MifCompiler.NAME_FORMAT)));
                else
                    return null; // Can't find the package
            }

            retVal.Class.Name = string.Format("{0}.{1}", cme.BoundStaticModel.ToString(MifCompiler.NAME_FORMAT), cme.EntryClass.Name);

            // Pseudo Heiarchy to get back to the class repository
            retVal.MemberOf = memberOf;
            retVal.Class.MemberOf = memberOf;

            // Classifier code
            retVal.ClassifierCode = cme.SupplierStructuralDomain.Code.Code;

            // Notify complete
            retVal.FireParsed();

            // Now return 
            return retVal;
        }
Exemplo n.º 33
0
        private void FillForm(int id)
        {
            ClassRepository tempClass = new ClassRepository();
            var             tempList  = tempClass.DeStringifyClass();

            foreach (ClassInfo item in tempList)
            {
                if (id == item.Id)
                {
                    var formId         = FindViewById <TextView>(Resource.Id.ClassNameForm);
                    var formName       = FindViewById <TextView>(Resource.Id.ProfNameForm);
                    var formEmail      = FindViewById <TextView>(Resource.Id.ProfEmailForm);
                    var formPhone      = FindViewById <TextView>(Resource.Id.ProfPhoneForm);
                    var formStartDate  = FindViewById <TextView>(Resource.Id.StartDateForm);
                    var formEndDate    = FindViewById <TextView>(Resource.Id.EndDateForm);
                    var formAssesment1 = FindViewById <TextView>(Resource.Id.Assesment1Form);
                    var formAssesment2 = FindViewById <TextView>(Resource.Id.Assesment2Form);
                    var formMemo       = FindViewById <TextView>(Resource.Id.MemoForm);

                    formId.Text        = item.Id.ToString();
                    formName.Text      = item.Name;
                    formStartDate.Text = item.StartDate;
                    formEndDate.Text   = item.EndDate;
                    formMemo.Text      = item.Memo;

                    if (item.AssesmentType == 0)
                    {
                        formAssesment1.Text = "Performance";
                    }
                    else
                    {
                        formAssesment1.Text = "Objective";
                    }

                    if (item.AssesmentType2 == 0)
                    {
                        formAssesment1.Text = "Performance";
                    }
                    else
                    {
                        formAssesment1.Text = "Objective";
                    }
                }
            }
        }
Exemplo n.º 34
0
        internal static MohawkCollege.EHR.gpmr.COR.Class Parse(ClassBase cls, string vocabularyBindingRealm, ClassRepository cr, Dictionary<string, Package> derivationSuppliers)
        {
            // Return value
            MohawkCollege.EHR.gpmr.COR.Class retVal = new MohawkCollege.EHR.gpmr.COR.Class();

            // Name of the class
            retVal.Name = cls.Name;

            // Identify where this class came from
            retVal.DerivedFrom = cls;

            // Set the business name
            foreach (BusinessName bn in cls.BusinessName)
                if (bn.Language == MifCompiler.Language || bn.Language == null)
                    retVal.BusinessName = bn.Name;

            // Set the documentation & Copyright
            retVal.Documentation = new MohawkCollege.EHR.gpmr.COR.Documentation();
            if(cls.Annotations != null)
                retVal.Documentation = DocumentationParser.Parse(cls.Annotations.Documentation);
            if (cls.Container.Header.Copyright != null)
                retVal.Documentation.Copyright = string.Format("Copyright (C){0}, {1}", cls.Container.Header.Copyright.Year,
                    cls.Container.Header.Copyright.Owner);

            // Set abstractiveness of the class
            retVal.IsAbstract = cls.IsAbstract;

            // Sort the properties and add them to the class
            cls.Attribute.Sort(new ClassAttribute.Comparator());
            retVal.Content = new List<ClassContent>();
            foreach (ClassAttribute ca in cls.Attribute)
            {
                if (ca.Conformance == ConformanceKind.NotPermitted) continue;
                MohawkCollege.EHR.gpmr.COR.Property prp = PropertyParser.Parse(ca, vocabularyBindingRealm, cr,derivationSuppliers);
                prp.Container = retVal;
                retVal.AddContent(prp);
            }

            // Set sort key
            retVal.SortKey = cls.SortKey;

            // Return
            return retVal;
        }
Exemplo n.º 35
0
        internal static void ParseClassFromPackage(string ClassName, PackageRepository mifRepo, ClassRepository repo)
        {
            // Class and package location
            string classNamePart = ClassName.Substring(ClassName.IndexOf(".") + 1);
            string packageLocationPart = ClassName.Substring(0, ClassName.IndexOf("."));

            // Find the package that contains the class we want
            GlobalStaticModel pkg = mifRepo.Find(p => (p is GlobalStaticModel) &&
                (p as GlobalStaticModel).OwnedClass.Find(c => c.Choice is MohawkCollege.EHR.HL7v3.MIF.MIF20.StaticModel.Flat.Class &&
                    (c.Choice as MohawkCollege.EHR.HL7v3.MIF.MIF20.StaticModel.Flat.Class).Name == classNamePart) != null &&
                p.PackageLocation.ToString(MifCompiler.NAME_FORMAT) == packageLocationPart) as GlobalStaticModel;


            // Process the package
            if (pkg == null)
                throw new InvalidOperationException(string.Format("Can't find '{0}' in the package repository, cannot continue processing", ClassName));

            StaticModelCompiler comp = new StaticModelCompiler();
            comp.ClassRepository = repo;
            comp.Package = pkg;
            comp.PackageRepository = pkg.MemberOfRepository;
            comp.Compile();
        }
Exemplo n.º 36
0
        /// <summary>
        /// Execute this pipeline object
        /// </summary>
        public void Execute()
        {

            System.Diagnostics.Trace.WriteLine("\r\nStarting MIF to COR Compilation Process", "information");

            // Grab the MifRepository"
            ClassRepository classRep = new ClassRepository();

            // Process the CMET Maps
            ProcessCmetBindings(classRep);

            // Compile the Mif 1 repository
            if (hostContext.Data.ContainsKey("Mif10Repository"))
                CompileMif(hostContext.Data["Mif10Repository"] as PackageRepository, classRep);

            // Compile mif 2 repository
            if (hostContext.Data.ContainsKey("MIF20Repository"))
                CompileMif(hostContext.Data["MIF20Repository"] as MohawkCollege.EHR.HL7v3.MIF.MIF20.Repository.PackageRepository, classRep);


            // Push our rendered classes back onto the pipeline
            hostContext.Data.Add("SourceCR", classRep);
        }
Exemplo n.º 37
0
        /// <summary>
        /// Apply the delta set against the class repository
        /// </summary>
        public void Apply(ClassRepository classRepository)
        {

            // Notify user
            Trace.WriteLine(String.Format("Delta: Adding supported annotation for realm '{0}'...", this.m_deltaSet.Realm.Code), "debug");
            // Mark all features as supported
            foreach (var itm in classRepository)
                AddSupportedAnnotation(itm.Value);

            // Apply the class deltas and models
            foreach (var ep in this.m_deltaSet.EntryPoint)
            {
                Feature subSystem = null;

                // Try to get the sub-system
                if (!classRepository.TryGetValue(ep.Id, out subSystem))
                {
                    Trace.WriteLine(String.Format("Delta: Can't find '{0}' in the repository, skipping...", ep.Id), "error");
                    continue;
                }

                // apply class delta
                foreach (var delta in ep.Delta)
                    ApplyDelta(subSystem as SubSystem, delta);
            }
        }
Exemplo n.º 38
0
        public ArticleCollection Process(ClassRepository rep)
        {

            ArticleCollection artc = new ArticleCollection();

            
            List<Feature> features = new List<Feature>();
            foreach (KeyValuePair<string, Feature> kv in rep)
                features.Add(kv.Value);
            // Sort so classes are processed first
            features.Sort(delegate(Feature a, Feature b)
            {
                if ((a is SubSystem) && !(b is SubSystem)) return -1;
                else if ((b is SubSystem) && !(a is SubSystem)) return 1;
                else if ((a is Class) && !(b is Class)) return 1;
                else if ((b is Class) && !(a is Class)) return -1;
                else return a.GetType().Name.CompareTo(b.GetType().Name);
            });

            //var vocabArticle = new MohawkCollege.EHR.gpmr.Pipeline.Renderer.Deki.Article.Article()
            //{
            //    Title = "Vocabulary",
            //    Children = new ArticleCollection()
            //};
            //vocabArticle.Children.Add(new Article.Article() { Title = "Code Systems" });
            //vocabArticle.Children.Add(new Article.Article() { Title = "Concept Domains" });
            //vocabArticle.Children.Add(new Article.Article() { Title = "Value Sets" });

            //artc.Add(vocabArticle);
            WaitThreadPool wtp = new WaitThreadPool();

            // A thread that does the doohickey thing
            Thread doohickeyThread = new Thread((ThreadStart)delegate()
            {
                string[] hickeythings = { "|", "/", "-", "\\" };
                int hickeyThingCount = 0;
                try
                {
                    while (true)
                    {
                        int cPosX = Console.CursorLeft, cPosY = Console.CursorTop;
                        Console.SetCursorPosition(1, cPosY);
                        Console.Write(hickeythings[hickeyThingCount++ % hickeythings.Length]);
                        Console.SetCursorPosition(cPosX, cPosY);
                        Thread.Sleep(1000);
                    }
                }
                catch { }
            });
            doohickeyThread.Start();

            // Loop through each feature
            foreach (Feature f in features)
            {
                // Find the feature template
                FeatureTemplate ftpl = NonParameterizedTemplate.Spawn(FindTemplate(f.GetType().FullName, f) as NonParameterizedTemplate, this, f) as FeatureTemplate;

                if (ftpl == null) System.Diagnostics.Trace.WriteLine(string.Format("Feature '{0}' won't be published as no feature template could be located", f.Name), "warn");
                else if(f.Annotations.Find(o=>o is SuppressBrowseAnnotation) != null) System.Diagnostics.Trace.WriteLine(String.Format("Feature '{0}' won't be published as a SuppressBrowse annotation was found", f.Name), "warn");
                else if(ftpl.NewPage)
                {
                    System.Diagnostics.Trace.WriteLine(string.Format("Queueing ({1}) '{0}'...", f.Name, f.GetType().Name), "debug");

                    // Create a new worker
                    Worker w = new Worker();
                    w.ArticleCollection = artc;
                    w.FeatureTemplate = ftpl;
                    w.OnComplete += delegate(object sender, EventArgs e)
                    {
                        Worker wrkr = sender as Worker;
                        System.Diagnostics.Trace.WriteLine(String.Format("Rendered ({1}) '{0}'...", (wrkr.FeatureTemplate.Context as Feature).Name, wrkr.FeatureTemplate.Context.GetType().Name), "debug");
                    };
                    wtp.QueueUserWorkItem(w.Start);
                }
            }

            System.Diagnostics.Trace.WriteLine("Waiting for work items to complete...", "debug");
            wtp.WaitOne();
            doohickeyThread.Abort();

            ArticleCollection retVal = new ArticleCollection();
            Article.Article MasterTOC = new MohawkCollege.EHR.gpmr.Pipeline.Renderer.Deki.Article.Article();
            MasterTOC.Children = artc;
            System.Diagnostics.Trace.WriteLine("Creating Table of Contents...", "information");
            PrepareTOC(MasterTOC);
            MasterTOC.Children = null;
            artc.Add(MasterTOC);


            return artc;
        }
Exemplo n.º 39
0
 /// <summary>
 /// Set the member of
 /// </summary>
 private void SetMemberOf(Feature feature, ClassRepository newOwner)
 {
     feature.MemberOf = newOwner;
     if (feature is Class)
         foreach (var p in (feature as Class).Content)
             SetMemberOf(p, newOwner);
     if (feature is Enumeration)
         foreach (var p in (feature as Enumeration).Literals)
             SetMemberOf(p, newOwner);
     if (feature is Choice)
         foreach (var p in (feature as Choice).Content)
             SetMemberOf(p, newOwner);
 }
 public ucClassListView()
 {
     InitializeComponent();
     _classRepository = new ClassRepository();
 }
Exemplo n.º 41
0
        /// <summary>
        /// Parse the specified stub as a common model element reference
        /// </summary>
        internal static CommonTypeReference Parse(StubDefinition stub, ClassRepository classRepository)
        {
            CommonTypeReference retVal = new CommonTypeReference();

            // Create the return value basic parameters
            retVal.Name = stub.Name;
            retVal.SortKey = stub.SortKey;

            if(stub.Annotations != null)
                retVal.Documentation = DocumentationParser.Parse(stub.Annotations.Documentation);

            retVal.DerivedFrom = stub;

            if (stub.SupplierStructuralDomain != null && stub.SupplierStructuralDomain.Code != null)
                retVal.ClassifierCode = stub.SupplierStructuralDomain.Code.Code;

            retVal.Class = new TypeReference();

            // Return value class binding
            if (stub.TypeStaticModel != null)
            {
                Package p = (Package)stub.Container.MemberOfRepository.Find(stub.TypeStaticModel);
                if (p is GlobalStaticModel && (p as GlobalStaticModel).OwnedEntryPoint.Count > 0)
                {
                    string entryClassName = stub.EntryClass;

                    if(entryClassName == null)
                        throw new InvalidOperationException(string.Format("Package '{1}' points to a valid model with more than one entry point, however no entryClass was specified ", stub.TypeStaticModel.ToString(MifCompiler.NAME_FORMAT)));

                    // Did we find the class with an entry point?
                    var search = (p as GlobalStaticModel).OwnedClass.Find(o=>o.Choice is MohawkCollege.EHR.HL7v3.MIF.MIF20.StaticModel.Flat.Class && (o.Choice as MohawkCollege.EHR.HL7v3.MIF.MIF20.StaticModel.Flat.Class).Name == entryClassName);
                    var entryClass = search.Choice as MohawkCollege.EHR.HL7v3.MIF.MIF20.StaticModel.Flat.Class;

                    // Entry class is not null
                    if (entryClass == null)
                        throw new InvalidOperationException(string.Format("Can't find entry class '{0}' in package '{1}', or entry class is not a class", entryClassName, stub.TypeStaticModel.ToString(MifCompiler.NAME_FORMAT)));

                    retVal.Class.Name = string.Format("{0}.{1}", stub.TypeStaticModel.ToString(MifCompiler.NAME_FORMAT), entryClass.Name);
                }
                else if (p is GlobalStaticModel && (p as GlobalStaticModel).OwnedEntryPoint.Count == 1)
                    retVal.Class.Name = string.Format("{0}.{1}", stub.TypeStaticModel.ToString(MifCompiler.NAME_FORMAT), (p as GlobalStaticModel).OwnedEntryPoint[0].Name);
                else if (p != null)
                    throw new InvalidOperationException(string.Format("Can't find static model '{0}'!", p.PackageLocation.ToString(MifCompiler.NAME_FORMAT)));
                else
                    return null; // Can't find the package
            }

            // Pseudo Heiarchy to get back to the class repository
            retVal.MemberOf = classRepository;
            retVal.Class.MemberOf = classRepository;

            // Notify complete
            retVal.FireParsed();

            // Now return 
            return retVal;
        }
Exemplo n.º 42
0
 public MohawkCollege.EHR.gpmr.COR.ClassRepository CompileMif(MohawkCollege.EHR.HL7v3.MIF.MIF20.Repository.PackageRepository pkr)
 {
     ClassRepository retVal = new ClassRepository();
     CompileMif(pkr, retVal);
     return retVal;
 }
Exemplo n.º 43
0
        // Add CMET Bindings
        private void ProcessCmetBindings(ClassRepository classRep)
        {
            // Get the parameters
            Dictionary<String, StringCollection> parameters = hostContext.Data["CommandParameters"] as Dictionary<String, StringCollection>;
            StringCollection cmetBinding = null;
            
            // Parameter was not provided
            if(!parameters.TryGetValue("cmet-binding", out cmetBinding))
                return;
            
            // Create type references for the cmets that have been bound
            foreach (var binding in cmetBinding)
            {
                string[] bindingData = binding.Split(';');
                cmetBindings.Add(bindingData[0], bindingData[1]);
            }

        }
Exemplo n.º 44
0
        /// <summary>
        /// Apply the delta set
        /// </summary>
        private void ApplyDelta(string delta, ClassRepository classRepository)
        {
            // Load the Delta Set
            try
            {
                DeltaSet ds = DeltaSet.Load(delta);
                if (ds.MetaData == null)
                    throw new InvalidOperationException("Delta set is missing data...");

                DeltaEngine de = new DeltaEngine(ds);
                de.Apply(classRepository);
                
            }
            catch (Exception e)
            {
                Trace.WriteLine(String.Format("Delta: Won't apply '{0}', reason: {1}", delta, e.Message), "error");
                Exception ie = e.InnerException;
                while (ie != null)
                {
                    Trace.WriteLine(String.Format("Caused by: {0}", ie.Message), "error");
                    ie = ie.InnerException;
                }
            }
        }