Ejemplo n.º 1
0
        private Resume CreateResume(Candidate candidate)
        {
            var resume = new Resume();

            // Set last two job details.

            var currentJob = new Job {
                Dates = new PartialDateRange(PartialDate.Parse("January 2005")), Title = "Coder", Description = "description", Company = "LinkMe"
            };
            var previousJob = new Job {
                Dates = new PartialDateRange(PartialDate.Parse("January 2004"), PartialDate.Parse("January 2005")), Title = "Developer", Description = "old description", Company = "OC"
            };

            resume.Jobs = new List <Job> {
                currentJob, previousJob
            };

            // Set education section.

            var school = new School {
                CompletionDate = new PartialCompletionDate(PartialDate.Parse("January 2004")), Institution = "LinkMe Mental Asylum", Degree = "Bachelor of Boredom", Major = "Meetings", Description = "description", City = "Melbourne", Country = "Australia"
            };

            resume.Schools = new List <School> {
                school
            };

            // Affiliations.

            resume.Affiliations = "What's this?";
            resume.Interests    = Interests;

            _candidateResumesCommand.CreateResume(candidate, resume);
            return(resume);
        }
Ejemplo n.º 2
0
 public void CheckOrdering()
 {
     Assert.AreEqual(0, PartialDate.Parse("2010-06-04").CompareTo(PartialDate.Parse("2010-06-04")));
     Assert.AreEqual(0, PartialDate.Parse("2010-06").CompareTo(PartialDate.Parse("2010-06")));
     Assert.AreEqual(0, PartialDate.Parse("2010").CompareTo(PartialDate.Parse("2010")));
     Assert.AreEqual(1, PartialDate.Parse("2010-06-04").CompareTo(PartialDate.Parse("2010-06-03")));
     Assert.AreEqual(1, PartialDate.Parse("2010-07").CompareTo(PartialDate.Parse("2010-06")));
     Assert.AreEqual(1, PartialDate.Parse("2017").CompareTo(PartialDate.Parse("2015")));
     Assert.AreEqual(-1, PartialDate.Parse("2010-06-04").CompareTo(PartialDate.Parse("2010-06-05")));
     Assert.AreEqual(-1, PartialDate.Parse("2010-05").CompareTo(PartialDate.Parse("2010-06")));
     Assert.AreEqual(-1, PartialDate.Parse("2010").CompareTo(PartialDate.Parse("2015")));
 }
Ejemplo n.º 3
0
        public void ToDateTimeOffset()
        {
            var plusOne = new TimeSpan(1, 0, 0);
            var plusTwo = new TimeSpan(2, 0, 0);

            var partialDate    = PartialDate.Parse("2010-06-04");
            var dateTimeOffset = partialDate.ToDateTimeOffset(12, 3, 4, 5, plusOne);

            Assert.AreEqual(2010, dateTimeOffset.Year);
            Assert.AreEqual(06, dateTimeOffset.Month);
            Assert.AreEqual(04, dateTimeOffset.Day);
            Assert.AreEqual(12, dateTimeOffset.Hour);
            Assert.AreEqual(3, dateTimeOffset.Minute);
            Assert.AreEqual(4, dateTimeOffset.Second);
            Assert.AreEqual(5, dateTimeOffset.Millisecond);
            Assert.AreEqual(plusOne, dateTimeOffset.Offset);

            partialDate    = PartialDate.Parse("2010-06-04+02:00");
            dateTimeOffset = partialDate.ToDateTimeOffset(12, 3, 4, 5, plusOne);
            Assert.AreEqual(2010, dateTimeOffset.Year);
            Assert.AreEqual(06, dateTimeOffset.Month);
            Assert.AreEqual(04, dateTimeOffset.Day);
            Assert.AreEqual(12, dateTimeOffset.Hour);
            Assert.AreEqual(3, dateTimeOffset.Minute);
            Assert.AreEqual(4, dateTimeOffset.Second);
            Assert.AreEqual(5, dateTimeOffset.Millisecond);
            Assert.AreEqual(plusTwo, dateTimeOffset.Offset);

            partialDate    = PartialDate.Parse("2010-06");
            dateTimeOffset = partialDate.ToDateTimeOffset(12, 3, 4, 5, plusOne);
            Assert.AreEqual(2010, dateTimeOffset.Year);
            Assert.AreEqual(06, dateTimeOffset.Month);
            Assert.AreEqual(1, dateTimeOffset.Day);
            Assert.AreEqual(12, dateTimeOffset.Hour);
            Assert.AreEqual(3, dateTimeOffset.Minute);
            Assert.AreEqual(4, dateTimeOffset.Second);
            Assert.AreEqual(5, dateTimeOffset.Millisecond);
            Assert.AreEqual(plusOne, dateTimeOffset.Offset);

            partialDate    = PartialDate.Parse("2010");
            dateTimeOffset = partialDate.ToDateTimeOffset(12, 3, 4, 5, plusOne);
            Assert.AreEqual(2010, dateTimeOffset.Year);
            Assert.AreEqual(1, dateTimeOffset.Month);
            Assert.AreEqual(1, dateTimeOffset.Day);
            Assert.AreEqual(12, dateTimeOffset.Hour);
            Assert.AreEqual(3, dateTimeOffset.Minute);
            Assert.AreEqual(4, dateTimeOffset.Second);
            Assert.AreEqual(5, dateTimeOffset.Millisecond);
            Assert.AreEqual(plusOne, dateTimeOffset.Offset);
        }
Ejemplo n.º 4
0
 public void DateComparison()
 {
     Assert.IsTrue(PartialDate.Parse("2010-06-03") > PartialDate.Parse("2010-05-03"));
     Assert.IsTrue(PartialDate.Parse("2010-06-03") < PartialDate.Parse("2010-07-03"));
     Assert.IsTrue(PartialDate.Parse("2010-12-05") > PartialDate.Parse("2010-12-04"));
     Assert.IsTrue(PartialDate.Parse("2010-12-03") < PartialDate.Parse("2010-12-04"));
     Assert.IsTrue(PartialDate.Parse("2011") > PartialDate.Parse("2010"));
     Assert.IsTrue(PartialDate.Parse("2011") < PartialDate.Parse("2013"));
     Assert.IsTrue(PartialDate.Parse("2011-03") > PartialDate.Parse("2011-02"));
     Assert.IsTrue(PartialDate.Parse("2011-03") < PartialDate.Parse("2011-04"));
     Assert.IsTrue(PartialDate.Parse("2010-12-03+02:00") < PartialDate.Parse("2010-12-04+02:00"));
     Assert.IsTrue(PartialDate.Parse("2010-12-05+02:00") > PartialDate.Parse("2010-12-04+02:00"));
     Assert.IsTrue(PartialDate.Parse("2010-12-03+06:00") < PartialDate.Parse("2010-12-04+02:00"));
     Assert.IsTrue(PartialDate.Parse("2010-12-05+08:00") > PartialDate.Parse("2010-12-04+02:00"));
 }
Ejemplo n.º 5
0
        public void FhirPath_Gramm_Literal()
        {
            var parser = Grammar.Literal.End();

            AssertParser.SucceedsMatch(parser, "'hi there'", new ConstantExpression("hi there"));
            AssertParser.SucceedsMatch(parser, "3", new ConstantExpression(3L));
            AssertParser.SucceedsMatch(parser, "3.14", new ConstantExpression(3.14m));
            AssertParser.SucceedsMatch(parser, "@2013-12", new ConstantExpression(PartialDate.Parse("2013-12")));
            AssertParser.SucceedsMatch(parser, "@2013-12T", new ConstantExpression(PartialDateTime.Parse("2013-12")));
            AssertParser.SucceedsMatch(parser, "@T12:23:34", new ConstantExpression(PartialTime.Parse("12:23:34")));
            AssertParser.SucceedsMatch(parser, "true", new ConstantExpression(true));
            AssertParser.SucceedsMatch(parser, "@2014-12-13T12:00:00+02:00", new ConstantExpression(PartialDateTime.Parse("2014-12-13T12:00:00+02:00")));

            AssertParser.FailsMatch(parser, "%constant");
            AssertParser.FailsMatch(parser, "`quotedstring`");
            AssertParser.FailsMatch(parser, "A23identifier");
        }
Ejemplo n.º 6
0
        public void FhirPath_Lex_Date()
        {
            var parser = Lexer.Date.End();

            accept("@2018-04-05");
            accept("@2018-04");
            accept("@2018");

            reject("@2018-04-05T");
            reject("@2018-04-05TZ");
            reject("@2018-04-05Z");
            reject("@2018-04-05T10:00:00");
            reject("@2018-04-05T10:00:00Z");

            void accept(string s) => AssertParser.SucceedsMatch(parser, s, PartialDate.Parse(s.Substring(1)));
            void reject(string s) => AssertParser.FailsMatch(parser, s);
        }
Ejemplo n.º 7
0
        public void FhirPath_Gramm_Term()
        {
            var parser = Grammar.Term.End();

            AssertParser.SucceedsMatch(parser, "childname", new ChildExpression(AxisExpression.This, "childname"));
            AssertParser.SucceedsMatch(parser, "$this", AxisExpression.This);
            AssertParser.SucceedsMatch(parser, "doSomething()", new FunctionCallExpression(AxisExpression.This, "doSomething", TypeSpecifier.Any));
            AssertParser.SucceedsMatch(parser, "doSomething('hi', 3.14)", new FunctionCallExpression(AxisExpression.This, "doSomething", TypeSpecifier.Any,
                                                                                                     new ConstantExpression("hi"), new ConstantExpression(3.14m)));
            AssertParser.SucceedsMatch(parser, "%external", new VariableRefExpression("external"));
            AssertParser.SucceedsMatch(parser, "@2013-12", new ConstantExpression(PartialDate.Parse("2013-12")));
            AssertParser.SucceedsMatch(parser, "@2013-12T", new ConstantExpression(PartialDateTime.Parse("2013-12")));
            AssertParser.SucceedsMatch(parser, "3", new ConstantExpression(3L));
            AssertParser.SucceedsMatch(parser, "true", new ConstantExpression(true));
            AssertParser.SucceedsMatch(parser, "(3)", new ConstantExpression(3L));
            AssertParser.SucceedsMatch(parser, "{}", NewNodeListInitExpression.Empty);
            AssertParser.SucceedsMatch(parser, "@2014-12-13T12:00:00+02:00", new ConstantExpression(PartialDateTime.Parse("2014-12-13T12:00:00+02:00")));
            AssertParser.SucceedsMatch(parser, "78 'kg'", new ConstantExpression(new Quantity(78m, "kg")));
            AssertParser.SucceedsMatch(parser, "10.1 'mg'", new ConstantExpression(new Quantity(10.1m, "mg")));
        }
Ejemplo n.º 8
0
        private void CreateFriends(Guid memberId, PersonalVisibility firstDegree, int start, int count, out IList <Member> friends, out IList <Candidate> candidates, out IList <Resume> resumes)
        {
            friends    = new List <Member>();
            candidates = new List <Candidate>();
            resumes    = new List <Resume>();

            for (var index = start; index < start + count; index++)
            {
                var friend    = _memberAccountsCommand.CreateTestMember(index);
                var candidate = _candidatesCommand.GetCandidate(friend.Id);

                // Set values.

                candidate.Status = CandidateStatus.OpenToOffers;

                var resume = new Resume
                {
                    Jobs = new List <Job> {
                        new Job {
                            Dates = new PartialDateRange(PartialDate.Parse("01/01/1970")), Title = string.Format(CurrentJobsTemplate, index)
                        }
                    }
                };

                _locationQuery.ResolvePostalSuburb(friend.Address.Location, Australia, Suburb + " " + Postcode + " " + CountrySubdivision);
                friend.VisibilitySettings.Personal.FirstDegreeVisibility = firstDegree;

                // Save.

                _memberAccountsCommand.UpdateMember(friend);
                _candidatesCommand.UpdateCandidate(candidate);
                _candidateResumesCommand.CreateResume(candidate, resume);

                friends.Add(friend);
                candidates.Add(candidate);
                resumes.Add(resume);

                _networkingCommand.CreateFirstDegreeLink(memberId, friend.Id);
            }
        }
Ejemplo n.º 9
0
        private static PartialDateRange GetDateTimeRange(string startDate, string endDate)
        {
            var start = string.IsNullOrEmpty(startDate)
                ? null
                : startDate == "N/A"
                    ? (PartialDate?)null
                    : PartialDate.Parse(startDate);

            if (string.IsNullOrEmpty(endDate) || endDate == "N/A")
            {
                return(null);
            }

            if (endDate == "Current")
            {
                return(start == null
                    ? new PartialDateRange()
                    : new PartialDateRange(start.Value));
            }

            return(new PartialDateRange(start, PartialDate.Parse(endDate)));
        }
        private static object convertXmlStringToPrimitive(Type to, string value)
        {
            if (typeof(bool) == to)
            {
                return(XmlConvert.ToBoolean(value));
            }
            if (typeof(Byte) == to)
            {
                return(XmlConvert.ToByte(value));        // Not used in FHIR serialization
            }
            if (typeof(Char) == to)
            {
                return(XmlConvert.ToChar(value));        // Not used in FHIR serialization
            }
            if (typeof(DateTime) == to)
            {
                return(convertToDatetimeOffset(value).UtcDateTime);  // Obsolete: use DateTimeOffset instead!!
            }
            if (typeof(decimal) == to)
            {
                if (FORBIDDEN_DECIMAL_PREFIXES.Any(prefix => value.StartsWith(prefix)) || value.EndsWith("."))
                {
                    // decimal cannot start with '+', '-' or '00' and cannot end with '.'
                    throw new FormatException("Input string was not in a correct format.");
                }
                return(decimal.Parse(value, NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture));
            }
            if (typeof(Double) == to)
            {
                return(XmlConvert.ToDouble(value));      // Could lead to loss in precision
            }
            if (typeof(Int16) == to)
            {
                return(XmlConvert.ToInt16(value));       // Could lead to loss in precision
            }
            if (typeof(Int32) == to)
            {
                return(XmlConvert.ToInt32(value));
            }
            if (typeof(Int64) == to)
            {
                return(XmlConvert.ToInt64(value));       // Not used in FHIR serialization
            }
            if (typeof(SByte) == to)
            {
                return(XmlConvert.ToSByte(value));       // Not used in FHIR serialization
            }
            if (typeof(Single) == to)
            {
                return(XmlConvert.ToSingle(value));      // Not used in FHIR serialization
            }
            if (typeof(UInt16) == to)
            {
                return(XmlConvert.ToUInt16(value));      // Not used in FHIR serialization
            }
            if (typeof(UInt32) == to)
            {
                return(XmlConvert.ToUInt32(value));      // Not used in FHIR serialization
            }
            if (typeof(UInt64) == to)
            {
                return(XmlConvert.ToUInt64(value));      // Not used in FHIR serialization
            }
            if (typeof(byte[]) == to)
            {
                return(System.Convert.FromBase64String(value));
            }
            if (typeof(DateTimeOffset) == to)
            {
                return(convertToDatetimeOffset(value));
            }
            if (typeof(System.Uri) == to)
            {
                return(new Uri(value, UriKind.RelativeOrAbsolute));
            }
            if (typeof(PartialDateTime) == to)
            {
                return(PartialDateTime.Parse(value));
            }
            if (typeof(PartialDate) == to)
            {
                return(PartialDate.Parse(value));
            }
            if (typeof(PartialTime) == to)
            {
                return(PartialTime.Parse(value));
            }
            if (typeof(Quantity) == to)
            {
                return(Quantity.Parse(value));
            }
            if (typeof(BigInteger) == to)
            {
                return(BigInteger.Parse(value));
            }

            if (to.IsEnum())
            {
                var result = EnumUtility.ParseLiteral(value, to);
                if (result == null)
                {
                    throw Error.NotSupported($"String value '{value}' is not a known literal in enum '{to.Name}'");
                }

                return(result);
            }

            throw Error.NotSupported($"Cannot convert string value '{value}' to a {to.Name}");
        }
Ejemplo n.º 11
0
        public AjaxResult SaveEducation(string schoolIdStr, string institution, string city, string qualification, string major, string completed, string description)
        {
            try
            {
                EnsureMemberLoggedIn();

                // Require at least the Qualification and Institution. This is a bit arbitrary, as LENS
                // doesn't really care what details are supplied.

                if (string.IsNullOrEmpty(qualification))
                {
                    throw new UserException("The qualification is required.");
                }
                if (string.IsNullOrEmpty(institution))
                {
                    throw new UserException("The institution is required.");
                }

                IList <School> newSchools;
                School         targetSchool = null;
                if (schoolIdStr == NoRecordId)
                {
                    targetSchool = new School {
                        Id = Guid.NewGuid()
                    };
                    newSchools = Resume.Schools;
                    newSchools.Add(targetSchool);
                }
                else
                {
                    var schoolId = ParseUtil.ParseUserInputGuid(schoolIdStr, "education record ID");
                    newSchools = new List <School>();
                    foreach (var school in Resume.Schools)
                    {
                        if (school.Id == schoolId)
                        {
                            targetSchool = school;
                        }
                        newSchools.Add(school);
                    }
                }

                if (targetSchool == null)
                {
                    HandleException(String.Format(ErrorUnknownSchoolId, LoggedInMember.Id, schoolIdStr));
                    return(new AjaxResult(AjaxResultCode.FAILURE, "Unknown Education ID"));
                }

                targetSchool.Institution    = institution;
                targetSchool.City           = city;
                targetSchool.Degree         = qualification;
                targetSchool.Major          = major;
                targetSchool.CompletionDate = string.IsNullOrEmpty(completed) ? null : new PartialCompletionDate(PartialDate.Parse(completed));
                targetSchool.Description    = description;

                Resume.Schools = newSchools;
                UpdateResume();
            }
            catch (Exception ex)
            {
                return(HandleException(ex));
            }

            var schools   = Resume.Schools;
            var schoolIds = new Guid?[schools.Count];

            for (var index = 0; index < schools.Count; index++)
            {
                schoolIds[index] = schools[index].Id;
            }

            return(new AjaxResult(AjaxResultCode.SUCCESS, schoolIdStr, new IdArrayUserData(schoolIds)));
        }