private async void TestInsertProject(object sender, EventArgs e) { DbContext DbContext = DbContext.GetDbContext; SQLiteConnection Db = DbContext.Db; System.Diagnostics.Debug.WriteLine("Before insert Project.Count: " + Db.Query<Project>("Select * from Project").Count()); ProjectsController jc = new ProjectsController(); string testUuid = "colemak"; Project project = new Project() { uuid = testUuid, }; string companyId = "Ikea"; Company comp = new Company() { id = companyId }; string courseId = "sverige"; Course course = new Course() { id = courseId }; string sgId = "dykking"; StudyGroup sg = new StudyGroup() { id = sgId }; StudyGroupProject sgj = new StudyGroupProject() { StudyGroupId = sgId, ProjectUuid = testUuid }; CourseProject lj = new CourseProject() { CourseId = courseId, ProjectUuid = testUuid }; CompanyProject cp = new CompanyProject() { CompanyId = companyId, ProjectUuid = testUuid }; string jtId = "10aarErfaringEcma6"; JobType jt = new JobType() { id = jtId }; JobTypeProject jtp = new JobTypeProject() { ProjectUuid = testUuid, JobTypeId = jtId }; // try catch on tables that will not be affected by a job delete try { Db.Insert(comp); } catch { } Db.Insert(project); try { Db.Insert(course); } catch { } try { Db.Insert(sg); } catch { } Db.Insert(sgj); Db.Insert(lj); Db.Insert(cp); try { Db.Insert(jt); } catch { } Db.Insert(jtp); System.Diagnostics.Debug.WriteLine("After insert: Project.Count: " + Db.Query<Project>("Select * from Project").Count()); }
private async void TestProjectsFilter_OnClicked(object sender, EventArgs e) { List<string> studyGroups = new List<string>(); string helse = Hasher.Base64Encode("helse"); string datateknologi = Hasher.Base64Encode("datateknologi"); studyGroups.Add(helse); studyGroups.Add(datateknologi); //LEGG FAGOMRÅDER TIL AKTIVT FILTER HER MED EN SWITCH ELLER LIGNENDE Dictionary<string, string> filter = new Dictionary<string, string>(); string DAT304 = Hasher.Base64Encode("DAT-304"); string virksomhet = Hasher.Base64Encode("virksomhet"); filter.Add("courses", DAT304); filter.Add("types", virksomhet); ProjectsController jc = new ProjectsController(); IEnumerable<Project> projects = await jc.GetProjectsBasedOnFilter(studyGroups, filter); if (!Authenticater.Authorized) { GoToLogin(); } if (projects != null) { System.Diagnostics.Debug.WriteLine("GetProjectsBasedOnFilter: projects.Count(): " + projects.Count()); foreach (var project in projects) { System.Diagnostics.Debug.WriteLine("Companies is not null: " + project.companies[0].id); System.Diagnostics.Debug.WriteLine("Companies is not null: " + project.companies[0].name); System.Diagnostics.Debug.WriteLine("Companies is not null: " + project.companies[0].logo); } } }
/// <summary> /// Inserts a notification into the database. /// </summary> /// <param name="type">This param can either be job or project, and will determine what kind of notification it is.</param> /// <param name="typeUuid">the foreign key of type</param> public async Task InsertNotification(string type, string typeUuid) { System.Diagnostics.Debug.WriteLine("DbNotification - InsertNotification: initiated"); Notification notification = new Notification(); System.Diagnostics.Debug.WriteLine("DbNotification - InsertNotification: type: " + type); System.Diagnostics.Debug.WriteLine("DbNotification - InsertNotification: typeUuid: " + typeUuid); if (String.IsNullOrEmpty(typeUuid) || String.IsNullOrEmpty(type)) { return; } if (type.Equals("job")) { // FIRST !! // insert a new job object matching the uuid as long as it doesn't exist System.Diagnostics.Debug.WriteLine("DbNotification - InsertNotification: new JobsController();"); DbJob dbJob = new DbJob(); JobsController jc = new JobsController(); System.Diagnostics.Debug.WriteLine( "DbNotification - InsertNotification: JobsController Created"); dbJob.InsertJob(typeUuid); // SECOND insert the notification. notification.jobUuid = typeUuid; lock (DbContext.locker) { Db.Insert(notification); } //THIRD: async get extra minimum info for the notification list. jc.UpdateJobFromServer(typeUuid); } else if (type.Equals("project")) { // FIRST !! // insert a new project object matching the uuid as long as it doesn't exist System.Diagnostics.Debug.WriteLine( "DbNotification - InsertNotification: new ProjectsController();"); ProjectsController pc = new ProjectsController(); DbProject dbProject = new DbProject(); System.Diagnostics.Debug.WriteLine( "DbNotification - InsertNotification: ProjectsController Created"); dbProject.InsertProject(typeUuid); // SECOND insert the notification. notification.projectUuid = typeUuid; lock (DbContext.locker) { Db.Insert(notification); } //THIRD: async get extra minimum info for the notification list. pc.UpdateProjectFromServer(typeUuid); } System.Diagnostics.Debug.WriteLine("DbNotification - InsertNotification: Test: End of method"); }
private async void GetAllProjectsFromWebApi_OnClicked(object sender, EventArgs e) { ProjectsController jc = new ProjectsController(); IEnumerable<Project> projects = await jc.GetProjectsBasedOnFilter(); if (!Authenticater.Authorized) { GoToLogin(); } if (projects != null) { System.Diagnostics.Debug.WriteLine("GetJobsBasedOnFilter: jobs.Count(): " + projects.Count()); } }
//public Dictionary<string, string> GetCourse() //{ // foreach (Course course in listInit.coursesSettings) // { // object itemname = OppgaverEmner.SelectedItem; // string i = itemname.ToString(); // if (course.name == i) { // listInit.coursesFilter.Add("courses", course.id); // System.Diagnostics.Debug.WriteLine("ITEMNAME TOSTRING DOES NOT WORK::::: " + i); // } // else // { // System.Diagnostics.Debug.WriteLine("ITEMNAME TOSTRING PRODUCES STRING::::: " + i); // } // } // return listInit.coursesFilter; //} //void OnSelection(object sender, SelectedItemChangedEventArgs e) //{ // if (e.SelectedItem == null) // { // return; //ItemSelected is called on deselection, which results in SelectedItem being set to null // } // DisplayAlert("Item Selected", e.SelectedItem.ToString(), "Ok"); // //((ListView)sender).SelectedItem = null; //uncomment line if you want to disable the visual selection state. //} private async Task AddData() { //Dictionary<string, string> filter = new Dictionary<string, string>(); //contains only one item from each group //filter.Add("courses", "DAT-304"); //filter.Add("types", "virksomhet"); //if (pullList == false) //{ //} //else if (pullList == true) //{ ProjectsController jc = new ProjectsController(); IEnumerable<Project> projects = await jc.GetProjectsBasedOnFilter(listInit.GetSettings(), null); HashSet<Project> newProjects = new HashSet<Project>(projects); HashSet<Project> oldProjects = new HashSet<Project>(oppgaver); bool sameProjects = newProjects.SetEquals(oldProjects); if (!sameProjects) { //OppgaveList.ItemsSource = null; oppgaver.Clear(); foreach (Project project in projects) { System.Diagnostics.Debug.WriteLine("project.title: " + project.title); oppgaver.Add(project); } //OppgaveList.ItemsSource = oppgaver; } if (!Authenticater.Authorized) { GoToLogin(); } }