Esempio n. 1
0
        private string SaveFileInFolder(HttpPostedFileBase file)
        {
            string path = "";

            if (file != null && file.ContentLength > 0)
            {
                var fileName  = Path.GetFileName(file.FileName);
                var localPath = new CONFIG_Service().GetConfigValueByName("FilesFromClientPath");
                path = localPath + fileName;
                //path = Path.Combine(Server.MapPath("~/UploadedFiles/"), fileName);
                file.SaveAs(path);
            }
            return(path);
        }
Esempio n. 2
0
        public ActionResult UploadFromUrl(string url)
        {
            var client = new System.Net.WebClient();

            try
            {
                var    localPath = new CONFIG_Service().GetConfigValueByName("FilesFromClientPath");
                string path      = localPath + url.Substring(url.LastIndexOf('/') + 1);
                client.DownloadFile(url, path);
                FileInfo  fileInfo  = new FileInfo(path);
                VideoFile videoFile = new VideoFile(path);

                double VideoDuration = videoFile.Duration.TotalMinutes;
                // On génére le prix en fonction de la durée
                double price = PriceGeneratorUtil.GetPriceByDuration(VideoDuration);
                // On recupere le format de base de la video
                string format     = fileInfo.Extension.Substring(fileInfo.Extension.LastIndexOf('.') + 1);
                var    formatBase = new FORMAT_Service().GetFormatByName(format);


                // Si le format a été trouvé dans nos bases on va proposer les conversions liées possibles.
                if (formatBase != null)
                {
                    var listFormatTypes = new FORMAT_TYPE_Service().GetSelectListFormatTypeByFormat((int)formatBase.FK_ID_FORMAT_TYPE);

                    return(Json(new
                    {
                        success = "true",
                        fileUrl = path,
                        fileLength = fileInfo.Length,
                        fileName = fileInfo.Name,
                        fileFormatBase = formatBase.PK_ID_FORMAT,
                        listFormatType = new SelectList(listFormatTypes, "Value", "Text"),
                        fileDuration = VideoDuration.ToString(),
                        filePrice = price.ToString()
                    }));
                }
                else
                {
                    return(Json(new { success = "false" }));
                }
            }
            catch (Exception e)
            {
                return(Json(new { success = "false" }));
            }
        }
Esempio n. 3
0
        public static bool VerifyTaskLengthAndSplitTask(TASK Task)
        {
            int    MaxLength;
            string MaxLengthString = new CONFIG_Service().GetConfigValueById((int)EnumManager.CONFIG.MAXLENGTHWITHOUTSPLIT);

            int.TryParse(MaxLengthString, out MaxLength);

            if (Task.LENGTH >= MaxLength)
            {
                VideoFile VideoFile = new VideoFile(Task.FILE_URL);
                VideoFile.GetVideoInfo();
                Task.STATUS = 0;
                new TASK_Service().AddOrUpdateTask(Task);
                CreateSplits(Task, VideoFile);
                return(true);
            }
            return(false);
        }