static void Menu_ViewUser(InputEventArgs e) { MatchPattern[] patterns = new MatchPattern[] { new MatchPattern("-uid", true), new MatchPattern("-all", false) }; Dictionary<string, string> parameters = Menu.ParseInput(e.Input, patterns); string uid = string.Empty; if (parameters.ContainsKey("-uid")) { uid = parameters["-uid"]; Yammer.User user = Yammer.User.GetUserByUserName(uid); if (user != null) { object[] args = new object[] { user.Name, user.JobTitle, user.MugshotUrl, user.WebUrl, user.Contact.PhoneNumbers[0].Number, user.Location }; Console.WriteLine(string.Format("UserName:{0}\r\nTitle:{1}\r\nAvatar:{2}\r\nUrl:{3}\r\nMobilePhone:{4}\r\nLocation:{5}", args)); } else Console.WriteLine("User not found"); } else if (parameters.ContainsKey("-all")) { List<Yammer.User> users = Yammer.User.GetAllUsers(); foreach (Yammer.User u in users) { object[] args = new object[] { u.Name, u.JobTitle, u.MugshotUrl, u.WebUrl, u.Contact.PhoneNumbers.Count > 0 ? u.Contact.PhoneNumbers[0].Number : string.Empty, u.Location }; Console.WriteLine(string.Format("UserName:{0}\r\nTitle:{1}\r\nAvatar:{2}\r\nUrl:{3}\r\nMobilePhone:{4}\r\n\r\nLocation:{5}", args)); } } }
static void Menu_PostMessage(InputEventArgs e) { MatchPattern[] patterns = new MatchPattern[] { new MatchPattern("-m", true), new MatchPattern("-a", true) }; Dictionary<string, string> parameters = Menu.ParseInput(e.Input, patterns); string body = string.Empty; if (parameters.ContainsKey("-m")) body = parameters["-m"]; List<string> attachmentList = new List<string>(); if (parameters.ContainsKey("-a")) attachmentList.AddRange(parameters["-a"].Split(';')); //post message Yammer.Message.PostMessage(body, attachmentList); }
static void Menu_DeleteUser(InputEventArgs e) { MatchPattern[] patterns = new MatchPattern[] { new MatchPattern("-uid", true) }; Dictionary<string, string> parameters = Menu.ParseInput(e.Input, patterns); string uid = string.Empty; if (parameters.ContainsKey("-uid")) uid = parameters["-uid"]; if(uid != null && uid != string.Empty) Yammer.User.GetUserByUserName(uid).Delete(); }
static void Menu_CurrentUser(InputEventArgs e) { string input = e.Input; Yammer.User user = Yammer.User.GetCurrentUser(); object[] args = new object[] { user.Name, user.JobTitle, user.MugshotUrl, user.WebUrl, user.Contact.PhoneNumbers[0].Number, user.Location }; Console.WriteLine(string.Format("UserName:{0}\r\nTitle:{1}\r\nAvatar:{2}\r\nUrl:{3}\r\nMobilePhone:{4}\r\nLocation:{5}", args)); }
static void Menu_UpdateUser(InputEventArgs e) { MatchPattern[] patterns = new MatchPattern[] { new MatchPattern("-uid", true), new MatchPattern("-params", true) }; Dictionary<string, string> parameters = Menu.ParseInput(e.Input, patterns); string uid = string.Empty; if (parameters.ContainsKey("-uid")) uid = parameters["-uid"]; Yammer.User user = null; if (uid != null && uid != string.Empty) user = Yammer.User.GetUserByUserName(uid); string attributes = string.Empty; Yammer.UserParameters userParams = null; List<PropertyInfo> properties = null; string[] props = null; if (parameters.ContainsKey("-params")) { attributes = parameters["-params"]; props = attributes.Split(';'); userParams = new Yammer.UserParameters(); properties = new List<PropertyInfo>(userParams.GetType().GetProperties()); } foreach (string prop in props) { string[] hash = prop.Split('='); PropertyInfo property = properties.Find(delegate(PropertyInfo p) { return p.Name == hash[0]; }); if (property != null) property.SetValue(userParams, hash[1], null); } if(user != null) user.Save(userParams); }
public static void OnDeleteUser(InputEventArgs e) { if (DeleteUser != null) DeleteUser(e); }
public static void OnUpdateUser(InputEventArgs e) { if (UpdateUser != null) UpdateUser(e); }
public static void OnCurrentUser(InputEventArgs e) { if (CurrentUser != null) CurrentUser(e); }
public static void OnViewUser(InputEventArgs e) { if (ViewUser != null) ViewUser( e); }
public static void OnPostMessage(InputEventArgs e) { if (PostMessage != null) PostMessage(e); }