コード例 #1
0
        public static void CreateActivity(SqlString url, SqlString username, SqlString password, SqlString token, SqlString employeeId, SqlXml messageBlob)
        {
            IChatterService service = new ChatterService(url.Value);
            service.AllowUntrustedConnection();
            service.Login(username.Value, password.Value, token.Value);

            CreateProfileActivity(service, employeeId.Value, messageBlob.Value);
        }
コード例 #2
0
            static Task ChatBufferHint(IAsyncStreamReader <ChatMessage> requestStream, IServerStreamWriter <ChatMessage> responseStream, ServerCallContext context)
            {
                context.WriteOptions = new WriteOptions(WriteFlags.BufferHint);

                return(ChatterService.ChatCore(requestStream, responseStream));
            }
コード例 #3
0
        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};
            }
        }
コード例 #4
0
        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;
        }