当前位置: 首页>>代码示例>>C#>>正文


C# Usr.CanUploadTo方法代码示例

本文整理汇总了C#中Bobs.Usr.CanUploadTo方法的典型用法代码示例。如果您正苦于以下问题:C# Usr.CanUploadTo方法的具体用法?C# Usr.CanUploadTo怎么用?C# Usr.CanUploadTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bobs.Usr的用法示例。


在下文中一共展示了Usr.CanUploadTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessUploadedFile

		public static void ProcessUploadedFile(HttpPostedFile httpPostedFile, Gallery gallery, Random random, Usr usr, int rotate, string tags)
		{
			if (usr.CanUploadTo(gallery))
			{

				Photo photo = new Photo();
				try
				{

					#region Set general stuff
					photo.UsrK = usr.K;
					photo.RandomNumber = random.NextDouble();
					photo.WeightedCoolRating = 5.0;
					photo.WeightedSexyRating = 5.0;
					photo.Order = 5.0;
					if (tags.Length > 512)
						tags = tags.Substring(0, 512);
					photo.UploadTemporaryTags = tags;
					photo.Status = Photo.StatusEnum.Processing;
					#endregion
					#region Set gallery / event / article / url fragment stuff
					photo.GalleryK = gallery.K;
					if (gallery.Event != null)
					{
						photo.EventK = gallery.EventK;
						photo.DateTime = gallery.Event.DateTime;
						photo.ParentDateTime = gallery.Event.DateTime;
					}
					else if (gallery.Article != null)
					{
						photo.ArticleK = gallery.ArticleK;
						photo.DateTime = gallery.Article.AddedDateTime;
						photo.ParentDateTime = gallery.Article.AddedDateTime;
					}
					else
					{
						photo.DateTime = DateTime.Now;
						photo.ParentDateTime = gallery.CreateDateTime;
					}
					photo.UpdateUrlFragmentNoUpdate();
					#endregion

					photo.MediaType = Photo.GetMediaType(httpPostedFile.FileName);

					if (photo.MediaType.Equals(Photo.MediaTypes.Image))
					{
						#region Initialise Guids
						photo.UploadTemporary = Guid.NewGuid();
						photo.Master = Guid.NewGuid();
						photo.Web = Guid.NewGuid();
						photo.Thumb = Guid.NewGuid();
						photo.Icon = Guid.NewGuid();
						#endregion

						photo.Rotate = rotate;
						#region Extention
						try
						{
							string s = httpPostedFile.FileName.Substring(httpPostedFile.FileName.LastIndexOf(".") + 1).ToLower();
							if (s.Length < 10)
							{
								if (s == "jpeg" || s == "jpe")
									photo.UploadTemporaryExtention = "jpg";
								else
									photo.UploadTemporaryExtention = s;
							}
							else
								photo.UploadTemporaryExtention = "jpg";
						}
						catch
						{
							photo.UploadTemporaryExtention = "jpg";
						}
						#endregion
						
					}
					else if (photo.MediaType.Equals(Photo.MediaTypes.Video))
					{
						#region Initialise Guids
						photo.UploadTemporary = Guid.NewGuid();
						photo.VideoMaster = Guid.NewGuid();
						photo.VideoMed = Guid.NewGuid();
						photo.Master = Guid.NewGuid();
						photo.Web = Guid.NewGuid();
						photo.Thumb = Guid.NewGuid();
						photo.Icon = Guid.NewGuid();
						#endregion

						#region Extention
						photo.VideoFileExtention = httpPostedFile.FileName.Substring(httpPostedFile.FileName.LastIndexOf(".") + 1).ToLower();
						photo.UploadTemporaryExtention = photo.VideoFileExtention;
						#endregion

					}

					httpPostedFile.SaveAs(Storage.TemporaryFilesystemPath(photo.UploadTemporary, photo.UploadTemporaryExtention));

					photo.Status = Photo.StatusEnum.Processing;
					photo.Update();

//.........这里部分代码省略.........
开发者ID:davelondon,项目名称:dontstayin,代码行数:101,代码来源:Photo.cs


注:本文中的Bobs.Usr.CanUploadTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。