コード例 #1
0
        public Responses.SlackFilesListResponse Files_List
        (
            String user_id = null,
            Models.SlackFileType file_types = null,
            UInt64 count      = 100,
            UInt64 page       = 1,
            String channel_id = null,
            String ts_from    = null,
            String ts_to      = null
        )
        {
            if (!IsAuthorized)
            {
                return(null);
            }

            Dictionary <String, String> parameters = new Dictionary <string, string>();

            parameters["token"]   = _access_token;
            parameters["types"]   = file_types.ToString();
            parameters["user"]    = user_id;
            parameters["channel"] = channel_id;
            parameters["count"]   = Convert.ToString(count);
            parameters["page"]    = Convert.ToString(page);
            parameters["ts_from"] = ts_from;
            parameters["ts_to"]   = ts_to;

            Uri files_list_uri = GetApiUri("files.list", parameters);

            Responses.SlackFilesListResponse fileListResponse = JsonConvert.DeserializeObject <Responses.SlackFilesListResponse>(NetHelper.GetRequest(files_list_uri));

            return(fileListResponse);
        }
コード例 #2
0
        public void GetPhotos()
        {
            SlackHelper slackHelper = null;

            for (int i = 0; i < users_helpers.Count; i++)
            {
                Responses.SlackUsersInfoResponse usersInfoResponse = users_helpers[i].Users_Info(applicationContract.GetPhotoUserID());

                if (usersInfoResponse.Ok)
                {
                    slackHelper = users_helpers[i];
                    break;
                }
            }

            if (!slackHelper.IsAuthorized)
            {
                return;
            }

            const UInt64 count = 20;
            UInt64       page  = applicationContract.GetPhotosCount() / count + 1;

            Responses.SlackFilesListResponse slackFilesListResponse = slackHelper.Files_List(applicationContract.GetPhotoUserID(), Models.SlackFileTypes.Images, count, page);

            if (!slackFilesListResponse.Ok)
            {
                return;
            }

            List <Models.SlackFile> files = slackFilesListResponse.Files.ToList();

            List <PhotosListItem> photosItems = new List <PhotosListItem>();

            foreach (Models.SlackFile file in files)
            {
                if (!file.PublicURLShared)
                {
                    continue;
                }

                String[] permalink_split = file.PermalinkPublic.Split('-');
                String   photo_link      = String.Format("{0}?pub_secret={1}", file.URLPrivate, permalink_split[permalink_split.Length - 1]);

                PhotosListItem photoItem = new PhotosListItem(new Uri(photo_link));

                photosItems.Add(photoItem);
            }

            applicationContract.AddItemsToPhotosList(photosItems);
            applicationContract.SetPhotosListSatusData(String.Format("{0}/{1}", applicationContract.GetPhotosCount(), slackFilesListResponse.Paging.Total));
            if (applicationContract.GetPhotosCount() == slackFilesListResponse.Paging.Total)
            {
                applicationContract.DisableNextPhotosButton();
            }
        }