public void TestDeleteActivitiesFromDisabledProfiles() { List <int> peopleToDelete = new ProfilesServices().GetInactiveProfiles(); System.Diagnostics.Debug.WriteLine("Found " + peopleToDelete.Count + " people to remove from activity stream"); int total = 0; List <Activity> killList = null; do { killList = new List <Activity>(); try { IChatterSoapService service = new ChatterService.ChatterSoapService(_url); service.Login(_username, _password, _token); // just do 1000 at a time foreach (Activity act in service.GetProfileActivities((Activity)null, 200)) { if (peopleToDelete.Contains(act.ParentId)) { killList.Add(act); System.Diagnostics.Debug.WriteLine("Deleting " + act.Id + " : " + act.Message + " for " + act.ParentName); } } ((ChatterSoapService)service).DeleteActivities(killList); System.Diagnostics.Debug.WriteLine("Deleted " + killList.Count + " activities"); total += killList.Count; } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); } } while (killList.Count > 0); System.Diagnostics.Debug.WriteLine("Total removed = " + total); }
public CreateResult CreateGroup(Stream stream) { NameValueCollection p = parseParameters(stream); if (string.IsNullOrEmpty(p["name"])) { return new CreateResult() { Success = false, ErrorMessage = "Group name is required."}; } if (string.IsNullOrEmpty(p["ownerId"])) { return new CreateResult() { Success = false, ErrorMessage = "OwnerId is required." }; } try { int personId = Int32.Parse(p["ownerId"]); string descr = p["description"]; if (string.IsNullOrEmpty(descr)) { descr = p["name"]; } IProfilesServices profiles = new ProfilesServices(); string employeeId = profiles.GetEmployeeId(personId); IChatterService service = new ChatterService(url); service.Login(userName, password, token); string groupId = service.CreateGroup(p["name"], descr, employeeId); string users = p["users"]; if(!string.IsNullOrEmpty(users)) { string[] personList = users.Split(','); List<string> employeeList = new List<string>(); foreach (string pId in personList) { try { string eId = profiles.GetEmployeeId(Int32.Parse(pId)); employeeList.Add(eId); } catch (Exception ex) { //TODO: need to report it back to the server } } if (employeeList.Count > 0) { service.AddUsersToGroup(groupId, employeeList.ToArray<string>()); } } return new CreateResult() { Success = true}; } catch (Exception ex) { return new CreateResult() { Success = false, ErrorMessage = ex.Message}; } }
public Activity[] GetUserActivities(string userId, string mode, int count) { IProfilesServices profiles = new ProfilesServices(); IChatterService service = new ChatterService(url); service.Login(userName, password, token); int personId = Int32.Parse(userId); bool includeUserActivities = mode.Equals("all", StringComparison.InvariantCultureIgnoreCase); string employeeId = profiles.GetEmployeeId(personId); var ssUserId = service.GetUserId(employeeId); Activity[] result = service.GetActivities(ssUserId, personId, includeUserActivities, count).ToArray(); return result; }