Esempio n. 1
0
        private void button5_Click(object sender, EventArgs e)
        {
            //decodr.Text = encodr.Text.ToString().Replace("<", "%3c").Replace(">", "%3e").Replace("=", "%3d").Replace("%", "%25");
            AppsService service = new AppsService("students.fhchs.edu", "*****@*****.**", "abc123");
            //UserEntry gmailUser = service.RetrieveUser(encodr.Text.ToString());
            //MessageBox.Show("base check dirt after content set dirty " + gmailUser.Login.AgreedToTerms.ToString() + " " + gmailUser.Login.UserName);
            //gmailUser.Login.AgreedToTerms = true;
            //service.UpdateUser(gmailUser);
            //MessageBox.Show("base check dirt after content set dirty  and update performed " + gmailUser.Login.AgreedToTerms.ToString() + " " + gmailUser.Login.UserName);

            SqlConnection sqlConn = new SqlConnection("Data Source=" + DBserver.Text + ";Initial Catalog=" + Catalog.Text + ";Integrated Security=SSPI;");
            string user = "";
            SqlCommand sqlComm = new SqlCommand("select FHC_test2_gmailnicknamestable.nickname, FHC_test2_gmailnicknamestable.soc_sec from FHC_test2_gmailnicknamestable where FHC_test2_gmailnicknamestable.nickname like '%.__.%'", sqlConn);
            // create the command object
            SqlDataReader r;
            sqlConn.Open();
            try
            {
                r = sqlComm.ExecuteReader();
                log.addTrn(sqlComm.CommandText.ToString(), "Query");
                while(r.Read())
                {
                    user = (string)r[0];
                    try
                    {
                        user = user.Remove(user.IndexOf("@students"));
                    }
                    catch
                    { }
                    try
                    {
                        service.DeleteNickname(user);
                    }
                    catch
                    {
                        log.addTrn("deletiing failed " + user, "Transaction");
                    }
                    log.addTrn("deleted nickname " + user, "Transaction");
                }
            }
            catch (Exception ex)
            {
                log.addTrn("Failed SQL command " + sqlComm.CommandText.ToString() + " error " + ex.Message.ToString() + "\n" + ex.StackTrace.ToString(), "Query");
            }
        }
Esempio n. 2
0
        private static void CleanUp(AppsService service)
        {
            // Delete the group that was created
            service.Groups.DeleteGroup(testGroup);
            Console.WriteLine("Deleted group {0}", testGroup);

            // Delete the nickname that was created.
            service.DeleteNickname(testNickname);
            Console.WriteLine("Deleted nickname {0}", testNickname);

            // Delete the user that was created.
            service.DeleteUser(testUserName);
            Console.WriteLine("Deleted user {0}", testUserName);            
        }
Esempio n. 3
0
        public void NicknameUpdate(AppsService service, SqlDataReader nicknames, string usernameFieldName, string userNicknameField, LogFile log)
        {
            // updates nicknames in gmail from sql data reader containing user ids and nicknames
            // finds the user with the ID listed and returns all the nicknames for that user
            // iterates trhrough the nicknames and delets all those which do not mathch the nickname from the usernickname field
            // if the nickname from the usernickname field does not exist it will be created fro the user listed
            //
            // usernameFieldName    userNicknameField
            // ------------------------------------
            // ID               |   Nickname
            // ------------------------------------
            // SB289312         |   test.user
            //
            //

            int i = 0;
            int nicknamecount = 0;
            bool foundnickname = false;
            try
            {
                while (nicknames.Read())
                {
                    // get all nicknames for user who has the wrong nickname
                    NicknameFeed userNicknames;
                    userNicknames = service.RetrieveNicknames(nicknames[usernameFieldName].ToString());

                    // get the count so we can iterate over them\

                    nicknamecount = userNicknames.Entries.Count;
                    // iterate and delete all nicknames that are not equal to the correct nickname
                    for (i = 0; i < nicknamecount; i++)
                    {
                        try
                        {

                            NicknameEntry nicknameEntry = userNicknames.Entries[nicknamecount] as NicknameEntry;
                            if (nicknameEntry.Nickname.Name.ToString() == nicknames[userNicknameField].ToString())
                            {
                                foundnickname = true;
                            }
                            else
                            {
                                service.DeleteNickname(nicknameEntry.Nickname.Name.ToString());
                                log.addTrn("Deleting user nickname " + nicknameEntry.Nickname.Name.ToString(), "Transaction");
                            }
                        }
                        catch
                        {
                            log.addTrn("Error deleting user nickname " + nicknames[userNicknameField].ToString(), "Error");
                        }
                    }
                    // if the nickname is not found create the new nickname
                    if (foundnickname == false)
                    {
                        try
                        {
                            service.CreateNickname(nicknames[usernameFieldName].ToString(), nicknames[userNicknameField].ToString());
                            log.addTrn("Creating user nickname " + nicknames[userNicknameField].ToString() + " for user " + nicknames[usernameFieldName].ToString(), "Transaction");
                        }
                        catch
                        {
                            log.addTrn("Error adding user nickname " + nicknames[userNicknameField].ToString() + " for user " + nicknames[usernameFieldName].ToString(), "Error");
                        }
                    }
                    // reset all variables
                    foundnickname = false;
                    i = 0;
                    nicknamecount = 0;
                }
            }
            catch (Exception ex)
            {
                log.addTrn("Issue updating nicknames datareader is null " + ex.Message.ToString() + "\n" + ex.StackTrace.ToString(), "Error");
            }
        }