Example #1
0
            public override bool TryGetLocationReference(string name, out LocationReference result)
            {
                if (string.IsNullOrEmpty(name))
                {
                    throw CoreWf.Internals.FxTrace.Exception.ArgumentNullOrEmpty("name");
                }

                return(_symbolResolver.TryGetLocationReference(name, out result));
            }
            public override bool IsVisible(LocationReference locationReference)
            {
                if (locationReference == null)
                {
                    throw FxTrace.Exception.ArgumentNull(nameof(locationReference));
                }

                return(this.symbolResolver.IsVisible(locationReference));
            }
Example #3
0
        internal void DeclareTemporaryLocation <T>(LocationReference locationReference, ActivityInstance activityInstance, bool bufferGetsOnCollapse)
            where T : Location
        {
            Location locationToDeclare = new Location <T>();

            locationToDeclare.SetTemporaryResolutionData(this, bufferGetsOnCollapse);

            this.Declare(locationReference, locationToDeclare, activityInstance);
        }
Example #4
0
            public override bool IsVisible(LocationReference locationReference)
            {
                if (locationReference == null)
                {
                    throw CoreWf.Internals.FxTrace.Exception.ArgumentNull("locationReference");
                }

                return(_symbolResolver.IsVisible(locationReference));
            }
Example #5
0
 public static double TriangleArea(LocationReference a, LocationReference b, LocationReference c)
 {
     return(Math.Abs(
                (
                    (float)a.X * (b.Y - c.Y) +
                    (float)b.X * (c.Y - a.Y) +
                    (float)c.X * (a.Y - b.Y)
                ) / 2f
                ));
 }
Example #6
0
        protected Sort GetSort(LocationReference location, bool reverse)
        {
            var comparatorFactory = new LocationComparatorSource(location.GeographicalArea.Id, _worldIndex, _locationFieldName);

            return(new Sort(new[]
            {
                new BoboCustomSortField(_locationFieldName, reverse, comparatorFactory),
                SortField.FIELD_SCORE
            }));
        }
Example #7
0
        public static T MapTo <T>(this LocationReference location)
            where T : ILocationReferenceEntity, new()
        {
            var t = new T {
                id = location.Id
            };

            location.MapTo(t);
            return(t);
        }
        internal bool IsVisible(LocationReference locationReference)
        {
            ExternalLocationReference reference;

            if (locationReference.Name == null)
            {
                return(false);
            }
            return(this.symbols.TryGetValue(locationReference.Name, out reference) && (reference.Type == locationReference.Type));
        }
Example #9
0
        public JobRegion Map(LocationReference location)
        {
            var l    = _world.GetPointSet(location);
            var id   = _mappings.First(x => l.IsSubsetOf(x.Key)).Value;
            var name = location.ToString();

            return(new JobRegion {
                id = id, name = name
            });
        }
Example #10
0
        internal bool TryGetLocationReference(string name, out LocationReference result)
        {
            if (this.symbols.TryGetValue(name, out ExternalLocationReference reference))
            {
                result = reference;
                return(true);
            }

            result = null;
            return(false);
        }
        public void Register(Location location, Activity activity, LocationReference locationOwner, ActivityInstance activityInstance)
        {
            Fx.Assert(location.CanBeMapped, "should only register mappable locations");

            if (this.mappableLocations == null)
            {
                this.mappableLocations = new List<MappableLocation>();
            }

            this.mappableLocations.Add(new MappableLocation(locationOwner, activity, activityInstance, location));
        }
        public void Register(Location location, Activity activity, LocationReference locationOwner, ActivityInstance activityInstance)
        {
            Fx.Assert(location.CanBeMapped, "should only register mappable locations");

            if (this.mappableLocations == null)
            {
                this.mappableLocations = new List <MappableLocation>();
            }

            this.mappableLocations.Add(new MappableLocation(locationOwner, activity, activityInstance, location));
        }
Example #13
0
 private static void AssertLocation(LocationReference expectedLocation, LocationReference location)
 {
     if (expectedLocation == null)
     {
         Assert.IsNull(location);
     }
     else
     {
         Assert.IsNotNull(location);
         Assert.AreEqual(expectedLocation, location);
     }
 }
        public void TestSearchLocality()
        {
            var titles   = new List <string>();
            var location = new LocationReference();

            // Create jobs.

            PostJobAds();

            // Search within 50km of Melbourne VIC 3000.

            LocationQuery.ResolveLocation(location, _australia, MelbourneVic3000);
            var criteria = new JobAdSearchCriteria {
                Location = location
            };

            titles.Clear();
            AddTitles(titles, _australia, MelbourneVic3000);
            AddTitles(titles, _australia, ArmadaleVic3143);
            AddTitles(titles, _australia, Melbourne);
            TestSearch(criteria, titles);

            // Search within 50km of Norlane VIC 3124.

            LocationQuery.ResolveLocation(location, _australia, NorlaneVic3214);
            criteria = new JobAdSearchCriteria {
                Location = location
            };
            titles.Clear();
            AddTitles(titles, _australia, NorlaneVic3214);
            TestSearch(criteria, titles);

            // Search within 50km of Sydney NSW 2000.

            LocationQuery.ResolveLocation(location, _australia, SydneyNsw2000);
            criteria = new JobAdSearchCriteria {
                Location = location
            };
            titles.Clear();
            AddTitles(titles, _australia, SydneyNsw2000);
            AddTitles(titles, _australia, Sydney);
            TestSearch(criteria, titles);

            // Search within 50km of Perth WA 6000.

            LocationQuery.ResolveLocation(location, _australia, PerthWa6000);
            criteria = new JobAdSearchCriteria {
                Location = location
            };
            titles.Clear();
            TestSearch(criteria, titles);
        }
Example #15
0
        private void AssertMember(Member member, string firstName, string lastName, string email)
        {
            Assert.AreEqual(firstName, member.FirstName);
            Assert.AreEqual(lastName, member.LastName);
            Assert.AreEqual(email, member.EmailAddresses[0].Address);
            Assert.AreEqual(email, member.GetLoginId());
            var location = new LocationReference();

            _locationQuery.ResolveLocation(location, Australia, string.Empty);
            Assert.AreEqual(location, member.Address.Location);
            Assert.AreEqual(true, member.IsEnabled);
            Assert.AreEqual(false, member.IsActivated);
        }
Example #16
0
        private void CreateMember(int index, string desiredJobTitle, LocationReference location, Salary salary)
        {
            var member = _memberAccountsCommand.CreateTestMember(index);

            member.Address.Location = location;
            _memberAccountsCommand.UpdateMember(member);
            var candidate = _candidatesCommand.GetCandidate(member.Id);

            candidate.DesiredJobTitle = desiredJobTitle;
            candidate.DesiredSalary   = salary;
            _candidatesCommand.UpdateCandidate(candidate);
            _candidateResumesCommand.AddTestResume(candidate);
        }
Example #17
0
        public static void MapTo(this LocationReference location, ILocationReferenceEntity entity)
        {
            // Need to ensure that objects match what is in the database.

            if (entity.id != Guid.Empty)
            {
                location.Id = entity.id;
            }

            entity.unstructuredLocation = location.UnstructuredLocation;
            entity.namedLocationId      = (location.NamedLocation == null ? (int?)null : location.NamedLocation.Id);
            entity.countrySubdivisionId = location.CountrySubdivision.Id;
            entity.localityId           = location.Locality == null ? (int?)null : location.Locality.Id;
        }
Example #18
0
        public static string GetUrlSegment(this LocationReference locationReference, string suffix)
        {
            if (locationReference == null)
            {
                return("-");
            }

            var location = locationReference.IsCountry
                ? locationReference.Country.ToString()
                : locationReference.ToString();

            location = location.EncodeUrlSegment();
            return(string.IsNullOrEmpty(location) ? "-" : location + GetSuffix(suffix));
        }
Example #19
0
        protected void TestResults(LocationReference location, int?distance, params JobAd[] expectedJobAds)
        {
            var criteria = new JobAdSearchCriteria {
                Location = location, Distance = distance
            };

            Get(GetSearchUrl(criteria));
            AssertResults(false, expectedJobAds);

            // Assert.

            var model = ApiSearch(criteria);

            AssertApiResults(model, false, expectedJobAds);
        }
Example #20
0
        protected override void OnCloned()
        {
            base.OnCloned();

            var keywords = GetValue <string>(KeywordsName);

            SetKeywords(keywords);

            CompanyKeywordsExpression   = Expression.Parse(CompanyKeywords);
            EducationKeywordsExpression = Expression.Parse(EducationKeywords);
            DesiredJobTitleExpression   = Expression.Parse(DesiredJobTitle);

            _locationReference = _locationReference == null ? null : _locationReference.Clone();
            JobTitleExpression = Expression.Parse(JobTitle);
        }
Example #21
0
        public void TestMapByPostcode()
        {
            var locationMapper = new LocationMapper(_locationQuery);

            LocationReference locationRef = locationMapper.Map("Australia", null, null, "3182");

            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.AreEqual("VIC", locationRef.CountrySubdivision.ShortName);
            Assert.AreEqual("3182", locationRef.NamedLocation.Name);

            locationRef = locationMapper.Map("Australia", "Melbourne", null, "3182");
            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.AreEqual("VIC", locationRef.CountrySubdivision.ShortName);
            Assert.AreEqual("3182", locationRef.NamedLocation.Name);
        }
Example #22
0
        protected ReadOnlyUrl GetJobUrl(Guid jobAdId, string jobAdTitle, LocationReference location, IList <Industry> industries)
        {
            var sb = new StringBuilder();

            // Location.

            if (location == null)
            {
                sb.Append("-");
            }
            else
            {
                sb.Append(!string.IsNullOrEmpty(location.ToString())
                    ? TextUtil.StripExtraWhiteSpace(TextUtil.StripToAlphaNumericAndWhiteSpace(location.ToString())).ToLower().Replace(' ', '-')
                    : location.Country.Name.ToLower());
            }

            // Industry. If there is only one industry then use it.  Do not concatenate more as this can easily lead to
            // urls being longer then url or segment lengths.

            var industrySb = new StringBuilder();

            if (industries != null && industries.Count > 0)
            {
                industrySb.Append(industries[0].UrlName);
            }
            sb.Append("/");
            if (industrySb.Length == 0)
            {
                sb.Append("-");
            }
            else
            {
                sb.Append(industrySb);
            }

            // Job title.

            sb.Append("/");
            sb.Append(TextUtil.StripExtraWhiteSpace(TextUtil.StripToAlphaNumericAndSpace(jobAdTitle)).ToLower().Replace(' ', '-'));

            // Id

            sb.Append("/");
            sb.Append(jobAdId.ToString());

            return(new ReadOnlyApplicationUrl(_baseJobUrl, sb.ToString()));
        }
 internal void Declare(LocationReference locationReference, Location location, System.Activities.ActivityInstance activityInstance)
 {
     if (location.CanBeMapped)
     {
         this.hasMappableLocations = true;
         this.MappableObjectManager.Register(location, this.Definition, locationReference, activityInstance);
     }
     if (this.locations == null)
     {
         this.singleLocation = location;
     }
     else
     {
         this.locations[locationReference.Id] = location;
     }
 }
Example #24
0
 private static bool Contains(Region region, LocationReference location)
 {
     if (location.NamedLocation is Locality)
     {
         return(Contains(region, location.Locality));
     }
     if (location.NamedLocation is PostalCode)
     {
         return(Contains(region, location.PostalCode));
     }
     if (location.NamedLocation is PostalSuburb)
     {
         return(Contains(region, location.PostalSuburb));
     }
     return(false);
 }
Example #25
0
        private ReadOnlyUrl GetJobUrl(Guid jobAdId, string jobAdTitle, LocationReference location, string industry)
        {
            var sb = new StringBuilder();

            // Location.

            sb.Append(!string.IsNullOrEmpty(location.ToString())
                ? TextUtil.StripExtraWhiteSpace(TextUtil.StripToAlphaNumericAndWhiteSpace(location.ToString())).ToLower().Replace(' ', '-')
                : "-");

            // Industry. If there is only one industry then use it.  Do not concatenate more as this can easily lead to
            // urls being longer then url or segment lengths.

            var industrySb = new StringBuilder();

            if (industry != null)
            {
                industrySb.Append(industry);
            }
            sb.Append("/");
            if (industrySb.Length == 0)
            {
                sb.Append("-");
            }
            else
            {
                sb.Append(industrySb);
            }

            // Job title.

            sb.Append("/");
            var segment = TextUtil.StripExtraWhiteSpace(TextUtil.StripToAlphaNumericAndSpace(jobAdTitle)).ToLower().Replace(' ', '-');

            if (segment.Length > MaxTitleSegmentLength)
            {
                segment = segment.Substring(0, MaxTitleSegmentLength);
            }
            sb.Append(segment);

            // Id

            sb.Append("/");
            sb.Append(jobAdId.ToString());

            return(new ReadOnlyApplicationUrl(_baseJobUrl, sb.ToString()));
        }
Example #26
0
        private LocationReference FindLocationReference(string name)
        {
            LocationReference returnValue = null;

            var current = this.accessor.ActivityMetadata.Environment;

            while (current != null)
            {
                if (current.TryGetLocationReference(name, out returnValue))
                {
                    return(returnValue);
                }
                current = current.Parent;
            }

            return(returnValue);
        }
Example #27
0
        public override bool Equals(object obj)
        {
            if (obj is TnfDirectLocationReference)
            {
                var v = obj as TnfDirectLocationReference;

                if (PropertyOid.Equals(v.PropertyOid) &&
                    LocationReferenceType.Equals(v.LocationReferenceType) &&
                    LocationReference.Equals(v.LocationReference) &&
                    SeqNo.Equals(v.SeqNo))
                {
                    return(true);
                }
            }

            return(false);
        }
        public void TestSearchCountrySubdivision()
        {
            var titles   = new List <string>();
            var location = new LocationReference();

            // Create jobs.

            PostJobAds();

            // Search within VIC.

            LocationQuery.ResolveLocation(location, _australia, Vic);
            var criteria = new JobAdSearchCriteria {
                Location = location
            };

            titles.Clear();
            AddTitles(titles, _australia, MelbourneVic3000);
            AddTitles(titles, _australia, ArmadaleVic3143);
            AddTitles(titles, _australia, NorlaneVic3214);
            AddTitles(titles, _australia, Melbourne);
            AddTitles(titles, _australia, Vic);
            TestSearch(criteria, titles);

            // Search within NSW.

            LocationQuery.ResolveLocation(location, _australia, Nsw);
            criteria = new JobAdSearchCriteria {
                Location = location
            };
            titles.Clear();
            AddTitles(titles, _australia, SydneyNsw2000);
            AddTitles(titles, _australia, Sydney);
            AddTitles(titles, _australia, Nsw);
            TestSearch(criteria, titles);

            // Search within WA.

            LocationQuery.ResolveLocation(location, _australia, Wa);
            criteria = new JobAdSearchCriteria {
                Location = location
            };
            titles.Clear();
            TestSearch(criteria, titles);
        }
Example #29
0
        public static void Structs()
        {
            LocationValue ldV = new LocationValue
            {
                city    = "London",
                country = "UK"
            };

            LocationReference nyR = new LocationReference
            {
                city    = "New York",
                country = "USA"
            };


            LocationValue     london  = ldV;
            LocationReference newyork = nyR;

            System.Console.WriteLine(ldV.city);
            System.Console.WriteLine(nyR.city);

            london.city  = "LONDON";
            newyork.city = "NEW YORK";


            System.Console.WriteLine(ldV.city);   //unchanged
            System.Console.WriteLine(nyR.city);   //changed

            System.Console.WriteLine(london.city);
            System.Console.WriteLine(newyork.city);

            /*
             *
             * class types are reference types,
             * variables denote *referenes* -- copying causes a copy of reference
             *
             * struct types are value types (eg. int, double..),
             * variables denote *values* -- copying causes a copy of value
             *
             * other reference types: string, interfaces, delegates, arrays...
             * other value types: all numeric, char, bool, enum
             *
             * (NB: the other two "types of type" are generics and pointers)
             */
        }
Example #30
0
        private JobAd CreateNewJobAd(string adContent, JobAdStatus adStatus, IHasId <Guid> adPoster,
                                     bool adHideContactDetails, ContactDetails adContactDetails, string summary, string bulletpoint1, string bulletpoint2,
                                     string bulletpoint3, FileReference logoImg, string adTitle, string positionTitle,
                                     JobTypes jobtypes, bool isResidenacyRequired, string externalRef, string maxsalary,
                                     string minsalary, string package, IList <Industry> reqIndustries, string companyname,
                                     LocationReference jobLocation, DateTime expiryDate)
        {
            var salary       = SalaryExtensions.Parse(minsalary, maxsalary, SalaryRate.Year, true);
            var bulletPoints = new[] { bulletpoint1, bulletpoint2, bulletpoint3 };

            var newJobAd = new JobAd
            {
                Status     = adStatus,
                PosterId   = adPoster.Id,
                Visibility =
                {
                    HideContactDetails = adHideContactDetails,
                    HideCompany        = false,
                },
                ContactDetails = adContactDetails,
                Title          = adTitle,
                Integration    = { ExternalReferenceId = externalRef },
                LogoId         = logoImg == null ? (Guid?)null : logoImg.Id,
                ExpiryTime     = expiryDate,
                Description    =
                {
                    CompanyName       = companyname,
                    Content           = adContent,
                    PositionTitle     = positionTitle,
                    ResidencyRequired = isResidenacyRequired,
                    JobTypes          = jobtypes,
                    Industries        = reqIndustries,
                    Summary           = summary,
                    Salary            = salary,
                    Package           = package,
                    BulletPoints      = bulletPoints,
                    Location          = jobLocation,
                }
            };

            _jobAdsCommand.CreateJobAd(newJobAd);
            _jobAdsCommand.OpenJobAd(newJobAd);

            return(newJobAd);
        }
Example #31
0
        private static EntitySet <JobAdLocationEntity> Map(this LocationReference locationReference, Guid jobAdId)
        {
            if (locationReference == null)
            {
                return(null);
            }

            // Even though it is a collection in the database only one location per ad is supported.

            return(new EntitySet <JobAdLocationEntity>
            {
                new JobAdLocationEntity
                {
                    jobAdId = jobAdId,
                    LocationReferenceEntity = locationReference.MapTo <LocationReferenceEntity>()
                }
            });
        }
 public override bool TryGetLocationReference(string name, out LocationReference result)
 {
     result = (LocationReference)this.Resolve(name);
     return result != null;
 }
 public MappableLocation(LocationReference locationOwner, Activity activity, ActivityInstance activityInstance, Location location)
 {
     this.Name = locationOwner.Name;
     this.OwnerDisplayName = activity.DisplayName;
     this.Location = location;
     this.MappingKeyName = string.Format(CultureInfo.InvariantCulture, "activity.{0}-{1}_{2}", activity.Id, locationOwner.Id, activityInstance.Id);
 }
 public override bool IsVisible(LocationReference reference)
 {
     object other = this.Resolve(reference.Name);
     
     return object.ReferenceEquals(other, reference);
 }