Пример #1
0
        private static void NicknameOperations(AppsService service)
        {
            // Create a new nickname.
            NicknameEntry insertedEntry = service.CreateNickname(testUserName, testNickname);
            Console.WriteLine("Created nickname '{0}' for user {1}", insertedEntry.Nickname.Name,
                insertedEntry.Login.UserName);

            // Retrieve the newly-created nickname.
            NicknameEntry entry = service.RetrieveNickname(testNickname);
            Console.WriteLine("Retrieved nickname {0}", entry.Nickname.Name);

            // Retrieve all nicknames for testUserName (really, just this one).
            NicknameFeed feed = service.RetrieveNicknames(testUserName);
            entry = feed.Entries[0] as NicknameEntry;
            Console.WriteLine("Retrieved nickname '{0}' for user {1}", entry.Nickname.Name,
                entry.Login.UserName);

            // Retrieve a page of nicknames.
            feed = service.RetrievePageOfNicknames(testNickname);
            entry = feed.Entries[0] as NicknameEntry;
            Console.WriteLine("Retrieved page of {0} nicknames, beginning with '{1}'",
                feed.Entries.Count, entry.Nickname.Name);

            // Retrieve the feed of all nicknames.
            feed = service.RetrieveAllNicknames();
            entry = feed.Entries[0] as NicknameEntry;
            Console.WriteLine("Retrieved all {0} nicknames in the domain, beginning with '{1}'",
                feed.Entries.Count, entry.Nickname.Name);
        }
Пример #2
0
        public DataTable Get_Gmail_Nicknames(AppsService service, GmailUsers gusersyn, string table, LogFile log)
        {
            // nicknames retrieval
            DataTable returnvalue = new DataTable();
            DataRow row;

            returnvalue.TableName = table;

            int i = 0;
            int count = 0;
            string nickname = "";
            returnvalue.Columns.Add(gusersyn.Writeback_primary_key);
            returnvalue.Columns.Add("nickname");
            returnvalue.Columns.Add("Email");

            try
            {
                NicknameFeed usersNicknameList = service.RetrieveAllNicknames();
                count = usersNicknameList.Entries.Count;
                //result.AppendText("domain " + service.Domain + "\n");
                //result.AppendText("app name " + service.ApplicationName + "\n");
                //result.AppendText("users " + count + "\n");
                row = returnvalue.NewRow();
                for (i = 0; i < count; i++)
                {
                    NicknameEntry userNicknameEntry = usersNicknameList.Entries[i] as NicknameEntry;
                    // special handling for userID due to % being an illegal character using _ as an escape character
                    row[0] = (System.Web.HttpUtility.UrlDecode(userNicknameEntry.Login.UserName.ToString().Replace("_", "%")));
                    // decode names due to encoding to remove <>= characters
                    nickname = (System.Web.HttpUtility.UrlDecode(userNicknameEntry.Nickname.Name.ToString()));
                    row[1] = nickname;
                    row[2] = nickname + "@" + gusersyn.Admin_domain.ToString();

                    returnvalue.Rows.Add(row);
                    row = returnvalue.NewRow();
                }
            }
            catch (Exception ex)
            {
                log.addTrn("failed to pull gmail nickname list exception " + ex.Message.ToString() + "\n" + ex.StackTrace.ToString(), "Error");
            }
            return returnvalue;
        }