Ejemplo n.º 1
0
        /// <summary>
        /// Classics the object model.
        /// </summary>
        /// <param name="tfs">The TFS.</param>
        private static void ClassicObjectModel(TfsTeamProjectCollection tfs)
        {
            tfs.EnsureAuthenticated();

            var workitemstore = tfs.GetService <WorkItemStore>();

            const string       wiql = "SELECT * FROM WorkItems WHERE [System.TeamProject] = 'RestPlaypen' ORDER BY [System.Id] ";
            WorkItemCollection wic  = workitemstore.Query(wiql);

            foreach (WorkItem wi in wic)
            {
                if (wi.Rev > 1)
                {
                    Console.WriteLine("{0}:{1}\t{2}", wi.Id, wi.Rev, wi.Title);
                    RevisionCollection revisions = wi.Revisions;
                    foreach (Revision revision in revisions)
                    {
                        Console.WriteLine("\t{0}\t{1}\t{2}", revision.Index, revision.Fields.Count, revision.Fields["System.ChangedDate"].Value);
                    }
                }
                if (wi.Links.Count > 0)
                {
                    Console.WriteLine("{0}:{1}\t{2}", wi.Id, wi.Rev, wi.Title);
                    Console.WriteLine("\t{0} Links", wi.Links.Count);
                    foreach (Link link in wi.Links)
                    {
                        Console.WriteLine("\t\t{0}\tComment: {1}", WriteSpecific(link), SafeWriteComment(link));
                    }
                }
            }
        }
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            RevisionCollection revisions = (RevisionCollection)value;

            writer.WriteStartArray();

            // Walk in reverse order to make latest first by default
            for (int i = revisions.Count - 1; i >= 0; --i)
            {
                Revision revision = revisions[i];
                string   history  = (string)revision.Fields["History"].Value;

                // Only add revisions with nonempty comments
                if (!String.IsNullOrEmpty(history))
                {
                    writer.WriteStartObject();

                    writer.WritePropertyName("when");
                    writer.WriteValue(((DateTime)revision.Fields["Changed Date"].Value).ToUniversalTime().ToString("u"));

                    writer.WritePropertyName("who");
                    writer.WriteValue(revision.Fields["Changed By"].Value);

                    writer.WritePropertyName("comment");
                    writer.WriteValue(history);

                    writer.WriteEndObject();
                }
            }

            writer.WriteEndArray();
        }
Ejemplo n.º 3
0
        public void RevisionCollection()
        {
            //ExStart
            //ExFor:Revision.ParentStyle
            //ExFor:RevisionCollection.GetEnumerator
            //ExFor:RevisionCollection.Groups
            //ExFor:RevisionCollection.RejectAll
            //ExFor:RevisionGroupCollection.GetEnumerator
            //ExSummary:Shows how to work with a document's collection of revisions.
            Document           doc       = new Document(MyDir + "Revisions.docx");
            RevisionCollection revisions = doc.Revisions;

            // This collection itself has a collection of revision groups.
            // Each group is a sequence of adjacent revisions.
            Assert.AreEqual(7, revisions.Groups.Count); //ExSkip
            Console.WriteLine($"{revisions.Groups.Count} revision groups:");

            // Iterate over the collection of groups and print the text that the revision concerns.
            using (IEnumerator <RevisionGroup> e = revisions.Groups.GetEnumerator())
            {
                while (e.MoveNext())
                {
                    Console.WriteLine($"\tGroup type \"{e.Current.RevisionType}\", " +
                                      $"author: {e.Current.Author}, contents: [{e.Current.Text.Trim()}]");
                }
            }

            // Each Run that a revision affects gets a corresponding Revision object.
            // The revisions' collection is considerably larger than the condensed form we printed above,
            // depending on how many Runs we have segmented the document into during Microsoft Word editing.
            Assert.AreEqual(11, revisions.Count); //ExSkip
            Console.WriteLine($"\n{revisions.Count} revisions:");

            using (IEnumerator <Revision> e = revisions.GetEnumerator())
            {
                while (e.MoveNext())
                {
                    // A StyleDefinitionChange strictly affects styles and not document nodes. This means the "ParentStyle"
                    // property will always be in use, while the ParentNode will always be null.
                    // Since all other changes affect nodes, ParentNode will conversely be in use, and ParentStyle will be null.
                    if (e.Current.RevisionType == RevisionType.StyleDefinitionChange)
                    {
                        Console.WriteLine($"\tRevision type \"{e.Current.RevisionType}\", " +
                                          $"author: {e.Current.Author}, style: [{e.Current.ParentStyle.Name}]");
                    }
                    else
                    {
                        Console.WriteLine($"\tRevision type \"{e.Current.RevisionType}\", " +
                                          $"author: {e.Current.Author}, contents: [{e.Current.ParentNode.GetText().Trim()}]");
                    }
                }
            }

            // Reject all revisions via the collection, reverting the document to its original form.
            revisions.RejectAll();

            Assert.AreEqual(0, revisions.Count);
            //ExEnd
        }
 /// <summary>Default Constructor</summary>
 public RevisionPasajeroInstance(ONContext onContext) : base(onContext, "RevisionPasajero", "Clas_1348178673664478_Alias")
 {
     Oid = new RevisionPasajeroOid();
     RevisionRoleTemp            = null;
     RevisionRoleOidTemp         = null;
     PasajeroAeronaveRoleTemp    = null;
     PasajeroAeronaveRoleOidTemp = null;
     StateObjAttrTemp            = null;
 }
Ejemplo n.º 5
0
        public static List <Revision> ToList(this RevisionCollection revCollection)
        {
            List <Revision> revisions = new List <Revision>();

            foreach (Revision revision in revCollection)
            {
                revisions.Add(revision);
            }
            return(revisions);
        }
 private SortedDictionary <int, RevisionItem> GetRevisionItems(RevisionCollection tfsRevisions)
 {
     return(new SortedDictionary <int, RevisionItem>((from Revision x in tfsRevisions
                                                      select new RevisionItem()
     {
         Index = x.Index,
         Number = (int)x.Fields["System.Rev"].Value,
         ChangedDate = (DateTime)x.Fields["System.ChangedDate"].Value,
         Type = x.Fields["System.WorkItemType"].Value as string,
         Fields = GetFieldItems(x.Fields)
     }).ToDictionary(r => r.Number, r => r)));
 }
Ejemplo n.º 7
0
        internal static RevisionCollectionWrapper GetInstance()
        {
            RevisionCollection real = default(RevisionCollection);

            RealInstanceFactory(ref real);
            var instance = (RevisionCollectionWrapper)RevisionCollectionWrapper.GetWrapper(real);

            InstanceFactory(ref instance);
            if (instance == null)
            {
                Assert.Inconclusive("Could not Create Test Instance");
            }
            return(instance);
        }
        public async Task <Response <RevisionCollection> > ListRevisionsAsync(string subscriptionId, string resourceGroupName, string containerAppName, string filter = null, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
            Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
            Argument.AssertNotNullOrEmpty(containerAppName, nameof(containerAppName));

            using var message = CreateListRevisionsRequest(subscriptionId, resourceGroupName, containerAppName, filter);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

            switch (message.Response.Status)
            {
            case 200:
            {
                RevisionCollection value = default;
                using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);

                value = RevisionCollection.DeserializeRevisionCollection(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
        public override void Copy(ONInstance instance)
        {
            RevisionPasajeroInstance linstance = instance as RevisionPasajeroInstance;

            Oid = new RevisionPasajeroOid(linstance.Oid);

            RevisionRoleTemp = linstance.RevisionRoleTemp;
            if (linstance.RevisionRoleOidTemp != null)
            {
                RevisionRoleOidTemp = new RevisionOid(linstance.RevisionRoleOidTemp);
            }
            PasajeroAeronaveRoleTemp = linstance.PasajeroAeronaveRoleTemp;
            if (linstance.PasajeroAeronaveRoleOidTemp != null)
            {
                PasajeroAeronaveRoleOidTemp = new PasajeroAeronaveOid(linstance.PasajeroAeronaveRoleOidTemp);
            }
            StateObj = new ONString(linstance.StateObj);

            base.Copy(instance);
        }
Ejemplo n.º 10
0
        private async void GetRevisionData()
        {
            await Task.Run(async() =>
            {
                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    RevisionProgressBar.Visibility = Visibility.Visible;
                });

                const string URL = @"https://costudio1122.blogspot.com/p/standard-korean-dictionary-revisions.html";

                HtmlWeb client        = new HtmlWeb();
                HtmlDocument document = client.Load(URL);

                HtmlNodeCollection revisions = document.DocumentNode.SelectNodes("//revision");
                HtmlNode versionTarget       = null;

                foreach (HtmlNode revisionNode in revisions)
                {
                    if (revisionNode.Attributes["version"].Value == "1")
                    {
                        versionTarget = revisionNode;
                        break;
                    }
                }

                if (versionTarget == null)
                {
                    throw new Exception("올바른 versionTarget이 없습니다.");
                }

                HtmlNodeCollection years = versionTarget.SelectNodes("./year");
                foreach (HtmlNode yearNode in years)
                {
                    RevisionCollection year = new RevisionCollection(yearNode.Attributes["year"].Value);

                    HtmlNodeCollection articles = yearNode.SelectNodes("./a");
                    foreach (HtmlNode articleNode in articles)
                    {
                        year.Add(articleNode.InnerText, articleNode.Attributes["href"].Value);
                    }

                    await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        collections.Add(year);
                    });
                }

                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    RevisionProgressBar.Visibility = Visibility.Collapsed;
                    RevisionPivot.Visibility       = Visibility.Visible;
                });
            }).ContinueWith(async(t) =>
            {
                if (t.IsFaulted)
                {
                    await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        RevisionProgressBar.Visibility = Visibility.Collapsed;
                        NetNoticeGrid.Visibility       = Visibility.Visible;
                    });
                }
            });
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Executes the SQL statment over the Data Base connected
        /// </summary>
        /// <param name="onSql">This parameter has the current SQL statment</param>
        /// <param name="onFilterList">List of filters to check</param>
        /// <param name="comparer">This parameter has all the information refering to the order criteria to add to SQL statment</param>
        /// <param name="startRowOid">This parameter has the OID necessary to start the search</param>
        /// <param name="blockSize">This parameter represents the number of instances to be returned</param>
        public override ONCollection ExecuteSql(ONSql onSql, ONFilterList onFilterList, ONDisplaySet displaySet, ONOrderCriteria orderCriteria, ONOid startRowOid, int blockSize)
        {
            RevisionCollection lQuery = null;
            bool lWithStartRow        = (startRowOid != null).TypedValue;
            long lCount = -1;

            if (!lWithStartRow)
            {
                lCount = 0;
            }

            IDataReader     lDataReader      = null;
            ONSQLConnection lOnSQLConnection = null;

            try
            {
                lDataReader = Execute(onSql) as IDataReader;

                RevisionInstance lInstance    = null;
                RevisionInstance lAntInstance = null;
                if (lDataReader != null)
                {
                    object[] lColumns;
                    if (displaySet == null)
                    {
                        lColumns = new object[6];
                    }
                    else
                    {
                        lColumns = new object[displaySet.ElementsInData];
                    }

                    lQuery = new RevisionCollection(OnContext);
                    bool lFoundStartRow = false;
                    while (lDataReader.Read())
                    {
                        lAntInstance = lInstance;

                        // Read Columns
                        lDataReader.GetValues(lColumns);

                        // Read Instance
                        int lIndex = 0;
                        lInstance = LoadFacet(OnContext, displaySet, lColumns, ref lIndex);

                        // Read related attributes
                        if (displaySet != null)
                        {
                            LoadRelated(OnContext, displaySet, lColumns, lIndex, lInstance);
                        }

                        if (lCount >= 0)                         // Add the load instance
                        {
                            if ((onFilterList == null) || (!onFilterList.InMemory))
                            {
                                // Add to the Instance list
                                lQuery.Add(lInstance);
                                lCount++;
                            }
                            else
                            {
                                ONSQLConnection lSQLConnectionOld = (ONSQLConnection)lInstance.OnContext.SqlConnection;

                                // Set another connection because it is imposible to use
                                // the same connection that is used in the DataReader
                                if (lOnSQLConnection == null)
                                {
                                    lOnSQLConnection = GetConnection();
                                }
                                lInstance.OnContext.SqlConnection = lOnSQLConnection;

                                if (onFilterList.FilterInMemory(lInstance))
                                {
                                    // Add to the Instance list
                                    lQuery.Add(lInstance);
                                    lCount++;
                                }

                                lInstance.OnContext.SqlConnection = lSQLConnectionOld;
                            }
                        }
                        else
                        {
                            if ((orderCriteria != null) && (orderCriteria.InMemory))                             // Need to load for ordering in memory after loading
                            {
                                if (lAntInstance != null)
                                {
                                    // Set another connection because it is imposible to use
                                    // the same connection that is used in the DataReader
                                    ONSQLConnection lOnSQLConnectionOld = lInstance.OnContext.SqlConnection as ONSQLConnection;
                                    if (lOnSQLConnection == null)
                                    {
                                        lOnSQLConnection = GetConnection();
                                    }
                                    lInstance.OnContext.SqlConnection = lOnSQLConnection;

                                    int lCompare = orderCriteria.CompareSql(lInstance, lAntInstance);
                                    if (lCompare != 0)
                                    {
                                        if (lFoundStartRow)
                                        {
                                            lCount = 1;
                                        }
                                        else
                                        {
                                            lQuery.Clear();
                                        }
                                    }

                                    // Restores the old connection
                                    lInstance.OnContext.SqlConnection = lOnSQLConnectionOld;
                                }

                                if ((onFilterList == null) || (!onFilterList.InMemory))
                                {
                                    // Add to the Instance list
                                    lQuery.Add(lInstance);
                                }
                                else
                                {
                                    ONSQLConnection lSQLConnectionOld = (ONSQLConnection)lInstance.OnContext.SqlConnection;

                                    // Set another connection because it is imposible to use
                                    // the same connection that is used in the DataReader
                                    if (lOnSQLConnection == null)
                                    {
                                        lOnSQLConnection = GetConnection();
                                    }
                                    lInstance.OnContext.SqlConnection = lOnSQLConnection;

                                    if (onFilterList.FilterInMemory(lInstance))
                                    {
                                        // Add to the Instance list
                                        lQuery.Add(lInstance);
                                    }
                                    else
                                    {
                                        lCount--;
                                    }

                                    lInstance.OnContext.SqlConnection = lSQLConnectionOld;
                                }

                                if (lInstance.Oid.Equals(startRowOid))
                                {
                                    lFoundStartRow = true;
                                }
                            }

                            else if (lInstance.Oid.Equals(startRowOid))                             // Search the start row
                            {
                                lCount = 0;
                            }
                        }

                        // Stop loading
                        if ((blockSize != 0) && (lCount > blockSize))
                        {
                            if (orderCriteria == null)
                            {
                                break;
                            }
                            else
                            {
                                // Set another connection because it is imposible to use
                                // the same connection that is used in the DataReader
                                ONSQLConnection lOnSQLConnectionOld = lInstance.OnContext.SqlConnection as ONSQLConnection;
                                if (lOnSQLConnection == null)
                                {
                                    lOnSQLConnection = GetConnection();
                                }
                                lInstance.OnContext.SqlConnection = lOnSQLConnection;

                                int lCompare = orderCriteria.CompareSql(lInstance, lAntInstance);

                                // Restores the old connection
                                lInstance.OnContext.SqlConnection = lOnSQLConnectionOld;

                                if (lCompare > 0)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                string ltraceItem = "Method: ExecuteSql, Component: RevisionData";
                if (e is ONSystemException)
                {
                    ONSystemException lException = e as ONSystemException;
                    lException.addTraceInformation(ltraceItem);
                    throw lException;
                }
                throw new ONSystemException(e, ltraceItem);
            }
            finally
            {
                if (lOnSQLConnection != null)
                {
                    ONDBData.CloseConnection(lOnSQLConnection);
                }
                if (lDataReader != null)
                {
                    if (mSqlCommand != null)
                    {
                        mSqlCommand.Cancel();
                    }
                    lDataReader.Close();
                }
                Close();
                if ((onFilterList != null) && (onFilterList.InMemory) && !lWithStartRow && (lCount <= blockSize))
                {
                    lQuery.totalNumInstances = lQuery.Count;
                }
            }

            return(lQuery);
        }
Ejemplo n.º 12
0
        private string GetFullHistory(WorkItem item)
        {
            RevisionCollection revisions = item.Revisions;

            return(Newtonsoft.Json.JsonConvert.SerializeObject(revisions, this.SerializerSettings));
        }
Ejemplo n.º 13
0
 static partial void RealInstanceFactory(ref RevisionCollection real, [CallerMemberName] string callerName = "");