//,string JobId, string groupType, string groupname) public ActionResult Save(IEnumerable<HttpPostedFileBase> files, VideoModel video, string JobOptionValue) { //, string Title, string Reference, string HostPrimary, string HostPrimaryLink, string HostSecondary, string HostSecondaryLink, string Comments // string Title = ""; string Reference = ""; string HostPrimary = ""; string HostPrimaryLink = ""; string HostSecondary = ""; string HostSecondaryLink = ""; string Comments = ""; // The Name of the Upload component is "files" try { int job_Id; bool res = int.TryParse(JobOptionValue, out job_Id); if (res) { job_Id = (Convert.ToInt32(JobOptionValue)); } if (files != null && (!string.IsNullOrEmpty(video.Title) && !string.IsNullOrEmpty(video.Status))) { foreach (var file in files) { string strImgShowingRepositoryUrl = string.Empty; string strFolder = string.Empty; var fileName = Path.GetFileName(file.FileName); strFolder = System.Configuration.ConfigurationManager.AppSettings["VideoUplaodLocation"]; if (video.Title.Contains("/")) { video.Title = video.Title.Replace("/", "-"); } strFolder = strFolder + "/" + video.ClientId + "/" + video.Title + "/"; string FilePath = strFolder; strImgShowingRepositoryUrl = System.Configuration.ConfigurationManager.AppSettings["VideoDisplayLocation"]; strFolder = strFolder + fileName.ToString(); if (System.IO.File.Exists(strFolder)) { // rename file string strRandomFileName = Path.GetRandomFileName(); //This method returns a random file name of 11 characters string FileExtension = System.IO.Path.GetExtension(file.FileName); string FileName = System.IO.Path.GetFileName(file.FileName); int fileSize = file.ContentLength; strRandomFileName = strRandomFileName.Replace(".", "") + FileExtension; strImgShowingRepositoryUrl = strImgShowingRepositoryUrl + video.ClientId + "/" + video.Title + "/" + strRandomFileName.ToString(); strFolder = string.Empty; strFolder = FilePath + strRandomFileName; file.SaveAs(strFolder); //////////////////////////////////////////// // Google.YouTube.YouTubeRequestSettings settings = //new Google.YouTube.YouTubeRequestSettings("Bobina Channel", "AI39si5uAJcnGQWqT7bOooT00fTbkCsMjImXlYoyZpkArc49nQvQF-UhxIQDUpwoLxdvf85t97K3wUP2SDrdm1Q8IchJT5mYgQ"); // Google.YouTube.YouTubeRequest request = new Google.YouTube.YouTubeRequest(settings); // Google.YouTube.Video newVideo = new Google.YouTube.Video(); // newVideo.Title = "test 1"; // // newVideo.Tags.Add(new MediaCategory("Gaming", YouTubeNameTable.CategorySchema)); // newVideo.Keywords = "mstest1 , mstest2"; // newVideo.Description = "test 3 test 4"; // newVideo.YouTubeEntry.Private = false; // Google.YouTube.Video createdVideo = request.Upload(newVideo); /////////////////////////////////////////// //--------------------------------------------------------------- YouTubeRequestSettings settings = new YouTubeRequestSettings("Zerofootprint", "532982290458-ua1mk31m7ke3pee5vas9rcr6rgfcmavf.apps.googleusercontent.com", "AI39si5uAJcnGQWqT7bOooT00fTbkCsMjImXlYoyZpkArc49nQvQF-UhxIQDUpwoLxdvf85t97K3wUP2SDrdm1Q8IchJT5mYgQ"); YouTubeRequest request = new YouTubeRequest(settings); //YouTubeRequestSettings settings = new YouTubeRequestSettings("Zerofootprint", "AI39si5uAJcnGQWqT7bOooT00fTbkCsMjImXlYoyZpkArc49nQvQF-UhxIQDUpwoLxdvf85t97K3wUP2SDrdm1Q8IchJT5mYgQ", "*****@*****.**", "[email protected]"); //YouTubeRequest request = new YouTubeRequest(settings); Google.YouTube.Video newVideo = new Google.YouTube.Video(); newVideo.Title = "ms test"; newVideo.Tags.Add(new MediaCategory("Autos", Google.GData.YouTube.YouTubeNameTable.CategorySchema)); newVideo.Keywords = "mstest"; newVideo.Description = "mstest"; newVideo.YouTubeEntry.Private = false; //newVideo.Tags.Add(new MediaCategory("mydevtag, anotherdevtag", // YouTubeNameTable.DeveloperTagSchema)); // newVideo.YouTubeEntry.Location = new GeoRssWhere(37, -122); // alternatively, you could just specify a descriptive string // newVideo.YouTubeEntry.setYouTubeExtension("location", "Mountain View, CA"); newVideo.YouTubeEntry.MediaSource = new Google.GData.Client.MediaFileSource(strFolder, "video/quicktime"); Google.YouTube.Video createdVideo = request.Upload(newVideo); //--------------------------------------------------------------- //var clients = _videoService.GetVideos(string.Empty, int.Parse(id)).ToList(); //int client_Id, string title, string fileName, string fileExtension, int fileSize, string files3location, // string reference, string host_Primary, string hostPrimaryLink, string hostSecondary, string hostSecondaryLink, string comments, // string status, bool isDeleted = false if (video.Row_Id > 0) { _videoService.UpdateVideo(Convert.ToInt32(video.ClientId), video.Title, FileName, FileExtension, fileSize, strImgShowingRepositoryUrl, video.Reference, video.HostPrimary, video.HostPrimaryLink, video.HostSecondary, video.HostSecondaryLink, video.Comments, video.Status, video.Row_Id, job_Id); } else { _videoService.Insertvideo(Convert.ToInt32(video.ClientId), video.Title, FileName, FileExtension, fileSize, strImgShowingRepositoryUrl, video.Reference, video.HostPrimary, video.HostPrimaryLink, video.HostSecondary, video.HostSecondaryLink, video.Comments, video.Status, false, job_Id); } //_repository.InsertJobAttachment(JobId, groupType, groupname, strRandomFileName, FileExtension, fileSize, selectedTags, strImgShowingRepositoryUrl, FileName); // this will rutund the exist file } else { DirectoryInfo diPath = new DirectoryInfo(FilePath); diPath.Create(); strImgShowingRepositoryUrl = strImgShowingRepositoryUrl + video.ClientId + "/" + video.Title + "/" + fileName.ToString(); string FileExtension = System.IO.Path.GetExtension(file.FileName); string FileName = System.IO.Path.GetFileName(file.FileName); int fileSize = file.ContentLength; file.SaveAs(strFolder); /////////////////////////// working except upload//////////////// //YouTubeRequestSettings settings = new YouTubeRequestSettings("Zerofootprint", "AI39si5uAJcnGQWqT7bOooT00fTbkCsMjImXlYoyZpkArc49nQvQF-UhxIQDUpwoLxdvf85t97K3wUP2SDrdm1Q8IchJT5mYgQ", "*****@*****.**", "[email protected]"); //YouTubeRequest request = new YouTubeRequest(settings); //Google.YouTube.Video newVideo = new Google.YouTube.Video(); //newVideo.Title = "ms test"; ////newVideo.Tags.Add(new MediaCategory("Autos", Google.GData.YouTube.YouTubeNameTable.CategorySchema)); //newVideo.Keywords = "mstest"; //newVideo.Description = "mstest"; //newVideo.YouTubeEntry.Private = false; ////newVideo.Tags.Add(new MediaCategory("mydevtag, anotherdevtag", //// YouTubeNameTable.DeveloperTagSchema)); //// newVideo.YouTubeEntry.Location = new GeoRssWhere(37, -122); //// alternatively, you could just specify a descriptive string //// newVideo.YouTubeEntry.setYouTubeExtension("location", "Mountain View, CA"); //newVideo.YouTubeEntry.MediaSource = new Google.GData.Client.MediaFileSource(strFolder, // "video/quicktime"); //Google.YouTube.Video createdVideo = request.Upload(newVideo); //////////////////////////////////////////////// //Google.YouTube.YouTubeRequestSettings settings = //new Google.YouTube.YouTubeRequestSettings("Bobina Channel", "AI39si5uAJcnGQWqT7bOooT00fTbkCsMjImXlYoyZpkArc49nQvQF-UhxIQDUpwoLxdvf85t97K3wUP2SDrdm1Q8IchJT5mYgQ"); //YouTubeRequest request = new YouTubeRequest(settings); //Google.YouTube.Video newVideo = new Google.YouTube.Video(); //newVideo.Title = "test 1"; //// newVideo.Tags.Add(new MediaCategory("Gaming", YouTubeNameTable.CategorySchema)); //newVideo.Keywords = "mstest1 , mstest2"; //newVideo.Description = "test 3 test 4"; //newVideo.YouTubeEntry.Private = false; //Google.YouTube.Video createdVideo = request.Upload(newVideo); ////////////////////////////////////////////// //--------------------------------------------------------- // var settings1 = new YouTubeRequestSettings("Zerofootprint", "AI39si5uAJcnGQWqT7bOooT00fTbkCsMjImXlYoyZpkArc49nQvQF-UhxIQDUpwoLxdvf85t97K3wUP2SDrdm1Q8IchJT5mYgQ", "*****@*****.**" //, "[email protected]"); // var youTubeRequest = new YouTubeRequest(settings1); // Google.YouTube.Video video1 = new Google.YouTube.Video(); // video1.Title = "First Test 1"; // video1.Keywords = "O2 Test"; // // MediaCategory category = new MediaCategory("Technology"); // // category.Attributes["scheme"] = YouTubeService.DefaultCategory; // // video1.Tags.Add(category); // video1.MediaSource = new Google.GData.Client.MediaFileSource(strFolder, "video/avi"); // youTubeRequest.Upload(video1); // //-------------------------------------------------------------------------------------------- // YouTubeRequestSettings settings = new YouTubeRequestSettings( //"whatwill come here ?", //"AIzaSyBM80iRA-wuMScreXvI2TfIkTncdt9Mx2s", //"*****@*****.**", //"[email protected]"); // YouTubeRequest request = new YouTubeRequest(settings); // Google.YouTube.Video newVideo = new Google.YouTube.Video(); // newVideo.Title = "test 1"; // // newVideo.Tags.Add(new MediaCategory("Gaming", YouTubeNameTable.CategorySchema)); // newVideo.Keywords = "mstest1 , mstest2"; // newVideo.Description = "test 3 test 4"; // newVideo.YouTubeEntry.Private = false; // //newVideo.Tags.Add(new MediaCategory("tag 1, tag 2", // // Google.GData.YouTube.YouTubeNameTable.DeveloperTagSchema)); // // newVideo.YouTubeEntry.Location = new GeoRssWhere(37, -122); // newVideo.YouTubeEntry.MediaSource = new MediaFileSource(strFolder, "video/quicktime"); // Google.YouTube.Video createdVideo = request.Upload(newVideo); /////////////////////////////////////////// // byte[] bytes = System.IO.File.ReadAllBytes(strFolder); CreateYoutubeVideo(video.Title, video.Title, video.Comments, false, strFolder, file.FileName, "video/quicktime"); if (video.Row_Id > 0) { _videoService.UpdateVideo(Convert.ToInt32(video.ClientId), video.Title, FileName, FileExtension, fileSize, strImgShowingRepositoryUrl, video.Reference, video.HostPrimary, video.HostPrimaryLink, video.HostSecondary, video.HostSecondaryLink, video.Comments, video.Status, video.Row_Id, job_Id); } else { _videoService.Insertvideo(Convert.ToInt32(video.ClientId), video.Title, FileName, FileExtension, fileSize, strImgShowingRepositoryUrl, video.Reference, video.HostPrimary, video.HostPrimaryLink, video.HostSecondary, video.HostSecondaryLink, video.Comments, video.Status, false, job_Id); } } } } } catch (Exception ex) { #region For Error string ErrorMsg = ex.Message; string Error = ErrorMsg; if (!string.IsNullOrEmpty(ErrorMsg)) { switch (Error) { case "FileExist": return Json(new DataSourceResult { // Errors = "You cannot change the organizer of an instance." Errors = "CustomError400" }); case "CustomError401": return Json(new DataSourceResult { //Errors = "You cannot turn an instance of a recurring event into a recurring event itself." Errors = "CustomError401" }); case "Null_Event": return Json(new DataSourceResult { Errors = "Null_Event" }); //default: // Logger(ex.InnerException.Message); // return Json(new DataSourceResult // { // Errors = string.Empty // }); } } else { return Json(new DataSourceResult { Errors = "" }); } #endregion } //var currentUser = UserManager.Current(); //if (currentUser != null) //{ // var videomodel = _videoService.GetVideos(string.Empty, (video.ClientId)).ToList(); // return PartialView("Controls/Video/_VideoList", videomodel); //} //return null; return Content(""); }
public ActionResult AddorUpdateVideos(VideoModel video) { var currentUser = UserManager.Current(); if (currentUser != null) { int jobId; bool res = int.TryParse(video.JobIdOptions, out jobId); if (res) { jobId = (Convert.ToInt32(video.JobIdOptions)); } if (video.Row_Id > 0) { _videoService.UpdateVideo(Convert.ToInt32(video.ClientId), video.Title, video.FileName, video.FileExtension, video.FileSize, video.Files3Location, video.Reference, video.HostPrimary, video.HostPrimaryLink, video.HostSecondary, video.HostSecondaryLink, video.Comments, video.Status, video.Row_Id, jobId); } else { _videoService.Insertvideo(Convert.ToInt32(video.ClientId), video.Title, video.FileName, video.FileExtension, video.FileSize, video.Files3Location, video.Reference, video.HostPrimary, video.HostPrimaryLink, video.HostSecondary, video.HostSecondaryLink, video.Comments, video.Status, false, jobId); } } return null; }
public ActionResult EditVideo(string id) { var model = new VideoModel(); var currentUser = UserManager.Current(); if (currentUser != null) { if (!string.IsNullOrEmpty(id)) { var lstClient = _videoService.SelectVideoById(string.Empty, int.Parse(id)).ToList(); foreach (var item in lstClient) { model.Row_Id = item.Row_Id; model.ClientId = item.Client_Id.Value; model.Title = item.Title; model.Reference = item.Reference; model.HostPrimary = item.Host_Primary; model.HostPrimaryLink = item.Host_Primary_Link; model.HostSecondary = item.Host_Secondary; model.HostSecondaryLink = item.Host_Secondary_Link; model.Status = item.Status; model.Comments = item.Comments; model.FileName = item.FileName; model.FileExtension = item.FileExtension; model.FileSize = item.FileSize.Value; model.Files3Location = item.File_s3_Location; if (item.JobId != null) { model.jobId = Convert.ToInt32(item.JobId); } else { model.jobId = 0; } model.jobTitle = item.JobTitle; //model.JobIdOptions=item.jo } } } return PartialView("Controls/Video/_AddVideo", model); }
public ActionResult AddNewVideos(string clientId, string videoid) { var model = new VideoModel(); var currentUser = UserManager.Current(); if (currentUser != null) { if (!string.IsNullOrEmpty(videoid)) { var lstViedo = _videoService.GetVideos(string.Empty, int.Parse(videoid)).ToList(); //List<string> optionlist = new List<string>(); //List<string> optionlistval = new List<string>(); foreach (var item in lstViedo) { model.Row_Id = item.Row_Id; model.ClientId = item.Client_Id.Value; model.Reference = item.Reference; model.HostPrimary = item.Host_Primary; model.HostPrimaryLink = item.Host_Primary_Link; model.HostSecondary = item.Host_Secondary; model.HostSecondaryLink = item.Host_Secondary_Link; model.Status = item.Status; model.Comments = item.Comments; //var options = item.Title.ToString().Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); //optionlist.AddRange(options); //var optionsval = item.Row_Id.ToString().Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); //optionlistval.AddRange(optionsval); } //model.JobOptionslist = optionlist; //model.JobOptionValue = optionlistval.ToArray(); } else { int client_id; bool res = int.TryParse(clientId, out client_id); if (res) { model.ClientId = client_id; } } } return PartialView("Controls/Video/_AddVideo", model); }