예제 #1
0
    //
    // GET: /Default1/Create

    public ActionResult Create()
    {
        UploadRepository.CreateUploadGUID(HttpContext);
        var medium = new Medium {Duration = TimeSpan.Zero};
        ViewBag.MediaType = new SelectList(_types.Distinct().ToList(), "", "");
        return View(medium);
    }
예제 #2
0
    //
    // GET: /Default1/Create

    public ActionResult Create()
    {
        UploadRepository.CreateUploadGUID(HttpContext);
        Medium medium = new Medium();
        medium.Duration = TimeSpan.Zero;

        return View(medium);
    }
예제 #3
0
   //
 // GET: /Default1/Create
 public ActionResult CreateFlash(string uploadid, string type, string thumbnail, string text, string path, string duration, string originalFileName)
 {
     var medium = new Medium { Duration = TimeSpan.Zero };
     medium.Duration = TimeSpan.Parse(duration);
     medium.Location = path;
     medium.Type = type;
     medium.ThumbnailUrl = thumbnail;
     medium.Name = Path.GetFileNameWithoutExtension(originalFileName).Replace("-", " ").Replace("_", " ");
     return View(medium);
 }
예제 #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Media EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToMedia(Medium medium)
 {
     base.AddObject("Media", medium);
 }
예제 #5
0
 /// <summary>
 /// Create a new Medium object.
 /// </summary>
 /// <param name="mediaID">Initial value of the MediaID property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="size">Initial value of the Size property.</param>
 /// <param name="userID">Initial value of the UserID property.</param>
 public static Medium CreateMedium(global::System.Int64 mediaID, global::System.String name, global::System.Int64 size, global::System.Int64 userID)
 {
     Medium medium = new Medium();
     medium.MediaID = mediaID;
     medium.Name = name;
     medium.Size = size;
     medium.UserID = userID;
     return medium;
 }
예제 #6
0
 public ActionResult CreateFlash(Medium medium)
 {
  return  Create(medium);
 }
예제 #7
0
 public ActionResult CreateVideo(Medium medium)
 {
     return Create(medium);
 }
예제 #8
0
    public ActionResult Edit(Medium medium)
    {
        if (ModelState.IsValid)
        {
            var dbmedium = _db.Media.Where(m => m.MediaID == medium.MediaID).SingleOrDefault();
            dbmedium.Name = medium.Name;
            dbmedium.Url = medium.Url;
            dbmedium.Duration = medium.Duration;
            dbmedium.Tags = medium.Tags;
          UploadedContent upload;
          var location = UploadRepository.GetFileUrl(this.HttpContext, dbmedium.MediaID.ToString(),
                           dbmedium.MediaID.ToString(), UploadType.Media, out upload);
            if (upload!=null)
            {
                dbmedium.Duration = new TimeSpan(upload.Duration.Ticks);
            }

            var shouldCalculatenewHash = false;
            if (location != null )
            {
                if (location[0] != dbmedium.Location)
                {
                    dbmedium.Location = location[0];
                    shouldCalculatenewHash = true;
                }
                if (location[1] != dbmedium.ThumbnailUrl)
                {
                    dbmedium.ThumbnailUrl = location[1];
                  
                }
            }
            if(dbmedium.Hash==null||dbmedium.Size==0)
            {
                shouldCalculatenewHash = true;
            }

            // Calculate new hash/size
            if(shouldCalculatenewHash)
            {

                using (var fs = new FileStream(Server.MapPath("~/" + dbmedium.Location), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    dbmedium.Hash = Hashes.MD5(fs);
                    dbmedium.Size = new FileInfo(Server.MapPath("~/" + dbmedium.Location)).Length;
                }
            }

            foreach (var mosaic in dbmedium.Positions.Select(p=>p.Mosaic))
            {
                mosaic.Updated = DateTime.Now;
            }

            dbmedium.Updated = DateTime.Now;
            _db.SaveChanges();
            return RedirectToAction("Index");
        }
        return View("Edit",  medium );
    }
예제 #9
0
    public ActionResult Create(Medium medium)
    {
        if (ModelState.IsValid)
        {
            medium.Created = DateTime.Now;
            _db.Media.AddObject(medium);
            _db.SaveChanges();
            UploadedContent upload;

            var   location = UploadRepository.GetFileUrl(this.HttpContext, medium.MediaID.ToString(CultureInfo.InvariantCulture),
                             medium.MediaID.ToString(CultureInfo.InvariantCulture), UploadType.Media, out upload);


            if (upload != null)
            {
                if (medium.Duration == TimeSpan.Zero)
                {
                    medium.Duration = new TimeSpan(upload.Duration.Ticks);
                }
                else
                {

                }
            }

            if (location != null && location[0] != null)
            {
                medium.Location = location[0];
                using(var fs = new FileStream(Server.MapPath("~/"+location[0]),FileMode.Open,FileAccess.Read,FileShare.ReadWrite))
                {
                    medium.Hash = Hashes.MD5(fs);
                }
                if(location.Length>1)
                {
                    medium.ThumbnailUrl = location[1];
                }

            }


            _db.SaveChanges();
            return RedirectToAction("Index");
        }

        return View(medium);
    }
예제 #10
0
 public ActionResult CreateMarquee(Medium medium, string foreColor,string backColor)
 {
     medium.Options = "foreColor=" + foreColor + ";backColor=" + backColor;
     return Create(medium);
 }
예제 #11
0
 public ActionResult CreatePowerpoint(Medium medium)
 {
     return Create(medium);
 }
예제 #12
0
 public ActionResult CreatePicture(Medium medium)
 {
     return Create(medium);
 }