예제 #1
0
        public async Task SQL_Case_CheckListSitesRead_DoesSiteRead()
        {
            Random rnd   = new Random();
            sites  site1 = await testHelpers.CreateSite("mySite2", 331);

            DateTime    cl1_Ca = DateTime.Now;
            DateTime    cl1_Ua = DateTime.Now;
            check_lists cl1    = await testHelpers.CreateTemplate(cl1_Ca, cl1_Ua, "template2", "template_desc", "", "", 1, 1);

            string guid          = Guid.NewGuid().ToString();
            string guid2         = Guid.NewGuid().ToString();
            int    lastCheckUid1 = rnd.Next(1, 255);
            int    lastCheckUid2 = rnd.Next(1, 255);

            check_list_sites cls1 = await testHelpers.CreateCheckListSite(cl1, cl1_Ca, site1, cl1_Ua, 1, Constants.WorkflowStates.Created, lastCheckUid1);

            check_list_sites cls2 = await testHelpers.CreateCheckListSite(cl1, cl1_Ca, site1, cl1_Ua, 2, Constants.WorkflowStates.Created, lastCheckUid2);

            // Act
            List <int> matches = await sut.CheckListSitesRead(cl1.Id, (int)site1.MicrotingUid, Constants.WorkflowStates.NotRemoved);

            List <int> matches2 = await sut.CheckListSitesRead(cl1.Id, (int)site1.MicrotingUid, null);

            List <check_list_sites> checkListSiteResult1 = dbContext.check_list_sites.AsNoTracking().ToList();
            var versionedMatches1 = dbContext.check_list_site_versions.AsNoTracking().ToList();


            // Assert
            Assert.NotNull(matches);
            Assert.AreEqual(2, matches.Count);
            Assert.AreEqual(2, matches2.Count);
            Assert.AreEqual(cls1.MicrotingUid, matches[0]);
            Assert.AreEqual(cls1.MicrotingUid, matches2[0]);
            Assert.AreEqual(cls2.MicrotingUid, matches2[1]);
        }
        public async Task <string> CreateSiteUnitWorkersForFullLoaed(bool create)
        {
            if (create)
            {
                int    id       = t.GetRandomInt(6);
                string siteName = Guid.NewGuid().ToString();
                sites  site     = await testHelpers.CreateSite(siteName, id);

                id = t.GetRandomInt(6);
                string  userFirstName = Guid.NewGuid().ToString();
                string  userLastName  = Guid.NewGuid().ToString();
                workers worker        = await testHelpers.CreateWorker("*****@*****.**", userFirstName, userLastName, id);

                return("");
            }

            try
            {
                sites   site   = testHelpers.dbContext.sites.First();
                workers worker = testHelpers.dbContext.workers.First();

                int     id     = t.GetRandomInt(6);
                JObject result = JObject.FromObject(new JArray(new
                {
                    id             = id, created_at = "2018-01-12T01:01:00Z", updated_at = "2018-01-12T01:01:10Z",
                    workflow_state = Constants.WorkflowStates.Created, person_type = "",
                    site_id        = site.MicrotingUid, user_id = worker.MicrotingUid
                }));
                return(result.ToString());
            }
            catch
            {
                return("{}");
            }
        }
예제 #3
0
        public void SQL_Case_CheckListSitesRead_DoesSiteRead()
        {
            sites       site1  = testHelpers.CreateSite("mySite2", 331);
            DateTime    cl1_Ca = DateTime.Now;
            DateTime    cl1_Ua = DateTime.Now;
            check_lists cl1    = testHelpers.CreateTemplate(cl1_Ca, cl1_Ua, "template2", "template_desc", "", "", 1, 1);

            string guid          = Guid.NewGuid().ToString();
            string guid2         = Guid.NewGuid().ToString();
            string lastCheckUid1 = Guid.NewGuid().ToString();
            string lastCheckUid2 = Guid.NewGuid().ToString();

            check_list_sites cls1 = testHelpers.CreateCheckListSite(cl1, cl1_Ca, site1, cl1_Ua, 1, Constants.WorkflowStates.Created, lastCheckUid1);
            check_list_sites cls2 = testHelpers.CreateCheckListSite(cl1, cl1_Ca, site1, cl1_Ua, 2, Constants.WorkflowStates.Created, lastCheckUid2);

            // Act
            List <string>           matches              = sut.CheckListSitesRead(cl1.id, (int)site1.microting_uid, Constants.WorkflowStates.NotRemoved);
            List <string>           matches2             = sut.CheckListSitesRead(cl1.id, (int)site1.microting_uid, null);
            List <check_list_sites> checkListSiteResult1 = DbContext.check_list_sites.AsNoTracking().ToList();
            var versionedMatches1 = DbContext.check_list_site_versions.AsNoTracking().ToList();


            // Assert
            Assert.NotNull(matches);
            Assert.AreEqual(2, matches.Count);
            Assert.AreEqual(2, matches2.Count);
            Assert.AreEqual(cls1.microting_uid, matches[0]);
            Assert.AreEqual(cls1.microting_uid, matches2[0]);
            Assert.AreEqual(cls2.microting_uid, matches2[1]);
        }
예제 #4
0
 public List <sites> getSites(string latlan, string type)
 {
     using (var client = new WebClient())
     {
         var          values         = new NameValueCollection();
         var          response       = client.DownloadData(FindPlaces(latlan, type));
         var          responseString = Encoding.Default.GetString(response);
         JObject      responseData   = JObject.Parse(responseString);
         List <sites> sites          = new List <TripAppServer.sites>();
         foreach (var item in responseData["results"])
         {
             var s = new sites();
             s.location_lat = item["geometry"]["location"]["lat"] == null ? 0 : double.Parse(item["geometry"]["location"]["lat"].ToString());
             s.location_lng = item["geometry"]["location"]["lng"] == null ? 0 : double.Parse(item["geometry"]["location"]["lng"].ToString());
             s.place_id     = item["place_id"].ToString();
             s.types        = item["types"].ToString();
             var     responseD       = client.DownloadData(PLACE_DETAILS(s.place_id));
             var     responseDString = Encoding.Default.GetString(responseD);
             JObject jData           = JObject.Parse(responseDString);
             s.name = jData["result"]["name"].ToString();
             s.formatted_address          = jData["result"]["formatted_address"].ToString();
             s.international_phone_number = jData["result"]["formatted_phone_number"] == null ? string.Empty : jData["result"]["formatted_phone_number"].ToString();
             s.rating = jData["result"]["rating"] == null ? 0 : double.Parse(jData["result"]["rating"].ToString());
             //opening_hours
             sites.Add(s);
         }
         return(sites);
     }
 }
        public void SQL_Case_CaseDeleteResult_DoesMarkCaseRemoved()
        {
            // Arrance
            sites site = new sites();

            site.name = "SiteName";
            DbContext.sites.Add(site);
            DbContext.SaveChanges();

            check_lists cl = new check_lists();

            cl.label = "label";

            DbContext.check_lists.Add(cl);
            DbContext.SaveChanges();

            cases aCase = new cases();

            aCase.microting_uid       = "microting_uid";
            aCase.microting_check_uid = "microting_check_uid";
            aCase.workflow_state      = Constants.WorkflowStates.Created;
            aCase.check_list_id       = cl.id;
            aCase.site_id             = site.id;

            DbContext.cases.Add(aCase);
            DbContext.SaveChanges();

            // Act
            sut.CaseDeleteResult(aCase.id);
            cases theCase = sut.CaseReadFull(aCase.microting_uid, aCase.microting_check_uid);

            // Assert
            Assert.NotNull(theCase);
            Assert.AreEqual(Constants.WorkflowStates.Removed, theCase.workflow_state);
        }
예제 #6
0
        public async Task Sites_Update_DoesUpdate()
        {
            //Arrange

            sites site = new sites
            {
                Name = Guid.NewGuid().ToString()
            };

            dbContext.sites.Add(site);
            await dbContext.SaveChangesAsync().ConfigureAwait(false);

            //Act

            site.Name = Guid.NewGuid().ToString();
            await site.Update(dbContext).ConfigureAwait(false);

            sites                dbSites       = dbContext.sites.AsNoTracking().First();
            List <sites>         sitesList     = dbContext.sites.AsNoTracking().ToList();
            List <site_versions> sitesVersions = dbContext.site_versions.AsNoTracking().ToList();

            //Assert

            Assert.NotNull(dbSites);
            Assert.NotNull(dbSites.Id);

            Assert.AreEqual(1, sitesList.Count());
            Assert.AreEqual(1, sitesVersions.Count());

            Assert.AreEqual(site.CreatedAt.ToString(), dbSites.CreatedAt.ToString());
            Assert.AreEqual(site.Version, dbSites.Version);
//            Assert.AreEqual(site.UpdatedAt.ToString(), dbSites.UpdatedAt.ToString());
            Assert.AreEqual(site.Name, dbSites.Name);
        }
예제 #7
0
        public async Task Put()
        {
            //Arrange
            var get = await controller.Get(1);

            var okgetResult = Assert.IsType <OkObjectResult>(get);

            var entity    = Assert.IsType <sites>(okgetResult.Value);
            var newEntity = new sites()
            {
                site_no = "A1", site_name = "name1", site_description = "test12", state = "WI", county = "Fort", waterbody = "test", latitude_dd = 34, longitude_dd = -90, hdatum_id = 3, hcollect_method_id = 1, member_id = 44
            };

            //should test the equals Equatable for all these too
            var huh = entity.Equals(newEntity);

            entity.site_no = "A5";
            //Act
            var response = await controller.Put(1, entity);

            // Assert
            var okResult = Assert.IsType <OkObjectResult>(response);
            var result   = Assert.IsType <sites>(okResult.Value);

            Assert.Equal(entity.site_no, result.site_no);
        }
예제 #8
0
        public async Task SQL_Case_CaseDeleteReversed_DoesDeletionReversed()
        {
            // Arrance
            Random rnd  = new Random();
            sites  site = await testHelpers.CreateSite("mySite", 987);

            DateTime    cl1_Ca = DateTime.Now;
            DateTime    cl1_Ua = DateTime.Now;
            check_lists cl1    = await testHelpers.CreateTemplate(cl1_Ca, cl1_Ua, "bla", "bla_desc", "", "", 0, 0);

            string guid          = Guid.NewGuid().ToString();
            int    lastCheckUid1 = rnd.Next(1, 255);


            check_list_sites cls1 = await testHelpers.CreateCheckListSite(cl1, cl1_Ca, site, cl1_Ua, 1, Constants.WorkflowStates.Created, lastCheckUid1);

            // Act
            await sut.CaseDeleteReversed(cls1.MicrotingUid);

            List <check_list_sites> checkListSiteResult = dbContext.check_list_sites.AsNoTracking().ToList();

            // Assert

            Assert.NotNull(checkListSiteResult);
            Assert.AreEqual(1, checkListSiteResult.Count);
            Assert.AreEqual(Constants.WorkflowStates.Removed, checkListSiteResult[0].WorkflowState);
        }
예제 #9
0
        public async Task Site_Create_DoesCreate()
        {
            //Arrange
            Random rnd = new Random();

            sites site = new sites
            {
                Name         = Guid.NewGuid().ToString(),
                MicrotingUid = rnd.Next(1, 255)
            };

            //Act

            await site.Create(dbContext).ConfigureAwait(false);

            sites        dbSites   = dbContext.sites.AsNoTracking().First();
            List <sites> sitesList = dbContext.sites.AsNoTracking().ToList();

            //Assert

            Assert.NotNull(dbSites);
            Assert.NotNull(dbSites.Id);

            Assert.AreEqual(1, sitesList.Count());
            Assert.AreEqual(site.CreatedAt.ToString(), dbSites.CreatedAt.ToString());
            Assert.AreEqual(site.Version, dbSites.Version);
//            Assert.AreEqual(site.UpdatedAt.ToString(), dbSites.UpdatedAt.ToString());
            Assert.AreEqual(dbSites.WorkflowState, Constants.WorkflowStates.Created);
            Assert.AreEqual(site.Name, dbSites.Name);
            Assert.AreEqual(site.MicrotingUid, dbSites.MicrotingUid);
        }
        public async Task SQL_File_FileCaseFindMUId_doesFindMUId()
        {
            Random rnd   = new Random();
            sites  site1 = await testHelpers.CreateSite("MySite", 22);

            DateTime    cl1_Ca = DateTime.Now;
            DateTime    cl1_Ua = DateTime.Now;
            check_lists cl1    = await testHelpers.CreateTemplate(cl1_Ca, cl1_Ua, "template1", "template_desc", "", "", 1, 1);

            string guid = Guid.NewGuid().ToString();


            DateTime c1_ca  = DateTime.Now.AddDays(-9);
            DateTime c1_da  = DateTime.Now.AddDays(-8).AddHours(-12);
            DateTime c1_ua  = DateTime.Now.AddDays(-8);
            workers  worker = await testHelpers.CreateWorker("*****@*****.**", "Arne", "Jensen", 21);

            site_workers site_workers = await testHelpers.CreateSiteWorker(55, site1, worker);

            units unit = await testHelpers.CreateUnit(48, 49, site1, 348);

            string microtingUId     = Guid.NewGuid().ToString();
            string microtingCheckId = Guid.NewGuid().ToString();
            cases  aCase1           = await testHelpers.CreateCase("case1UId", cl1, c1_ca, "custom1",
                                                                   c1_da, worker, rnd.Next(1, 255), rnd.Next(1, 255),
                                                                   site1, 1, "caseType1", unit, c1_ua, 1, worker, Constants.WorkflowStates.Created);

            uploaded_data ud = new uploaded_data
            {
                Checksum     = "checksum1",
                Extension    = "extension",
                CurrentFile  = "currentFile1",
                UploaderId   = 223,
                UploaderType = "uploader_type",
                FileLocation = "url",
                FileName     = "fileName"
            };

            dbContext.uploaded_data.Add(ud);
            await dbContext.SaveChangesAsync().ConfigureAwait(false);

            field_values fVs = new field_values
            {
                UploadedDataId = ud.Id,
                CaseId         = aCase1.Id
            };

            dbContext.field_values.Add(fVs);
            await dbContext.SaveChangesAsync().ConfigureAwait(false);


            // Act
            await sut.FileCaseFindMUId("url");


            Assert.NotNull(fVs);
            Assert.AreEqual(fVs.CaseId, aCase1.Id);
        }
예제 #11
0
        [Test]//Using Communicatorn needs httpMock
        public void Core_Site_SiteReset_ReturnsSite()
        {
            //Arrance
            #region site
            sites site = testHelpers.CreateSite("SiteName", 88);

            #endregion
            //Act

            //Assert
        }
        [Test]//Using Communicatorn needs httpMock
        public async Task Core_Site_SiteReset_ReturnsSite()
        {
            // Arrange
            #region site
            sites site = await testHelpers.CreateSite("SiteName", 88);

            #endregion
            // Act

            // Assert
        }
예제 #13
0
        public void SQL_File_FileCaseFindMUId_doesFindMUId()
        {
            sites       site1  = testHelpers.CreateSite("MySite", 22);
            DateTime    cl1_Ca = DateTime.Now;
            DateTime    cl1_Ua = DateTime.Now;
            check_lists cl1    = testHelpers.CreateTemplate(cl1_Ca, cl1_Ua, "template1", "template_desc", "", "", 1, 1);

            string guid = Guid.NewGuid().ToString();


            DateTime     c1_ca        = DateTime.Now.AddDays(-9);
            DateTime     c1_da        = DateTime.Now.AddDays(-8).AddHours(-12);
            DateTime     c1_ua        = DateTime.Now.AddDays(-8);
            workers      worker       = testHelpers.CreateWorker("*****@*****.**", "Arne", "Jensen", 21);
            site_workers site_workers = testHelpers.CreateSiteWorker(55, site1, worker);
            units        unit         = testHelpers.CreateUnit(48, 49, site1, 348);

            string microtingUId     = Guid.NewGuid().ToString();
            string microtingCheckId = Guid.NewGuid().ToString();
            cases  aCase1           = testHelpers.CreateCase("case1UId", cl1, c1_ca, "custom1",
                                                             c1_da, worker, "microtingCheckUId1", "microtingUId1",
                                                             site1, 1, "caseType1", unit, c1_ua, 1, worker, Constants.WorkflowStates.Created);

            uploaded_data ud = new uploaded_data();

            ud.checksum      = "checksum1";
            ud.extension     = "extension";
            ud.current_file  = "currentFile1";
            ud.uploader_id   = 223;
            ud.uploader_type = "uploader_type";
            ud.file_location = "url";
            ud.file_name     = "fileName";
            //ud.id = 111;

            DbContext.uploaded_data.Add(ud);
            DbContext.SaveChanges();

            field_values fVs = new field_values();

            fVs.uploaded_data_id = ud.id;
            fVs.case_id          = aCase1.id;

            DbContext.field_values.Add(fVs);
            DbContext.SaveChanges();


            //Act
            sut.FileCaseFindMUId("url");


            Assert.NotNull(fVs);
            Assert.AreEqual(fVs.case_id, aCase1.id);
        }
예제 #14
0
        [HttpGet("Search")] //?bySiteNo={siteNo}&bySiteName={siteName}&bySiteId={siteId}
        public async Task <IActionResult> GetSiteBySearch([FromQuery] string bySiteNo = "", [FromQuery] string bySiteName = "", [FromQuery] string bySiteId = "")
        {
            try
            {
                if (string.IsNullOrEmpty(bySiteNo) && string.IsNullOrEmpty(bySiteName) && string.IsNullOrEmpty(bySiteId))
                {
                    return(new BadRequestResult());
                }
                sites objectRequested = null;
                //only one will be provided
                if (!string.IsNullOrEmpty(bySiteNo))
                {
                    objectRequested = agent.Select <sites>().SingleOrDefault(s => s.site_no.ToUpper() == bySiteNo.ToUpper());
                    if (objectRequested == null)
                    {
                        return(new BadRequestObjectResult(new Error(errorEnum.e_notFound)));
                    }
                    //sm(sa.Messages);
                }
                if (!string.IsNullOrEmpty(bySiteName))
                {
                    objectRequested = agent.Select <sites>().SingleOrDefault(s => s.site_name.ToUpper() == bySiteName.ToUpper());
                    if (objectRequested == null)
                    {
                        return(new BadRequestObjectResult(new Error(errorEnum.e_notFound)));
                    }
                    //sm(sa.Messages);
                }
                if (!string.IsNullOrEmpty(bySiteId))
                {
                    Int32 sid = Convert.ToInt32(bySiteId);
                    objectRequested = agent.Select <sites>().SingleOrDefault(s => s.site_id == sid);
                    if (objectRequested == null)
                    {
                        return(new BadRequestObjectResult(new Error(errorEnum.e_notFound)));
                    }
                    //sm(sa.Messages);
                }

                if (objectRequested == null)
                {
                    return(new BadRequestObjectResult(new Error(errorEnum.e_notFound)));
                }
                //sm(agent.Messages);
                return(Ok(objectRequested));
            }
            catch (Exception ex)
            {
                //sm(agent.Messages);
                return(await HandleExceptionAsync(ex));
            }
        }
예제 #15
0
        public async Task SiteTags_Delete_DoesDelete()
        {
            // Arrange
            Random rnd = new Random();

            sites site = new sites
            {
                Name         = Guid.NewGuid().ToString(),
                MicrotingUid = rnd.Next(1, 255)
            };
            await site.Create(dbContext).ConfigureAwait(false);

            tags tag = new tags
            {
                Name          = Guid.NewGuid().ToString(),
                TaggingsCount = rnd.Next(1, 255)
            };
            await tag.Create(dbContext).ConfigureAwait(false);


            site_tags siteTag = new site_tags
            {
                SiteId = site.Id,
                TagId  = tag.Id
            };
            await siteTag.Create(dbContext).ConfigureAwait(false);

            // Act
            await siteTag.Delete(dbContext).ConfigureAwait(false);

            List <site_tags>         siteTags        = dbContext.SiteTags.AsNoTracking().ToList();
            List <site_tag_versions> siteTagVersions = dbContext.SiteTagVersions.AsNoTracking().ToList();

            // Assert
            Assert.NotNull(siteTags);
            Assert.NotNull(siteTagVersions);

            Assert.AreEqual(siteTag.SiteId, siteTags[0].SiteId);
            Assert.AreEqual(siteTag.TagId, siteTags[0].TagId);
            Assert.AreEqual(siteTag.WorkflowState, Constants.WorkflowStates.Removed);

            Assert.AreEqual(siteTag.SiteId, siteTagVersions[0].SiteId);
            Assert.AreEqual(siteTag.TagId, siteTagVersions[0].TagId);
            Assert.AreEqual(siteTagVersions[0].WorkflowState, Constants.WorkflowStates.Created);

            Assert.AreEqual(siteTag.SiteId, siteTagVersions[1].SiteId);
            Assert.AreEqual(siteTag.TagId, siteTagVersions[1].TagId);
            Assert.AreEqual(siteTagVersions[1].WorkflowState, Constants.WorkflowStates.Removed);
        }
예제 #16
0
        public async Task siteSurveyConfiguration_Delete_DoesDelete()
        {
            // Arrange
            Random rnd = new Random();

            question_sets questionSet = new question_sets()
            {
                ParentId = 0
            };

            await questionSet.Create(dbContext).ConfigureAwait(false);

            survey_configurations surveyConfiguration = new survey_configurations
            {
                Name          = Guid.NewGuid().ToString(),
                Stop          = DateTime.Now,
                Start         = DateTime.Now,
                TimeOut       = rnd.Next(1, 255),
                TimeToLive    = rnd.Next(1, 255),
                QuestionSetId = questionSet.Id
            };

            await surveyConfiguration.Create(dbContext).ConfigureAwait(false);

            sites site1 = await testHelpers.CreateSite("SiteName1", 88);

            site_survey_configurations siteSurveyConfiguration = new site_survey_configurations
            {
                SiteId = site1.Id,
                SurveyConfigurationId = surveyConfiguration.Id
            };
            await siteSurveyConfiguration.Create(dbContext).ConfigureAwait(false);

            // Act
            await siteSurveyConfiguration.Delete(dbContext);

            site_survey_configurations dbSiteSurveyConfiguration =
                dbContext.site_survey_configurations.AsNoTracking().First();
            site_survey_configuration_versions dbSiteSurveyConfigurationVersion =
                dbContext.site_survey_configuration_versions.AsNoTracking().First();

            // Assert
            Assert.NotNull(dbSiteSurveyConfiguration);
            Assert.NotNull(dbSiteSurveyConfigurationVersion);

            Assert.AreEqual(site1.Id, dbSiteSurveyConfiguration.SiteId);
            Assert.AreEqual(surveyConfiguration.Id, siteSurveyConfiguration.SurveyConfigurationId);
            Assert.AreEqual(Constants.WorkflowStates.Removed, siteSurveyConfiguration.WorkflowState);
        }
        public async Task <sites> CreateSite(string name, int microtingUId)
        {
            sites site = new sites();

            site.Name          = name;
            site.MicrotingUid  = microtingUId;
            site.UpdatedAt     = DateTime.UtcNow;
            site.CreatedAt     = DateTime.UtcNow;
            site.Version       = 64;
            site.WorkflowState = Constants.WorkflowStates.Created;
            dbContext.sites.Add(site);
            await dbContext.SaveChangesAsync().ConfigureAwait(false);

            return(site);
        }
예제 #18
0
        public sites CreateSite(string name, int microtingUId)
        {
            sites site = new sites();

            site.name           = name;
            site.microting_uid  = microtingUId;
            site.updated_at     = DateTime.Now;
            site.created_at     = DateTime.Now;
            site.version        = 64;
            site.workflow_state = Constants.WorkflowStates.Created;
            DbContext.sites.Add(site);
            DbContext.SaveChanges();

            return(site);
        }
예제 #19
0
        public check_list_sites CreateCheckListSite(check_lists checklist, DateTime createdAt,
                                                    sites site, DateTime updatedAt, int version, string workflowState, string microting_uid)
        {
            check_list_sites cls = new check_list_sites();

            cls.check_list     = checklist;
            cls.created_at     = createdAt;
            cls.site           = site;
            cls.updated_at     = updatedAt;
            cls.version        = version;
            cls.workflow_state = workflowState;
            cls.microting_uid  = microting_uid;
            DbContext.check_list_sites.Add(cls);
            DbContext.SaveChanges();
            return(cls);
        }
예제 #20
0
        public void Core_Advanced_UnitRequestOtp_SetsNewOtp()
        {
            //Arrance
            sites site = testHelpers.CreateSite("test site 1", 1313);
            units unit = testHelpers.CreateUnit(564646, 0, site, 0);

            //Act
            sut.Advanced_UnitRequestOtp((int)unit.microting_uid);

            //Assert
            List <units> matches = DbContext.units.AsNoTracking().ToList();

            Assert.NotNull(matches);
            Assert.AreEqual(1, matches.Count);
            Assert.AreEqual(558877, matches[0].otp_code);
        }
예제 #21
0
        /// <summary>
        /// Casts ray to direction a compares to clostst hit.
        /// </summary>
        /// <param name="SideVector">direction to cast ray.</param>
        void ManageRays(Vector3 sideVector, sites direction)
        {
            RaycastHit hit;
            Ray        ray1 = new Ray(this.drone.transform.position, sideVector);

            if (Physics.SphereCast(ray1, 0.01f, out hit))
            {
                if (hit.transform.gameObject.layer == 31)  //layer for spatialAwareness
                {
                    if (hit.distance < this.closestHit.distance)
                    {
                        this.closestHit = hit;
                        hitDirection    = direction;
                    }
                }
            }
        }
예제 #22
0
        public site_workers CreateSiteWorker(int microtingUId, sites site, workers worker)
        {
            site_workers site_workers = new site_workers();

            site_workers.created_at     = DateTime.Now;
            site_workers.microting_uid  = microtingUId;
            site_workers.updated_at     = DateTime.Now;
            site_workers.version        = 63;
            site_workers.site           = site;
            site_workers.site_id        = site.id;
            site_workers.worker         = worker;
            site_workers.worker_id      = worker.id;
            site_workers.workflow_state = Constants.WorkflowStates.Created;
            DbContext.site_workers.Add(site_workers);
            DbContext.SaveChanges();
            return(site_workers);
        }
예제 #23
0
        public async Task Core_Advanced_UnitRequestOtp_SetsNewOtp()
        {
            // Arrange
            sites site = await testHelpers.CreateSite("test site 1", 1313);

            units unit = await testHelpers.CreateUnit(564646, 0, site, 0);

            // Act
            await sut.Advanced_UnitRequestOtp((int)unit.MicrotingUid);

            // Assert
            List <units> matches = dbContext.units.AsNoTracking().ToList();

            Assert.NotNull(matches);
            Assert.AreEqual(1, matches.Count);
            Assert.AreEqual(558877, matches[0].OtpCode);
        }
예제 #24
0
        /// <summary>
        /// Changes direction of danger based on vector.
        /// </summary>
        /// <param name="DangerDirection">direction od danger.</param>
        void ManageDangerDirection(sites DangerDirection)
        {
            switch (DangerDirection)
            {
            case sites.back:
                dangerIndicator.rotation = Quaternion.Euler(0, 180, 0);
                break;

            case sites.backleft:
                dangerIndicator.rotation = Quaternion.Euler(0, -135, 0);
                break;

            case sites.backright:
                dangerIndicator.rotation = Quaternion.Euler(0, 135, 0);
                break;

            case sites.front:
                dangerIndicator.rotation = Quaternion.Euler(0, 0, 0);
                break;

            case sites.frontleft:
                dangerIndicator.rotation = Quaternion.Euler(0, -45, 0);
                break;

            case sites.frontright:
                dangerIndicator.rotation = Quaternion.Euler(0, 45, 0);
                break;

            case sites.left:
                dangerIndicator.rotation = Quaternion.Euler(0, -90, 0);
                break;

            case sites.right:
                dangerIndicator.rotation = Quaternion.Euler(0, 90, 0);
                break;

            case sites.top:
                dangerIndicator.rotation = Quaternion.Euler(-90, 0, 0);
                break;

            case sites.bottom:
                dangerIndicator.rotation = Quaternion.Euler(90, 0, 0);
                break;
            }
        }
        public async Task <check_list_sites> CreateCheckListSite(check_lists checklist, DateTime createdAt,
                                                                 sites site, DateTime updatedAt, int version, string workflowState, int microting_uid)
        {
            check_list_sites cls = new check_list_sites();

            cls.CheckList     = checklist;
            cls.CreatedAt     = createdAt;
            cls.Site          = site;
            cls.UpdatedAt     = updatedAt;
            cls.Version       = version;
            cls.WorkflowState = workflowState;
            cls.MicrotingUid  = microting_uid;
            await cls.Create(dbContext).ConfigureAwait(false);

//            DbContext.check_list_sites.Add(cls);
//            await dbContext.SaveChangesAsync().ConfigureAwait(false);
            return(cls);
        }
예제 #26
0
        // Check if site is open for a visit in the current time.
        private bool checkIfSiteIsOpen(smart_trip_dbEntities se, sites siteInDb, String currentTime)
        {
            // Get current day number.
            String openingHours = getSiteHours(se, (int)siteInDb.id);

            if (openingHours.Equals(OPEN_24_HOURS))
            {
                return(true);
            }
            else if (openingHours.Equals(CLOSED))
            {
                return(false);
            }
            else
            {
                return(currentTimeInRange(currentTime, openingHours));
            }
        }
        public async Task <units> CreateUnit(int microtingUId, int otpCode, sites site, int customerNo)
        {
            units unit = new units();

            unit.MicrotingUid  = microtingUId;
            unit.OtpCode       = otpCode;
            unit.Site          = site;
            unit.SiteId        = site.Id;
            unit.CreatedAt     = DateTime.UtcNow;
            unit.CustomerNo    = customerNo;
            unit.UpdatedAt     = DateTime.UtcNow;
            unit.Version       = 9;
            unit.WorkflowState = Constants.WorkflowStates.Created;

            dbContext.units.Add(unit);
            await dbContext.SaveChangesAsync().ConfigureAwait(false);

            return(unit);
        }
예제 #28
0
        public async Task Post()
        {
            //Arrange
            var entity = new sites()
            {
                site_id = 5, site_no = "a3", site_name = "nameA1", site_description = "test12", state = "WI", county = "Fort", waterbody = "test", latitude_dd = 35, longitude_dd = -91, hdatum_id = 3, hcollect_method_id = 1, member_id = 44
            };


            //Act
            var response = await controller.Post(entity);

            // Assert
            var okResult = Assert.IsType <OkObjectResult>(response);
            var result   = Assert.IsType <sites>(okResult.Value);


            Assert.Equal("a3", result.site_no);
        }
        public async Task <site_workers> CreateSiteWorker(int microtingUId, sites site, workers worker)
        {
            site_workers site_workers = new site_workers();

            site_workers.CreatedAt     = DateTime.UtcNow;
            site_workers.MicrotingUid  = microtingUId;
            site_workers.UpdatedAt     = DateTime.UtcNow;
            site_workers.Version       = 63;
            site_workers.Site          = site;
            site_workers.SiteId        = site.Id;
            site_workers.Worker        = worker;
            site_workers.WorkerId      = worker.Id;
            site_workers.WorkflowState = Constants.WorkflowStates.Created;

            dbContext.site_workers.Add(site_workers);
            await dbContext.SaveChangesAsync().ConfigureAwait(false);

            return(site_workers);
        }
예제 #30
0
        public units CreateUnit(int microtingUId, int otpCode, sites site, int customerNo)
        {
            units unit = new units();

            unit.microting_uid  = microtingUId;
            unit.otp_code       = otpCode;
            unit.site           = site;
            unit.site_id        = site.id;
            unit.created_at     = DateTime.Now;
            unit.customer_no    = customerNo;
            unit.updated_at     = DateTime.Now;
            unit.version        = 9;
            unit.workflow_state = Constants.WorkflowStates.Created;

            DbContext.units.Add(unit);
            DbContext.SaveChanges();

            return(unit);
        }