The user account I'm trying is "acslab2" - I'm putting that into an
array.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Data.SqlClient;
using System.Data;
using System.Threading;
using Google.GData.Apps;
using Google.GData.Extensions;
using Google.GData.Extensions.Apps;
using Google.GData.Client;
using System.IO;

namespace Listof100users
{
    class Program
    {

        static void Main(string[] args)
        {
                    ArrayList topHolder = new ArrayList();
            ArrayList Students = new ArrayList();

           // Only giving it one value to test
           //
           topHolder.Add("acslib2");

            GoogleToken.InitService();

            for (int i = 0; i < topHolder.Count; i++)
            {
                Console.WriteLine("Top Holder is: " + topHolder
[i].ToString());

                    try
                    {
                        UserFeed feed = GoogleToken.GoogleConnect
().RetrievePageOfUsers( topHolder[i].ToString() );

                        for (int k = 0; k < feed.Entries.Count; k++)
                        {
                            UserEntry entry = feed.Entries[k] as UserEntry;
                            Students.Add(entry.Login.UserName + "," +
entry.Name.GivenName + "," + entry.Name.FamilyName);
                            Console.WriteLine(entry.Login.UserName + "," +
entry.Name.GivenName + "," + entry.Name.FamilyName);
                        }

                        Console.WriteLine("Count is: " +
Program.Students.Count);

                    }  // try

                    catch (Exception e)
                    {
                        Console.WriteLine(e.ToString());
                    }
            }  // for

            foreach (string s in Students)
            {
                writer.WriteLine( s.ToString() );
            }

            writer.Close();

        }  // main

    }  // class




    class GoogleToken
    {

        public static string DOMAIN = "XXXXXXXX.edu";
        public static string USERNAME = "XXXXXXXXX.edu";
        public static string PASSWORD = "XXXXX";

        public static string token = null;

        public static Service service;
        public static AppsService APPSservice;

        public static void InitService()
        {

            service = new Service(AppsNameTable.GAppsService,
                       "APP-1.0", AppsNameTable.GAppsAgent);

            service.setUserCredentials(USERNAME, PASSWORD);

            //
            // Check to see if file exists, if not create a file with
the token
            //
            if (File.Exists("C:\\token.txt"))
            {
                DateTime fileCreate = File.GetCreationTime("C:\
\token.txt");

                // Make sure it was less than 23 hours, else we need a
new token
                if ((DateTime.Now - fileCreate).TotalHours < 23)
                {
                    // Open the file, read and set the token
                    StreamReader read = new StreamReader("C:\
\token.txt");
                    token = read.ReadLine();
                    read.Close();
                }
                // Past 24 Hours, get a new token
                //
                else
                {
                    token = service.QueryAuthenticationToken();

                    // Delete the old C:\token.txt file
                    //
                    File.Delete("C:\\token.txt");

                    StreamWriter write = new StreamWriter("C:\
\token.txt");
                    write.WriteLine(token);
                    write.Close();
                }

            }

            else  // No token.txt file, get a token and store it in
the file
            {
                token = service.QueryAuthenticationToken();

                StreamWriter write = new StreamWriter("C:\
\token.txt");
                write.WriteLine(token);
                write.Close();
            }

            APPSservice = new AppsService(DOMAIN, token);

        }

        public static AppsService GoogleConnect()
        {
            //
            // Return the Google Apps Object
            //
            return (APPSservice);

        }
    }  // class
} // namespace


On Feb 11, 8:38 pm, "Tony (Google)" <[email protected]> wrote:
> Hi Fred,
>
> Can we share with us the code you use to make the call to
> RetrievePageOfUsers with the username at record 22,601?  Please feel
> free to raise a support request if you prefer to do it privately.
>
> Thanks,
>
> --Tony
>
> On Feb 11, 5:30 pm, NCCFred <[email protected]> wrote:
>
>
>
> > Hi Julian,
>
> > I got the same result today using a single threaded application.
> > Here's a summary of my application and I guess we can try and pin
> > point what my error is.
>
> > I have a SQL Server 2005 database base table called "GoogleMaster".
> > In this table I keep an exact copy of the accounts we have with
> > Google, this contains username, firstname, lastname, password, term
> > and timestamp.  I also created a SQL stored procedure that will return
> > the first value or "TOP" for every 100 users and store that in an
> > array.
>
> > I believe we have 22,689 email accounts with Google, so the length of
> > my array should be 227, to illustrate:
>
> > array[0] = starting username for accounts 1-100  (length = 100)
> > array[1] = starting username for accounts 101-200 (length = 100)
> > ..
> > array[225] = starting username for accounts 22,501-22,600 (length =
> > 100)
> > array[226] = starting username for accounts 22,601-22,689 (length =
> > 89)  <=== This is my problem
>
> > In my single thread model I use a for loop:
>
> > for(int z=0; z < array.Length; z++) {
>
> > UserFeedObject  =  RetrievePageOfUsers( array[z].ToString() );
> > // Code to add UserFeedObject's firstname to another array
>
> > }
>
> > Everything goes as planned, just as a visual I have the length of the
> > array print on the screen as the data gets added to it.  When it's
> > time for the remaining 89 records - it never ends successfully and
> > times out.  That's why in my first post I was wondering if the
> > resulting UserFeed is less than 100 records will there be a problem.
> > I can email you or post my code for you to look at.
>
> > As another test I made a simple application that only made one
> > function call to  RetrievePageOfUsers with the username at record
> > number 22,601 and I got the same result.
>
> > Does this help?
>
> > Would you mind posting your solution, maybe I'm totally missing
> > something here.
>
> > On Feb 11, 8:56 am, "Julian (Google)" <[email protected]> wrote:
>
> > > Hi,
>
> > > I am not able to reproduce the problem with a single thread using
> > > the .NET client library. Please, share more details of your
> > > implementation if you can.
>
> > > Cheers,
> > > Julian.
>
> > > On Feb 10, 7:06 pm, NCCFred <[email protected]> wrote:
>
> > > > Hello Group,
>
> > > > I had a question about the RetrievePageOfUsers function.  I understand
> > > > the function takes a starting username and it will return a list of
> > > > 100 users – starting from the given name, inclusively.
>
> > > > I’ve had some odd behavior in my application and narrowed it down to
> > > > this function.  My application is a multi-threaded GUI in C# that
> > > > spawns a maximum of 10 concurrent threads to Google while iterating
> > > > through an array that contains all beginning account Id’s for each set
> > > > of 100 users (our domain has 22,673 email accounts).  I noticed the
> > > > last call of this function, which does not return 100 accounts because
> > > > only 73 are remaining will eventually time out.
>
> > > > Why would this be happening? Is there something in the documentation
> > > > or some unwritten rule that states if it’s less than 100 users being
> > > > returned then it won’t return anything?  I’ve tried this with a small
> > > > application to isolate this and came up with the same result.
>
> > > > Any ideas?- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Apps APIs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-apps-apis?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to