📄 galleryservice.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Security;
using System.Web.Services;
using System.Web.Services.Protocols;
using CommunityServer.Components;
namespace CommunityServer.Galleries.Components
{
/// <summary>
/// Summary description for GalleryService.
/// </summary>
[ WebService(Name="GalleryService",
Description="Community Server :: Photo Posting Web Service",Namespace="http://communityserver.org/gallery/services/posts/")]
public class GalleryService : CSWebServiceBase
{
public GalleryService()
{
}
public struct GalleryPost
{
public int PostID;
public string Subject;
public string Description;
public string Filename;
public byte[] PictureData;
}
#region Gallery Post
#endregion
#region Service Methods
//[WebMethod]
//public GalleryPost AddPicture( byte[] pictureData )
//{
//}
//[WebMethod]
//public void RemovePicture()
//{
//}
[WebMethod]
[SoapHeader("Credentials")]
public GalleryPost[] GetPictures()
{
GalleryThreadQuery query = new GalleryThreadQuery();
query.SectionID = currentGallery.SectionID;
query.PageSize = 100;
ArrayList pictures = Pictures.GetPictures(query).Threads;
GalleryPost[] posts = new GalleryPost[pictures.Count];
for(int i = 0 ; i < pictures.Count ; i++)
posts[i] = PictureToGalleryPost((Picture)pictures[i]);
return posts;
}
[WebMethod]
[SoapHeader("Credentials")]
public GalleryPost GetPicture(int pictureID )
{
Picture picture = Pictures.GetPicture(pictureID);
return PictureToGalleryPost(picture);
}
#endregion
#region Protected Methods
protected override void AllocateSection() {
if(Globals.IsNullorEmpty(Credentials.SectionName))
throw new SecurityException("Invalid (or unsupplied) Blogname");
ArrayList galleries = Galleries.GetGalleries();
foreach( Gallery gallery in galleries ) {
if( gallery.Name == Credentials.SectionName ) {
currentGallery = gallery;
break;
}
}
if(currentGallery == null)
throw new Exception("The requested gallery does not exist");
Permissions.AccessCheck(currentGallery,Permission.Post,CurrentUser);
return;
}
#endregion
#region Private Methods
private GalleryPost PictureToGalleryPost(Picture picture)
{
PostAttachment pictureData = Pictures.GetPictureData(picture.PostID);
GalleryPost post = new GalleryPost();
post.PostID = picture.PostID;
post.Subject = picture.Subject;
post.Description = picture.FormattedBody;
post.Filename = pictureData.FileName;
post.PictureData = pictureData.Content;
return post;
}
#endregion
#region Private Data
protected Gallery currentGallery = null;
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -