コード例 #1
0
        public void InsertStudyGroupJob(string studygroupId, string jobUuid)
        {
            System.Diagnostics.Debug.WriteLine("StudyGroupJob created");
            StudyGroupJob sgj = new StudyGroupJob();

            sgj.StudyGroupId = Hasher.Base64Encode(studygroupId);
            sgj.JobUuid      = jobUuid;
            System.Diagnostics.Debug.WriteLine("StudyGroupJob before insert");

            lock (DbContext.locker)
            {
                var rowsAffected =
                    Db.Query <StudyGroupJob>(
                        "Select * FROM StudyGroupJob WHERE StudyGroupJob.StudyGroupId = ?" +
                        " AND StudyGroupJob.JobUuid = ?", sgj.StudyGroupId, sgj.JobUuid).Count;
                System.Diagnostics.Debug.WriteLine("DeserializeOneJobs: StudyGroupJob rowsAffected: " +
                                                   rowsAffected);
                if (rowsAffected == 0)
                {
                    // The item does not exists in the database so safe to insert
                    Db.Insert(sgj);
                }
            }
            System.Diagnostics.Debug.WriteLine("StudyGroupJob after insert");
        }
コード例 #2
0
        private async void TestInsertJob(object sender, EventArgs e)
        {
            DbContext        DbContext = DbContext.GetDbContext;
            SQLiteConnection Db        = DbContext.Db;

            System.Diagnostics.Debug.WriteLine("Before insert Job.Count: " +
                                               Db.Query <Job>("Select * from Job").Count());

            JobsController jc        = new JobsController();
            DateTime       yesterday = DateTime.Now.AddDays(-1);
            long           n         = long.Parse(yesterday.ToString("yyyyMMddHHmmss"));

            string testUuid = "colemak";
            Job    job      = new Job()
            {
                uuid       = testUuid,
                expiryDate = n
            };

            string  companyId = "Ikea";
            Company comp      = new Company()
            {
                id = companyId
            };

            string   locationId = "sverige";
            Location loc        = new Location()
            {
                id = locationId
            };

            string     sgId = "dykking";
            StudyGroup sg   = new StudyGroup()
            {
                id = sgId
            };

            StudyGroupJob sgj = new StudyGroupJob()
            {
                StudyGroupId = sgId,
                JobUuid      = testUuid
            };

            LocationJob lj = new LocationJob()
            {
                LocationId = locationId,
                JobUuid    = testUuid
            };

            CompanyJob cj = new CompanyJob()
            {
                CompanyId = companyId,
                JobUuid   = testUuid
            };

            string  jtId = "10aarErfaringEcma6";
            JobType jt   = new JobType()
            {
                id = jtId
            };

            JobTypeJob jtj = new JobTypeJob()
            {
                JobUuid   = testUuid,
                JobTypeId = jtId
            };

            // try catch on tables that will not be affected by a job delete
            try
            {
                Db.Insert(comp);
            }
            catch
            {
            }
            Db.Insert(job);
            try
            {
                Db.Insert(loc);
            }
            catch
            {
            }
            try
            {
                Db.Insert(sg);
            }
            catch
            {
            }
            Db.Insert(sgj);
            Db.Insert(lj);
            Db.Insert(cj);
            try
            {
                Db.Insert(jt);
            }
            catch
            {
            }
            Db.Insert(jtj);

            System.Diagnostics.Debug.WriteLine("After insert: Job.Count: " +
                                               Db.Query <Job>("Select * from Job").Count());
        }
コード例 #3
0
        /// <summary>
        /// This test method require that you have not logged in and got no authorization
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void TestDeleteExpiredJobs(object sender, EventArgs e)
        {
            DbJob jc = new DbJob();

            DbContext        DbContext = DbContext.GetDbContext;
            SQLiteConnection Db        = DbContext.Db;

            DateTime yesterday = DateTime.Now.AddDays(-1);
            long     n         = long.Parse(yesterday.ToString("yyyyMMddHHmmss"));

            string testUuid = "colemak";
            Job    job      = new Job()
            {
                uuid       = testUuid,
                expiryDate = n
            };

            string  companyId = "Ikea";
            Company comp      = new Company()
            {
                id = companyId
            };

            string   locationId = "sverige";
            Location loc        = new Location()
            {
                id = locationId
            };

            string     sgId = "dykking";
            StudyGroup sg   = new StudyGroup()
            {
                id = sgId
            };

            StudyGroupJob sgj = new StudyGroupJob()
            {
                StudyGroupId = sgId,
                JobUuid      = testUuid
            };

            LocationJob lj = new LocationJob()
            {
                LocationId = locationId,
                JobUuid    = testUuid
            };

            CompanyJob cj = new CompanyJob()
            {
                CompanyId = companyId,
                JobUuid   = testUuid
            };

            string  jtId = "10aarErfaringEcma6";
            JobType jt   = new JobType()
            {
                id = jtId
            };

            JobTypeJob jtj = new JobTypeJob()
            {
                JobUuid   = testUuid,
                JobTypeId = jtId
            };

            Db.Insert(comp);
            Db.Insert(job);
            Db.Insert(loc);
            Db.Insert(sg);
            Db.Insert(sgj);
            Db.Insert(lj);
            Db.Insert(cj);
            Db.Insert(jt);
            Db.Insert(jtj);

            Job j = Db.Get <Job>(testUuid);

            System.Diagnostics.Debug.WriteLine("j.expiryDate: " + j.expiryDate);
            System.Diagnostics.Debug.WriteLine("StudyGroup.Count: " +
                                               Db.Query <StudyGroup>("Select * from StudyGroup").Count());
            System.Diagnostics.Debug.WriteLine("Job.Count: " +
                                               Db.Query <Job>("Select * from Job").Count());
            System.Diagnostics.Debug.WriteLine("JobType.Count: " +
                                               Db.Query <JobType>("Select * from JobType").Count());
            System.Diagnostics.Debug.WriteLine("Location.Count: " +
                                               Db.Query <Location>("Select * from Location").Count());
            System.Diagnostics.Debug.WriteLine("Company.Count: " +
                                               Db.Query <Company>("Select * from Company").Count());

            System.Diagnostics.Debug.WriteLine("CompanyJob.Count: " +
                                               Db.Query <CompanyJob>("Select * from CompanyJob").Count());
            System.Diagnostics.Debug.WriteLine("JobTypeJob.Count: " +
                                               Db.Query <JobTypeJob>("Select * from JobTypeJob").Count());
            System.Diagnostics.Debug.WriteLine("LocationJob.Count: " +
                                               Db.Query <LocationJob>("Select * from LocationJob").Count());
            System.Diagnostics.Debug.WriteLine("StudyGroupJob.Count: " +
                                               Db.Query <StudyGroupJob>("Select * from StudyGroupJob").Count());

            System.Diagnostics.Debug.WriteLine("Time for delete");
            jc.DeleteAllExpiredJobs();
            System.Diagnostics.Debug.WriteLine("Job.Count: " +
                                               Db.Query <Job>("Select * from Job").Count());
            System.Diagnostics.Debug.WriteLine("CompanyJob.Count: " +
                                               Db.Query <CompanyJob>("Select * from CompanyJob").Count());
            System.Diagnostics.Debug.WriteLine("JobTypeJob.Count: " +
                                               Db.Query <JobTypeJob>("Select * from JobTypeJob").Count());
            System.Diagnostics.Debug.WriteLine("LocationJob.Count: " +
                                               Db.Query <LocationJob>("Select * from LocationJob").Count());
            System.Diagnostics.Debug.WriteLine("StudyGroupJob.Count: " +
                                               Db.Query <StudyGroupJob>("Select * from StudyGroupJob").Count());
            //CompanyJobs, StudyGroupJob, LocationJob og JobTypeJob.
        }