Exemplo n.º 1
0
 /// <summary> Adds a single item result to this private item title </summary>
 /// <param name="New_Item"> Item to add to the collection for this title </param>
 public void Add_Item_Result(Private_Items_List_Item New_Item)
 {
     items.Add(New_Item);
 }
 /// <summary> Adds a single item result to this private item title </summary>
 /// <param name="New_Item"> Item to add to the collection for this title </param>
 public void Add_Item_Result( Private_Items_List_Item New_Item )
 {
     items.Add(New_Item);
 }
        private static List<Private_Items_List_Title> DataReader_To_Private_Items_List(SqlDataReader Reader)
        {
            // Create return list
            List<Private_Items_List_Title> returnValue = new List<Private_Items_List_Title>();

            Dictionary<int, int> lookup = new Dictionary<int, int>();

            // Get all the main title values first
            while (Reader.Read())
            {
                // Create new database title object for this
                Private_Items_List_Title result = new Private_Items_List_Title
                                                      {
                                                          RowNumber = Reader.GetInt32(0),
                                                          BibID = Reader.GetString(1),
                                                          Group_Title = Reader.GetString(2),
                                                          Type = Reader.GetString(3),
                                                          ALEPH_Number = Reader.GetInt32(4),
                                                          OCLC_Number = Reader.GetInt64(5),
                                                          Last_Activity_Date = Reader.GetDateTime(6),
                                                          Last_Milestone_Date = Reader.GetDateTime(7),
                                                          Complete_Item_Count = Reader.GetInt32(8),
                                                          Primary_Identifier_Type = Reader.GetString(9),
                                                          Primary_Identifier = Reader.GetString(10)
                                                      };

                returnValue.Add(result);

                lookup.Add(result.RowNumber, returnValue.Count - 1);
            }

            // Move to the item table
            Reader.NextResult();

            // If there were no titles, then there are no results
            if (returnValue.Count == 0)
                return returnValue;

            // Step through all the item rows, build the item, and add to the title
            Private_Items_List_Title titleResult = returnValue[0];
            int lastRownumber = titleResult.RowNumber;
            while (Reader.Read())
            {
                // Ensure this is the right title for this item
                int thisRownumber = Reader.GetInt32(0);
                if (thisRownumber != lastRownumber)
                {
                    titleResult = returnValue[lookup[thisRownumber]];
                    lastRownumber = thisRownumber;
                }

                // Create new database item object for this
                Private_Items_List_Item result = new Private_Items_List_Item
                                                     {
                                                         VID = Reader.GetString(1),
                                                         Title = Reader.GetString(2),
                                                         Internal_Comments = Reader.GetString(3),
                                                         PubDate = Reader.GetString(4),
                                                         Locally_Archived = Reader.GetBoolean(5),
                                                         Remotely_Archived = Reader.GetBoolean(6),
                                                         Aggregation_Codes = Reader.GetString(7),
                                                         Last_Activity_Date = Reader.GetDateTime(8),
                                                         Last_Activity_Type = Reader.GetString(9),
                                                         Last_Milestone = Reader.GetInt32(10),
                                                         Last_Milestone_Date = Reader.GetDateTime(11)
                                                     };

                // Add this to the title object
                titleResult.Add_Item_Result(result);
            }

            return returnValue;
        }