Пример #1
0
        /// <summary>
        /// 提交按钮点击方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            PhotoSizeInfo photoSize = new PhotoSizeInfo();

            photoSize.Id = RequestHelper.GetQueryString <int>("ID");
            int photoType = (int)PhotoType.Article;

            if (!int.TryParse(Type.SelectedValue, out photoType))
            {
                photoType = (int)PhotoType.Article;
            }
            photoSize.Type      = photoType;
            photoSize.Title     = Title.Text;
            photoSize.Introduce = Introduce.Text;
            photoSize.Width     = Convert.ToInt32(Width.Text) < 0 ? 0 : Convert.ToInt32(Width.Text);
            photoSize.Height    = Convert.ToInt32(Height.Text) < 0 ? 0 : Convert.ToInt32(Height.Text);

            string alertMessage = ShopLanguage.ReadLanguage("AddOK");

            if (photoSize.Id == int.MinValue)
            {
                CheckAdminPower("AddPhotoSize", PowerCheckType.Single);
                int id = PhotoSizeBLL.Add(photoSize);
                AdminLogBLL.Add(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("PhotoSize"), id);
            }
            else
            {
                CheckAdminPower("UpdatePhotoSize", PowerCheckType.Single);
                PhotoSizeBLL.Update(photoSize);
                AdminLogBLL.Add(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("PhotoSize"), photoSize.Id);
                alertMessage = ShopLanguage.ReadLanguage("UpdateOK");
            }
            ScriptHelper.Alert(alertMessage, "photosize.aspx");
        }
Пример #2
0
 public void Update(PhotoSizeInfo entity)
 {
     using (var conn = new SqlConnection(connectString))
     {
         string sql = @"UPDATE [PhotoSize] SET [Type]=@Type, Title = @Title,[Introduce]=@Introduce,[Width]=@Width,[Height]=@Height where Id=@Id";
         conn.Execute(sql, entity);
     }
 }
Пример #3
0
 public int Add(PhotoSizeInfo entity)
 {
     using (var conn = new SqlConnection(connectString))
     {
         string sql = @"INSERT INTO [PhotoSize]([Type],[Title],[Width],[Height],[Introduce]) VALUES(@Type,@Title,@Width,@Height,@Introduce);
                     select SCOPE_IDENTITY()";
         return(conn.Query <int>(sql, entity).Single());
     }
 }
Пример #4
0
 private static void AssertPhotoSizeInfo(PhotoSizeInfo photoSize)
 {
     Assert.Multiple(() =>
     {
         Assert.AreEqual(mFileId, photoSize.FileId);
         Assert.AreEqual(mWidth, photoSize.Width);
         Assert.AreEqual(mHeight, photoSize.Height);
         Assert.AreEqual(mFileSize, photoSize.FileSize);
     });
 }
        private PhotoAttachment ParsePhotoAttachment(JObject _jPhoto)
        {
            try
            {
                if (_jPhoto[PAttachmentsPhoto] is JObject photoJObj)
                {
                    var photoAttachment = new PhotoAttachment();

                    photoAttachment.Id        = photoJObj[PId].Value <int>();
                    photoAttachment.AlbumId   = photoJObj[PPhotoAlbumId].Value <int>();
                    photoAttachment.OwnerId   = photoJObj[PAttachmentOwnerId].Value <int>();
                    photoAttachment.UserId    = photoJObj[PPhotoUserId]?.Value <int>();
                    photoAttachment.Text      = photoJObj[PPhotoText]?.Value <string>();
                    photoAttachment.Date      = EpochTimeConverter.ConvertToDateTime(photoJObj[PDate].Value <long>());
                    photoAttachment.AccessKey = photoJObj[PAttachmentAccessKey]?.Value <string>();

                    var sizes = new List <PhotoSizeInfo>();

                    if (photoJObj[PPhotoSizes] is JArray jSizes)
                    {
                        foreach (var jSize in jSizes)
                        {
                            var type   = (PhotoSizeType)Enum.Parse(typeof(PhotoSizeType), jSize[PSizesType].Value <string>());
                            var url    = jSize[PUrl].Value <string>();
                            var width  = jSize[PSizesWidth].Value <int>();
                            var height = jSize[PSizesHeight].Value <int>();

                            var sizeInfo = new PhotoSizeInfo(type, url, width, height);

                            sizes.Add(sizeInfo);
                        }
                    }

                    photoAttachment.Sizes = sizes.ToArray();

                    return(photoAttachment);
                }
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException($"Failed to parse photo attachment \n {_jPhoto.ToString()}", ex);
            }

            throw new ArgumentException($"Failed recognize jObject as photo attachment \n {_jPhoto?.ToString()}");
        }
Пример #6
0
        /// <summary>
        /// 页面加载方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                int ID = RequestHelper.GetQueryString <int>("ID");

                if (ID != int.MinValue)
                {
                    CheckAdminPower("ReadPhotoSize", PowerCheckType.Single);
                    PhotoSizeInfo photoSize = PhotoSizeBLL.Read(ID);
                    Type.Text      = photoSize.Type.ToString();
                    Title.Text     = photoSize.Title;
                    Introduce.Text = photoSize.Introduce;
                    Width.Text     = photoSize.Width.ToString();
                    Height.Text    = photoSize.Height.ToString();
                }
            }
        }
Пример #7
0
        internal GameInfo(JObject jsonObject)
        {
            Title       = jsonObject["title"].Value <string>();
            Description = jsonObject["description"].Value <string>();
            Photo       = PhotoSizeInfo.ParseArray(jsonObject["photo"].Value <JArray>());

            if (jsonObject["text"] != null)
            {
                Text = jsonObject["text"].Value <string>();
            }
            if (jsonObject["text_entities"] != null)
            {
                Entities = MessageEntityInfo.ParseArray(jsonObject["text_entities"].Value <JArray>());
            }
            if (jsonObject["animation"] != null)
            {
                Animation = new AnimationInfo(jsonObject["animation"].Value <JObject>());
            }
        }
Пример #8
0
 internal AnimationInfo(JObject jsonObject)
 {
     FileId = jsonObject["file_id"].Value <string>();
     if (jsonObject["thumb"] != null)
     {
         Thumb = new PhotoSizeInfo(jsonObject["thumb"].Value <JObject>());
     }
     if (jsonObject["file_name"] != null)
     {
         FileName = jsonObject["file_name"].Value <string>();
     }
     if (jsonObject["mime_type"] != null)
     {
         MimeType = jsonObject["mime_type"].Value <string>();
     }
     if (jsonObject["file_size"] != null)
     {
         FileSize = jsonObject["file_size"].Value <int>();
     }
 }
Пример #9
0
 public static void Update(PhotoSizeInfo entity)
 {
     CacheHelper.Remove(cacheKey);
     dal.Update(entity);
 }
Пример #10
0
 public static int Add(PhotoSizeInfo entity)
 {
     entity.Id = dal.Add(entity);
     CacheHelper.Remove(cacheKey);
     return(entity.Id);
 }