public void TimeZonePropertyTest2()
    {
        var tz   = new TimeZoneID(TimeZoneInfo.GetSystemTimeZones()[4].Id);
        var prop = new TimeZoneProperty(tz, GROUP);

        var vcard = new VCard
        {
            TimeZones = prop
        };

        string s = vcard.ToVcfString();

        IList <VCard> list = VCard.ParseVcf(s);

        Assert.IsNotNull(list);
        Assert.AreEqual(1, list.Count);

        vcard = list[0];

        Assert.IsNotNull(vcard.TimeZones);

        prop = vcard.TimeZones !.First();
        Assert.IsFalse(prop !.IsEmpty);
        Assert.AreEqual(GROUP, prop.Group);
        Assert.IsTrue(tz.TryGetUtcOffset(out TimeSpan utc1));
        Assert.IsTrue(prop.Value !.TryGetUtcOffset(out TimeSpan utc2));
        Assert.AreEqual(utc1, utc2);
    }
    public void TimeZonePropertyTest1()
    {
        var tz   = new TimeZoneID(TimeZoneInfo.GetSystemTimeZones()[7].Id);
        var prop = new TimeZoneProperty(tz, GROUP);

        Assert.AreEqual(tz, prop.Value);
        Assert.AreEqual(GROUP, prop.Group);
        Assert.IsFalse(prop.IsEmpty);
    }
Example #3
0
    /// <summary>
    /// Copy ctor
    /// </summary>
    /// <param name="vCard">The vCard to clone.</param>
    private VCard(VCard vCard)
    {
        Version = vCard.Version;

        Func <ICloneable?, object?> cloner = Cloned;

        foreach (KeyValuePair <VCdProp, object> kvp in vCard._propDic)
        {
            Set(kvp.Key, kvp.Value switch
            {
                XmlProperty xmlProp => xmlProp.Clone(),
                IEnumerable <XmlProperty?> xmlPropEnumerable => xmlPropEnumerable.Select(cloner).Cast <XmlProperty?>().ToArray(),
                ProfileProperty profProp => profProp.Clone(),
                TextProperty txtProp => txtProp.Clone(),
                IEnumerable <TextProperty?> txtPropEnumerable => txtPropEnumerable.Select(cloner).Cast <TextProperty?>().ToArray(),
                DateTimeProperty dtTimeProp => dtTimeProp.Clone(),
                IEnumerable <DateTimeProperty?> dtTimePropEnumerable => dtTimePropEnumerable.Select(cloner).Cast <DateTimeProperty?>().ToArray(),
                AddressProperty adrProp => adrProp.Clone(),
                IEnumerable <AddressProperty?> adrPropEnumerable => adrPropEnumerable.Select(cloner).Cast <AddressProperty?>().ToArray(),
                NameProperty nameProp => nameProp.Clone(),
                IEnumerable <NameProperty?> namePropEnumerable => namePropEnumerable.Select(cloner).Cast <NameProperty?>().ToArray(),
                RelationProperty relProp => relProp.Clone(),
                IEnumerable <RelationProperty?> relPropEnumerable => relPropEnumerable.Select(cloner).Cast <RelationProperty?>().ToArray(),
                OrganizationProperty orgProp => orgProp.Clone(),
                IEnumerable <OrganizationProperty?> orgPropEnumerable => orgPropEnumerable.Select(cloner).Cast <OrganizationProperty?>().ToArray(),
                StringCollectionProperty strCollProp => strCollProp.Clone(),
                IEnumerable <StringCollectionProperty?> strCollPropEnumerable => strCollPropEnumerable.Select(cloner).Cast <StringCollectionProperty?>().ToArray(),
                GenderProperty sexProp => sexProp.Clone(),
                IEnumerable <GenderProperty?> sexPropEnumerable => sexPropEnumerable.Select(cloner).Cast <GenderProperty?>().ToArray(),
                GeoProperty geoProp => geoProp.Clone(),
                IEnumerable <GeoProperty?> geoPropEnumerable => geoPropEnumerable.Select(cloner).Cast <GeoProperty?>().ToArray(),
                DataProperty dataProp => dataProp.Clone(),
                IEnumerable <DataProperty?> dataPropEnumerable => dataPropEnumerable.Select(cloner).Cast <DataProperty?>().ToArray(),
                NonStandardProperty nStdProp => nStdProp.Clone(),
                IEnumerable <NonStandardProperty?> nStdPropEnumerable => nStdPropEnumerable.Select(cloner).Cast <NonStandardProperty?>().ToArray(),
                PropertyIDMappingProperty pidMapProp => pidMapProp.Clone(),
                IEnumerable <PropertyIDMappingProperty?> pidMapPropEnumerable => pidMapPropEnumerable.Select(cloner).Cast <PropertyIDMappingProperty?>().ToArray(),
                TimeZoneProperty tzProp => tzProp.Clone(),
                IEnumerable <TimeZoneProperty?> tzPropEnumerable => tzPropEnumerable.Select(cloner).Cast <TimeZoneProperty?>().ToArray(),

                ICloneable cloneable => cloneable.Clone(), // AccessProperty, KindProperty, TimeStampProperty, UuidProperty
                _ => kvp.Value
            });
Example #4
0
        /// <summary>
        /// This is overridden to allow copying of the additional properties
        /// </summary>
        /// <param name="p">The PDI object from which the settings are to be copied</param>
        protected override void Clone(PDIObject p)
        {
            VCard o = (VCard)p;

            this.ClearProperties();

            groupName = o.Group;

            fn     = (FormattedNameProperty)o.FormattedName.Clone();
            name   = (NameProperty)o.Name.Clone();
            title  = (TitleProperty)o.Title.Clone();
            role   = (RoleProperty)o.Role.Clone();
            mailer = (MailerProperty)o.Mailer.Clone();
            url    = (UrlProperty)o.Url.Clone();
            org    = (OrganizationProperty)o.Organization.Clone();
            uid    = (UniqueIdProperty)o.UniqueId.Clone();
            bday   = (BirthDateProperty)o.BirthDate.Clone();
            rev    = (LastRevisionProperty)o.LastRevision.Clone();
            tz     = (TimeZoneProperty)o.TimeZone.Clone();
            geo    = (GeographicPositionProperty)o.GeographicPosition.Clone();
            key    = (PublicKeyProperty)o.PublicKey.Clone();
            photo  = (PhotoProperty)o.Photo.Clone();
            logo   = (LogoProperty)o.Logo.Clone();
            sound  = (SoundProperty)o.Sound.Clone();

            this.Notes.CloneRange(o.Notes);
            this.Addresses.CloneRange(o.Addresses);
            this.Labels.CloneRange(o.Labels);
            this.Telephones.CloneRange(o.Telephones);
            this.EMailAddresses.CloneRange(o.EMailAddresses);
            this.Agents.CloneRange(o.Agents);
            this.CustomProperties.CloneRange(o.CustomProperties);

            addProfile     = o.AddProfile;
            mimeName       = (MimeNameProperty)o.MimeName.Clone();
            mimeSource     = (MimeSourceProperty)o.MimeSource.Clone();
            prodId         = (ProductIdProperty)o.ProductId.Clone();
            nickname       = (NicknameProperty)o.Nickname.Clone();
            sortString     = (SortStringProperty)o.SortString.Clone();
            classification = (ClassificationProperty)o.Classification.Clone();
            categories     = (CategoriesProperty)o.Categories.Clone();
        }
Example #5
0
        /// <summary>
        /// The method can be called to clear all current property values from the vCard.  The version is left
        /// unchanged.
        /// </summary>
        public void ClearProperties()
        {
            groupName = null;

            fn     = null;
            name   = null;
            title  = null;
            role   = null;
            mailer = null;
            url    = null;
            org    = null;
            uid    = null;
            bday   = null;
            rev    = null;
            tz     = null;
            geo    = null;
            key    = null;
            photo  = null;
            logo   = null;
            sound  = null;

            notes       = null;
            addrs       = null;
            labels      = null;
            phones      = null;
            email       = null;
            agents      = null;
            customProps = null;

            addProfile     = false;
            mimeName       = null;
            mimeSource     = null;
            prodId         = null;
            nickname       = null;
            sortString     = null;
            classification = null;
            categories     = null;
        }
Example #6
0
        public void UpdateToTime(int id, DateTime?time)
        {
            using (IUnitOfWork work = UnitOfWork.Begin())
            {
                TimeZoneProperty timeZoneProperty = _timeZonePropertyRepository.FindById(id);
                var oldTime = timeZoneProperty.ValidTo;
                timeZoneProperty.ValidTo = time;

                var message = new XElement(XMLLogLiterals.LOG_MESSAGE);
                message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageTimeZonePropertyChanged", new List <string> {
                    timeZoneProperty.TimeZone.Name
                }));
                message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageValidToChanged", new List <string> {
                    oldTime == null ? "empty" : oldTime.Value.ToString("HH:mm"),
                    timeZoneProperty.ValidTo == null
                                                ? "empty"
                                                : timeZoneProperty.ValidTo.Value.ToString("HH:mm")
                }));
                work.Commit();

                _logService.CreateLog(CurrentUser.Get().Id, "web", CurrentUser.Get().HostName, CurrentUser.Get().CompanyId, message.ToString());
            }
        }
Example #7
0
        public void ToggleZone(int id, int day)
        {
            using (IUnitOfWork work = UnitOfWork.Begin())
            {
                TimeZoneProperty timeZoneProperty = _timeZonePropertyRepository.FindById(id);
                bool             dayVal           = false;
                string           dayName          = string.Empty;
                switch (day)
                {
                case 1:
                    dayVal = timeZoneProperty.IsMonday;
                    timeZoneProperty.IsMonday = !timeZoneProperty.IsMonday;
                    dayName = "LogMessageMonday";
                    break;

                case 2:
                    dayVal = timeZoneProperty.IsTuesday;
                    timeZoneProperty.IsTuesday = !timeZoneProperty.IsTuesday;
                    dayName = "LogMessageTuesday";
                    break;

                case 3:
                    dayVal = timeZoneProperty.IsWednesday;
                    timeZoneProperty.IsWednesday = !timeZoneProperty.IsWednesday;
                    dayName = "LogMessageWednesday";
                    break;

                case 4:
                    dayVal = timeZoneProperty.IsThursday;
                    timeZoneProperty.IsThursday = !timeZoneProperty.IsThursday;
                    dayName = "LogMessageThursday";
                    break;

                case 5:
                    dayVal = timeZoneProperty.IsFriday;
                    timeZoneProperty.IsFriday = !timeZoneProperty.IsFriday;
                    dayName = "LogMessageFriday";
                    break;

                case 6:
                    dayVal = timeZoneProperty.IsSaturday;
                    timeZoneProperty.IsSaturday = !timeZoneProperty.IsSaturday;
                    dayName = "LogMessageSaturday";
                    break;

                case 7:
                    dayVal = timeZoneProperty.IsSunday;
                    timeZoneProperty.IsSunday = !timeZoneProperty.IsSunday;
                    dayName = "LogMessageSunday";
                    break;
                }

                var message = new XElement(XMLLogLiterals.LOG_MESSAGE);
                message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageTimeZonePropertyChanged", new List <string> {
                    timeZoneProperty.TimeZone.Name
                }));
                message.Add(XMLLogMessageHelper.TemplateToXml(dayName, null));
                message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageCommonIsChanged", new List <string> {
                    dayVal.ToString(), (!dayVal).ToString()
                }));

                work.Commit();
                _logService.CreateLog(CurrentUser.Get().Id, "web", CurrentUser.Get().HostName, CurrentUser.Get().CompanyId, message.ToString());
            }
        }
Example #8
0
        public int CreateTimeZoneProperty(int timeZoneId, int order, DateTime?validFrom, DateTime?validTo, bool isMonday, bool isTuesday, bool isWednesday, bool isThursday, bool isFriday, bool isSaturday, bool isSunday)
        {
            using (IUnitOfWork work = UnitOfWork.Begin())
            {
                TimeZoneProperty timeZoneProperty = DomainObjectFactory.CreateTimeZoneProperty();

                timeZoneProperty.TimeZoneId   = timeZoneId;
                timeZoneProperty.OrderInGroup = order;
                timeZoneProperty.ValidFrom    = validFrom;
                timeZoneProperty.ValidTo      = validTo;
                timeZoneProperty.IsMonday     = isMonday;
                timeZoneProperty.IsTuesday    = isTuesday;
                timeZoneProperty.IsWednesday  = isWednesday;
                timeZoneProperty.IsThursday   = isThursday;
                timeZoneProperty.IsFriday     = isFriday;
                timeZoneProperty.IsSaturday   = isSaturday;
                timeZoneProperty.IsSunday     = isSunday;

                _timeZonePropertyRepository.Add(timeZoneProperty);

                work.Commit();

                var tzProperty = _timeZonePropertyRepository.FindById(timeZoneProperty.Id);

                var message = new XElement(XMLLogLiterals.LOG_MESSAGE);
                message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageTimeZonePropertyCreated", new List <string> {
                    tzProperty.TimeZone.Name
                }));
                message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageOrderInGroup", new List <string> {
                    order.ToString()
                }));
                message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageValidFrom", new List <string> {
                    tzProperty.ValidFrom == null ? "empty" : tzProperty.ValidFrom.Value.ToString("HH:mm")
                }));
                message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageValidTo", new List <string> {
                    tzProperty.ValidTo == null ? "empty" : tzProperty.ValidTo.Value.ToString("HH:mm")
                }));
                message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageIsMonday", new List <string> {
                    tzProperty.IsMonday.ToString()
                }));
                message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageIsTuesday", new List <string> {
                    tzProperty.IsTuesday.ToString()
                }));
                message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageIsWednesday", new List <string> {
                    tzProperty.IsWednesday.ToString()
                }));
                message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageIsThursday", new List <string> {
                    tzProperty.IsThursday.ToString()
                }));
                message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageIsFriday", new List <string> {
                    tzProperty.IsFriday.ToString()
                }));
                message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageIsSaturday", new List <string> {
                    tzProperty.IsSaturday.ToString()
                }));
                message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageIsSunday", new List <string> {
                    tzProperty.IsSunday.ToString()
                }));

                _logService.CreateLog(CurrentUser.Get().Id, "web", CurrentUser.Get().HostName, CurrentUser.Get().CompanyId, message.ToString());

                return(timeZoneProperty.Id);
            }
        }