本文整理汇总了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();
//.........这里部分代码省略.........