public ActionResult Edit(Gallery gallery)
        {
            var viewOf = ViewTapping(ViewStates.EditPost, gallery);

            if (gallery.File != null)
            {
                gallery.Extension = UploadProcessor.GetExtension(gallery.File);
            }
            if (ModelState.IsValid)
            {
                db.Entry(gallery).State = EntityState.Modified;
                var state = SaveDatabase(ViewStates.Edit, gallery);
                DoUpload(gallery);
                if (state)
                {
                    AppVar.SetSavedStatus(ViewBag, _editedSaved); // Saved Successfully.
                }
                else
                {
                    AppVar.SetErrorStatus(ViewBag, _editedError); // Failed to Save
                }

                return(RedirectToAction("Index"));
            }

            GetDropDowns(gallery);
            AppVar.SetErrorStatus(ViewBag, _editedError); // Failed to save
            return(View(gallery));
        }
        public ActionResult Create(Gallery gallery)
        {
            var viewOf = ViewTapping(ViewStates.CreatePost, gallery);

            if (gallery.File != null)
            {
                gallery.Extension = UploadProcessor.GetExtension(gallery.File);
            }
            GetDropDowns(gallery);
            if (ModelState.IsValid)
            {
                gallery.GalleryID  = Guid.NewGuid();
                gallery.UploadGuid = gallery.GalleryID;
                db.Galleries.Add(gallery);
                var state = SaveDatabase(ViewStates.Create, gallery);
                DoUpload(gallery);
                if (state)
                {
                    AppVar.SetSavedStatus(ViewBag, _createdSaved); // Saved Successfully.
                }
                else
                {
                    AppVar.SetErrorStatus(ViewBag, _createdError); // Failed to save
                }

                return(View(gallery));
            }
            AppVar.SetErrorStatus(ViewBag, _createdError); // Failed to Save
            return(View(gallery));
        }
示例#3
0
        public ActionResult EditGalleryUploads(App app)
        {
            var token = Request["__RequestVerificationToken"];
            var path  = AppVar.Url + Statics.UProcessorGallery.RootPath.Replace("~/", "/") +
                        Statics.UProcessorGallery.AdditionalRoots;

            var uploadedImages = db.Galleries
                                 .Where(
                n =>
                n.GalleryCategoryID == GalleryCategoryIDs.AppPageGallery &&
                n.UploadGuid == app.UploadGuid)
                                 .OrderBy(n => n.Sequence)
                                 .AsEnumerable()
                                 .Select(n => new UploadedGalleryImageEditViewModel {
                Tile       = n.Title,
                Subtitle   = n.Subtitle,
                Sequence   = n.Sequence,
                UploadGuid = n.UploadGuid,
                Id         = app.AppID,
                ImageURL   = path + UploadProcessor.GetOrganizeNameStatic(n, true, false, ""),
                DeleteURL  = "/" + ControllerName +
                             "/DeleteGalleryImage?uploadGuid=" + n.UploadGuid +
                             "&sequence=" + n.Sequence +
                             "&__RequestVerificationToken=" + token
                             //ReUploadURL = "/" + _controllerName +
                             //"/ReuploadGalleryImage?uploadGuid=" + n.UploadGuid +
                             //"&sequence=" + n.Sequence +
                             //"&__RequestVerificationToken=" + token
            }).ToList();

            return(View(uploadedImages));
        }
示例#4
0
        public void GetSongContent()
        {
            var azureService    = new AzureService(Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey);
            var uploadProcessor = new UploadProcessor(Settings.Default.AzureContainerName, Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey);
            var musicDao        = new MusicDao(Settings.Default.ConnectionString, null, uploadProcessor, azureService);

            musicDao.Initialize();
            musicDao.GetSongContent();
        }
 public UploadCallbackHandler(UploadProcessor processor,
                              ContentProviderProcessor resourceProcessor,
                              IConnectionManager connectionManager,
                              IChatService service)
 {
     _processor         = processor;
     _resourceProcessor = resourceProcessor;
     _hubContext        = connectionManager.GetHubContext <Chat>();
     _service           = service;
 }
示例#6
0
        public void Fill()
        {
            Status("Filling");
            AzureService     azureService    = new AzureService(Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey);
            IUploadProcessor uploadProcessor = new UploadProcessor(Settings.Default.AzureContainerName, Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey);
            IMusicDao        musicDao        = new MusicDao(Settings.Default.ConnectionString, new string[] { Settings.Default.MusicFolder }, uploadProcessor, azureService);

            musicDao.Initialize();
            musicDao.RandomFill();
            Status("Done");
        }
示例#7
0
        public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
        .ConfigureAppConfiguration(config => config.AddUserSecrets(Assembly.GetExecutingAssembly()))
        .ConfigureServices((hostContext, services) =>
        {
            var uploadProcessor = new UploadProcessor(new UploadProcessorOptions {
                UploadDirectory = hostContext.Configuration.GetSection("App:UploadDirectory").Value,
                OutputDirectory = hostContext.Configuration.GetSection("App:OutputDirectory").Value
            });

            uploadProcessor.Process();
        });
示例#8
0
        public void Reindex(int threadsNum = 10)
        {
            Model model = new Model();

            string[] musicFolders = new string[1];
            musicFolders[0] = Settings.Default.MusicFolder;
            var azureService = new AzureService(Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey);
            IUploadProcessor uploadProcessor = new UploadProcessor(Settings.Default.AzureContainerName, Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey);
            var musicDao = new MusicDao(Settings.Default.ConnectionString, musicFolders, uploadProcessor, azureService);

            model.Reindex(threadsNum, musicFolders, musicDao);
        }
示例#9
0
        public new void Process(UploadArgs args)
        {
            if (Sitecore.UIUtil.IsIE())
            {
                // We need to use the original functionality for IE
                base.Process(args);
                return;
            }

            Assert.ArgumentNotNull((object)args, "args");
            if (args.Destination == UploadDestination.File)
            {
                return;
            }
            foreach (string index in (NameObjectCollectionBase)args.Files)
            {
                HttpPostedFile file = args.Files[index];
                if (!string.IsNullOrEmpty(file.FileName))
                {
                    if (UploadProcessor.IsUnpack(args, file))
                    {
                        ZipReader zipReader = new ZipReader(file.InputStream);
                        try
                        {
                            foreach (ZipEntry zipEntry in zipReader.Entries)
                            {
                                if (!zipEntry.IsDirectory && zipEntry.Size > Settings.Media.MaxSizeInDatabase)
                                {
                                    string text = file.FileName + "/" + zipEntry.Name;
                                    HttpContext.Current.Response.Write("<html><head><script type=\"text/JavaScript\" language=\"javascript\">window.top.scForm.browser.getTopModalDialog().frames[0].scForm.postRequest(\"\", \"\", \"\", 'ShowFileTooBig(" + StringUtil.EscapeJavascriptString(text) + ")')</script></head><body>Done</body></html>");
                                    args.ErrorText = string.Format("The file \"{0}\" is too big to be uploaded. The maximum size for uploading files is {1}.", (object)text, (object)MainUtil.FormatSize(Settings.Media.MaxSizeInDatabase));
                                    args.AbortPipeline();
                                    return;
                                }
                            }
                        }
                        finally
                        {
                            file.InputStream.Position = 0L;
                        }
                    }
                    else if ((long)file.ContentLength > Settings.Media.MaxSizeInDatabase)
                    {
                        string fileName = file.FileName;
                        HttpContext.Current.Response.Write("<html><head><script type=\"text/JavaScript\" language=\"javascript\">window.top.scForm.browser.getTopModalDialog().frames[0].scForm.postRequest(\"\", \"\", \"\", 'ShowFileTooBig(" + StringUtil.EscapeJavascriptString(fileName) + ")')</script></head><body>Done</body></html>");
                        args.ErrorText = string.Format("The file \"{0}\" is too big to be uploaded. The maximum size for uploading files is {1}.", (object)fileName, (object)MainUtil.FormatSize(Settings.Media.MaxSizeInDatabase));
                        args.AbortPipeline();
                        break;
                    }
                }
            }
        }
示例#10
0
        private ServiceResponse HandleUploadRequest(HttpContextBase context)
        {
            if (context.Request.Files.Count != 1)
            {
                throw new ArgumentOutOfRangeException("files");
            }

            HttpPostedFileBase file = context.Request.Files[0];

            if (file == null)
            {
                throw new ArgumentNullException("file");
            }

            if (file.FileName.IsEmptyOrNull())
            {
                throw new ArgumentNullException("filename");
            }

            var processor = new UploadProcessor
            {
                ThumbWidth  = 128,
                ThumbHeight = 96
            };

            if (processor.ProcessStream(file.InputStream, Path.GetExtension(file.FileName)))
            {
                var temporaryFile = "temporary/" + Path.GetFileName(processor.FilePath);
                using (var sw = new StreamWriter(Path.ChangeExtension(UploadHelper.DbFilePath(temporaryFile), ".orig")))
                    sw.WriteLine(file.FileName);

                return(new UploadResponse()
                {
                    TemporaryFile = temporaryFile,
                    Size = processor.FileSize,
                    IsImage = processor.IsImage,
                    Width = processor.ImageWidth,
                    Height = processor.ImageHeight
                });
            }
            else
            {
                return(new UploadResponse()
                {
                    Error = new ServiceError()
                    {
                        Code = "Exception",
                        Message = processor.ErrorMessage
                    }
                });
            }
        }
示例#11
0
        private ServiceResponse HandleUploadRequest(HttpContext context)
        {
            if (context.Request.Form.Files.Count != 1)
            {
                throw new ArgumentOutOfRangeException("files");
            }

            var file = context.Request.Form.Files[0];

            if (file == null)
            {
                throw new ArgumentNullException("file");
            }

            if (file.FileName.IsEmptyOrNull())
            {
                throw new ArgumentNullException("filename");
            }

            var processor = new UploadProcessor(UploadStorage, Logger)
            {
                ThumbWidth  = 128,
                ThumbHeight = 96
            };

            if (processor.ProcessStream(file.OpenReadStream(),
                                        Path.GetExtension(file.FileName), Localizer))
            {
                var temporaryFile = processor.TemporaryFile;
                UploadStorage.SetOriginalName(temporaryFile, file.FileName);

                return(new UploadResponse()
                {
                    TemporaryFile = temporaryFile,
                    Size = processor.FileSize,
                    IsImage = processor.IsImage,
                    Width = processor.ImageWidth,
                    Height = processor.ImageHeight
                });
            }
            else
            {
                return(new UploadResponse()
                {
                    Error = new ServiceError()
                    {
                        Code = "Exception",
                        Message = processor.ErrorMessage
                    }
                });
            }
        }
示例#12
0
        public void GetSelectedSongs()
        {
            UploadProcessor uploadProcessor = new UploadProcessor(containerName, Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey);
            MusicDao        musicDao        = GetMusicDao();

            String[]           desiredGenres = { "trance", "techno", "electronic", "ambient" };
            IEnumerable <SONG> actual;

            actual = musicDao.GetSelectedSongs(desiredGenres);
            foreach (SONG song in actual)
            {
                Console.WriteLine(song.TITLE);
            }
        }
        public void Process(UploadArgs args)
        {
            Assert.ArgumentNotNull((object)args, nameof(args));
            if (args.Destination == UploadDestination.File)
            {
                return;
            }

            foreach (string file1 in args.Files)
            {
                HttpPostedFile file2 = args.Files[file1];
                if (!string.IsNullOrEmpty(file2.FileName))
                {
                    if (UploadProcessor.IsUnpack(args, file2))
                    {
                        ZipReader zipReader = new ZipReader(file2.InputStream);
                        try
                        {
                            foreach (ZipEntry entry in zipReader.Entries)
                            {
                                if (!entry.IsDirectory && !UploadFileSettings.IsAllowedFile(entry.Name, entry.Size))
                                {
                                    string text = file2.FileName + "/" + entry.Name;
                                    args.UiResponseHandlerEx.FileTooBigForUpload(StringUtil.EscapeJavascriptString(text));
                                    args.ErrorText = UploadFileSettings.FileErrorMessage(file2.FileName);
                                    args.AbortPipeline();
                                    return;
                                }
                            }
                        }
                        finally
                        {
                            file2.InputStream.Position = 0L;
                        }
                    }
                    else if (!UploadFileSettings.IsAllowedFile(file2))
                    {
                        string fileName = file2.FileName;

                        if (HttpContext.Current.Request.Url.AbsolutePath != "/sitecore/shell/api/sitecore/Media/Upload")
                        {
                            args.UiResponseHandlerEx.FileTooBigForUpload(StringUtil.EscapeJavascriptString(fileName));
                        }
                        args.ErrorText = UploadFileSettings.FileErrorMessage(file2.FileName);
                        args.AbortPipeline();
                        break;
                    }
                }
            }
        }
示例#14
0
        public JsonResult ProcessSingleUploads(App app, HttpPostedFileBase file, int galleryId,
                                               UploadProcessor uploadProcessorSepecific)
        {
            if (file != null && app.UploadGuid != null)
            {
                //look for cache if sequence exist before
                var fileName = app.UploadGuid.ToString();
                if (file.ContentLength > 0)
                {
                    // first save gallery and temp record.
                    //upload the image
                    uploadProcessorSepecific.UploadFile(file, fileName, 0, true, true);
                    //successfully uploaded now save a gallery info
                    var galleryCategory = db.GalleryCategories.Find(galleryId);
                    var gallery         =
                        db.Galleries.FirstOrDefault(
                            n =>
                            n.UploadGuid == app.UploadGuid &&
                            n.GalleryCategoryID == galleryCategory.GalleryCategoryID);
                    if (gallery == null)
                    {
                        gallery                   = new Gallery();
                        gallery.GalleryID         = Guid.NewGuid();
                        gallery.UploadGuid        = app.UploadGuid;
                        gallery.Title             = app.AppName;
                        gallery.Extension         = UploadProcessor.GetExtension(file);
                        gallery.GalleryCategoryID = galleryCategory.GalleryCategoryID;
                        gallery.Sequence          = 0;
                        db.Galleries.Add(gallery);
                        // try to add a temp record as well.
                        var tempUpload = new TempUpload();
                        tempUpload.TempUploadID = Guid.NewGuid();
                        tempUpload.UserID       = UserManager.GetLoggedUserId();
                        tempUpload.GalleryID    = gallery.GalleryID;
                        tempUpload.RelatingUploadGuidForDelete = app.UploadGuid;
                        db.TempUploads.Add(tempUpload);
                        db.SaveChanges();
                    }
                    // resize
                    //new Thread(() => {

                    uploadProcessorSepecific.ResizeImageAndProcessImage(gallery, galleryCategory);
                    uploadProcessorSepecific.RemoveTempImage(gallery);
                    //}).Start();
                }
                return(Json(new { isUploaded = true, message = "successfully done" }, "text/html"));
            }
            return(Json(new { isUploaded = false, message = "No file send." }, "text/html"));
        }
示例#15
0
        public void GetSongMetadata()
        {
            String filename, title, artist, album, genre;

            filename = @"";
            var azureService    = new AzureService(Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey);
            var uploadProcessor = new UploadProcessor(Settings.Default.AzureContainerName, Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey);
            var musicDao        = new MusicDao(Settings.Default.ConnectionString, null, uploadProcessor, azureService);

            musicDao.GetMp3Tags(filename, out title, out artist, out album, out genre);
            Assert.IsNotNull(title);
            Assert.IsNotNull(artist);
            Assert.IsNotNull(album);
            Assert.IsNotNull(genre);
        }
示例#16
0
        static void Main(string[] args)
        {
            var fileSystemWatcher = new FileSystemWatcher("../Data/uploads", "metadata.json");

            fileSystemWatcher.IncludeSubdirectories = true;
            while (true)
            {
                var result = fileSystemWatcher.WaitForChanged(WatcherChangeTypes.Created);
                Console.WriteLine($"New Metadata file {result.Name}");
                var fullMetadataFilePath = Path.Combine("../Data/uploads", result.Name);
                var subfolder            = Path.GetDirectoryName(fullMetadataFilePath);
                var processor            = new UploadProcessor(subfolder);
                processor.Process();
            }
        }
示例#17
0
        public void ReindexTest1()
        {
            Model           target          = new Model();
            Action <string> errorAction     = WriteOutput;
            Action <string> statusAction    = WriteOutput;
            Action <string> newSongAction   = WriteOutput;
            Action <string> newArtistAction = WriteOutput;
            int             threadsNum      = 1;

            var             azureService    = new AzureService(Properties.Settings.Default.AzureAccountName, Properties.Settings.Default.AzureAccountKey);
            UploadProcessor uploadProcessor = new UploadProcessor(Properties.Settings.Default.AzureContainerName, Properties.Settings.Default.AzureAccountName, Properties.Settings.Default.AzureAccountKey);
            IMusicDao       musicDao        = new MusicDao(Properties.Settings.Default.ConnectionString, new string[] { Properties.Settings.Default.MusicFolder }, uploadProcessor, azureService);

            target.Reindex(threadsNum, new string[] { Properties.Settings.Default.MusicFolder }, musicDao);
        }
示例#18
0
        public void GetSongMetadata1()
        {
            String filename, title, artist, album, genre;

            filename = @"e:\Music\Apollo Four Fourty\Electro Glide In Blue\Carrera Rapida.mp3";
            var azureService    = new AzureService(Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey);
            var uploadProcessor = new UploadProcessor(Settings.Default.AzureContainerName, Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey);
            var musicDao        = new MusicDao(Settings.Default.ConnectionString, null, uploadProcessor, azureService);

            musicDao.GetMp3Tags(filename, out title, out artist, out album, out genre);
            Assert.IsNotNull(title);
            Assert.IsNotNull(artist);
            Assert.IsNotNull(album);
            Assert.IsNotNull(genre);
        }
示例#19
0
 public void GetProcSongs()
 {
     try
     {
         var azureService    = new AzureService(Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey);
         var uploadProcessor = new UploadProcessor(Settings.Default.AzureContainerName, Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey);
         var musicDao        = new MusicDao(Settings.Default.ConnectionString, null, uploadProcessor, azureService);
         musicDao.GetProcSongs();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         Console.WriteLine(ex.StackTrace);
         throw;
     }
 }
示例#20
0
        public void SelectSongs()
        {
            String[]           desiredGenres = { "trance", "techno",   "electronic", "ambient",       "house",
                                                 "beats",            "big beat", "chill",      "dub",           "Electro","grime","hard psyche",
                                                 "illbient",         "jungle",   "leftfield",  "plunderphonic", "trip",   "turn" };
            var                azureService    = new AzureService(Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey);
            var                uploadProcessor = new UploadProcessor(Settings.Default.AzureContainerName, Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey);
            var                musicDao        = new MusicDao(Settings.Default.ConnectionString, null, uploadProcessor, azureService);
            IEnumerable <SONG> songs           = musicDao.GetSelectedSongs(desiredGenres);

            Assert.IsTrue(songs.GetEnumerator().MoveNext());
            foreach (SONG song in songs)
            {
                testContextInstance.WriteLine(song.TITLE);
            }
        }
示例#21
0
        public MusicManager(int threadsNum, int maxSongsToProcess, string connectionString, string musicFolder)
        {
            model = new Model();

            var azureService    = new AzureService(Properties.Settings.Default.AzureAccountName, Properties.Settings.Default.AzureAccountKey);
            var uploadProcessor = new UploadProcessor(Properties.Settings.Default.AzureContainerName, Properties.Settings.Default.AzureAccountName, Properties.Settings.Default.AzureAccountKey);

            uploadProcessor.OnError  += Error;
            uploadProcessor.OnStatus += Status;
            musicDao                = new MusicDao(connectionString, new string[] { Properties.Settings.Default.MusicFolder }, uploadProcessor, azureService);
            musicDao.OnError       += Error;
            musicDao.OnNewArtist   += AddArtist;
            musicDao.OnNewSong     += NewSong;
            musicDao.OnProcessFile += Status;
            musicDao.OnStatus      += Status;
        }
示例#22
0
        static void Main(string[] args)
        {
            int counter = 0;

            Parallel.ForEach(
                Directory.GetDirectories("../../uploads"),
                subFolder =>
            {
                var uploadProcessor = new UploadProcessor(subFolder);
                uploadProcessor.Process();
                ++counter;
            });

            string msg = $"{counter} uploads were processed.";

            GtkHelper.DisplayAlert(msg);
        }
示例#23
0
        public void UpdateSongs()
        {
            String container       = "songs";
            var    uploadProcessor = new UploadProcessor(container, Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey);
            var    azureService    = new AzureService(Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey);
            var    musicDao        = new MusicDao(Settings.Default.ConnectionString, null, uploadProcessor, azureService);

            musicDao.OnNewSong += Log;
            var dataContext             = new MusicEntities1();
            IQueryable <SONG> songQuery = from s in dataContext.SONG
                                          orderby s.HASH
                                          where s.HASH != null
                                          select s;

            foreach (SONG song in songQuery)
            {
                try
                {
                    byte[] hash     = MusicDao.GenerateHashCode(song.LOCATION);
                    bool   hashSame = true;
                    for (int i = 0; i < hash.Length; i++)
                    {
                        if (hash[i] != song.HASH.ToArray()[i])
                        {
                            hashSame = false;
                            break;
                        }
                    }

                    if (!hashSame)
                    {
                        testContextInstance.WriteLine("{0}", song.LOCATION);
                        musicDao.ProcessFile(song.LOCATION);
                        dataContext.SONG.Remove(song);
                    }
                    dataContext.SaveChanges();
                }
                catch (Exception ex)
                {
                    testContextInstance.WriteLine("{0}", ex.Message);
                    testContextInstance.WriteLine("{0}", song.LOCATION);
                }
            }
//            uploadProcessor.EndProcess();
        }
示例#24
0
        public static void Upload(string connectionString, string accountName, string accountKey, string containerName)
        {
            int numSongs = 100;

/*            String[] desiredGenres = { "trance", "techno", "electronic", "ambient" ,"house",
 *                                       "beats", "big beat", "chill", "dub", "Electro", "grime", "hard psyche",
 *                                       "illbient", "jungle", "leftfield", "plunderphonic", "trip", "turn"}; */

            try
            {
                Console.WriteLine("Starting");

                var azureService           = new AzureService(accountName, accountKey);
                var uploadProcessor        = new UploadProcessor(containerName, accountName, accountKey);
                var musicDao               = new MusicDao(connectionString, null, uploadProcessor, azureService);
                IEnumerable <String> songs = FtpManager.List();

                foreach (String song in songs)
                {
                    if (song.Length > 0)
                    {
                        Console.WriteLine("Deleting: {0}", song);
                        FtpManager.Delete(song);
                        String songIdString = song.Substring(5);
                        songIdString = songIdString.Substring(0, songIdString.IndexOf('.'));
                        int songId = Convert.ToInt32(songIdString);
                        var song1  = new SONG()
                        {
                            ID = songId, UPLOADED = false
                        };
                        musicDao.UpdateSongUploadStatus(song1);
                    }
                }

                musicDao.UploadSongs(numSongs);

                Console.WriteLine("Done");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                throw;
            }
        }
示例#25
0
        static void Main(string[] args)
        {
            int i = 0;

            foreach (var subfolder in Directory.GetDirectories("../Data/uploads"))
            {
                var uploadProcessor = new UploadProcessor(subfolder);
                uploadProcessor.Process();
                i++;
            }

            var message = $"{i} uploads were processed";

            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                AppKitHelper.DisplayAlert(message);
            }
        }
示例#26
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting service.");
            string uploadPath        = "../../uploads";
            var    fileSystemWatcher = new FileSystemWatcher(uploadPath, "metadata.json");

            fileSystemWatcher.IncludeSubdirectories = true;
            while (true)
            {
                Console.WriteLine("Waiting...");
                var result = fileSystemWatcher.WaitForChanged(WatcherChangeTypes.Created);
                Console.WriteLine($"New metadata file {result.Name}");
                var fullMetadataFilePath = Path.Combine(uploadPath, result.Name);
                var subFolder            = Path.GetDirectoryName(fullMetadataFilePath);
                var processor            = new UploadProcessor(subFolder);
                Console.WriteLine("Starting Process.");
                processor.Process();
            }
        }
示例#27
0
        static void Main(string[] args)
        {
            var i = 0;

            //iterate through subfolders of /mnt/uploads
            foreach (var subfolder in Directory.GetDirectories("../../../../uploads"))
            {
                var uploadProcessor = new UploadProcessor(subfolder);
                uploadProcessor.Process();
                i++;
            }

            var message = $"{i} uploads were processed";

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                GtkHelper.DisplayAlert(message);
            }
        }
示例#28
0
        public MusicDao GetMusicDao()
        {
            var uploadProcessor = new UploadProcessor(containerName, Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey);

            uploadProcessor.OnError  += (s) => { testContextInstance.WriteLine("Error: {0}", s); };
            uploadProcessor.OnStatus += (s) => { testContextInstance.WriteLine("{0}", s); };
            var azureService = new AzureService(Properties.Settings.Default.AzureAccountName, Properties.Settings.Default.AzureAccountKey);
            var musicDao     = new MusicDao(Settings.Default.ConnectionString, new String[] { targetFolder }, uploadProcessor, azureService);

            musicDao.OnError   += (s) => { testContextInstance.WriteLine("Error: {0}", s); };
            musicDao.OnStatus  += (s) => { testContextInstance.WriteLine("{0}", s); };
            musicDao.OnNewSong += (s) =>
            {
                testContextInstance.WriteLine("New Song: {0}", s);
            };
            musicDao.OnNewArtist += (s) => { testContextInstance.WriteLine("New Artist: {0}", s); };

            return(musicDao);
        }
        private void UploadImage(UploadArgs args, HttpPostedFile file, string krakedImgePath)
        {
            Assert.ArgumentNotNull(args, "args");
            Assert.ArgumentNotNull(file, "file");

            var newFile = DownloadAndCreateFile(krakedImgePath, file);

            if (newFile == null)
            {
                base.Process(args);
            }
            else
            {
                bool flag    = UploadProcessor.IsUnpack(args, newFile);
                var  altText = args.GetFileParameter(file.FileName, "alt");

                MediaUploader mediaUploader = new MediaUploader
                {
                    File          = newFile,
                    Unpack        = flag,
                    Folder        = args.Folder,
                    Versioned     = args.Versioned,
                    Language      = args.Language,
                    AlternateText = !(string.IsNullOrEmpty(altText)) ? altText : file.FileName,
                    Overwrite     = args.Overwrite,
                    FileBased     = args.Destination == UploadDestination.File
                };
                System.Collections.Generic.List <MediaUploadResult> list;
                using (new SecurityDisabler())
                {
                    list = mediaUploader.Upload();
                }
                Log.Audit(this, "Upload: {0}", new string[]
                {
                    file.FileName
                });
                foreach (MediaUploadResult current in list)
                {
                    this.ProcessItem(args, current.Item, current.Path);
                }
            }
        }
示例#30
0
        public void UpdateSongMetadata()
        {
            try
            {
                var azureService    = new AzureService(Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey);
                var uploadProcessor = new UploadProcessor(Settings.Default.AzureContainerName, Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey);
                var musicDao        = new MusicDao(Settings.Default.ConnectionString, null, uploadProcessor, azureService);
                var dataContext     = new MusicEntities1();
                var songs           = dataContext.SONG;

                foreach (SONG song in songs)
                {
                    try
                    {
                        if (song.LOCATION.ToUpper().StartsWith("C:"))
                        {
                            song.LOCATION = song.LOCATION.Remove(0, 2);
                            song.LOCATION = "D:" + song.LOCATION;
                        }
                        if (File.Exists(song.LOCATION))
                        {
                            String title, artist, album, genre;
                            musicDao.GetSongMetadata(song.LOCATION, out title, out artist, out album, out genre);
                            if ((String.IsNullOrEmpty(genre)) && (genre != song.GENRE))
                            {
                                song.GENRE = genre;
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        testContextInstance.WriteLine(song.LOCATION);
                    }
                }
                dataContext.SaveChanges();
            }
            catch (Exception ex)
            {
                testContextInstance.WriteLine(ex.Message);
                testContextInstance.WriteLine(ex.StackTrace);
            }
        }