Beispiel #1
0
        /// <summary>
        /// The method can be called to clear all current property values from the journal.  The version is left
        /// unchanged.
        /// </summary>
        public override void ClearProperties()
        {
            classification = null;
            categories     = null;
            url            = null;
            uid            = null;
            lastMod        = null;
            dateCreated    = null;
            startDate      = null;
            timeStamp      = null;
            summary        = null;
            desc           = null;
            sequence       = null;
            comment        = null;
            organizer      = null;
            recurId        = null;
            status         = null;

            contacts    = null;
            attendees   = null;
            relatedTo   = null;
            attachments = null;
            reqStats    = null;
            customProps = null;

            base.ClearProperties();
        }
Beispiel #2
0
        //=====================================================================

        /// <summary>
        /// This is overridden to allow cloning of a PDI object
        /// </summary>
        /// <returns>A clone of the object</returns>
        public override object Clone()
        {
            UrlProperty o = new UrlProperty();

            o.Clone(this);
            return(o);
        }
Beispiel #3
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)
        {
            VJournal o = (VJournal)p;

            this.ClearProperties();

            classification = (ClassificationProperty)o.Classification.Clone();
            categories     = (CategoriesProperty)o.Categories.Clone();
            url            = (UrlProperty)o.Url.Clone();
            uid            = (UniqueIdProperty)o.UniqueId.Clone();
            lastMod        = (LastModifiedProperty)o.LastModified.Clone();
            dateCreated    = (DateCreatedProperty)o.DateCreated.Clone();
            startDate      = (StartDateProperty)o.StartDateTime.Clone();
            timeStamp      = (TimeStampProperty)o.TimeStamp.Clone();
            summary        = (SummaryProperty)o.Summary.Clone();
            desc           = (DescriptionProperty)o.Description.Clone();
            sequence       = (SequenceProperty)o.Sequence.Clone();
            comment        = (CommentProperty)o.Comment.Clone();
            organizer      = (OrganizerProperty)o.Organizer.Clone();
            recurId        = (RecurrenceIdProperty)o.RecurrenceId.Clone();
            status         = (StatusProperty)o.Status.Clone();

            this.Contacts.CloneRange(o.Contacts);
            this.Attendees.CloneRange(o.Attendees);
            this.RelatedTo.CloneRange(o.RelatedTo);
            this.Attachments.CloneRange(o.Attachments);
            this.RequestStatuses.CloneRange(o.RequestStatuses);
            this.CustomProperties.CloneRange(o.CustomProperties);

            base.Clone(p);
        }
        private void SelectUrlTextClick(object sender, EventArgs e)
        {
            ButtonSpecAny  button = (ButtonSpecAny)sender;
            UrlProperty    prop   = (UrlProperty)button.Tag;
            KryptonTextBox txt    = button.Owner as KryptonTextBox;

            this.ShowSelectUrlDialog(txt, prop.Type);
        }
Beispiel #5
0
        public static UrlProperty SetUrl()
        {
            UrlProperty url = new UrlProperty
            {
                UrlApi  = ConfigurationManager.AppSettings["url"],
                UrlDays = ConfigurationManager.AppSettings["urldays"]
            };

            return(url);
        }
Beispiel #6
0
        /// <summary>
        /// The method can be called to clear all current property values from the free/busy object.  The version
        /// is left unchanged.
        /// </summary>
        public override void ClearProperties()
        {
            url       = null;
            uid       = null;
            startDate = null;
            endDate   = null;
            timeStamp = null;
            comment   = null;
            organizer = null;
            duration  = null;
            contact   = null;

            attendees   = null;
            reqstats    = null;
            freebusy    = null;
            customProps = null;
        }
Beispiel #7
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();
        }
Beispiel #8
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)
        {
            VFreeBusy o = (VFreeBusy)p;

            this.ClearProperties();

            url       = (UrlProperty)o.Url.Clone();
            uid       = (UniqueIdProperty)o.UniqueId.Clone();
            startDate = (StartDateProperty)o.StartDateTime.Clone();
            endDate   = (EndDateProperty)o.EndDateTime.Clone();
            timeStamp = (TimeStampProperty)o.TimeStamp.Clone();
            comment   = (CommentProperty)o.Comment.Clone();
            organizer = (OrganizerProperty)o.Organizer.Clone();
            duration  = (DurationProperty)o.Duration.Clone();
            contact   = (ContactProperty)o.Contact.Clone();

            this.Attendees.CloneRange(o.Attendees);
            this.RequestStatuses.CloneRange(o.RequestStatuses);
            this.FreeBusy.CloneRange(o.FreeBusy);
            this.CustomProperties.CloneRange(o.CustomProperties);
        }
Beispiel #9
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)
        {
            VEvent o = (VEvent)p;

            this.ClearProperties();

            classification = (ClassificationProperty)o.Classification.Clone();
            categories     = (CategoriesProperty)o.Categories.Clone();
            resources      = (ResourcesProperty)o.Resources.Clone();
            url            = (UrlProperty)o.Url.Clone();
            uid            = (UniqueIdProperty)o.UniqueId.Clone();
            geo            = (GeographicPositionProperty)o.GeographicPosition.Clone();
            lastMod        = (LastModifiedProperty)o.LastModified.Clone();
            dateCreated    = (DateCreatedProperty)o.DateCreated.Clone();
            startDate      = (StartDateProperty)o.StartDateTime.Clone();
            endDate        = (EndDateProperty)o.EndDateTime.Clone();
            dateStamp      = (TimeStampProperty)o.TimeStamp.Clone();
            summary        = (SummaryProperty)o.Summary.Clone();
            desc           = (DescriptionProperty)o.Description.Clone();
            location       = (LocationProperty)o.Location.Clone();
            priority       = (PriorityProperty)o.Priority.Clone();
            sequence       = (SequenceProperty)o.Sequence.Clone();
            transp         = (TimeTransparencyProperty)o.Transparency.Clone();
            rNum           = (RecurrenceCountProperty)o.RecurrenceCount.Clone();
            comment        = (CommentProperty)o.Comment.Clone();
            organizer      = (OrganizerProperty)o.Organizer.Clone();
            recurId        = (RecurrenceIdProperty)o.RecurrenceId.Clone();
            status         = (StatusProperty)o.Status.Clone();
            duration       = (DurationProperty)o.Duration.Clone();

            this.Contacts.CloneRange(o.Contacts);
            this.Attendees.CloneRange(o.Attendees);
            this.RelatedTo.CloneRange(o.RelatedTo);
            this.Attachments.CloneRange(o.Attachments);
            this.RequestStatuses.CloneRange(o.RequestStatuses);
            this.Alarms.CloneRange(o.Alarms);
            this.CustomProperties.CloneRange(o.CustomProperties);

            base.Clone(p);
        }
Beispiel #10
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;
        }
Beispiel #11
0
 set => SetValue(UrlProperty, value);
Beispiel #12
0
        /// <summary>
        /// This is implemented to handle properties as they are parsed from the data stream
        /// </summary>
        /// <param name="propertyName">The name of the property.</param>
        /// <param name="parameters">A string collection containing the parameters and their values.  If empty,
        /// there are no parameters.</param>
        /// <param name="propertyValue">The value of the property.</param>
        /// <remarks><para>There may be a mixture of name/value pairs or values alone in the parameters string
        /// collection.  It is up to the derived class to process the parameter list based on the specification
        /// to which it conforms.  For entries that are parameter names, the entry immediately following it in
        /// the collection is its associated parameter value.  The property name, parameter names, and their
        /// values may be in upper, lower, or mixed case.</para>
        ///
        /// <para>The value may be an encoded string.  The properties are responsible for any decoding that may
        /// need to occur (i.e. base 64 encoded image data).</para></remarks>
        /// <exception cref="PDIParserException">This is thrown if an error is encountered while parsing the data
        /// stream.  Refer to the and inner exceptions for information on the cause of the problem.</exception>
        protected override void PropertyParser(string propertyName, StringCollection parameters, string propertyValue)
        {
            string temp, group = null;
            int    idx;

            // Parse out the group name if there is one
            idx = propertyName.IndexOf('.');

            if (idx != -1)
            {
                group        = propertyName.Substring(0, idx).Trim();
                propertyName = propertyName.Substring(idx + 1).Trim();
            }

            // The last entry is always CustomProperty so scan for length minus one
            for (idx = 0; idx < ntv.Length - 1; idx++)
            {
                if (ntv[idx].IsMatch(propertyName))
                {
                    break;
                }
            }

            // An opening BEGIN:VCARD property must have been seen
            if (currentCard == null && ntv[idx].EnumValue != PropertyType.Begin)
            {
                throw new PDIParserException(this.LineNumber, LR.GetString("ExParseNoBeginProp", "BEGIN:VCARD",
                                                                           propertyName));
            }

            // Handle or create the property
            switch (ntv[idx].EnumValue)
            {
            case PropertyType.Begin:
                // The value must be VCARD
                if (String.Compare(propertyValue.Trim(), "VCARD", StringComparison.OrdinalIgnoreCase) != 0)
                {
                    throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedTagValue",
                                                                               ntv[idx].Name, propertyValue));
                }

                // NOTE: If serializing into an existing instance, this may not be null.  If so, it is
                // ignored.
                if (currentCard == null)
                {
                    currentCard = new VCard();
                    vCards.Add(currentCard);
                }

                currentCard.Group = group;
                break;

            case PropertyType.End:
                // The value must be VCARD
                if (String.Compare(propertyValue.Trim(), "VCARD", StringComparison.OrdinalIgnoreCase) != 0)
                {
                    throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedTagValue",
                                                                               ntv[idx].Name, propertyValue));
                }

                // The group must match too
                if (currentCard.Group != group)
                {
                    throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnexpectedGroupTag",
                                                                               currentCard.Group, group));
                }

                // When done, we'll propagate the version number to all objects to make it consistent
                currentCard.PropagateVersion();

                // The vCard is added to the collection when created so we don't have to rely on an END:VCARD
                // to add it.
                currentCard = null;
                break;

            case PropertyType.Profile:
                // The value must be VCARD
                if (String.Compare(propertyValue.Trim(), "VCARD", StringComparison.OrdinalIgnoreCase) != 0)
                {
                    throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedTagValue",
                                                                               ntv[idx].Name, propertyValue));
                }

                currentCard.AddProfile = true;
                break;

            case PropertyType.Version:
                // Version must be 2.1, 3.0, or 4.0
                temp = propertyValue.Trim();

                SpecificationVersions version;

                if (temp == "2.1")
                {
                    version = SpecificationVersions.vCard21;
                }
                else
                if (temp == "3.0")
                {
                    version = SpecificationVersions.vCard30;
                }
                else
                if (temp == "4.0")
                {
                    version = SpecificationVersions.vCard40;
                }
                else
                {
                    throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedVersion",
                                                                               "vCard", temp));
                }

                currentCard.Version = version;
                break;

            case PropertyType.MimeName:
                currentCard.MimeName.EncodedValue = propertyValue;
                break;

            case PropertyType.MimeSource:
                currentCard.MimeSource.DeserializeParameters(parameters);
                currentCard.MimeSource.EncodedValue = propertyValue;
                break;

            case PropertyType.ProductId:
                currentCard.ProductId.EncodedValue = propertyValue;
                break;

            case PropertyType.Kind:
                currentCard.Kind.DeserializeParameters(parameters);
                currentCard.Kind.EncodedValue = propertyValue;
                currentCard.Kind.Group        = group;
                break;

            case PropertyType.Nickname:
                currentCard.Nickname.DeserializeParameters(parameters);
                currentCard.Nickname.EncodedValue = propertyValue;
                currentCard.Nickname.Group        = group;
                break;

            case PropertyType.SortString:
                currentCard.SortString.DeserializeParameters(parameters);
                currentCard.SortString.EncodedValue = propertyValue;
                currentCard.SortString.Group        = group;
                break;

            case PropertyType.Class:
                currentCard.Classification.EncodedValue = propertyValue;
                currentCard.Classification.Group        = group;
                break;

            case PropertyType.Categories:
                currentCard.Categories.DeserializeParameters(parameters);
                currentCard.Categories.EncodedValue = propertyValue;
                currentCard.Categories.Group        = group;
                break;

            case PropertyType.FormattedName:
                currentCard.FormattedName.DeserializeParameters(parameters);
                currentCard.FormattedName.EncodedValue = propertyValue;
                currentCard.FormattedName.Group        = group;
                break;

            case PropertyType.Name:
                currentCard.Name.DeserializeParameters(parameters);
                currentCard.Name.EncodedValue = propertyValue;
                currentCard.Name.Group        = group;
                break;

            case PropertyType.Gender:
                currentCard.Gender.DeserializeParameters(parameters);
                currentCard.Gender.EncodedValue = propertyValue;
                currentCard.Gender.Group        = group;
                break;

            case PropertyType.Title:
                currentCard.Title.DeserializeParameters(parameters);
                currentCard.Title.EncodedValue = propertyValue;
                currentCard.Title.Group        = group;
                break;

            case PropertyType.Role:
                currentCard.Role.DeserializeParameters(parameters);
                currentCard.Role.EncodedValue = propertyValue;
                currentCard.Role.Group        = group;
                break;

            case PropertyType.Mailer:
                currentCard.Mailer.DeserializeParameters(parameters);
                currentCard.Mailer.EncodedValue = propertyValue;
                currentCard.Mailer.Group        = group;
                break;

            case PropertyType.Organization:
                currentCard.Organization.DeserializeParameters(parameters);
                currentCard.Organization.EncodedValue = propertyValue;
                currentCard.Organization.Group        = group;
                break;

            case PropertyType.UniqueId:
                currentCard.UniqueId.EncodedValue = propertyValue;
                currentCard.UniqueId.Group        = group;
                break;

            case PropertyType.BirthDate:
                currentCard.BirthDate.DeserializeParameters(parameters);
                currentCard.BirthDate.EncodedValue = propertyValue;
                currentCard.BirthDate.Group        = group;
                break;

            case PropertyType.Anniversary:
                currentCard.Anniversary.DeserializeParameters(parameters);
                currentCard.Anniversary.EncodedValue = propertyValue;
                currentCard.Anniversary.Group        = group;
                break;

            case PropertyType.Revision:
                currentCard.LastRevision.DeserializeParameters(parameters);
                currentCard.LastRevision.EncodedValue = propertyValue;
                currentCard.LastRevision.Group        = group;
                break;

            case PropertyType.TimeZone:
                currentCard.TimeZone.DeserializeParameters(parameters);
                currentCard.TimeZone.EncodedValue = propertyValue;
                currentCard.TimeZone.Group        = group;
                break;

            case PropertyType.GeographicPosition:
                currentCard.GeographicPosition.EncodedValue = propertyValue;
                currentCard.GeographicPosition.Group        = group;
                break;

            case PropertyType.PublicKey:
                currentCard.PublicKey.DeserializeParameters(parameters);
                currentCard.PublicKey.EncodedValue = propertyValue;
                currentCard.PublicKey.Group        = group;
                break;

            case PropertyType.Photo:
                currentCard.Photo.DeserializeParameters(parameters);
                currentCard.Photo.EncodedValue = propertyValue;
                currentCard.Photo.Group        = group;
                break;

            case PropertyType.Logo:
                currentCard.Logo.DeserializeParameters(parameters);
                currentCard.Logo.EncodedValue = propertyValue;
                currentCard.Logo.Group        = group;
                break;

            case PropertyType.Sound:
                currentCard.Sound.DeserializeParameters(parameters);
                currentCard.Sound.EncodedValue = propertyValue;
                currentCard.Sound.Group        = group;
                break;

            case PropertyType.Note:
                NoteProperty n = new NoteProperty();
                n.DeserializeParameters(parameters);
                n.EncodedValue = propertyValue;
                n.Group        = group;
                currentCard.Notes.Add(n);
                break;

            case PropertyType.Address:
                AddressProperty a = new AddressProperty();
                a.DeserializeParameters(parameters);
                a.EncodedValue = propertyValue;
                a.Group        = group;
                currentCard.Addresses.Add(a);
                break;

            case PropertyType.Label:
                LabelProperty l = new LabelProperty();
                l.DeserializeParameters(parameters);
                l.EncodedValue = propertyValue;
                l.Group        = group;
                currentCard.Labels.Add(l);
                break;

            case PropertyType.Telephone:
                TelephoneProperty t = new TelephoneProperty();
                t.DeserializeParameters(parameters);
                t.EncodedValue = propertyValue;
                t.Group        = group;
                currentCard.Telephones.Add(t);
                break;

            case PropertyType.EMail:
                EMailProperty e = new EMailProperty();
                e.DeserializeParameters(parameters);
                e.EncodedValue = propertyValue;
                e.Group        = group;
                currentCard.EMailAddresses.Add(e);
                break;

            case PropertyType.Url:
                UrlProperty u = new UrlProperty();
                u.DeserializeParameters(parameters);
                u.EncodedValue = propertyValue;
                u.Group        = group;
                currentCard.Urls.Add(u);
                break;

            case PropertyType.Agent:
                AgentProperty ag = new AgentProperty();
                ag.DeserializeParameters(parameters);
                ag.EncodedValue = propertyValue;
                ag.Group        = group;
                currentCard.Agents.Add(ag);
                break;

            case PropertyType.ClientPidMap:
                var cpm = new ClientPidMapProperty();
                cpm.DeserializeParameters(parameters);
                cpm.EncodedValue = propertyValue;
                cpm.Group        = group;
                currentCard.ClientPidMaps.Add(cpm);
                break;

            case PropertyType.Member:
                var member = new MemberProperty();
                member.DeserializeParameters(parameters);
                member.EncodedValue = propertyValue;
                member.Group        = group;
                currentCard.Members.Add(member);
                break;

            case PropertyType.Related:
                RelatedProperty r = new RelatedProperty();
                r.DeserializeParameters(parameters);
                r.EncodedValue = propertyValue;
                r.Group        = group;
                currentCard.Related.Add(r);
                break;

            default:        // Anything else is a custom property
                CustomProperty c = new CustomProperty(propertyName);
                c.DeserializeParameters(parameters);
                c.EncodedValue = propertyValue;
                c.Group        = group;
                currentCard.CustomProperties.Add(c);
                break;
            }
        }
 set { SetValue(UrlProperty, value); }
        private static void ExportField(XmlDocument doc, XmlElement f, Field field)
        {
            switch (field.FieldType)
            {
            case FieldType.Url:
                UrlProperty uprop = (UrlProperty)field.Data;
                switch (uprop.Type)
                {
                case UrlType.File:
                    doc.AddAttribute(f, new XmlAttributeElement("method", "file"));
                    break;

                case UrlType.Folder:
                    doc.AddAttribute(f, new XmlAttributeElement("method", "folder"));
                    break;

                case UrlType.Url:
                    doc.AddAttribute(f, new XmlAttributeElement("method", "url"));
                    break;
                }

                break;

            case FieldType.Text:
                if (field.DefaultValue.Enabled)
                {
                    doc.AddAttribute(f, new XmlAttributeElement("default", field.DefaultValue.AsText, string.Empty));
                }

                break;

            case FieldType.Select:
                List <string> sc           = (List <string>)field.Data;
                string        selectValues = string.Empty;
                foreach (string s in sc)
                {
                    if (selectValues.Length != 0)
                    {
                        selectValues += ";";
                    }

                    selectValues += s;
                }

                doc.AddAttribute(f, new XmlAttributeElement("values", selectValues));
                if (field.DefaultValue.Enabled)
                {
                    doc.AddAttribute(f, new XmlAttributeElement("default", field.DefaultValue.Value.ToString(), (-1).ToString()));
                }

                break;

            case FieldType.Number:
                if (field.DefaultValue.Enabled)
                {
                    doc.AddAttribute(f, new XmlAttributeElement("default", field.DefaultValue.Value.ToString(), (0).ToString()));
                }

                NumberProperty prop = field.Data as NumberProperty;
                if (prop != null)
                {
                    doc.AddAttributes(f, new XmlAttributeElement[] {
                        new XmlAttributeElement("decimal", prop.DecimalPlaces.ToString(), (0).ToString()),
                        new XmlAttributeElement("increment", prop.Increment.ToString(), (1).ToString()),
                        new XmlAttributeElement("thousands", prop.Thousands.ToString(), false.ToString()),
                        new XmlAttributeElement("prefix", prop.Prefix, string.Empty),
                        new XmlAttributeElement("suffix", prop.Suffix, string.Empty)
                    });
                    if (prop.Bounds)
                    {
                        doc.AddAttributes(f, new XmlAttributeElement[] {
                            new XmlAttributeElement("maximum", prop.Maximum.ToString()),
                            new XmlAttributeElement("minimum", prop.Minimum.ToString())
                        });
                    }
                }

                break;

            case FieldType.List:
                ListProperty listRef = field.Data as ListProperty;
                if (listRef != null)
                {
                    doc.AddAttribute(f, new XmlAttributeElement("ref_guid", listRef.Reference.Identifier.ToString()));
                }

                break;

            case FieldType.Boolean:
                if (field.DefaultValue.Enabled)
                {
                    doc.AddAttribute(f, new XmlAttributeElement("default", field.DefaultValue.Value.ToString()));
                }

                break;

            case FieldType.Date:
                if (field.DefaultValue.Enabled)
                {
                    doc.AddAttribute(f, new XmlAttributeElement("default", field.DefaultValue.Value.ToString(), DateTime.MinValue.ToString()));
                    DateProperty dprop = field.Data as DateProperty;
                    if (dprop != null)
                    {
                        doc.AddAttribute(f, new XmlAttributeElement("time", dprop.ViewTime.ToString(), false.ToString()));
                    }
                }

                break;

            case FieldType.Rating:
                if (field.DefaultValue.Enabled)
                {
                    doc.AddAttribute(f, new XmlAttributeElement("default", field.DefaultValue.Value.ToString(), (0).ToString()));
                }

                break;

            case FieldType.Reference:
                ReferenceProperty reference = field.Data as ReferenceProperty;
                if (reference != null)
                {
                    doc.AddAttribute(f, new XmlAttributeElement("ref_guid", reference.Reference.Identifier.ToString()));
                }

                break;

            case FieldType.Table:
                List <ColumnProperty> list = (List <ColumnProperty>)field.Data;
                foreach (ColumnProperty cp in list)
                {
                    XmlElement c = doc.CreateElement(f, "column", "name", cp.Name);
                    if (cp.Reference != null)
                    {
                        doc.AddAttribute(c, new XmlAttributeElement("ref_guid", cp.Reference.Identifier.ToString()));
                    }
                }

                break;
            }
        }
Beispiel #15
0
        //=====================================================================

        /// <summary>
        /// This is overridden to allow cloning of a PDI object
        /// </summary>
        /// <returns>A clone of the object</returns>
        public override object Clone()
        {
            UrlProperty o = new UrlProperty();
            o.Clone(this);
            return o;
        }
        private void ImportField(XmlNode fieldNode, ObjectClass obj)
        {
            XmlAttribute attr = null;

            if (fieldNode.Name == "forms")
            {
                obj.Form = this.ConvertXmlToString(fieldNode.InnerXml);
                return;
            }

            if (fieldNode.Name == "fieldname")
            {
                attr = fieldNode.Attributes["expression"];
                if (attr != null)
                {
                    obj[SystemProperty.Name].Evaluated  = true;
                    obj[SystemProperty.Name].Expression = attr.Value;
                }

                return;
            }

            attr = fieldNode.Attributes["name"];
            if (attr == null)
            {
                return;
            }

            string fieldName = attr.Value;

            attr = fieldNode.Attributes["type"];
            if (attr == null)
            {
                return;
            }

            FieldType fieldType = Utils.Parse(attr.Value);
            Field     field     = this.Database.Classes.AddField(obj, fieldName, fieldType);

            attr = fieldNode.Attributes["category"];
            if (attr != null)
            {
                field.Category = attr.Value;
            }

            attr = fieldNode.Attributes["group"];
            if (attr != null)
            {
                field.Group = bool.Parse(attr.Value);
            }

            field.Comment = fieldNode.AttributeValueOrDefault("comment");

            attr = fieldNode.Attributes["expression"];
            if (attr != null && field.FieldType == FieldType.Text)
            {
                field.Evaluated  = true;
                field.Expression = attr.Value;
            }

            attr = fieldNode.Attributes["order"];
            if (attr != null)
            {
                field.Order = int.Parse(attr.Value);
            }

            switch (fieldType)
            {
            case FieldType.Url:
                attr = fieldNode.Attributes["method"];
                if (attr != null)
                {
                    UrlProperty.Get(field).Type = UrlProperty.Parse(attr.Value);
                }

                break;

            case FieldType.Text:
                XmlAttribute xmlTextDef = fieldNode.Attributes["default"];
                if (xmlTextDef != null)
                {
                    field.DefaultValue.AsText = xmlTextDef.Value;
                }

                break;

            case FieldType.Select:
                XmlAttribute xmlValues = fieldNode.Attributes["values"];
                if (xmlValues != null)
                {
                    List <string> sc = (List <string>)field.Data;
                    sc.AddRange(xmlValues.Value.Split(new char[] { ';' }));
                    XmlAttribute xmlValuesDef = fieldNode.Attributes["default"];
                    if (xmlValuesDef != null)
                    {
                        field.DefaultValue.AsInteger = sc.IndexOf(xmlValuesDef.Value);
                    }
                }

                break;

            case FieldType.Number:
                attr = fieldNode.Attributes["default"];
                if (attr != null)
                {
                    field.DefaultValue.AsDecimal = decimal.Parse(attr.Value);
                }

                NumberProperty prop = (NumberProperty)field.Data;
                attr = fieldNode.Attributes["decimal"];
                if (attr != null)
                {
                    prop.DecimalPlaces = int.Parse(attr.Value);
                }

                attr = fieldNode.Attributes["maximum"];
                if (attr != null)
                {
                    prop.Maximum = decimal.Parse(attr.Value);
                    prop.Bounds  = true;
                }

                attr = fieldNode.Attributes["minimum"];
                if (attr != null)
                {
                    prop.Minimum = decimal.Parse(attr.Value);
                    prop.Bounds  = true;
                }

                attr = fieldNode.Attributes["increment"];
                if (attr != null)
                {
                    prop.Increment = decimal.Parse(attr.Value);
                }

                attr = fieldNode.Attributes["thousands"];
                if (attr != null)
                {
                    prop.Thousands = bool.Parse(attr.Value);
                }

                prop.Prefix = fieldNode.AttributeValueOrDefault("prefix");
                prop.Suffix = fieldNode.AttributeValueOrDefault("suffix");

                break;

            case FieldType.List:
                XmlAttribute xmlListRef = fieldNode.Attributes["ref_guid"];
                if (xmlListRef != null)
                {
                    ListProperty.Get(field).Reference = Database.Classes[new Guid(xmlListRef.Value)];
                }
                else
                {
                    xmlListRef = fieldNode.Attributes["reference"];
                    if (xmlListRef != null)
                    {
                        ImportObjectClass ic_list = this[xmlListRef.Value];
                        ListProperty.Get(field).Reference = Database.Classes[ic_list.Identifier];
                    }
                }

                break;

            case FieldType.Boolean:
                XmlAttribute xmlBoolDef = fieldNode.Attributes["default"];
                if (xmlBoolDef != null)
                {
                    field.DefaultValue.AsBoolean = bool.Parse(xmlBoolDef.Value);
                }

                break;

            case FieldType.Date:
                XmlAttribute xmlDateDef = fieldNode.Attributes["default"];
                if (xmlDateDef != null)
                {
                    field.DefaultValue.AsDateTime = DateTime.Parse(xmlDateDef.Value);
                }

                attr = fieldNode.Attributes["time"];
                if (attr != null)
                {
                    DateProperty.Get(field).ViewTime = bool.Parse(attr.Value);
                }

                break;

            case FieldType.Table:
                XmlAttribute          xmlTableCols = fieldNode.Attributes["columns"];
                List <ColumnProperty> list         = new List <ColumnProperty>();
                if (xmlTableCols != null)
                {
                    foreach (string col in xmlTableCols.Value.Split(new char[] { ';' }))
                    {
                        list.Add(new ColumnProperty(col));
                    }
                }
                else
                {
                    foreach (XmlNode xmlColumn in fieldNode.ChildNodes)
                    {
                        XmlAttribute xmlColName = xmlColumn.Attributes["name"];
                        if (xmlColName != null)
                        {
                            string         colName   = xmlColName.Value;
                            ColumnProperty cp        = new ColumnProperty(colName);
                            XmlAttribute   xmlColRef = xmlColumn.Attributes["ref_guid"];
                            if (xmlColRef != null)
                            {
                                cp.Reference = Database.Classes[new Guid(xmlColRef.Value)];
                            }
                            else
                            {
                                xmlColRef = xmlColumn.Attributes["reference"];
                                if (xmlColRef != null)
                                {
                                    ImportObjectClass c_ref = this[xmlColRef.Value];
                                    cp.Reference = Database.Classes[c_ref.Identifier];
                                }
                            }

                            attr = xmlColumn.Attributes["width"];
                            if (attr != null)
                            {
                                cp.Width = int.Parse(attr.Value);
                            }

                            attr = xmlColumn.Attributes["min_width"];
                            if (attr != null)
                            {
                                cp.MinWidth = int.Parse(attr.Value);
                            }

                            attr = xmlColumn.Attributes["visible"];
                            if (attr != null)
                            {
                                cp.Visible = bool.Parse(attr.Value);
                            }

                            attr = xmlColumn.Attributes["resizable"];
                            if (attr != null)
                            {
                                cp.Resizable = bool.Parse(attr.Value);
                            }

                            attr = xmlColumn.Attributes["frozen"];
                            if (attr != null)
                            {
                                cp.Frozen = bool.Parse(attr.Value);
                            }

                            attr = xmlColumn.Attributes["div_width"];
                            if (attr != null)
                            {
                                cp.DividerWidth = int.Parse(attr.Value);
                            }

                            attr = xmlColumn.Attributes["auto_size"];
                            if (attr != null)
                            {
                                cp.AutoSize = bool.Parse(attr.Value);
                            }

                            attr = xmlColumn.Attributes["fill_weight"];
                            if (attr != null)
                            {
                                cp.FillWeight = int.Parse(attr.Value);
                            }

                            list.Add(cp);
                        }
                    }
                }

                ((List <ColumnProperty>)field.Data).AddRange(list);
                break;

            case FieldType.Rating:
                XmlAttribute xmlRaitDef = fieldNode.Attributes["default"];
                if (xmlRaitDef != null)
                {
                    field.DefaultValue.AsDecimal = decimal.Parse(xmlRaitDef.Value);
                }

                break;

            case FieldType.Reference:
                XmlAttribute xmlRef = fieldNode.Attributes["ref_guid"];
                if (xmlRef != null)
                {
                    ReferenceProperty.Get(field).Reference = Database.Classes[new Guid(xmlRef.Value)];
                }
                else
                {
                    xmlRef = fieldNode.Attributes["reference"];
                    if (xmlRef != null)
                    {
                        ImportObjectClass ic_ref = this[xmlRef.Value];
                        ReferenceProperty.Get(field).Reference = Database.Classes[ic_ref.Identifier];
                    }
                }

                break;
            }
        }