Ejemplo n.º 1
0
        static public Microsoft.Samples.FeedSync.HistoryNode CreateNew(Microsoft.Samples.FeedSync.SyncNode i_SyncNode, System.DateTime? i_WhenDateTime, string i_By)
        {
            Microsoft.Samples.FeedSync.Feed Feed = i_SyncNode.FeedItemNode.Feed;

            string ElementName = System.String.Format
                (
                "{0}:{1}",
                Feed.FeedSyncNamespacePrefix,
                Microsoft.Samples.FeedSync.Constants.HISTORY_ELEMENT_NAME
                );

            System.Xml.XmlElement HistoryNodeXmlElement = Feed.XmlDocument.CreateElement
                (
                ElementName,
                Microsoft.Samples.FeedSync.Constants.FEEDSYNC_XML_NAMESPACE_URI
                );

            if (i_WhenDateTime != null)
            {
                System.DateTime WhenDateTime = ((System.DateTime)i_WhenDateTime).ToUniversalTime();
                string When = WhenDateTime.ToString(Microsoft.Samples.FeedSync.Constants.DATE_STRING_FORMAT);

                HistoryNodeXmlElement.SetAttribute
                    (
                    Microsoft.Samples.FeedSync.Constants.WHEN_ATTRIBUTE,
                    When
                    );
            }

            int Sequence = i_SyncNode.Updates + 1;

            if (!System.String.IsNullOrEmpty(i_By))
            {
                HistoryNodeXmlElement.SetAttribute
                    (
                    Microsoft.Samples.FeedSync.Constants.BY_ATTRIBUTE,
                    i_By
                    );

                foreach (Microsoft.Samples.FeedSync.HistoryNode ExistingHistoryNode in i_SyncNode.HistoryNodes)
                {
                    if ((ExistingHistoryNode.By == i_By) && (ExistingHistoryNode.Sequence >= Sequence))
                        Sequence = ExistingHistoryNode.Sequence + 1;
                }
            }

            HistoryNodeXmlElement.SetAttribute
                (
                Microsoft.Samples.FeedSync.Constants.SEQUENCE_ATTRIBUTE,
                (i_SyncNode.Updates + 1).ToString()
                );

            Microsoft.Samples.FeedSync.HistoryNode HistoryNode = new Microsoft.Samples.FeedSync.HistoryNode
                (
                null,
                HistoryNodeXmlElement
                );

            return HistoryNode;
        }
Ejemplo n.º 2
0
        static public Microsoft.Samples.FeedSync.HistoryNode CreateFromXmlElement(Microsoft.Samples.FeedSync.SyncNode i_SyncNode, System.Xml.XmlElement i_HistoryNodeXmlElement)
        {
            if (i_HistoryNodeXmlElement.OwnerDocument != i_SyncNode.FeedItemNode.Feed.XmlDocument)
                i_HistoryNodeXmlElement = (System.Xml.XmlElement)i_SyncNode.FeedItemNode.Feed.XmlDocument.ImportNode(i_HistoryNodeXmlElement, true);

            Microsoft.Samples.FeedSync.HistoryNode HistoryNode = new Microsoft.Samples.FeedSync.HistoryNode
                (
                i_SyncNode,
                i_HistoryNodeXmlElement
                );

            return HistoryNode;
        }