private void uxUploadBtn_Click(object sender, EventArgs e) { if (uxFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { uxUploadBtn.Enabled = false; uxStatus.Text = "Uploading"; var uploader = new SherpaArchiveUploader() { FilePath = uxFileDialog.FileName, ArchiveBucket = "test_collection", Title = "Archive Sherpa Test Upload", ArchiveAccessKey = "Cm5Fwwwj68iaTVBF", ArchiveSecret = "mSQqurxXNkrXX3Ux", IdentityToken = "ray-tiley" }; uploader.UploadProgressChanged += uploader_UploadProgressChanged; uploader.UploadComplete += uploader_UploadComplete; uploader.StartUploadAsync(); } }
private void RunLoop() { while (m_run) { System.Threading.Thread.Sleep(1000 * 60 * 5); //Sleep five minute try { ShowInfo showToUpload = null; string pathToFile = String.Empty; //This is specific for archive. Eventually pull it out into the Archive Class var interestedFields = new Dictionary<string, List<string>>(); var yesValues = new List<string>(new string[] { "yes", "true", "x" }); interestedFields.Add("Archive-Upload", yesValues); var shows = m_CCManager.GetUploads(interestedFields, "Archive-URL"); if (shows.Count == 0) continue; LogHelper.Logger.Debug(String.Format("Found {0} shows from cablecast that need uploading. ", shows.Count)); //TODO get from config var paths = new List<string>(); foreach (var path in m_ContentPaths.Split('|')) { paths.Add(path); } //Try Uploading the first show with a file. foreach (var show in shows) { pathToFile = CCFileFinder.FindFile(show.ShowID, paths); if (String.IsNullOrWhiteSpace(pathToFile) == false) { showToUpload = show; break; } else { LogHelper.Logger.Debug(String.Format("Could not find file for show: {0} - {1}", show.ShowID, show.Title)); } } if (showToUpload != null) { var archiveURL = showToUpload.CustomFields.FirstOrDefault(f => f.Name == "Archive-CC-License"); LogHelper.Logger.Debug(String.Format("Beginning Upload of {0}", pathToFile)); var uploader = new SherpaArchiveUploader() { FilePath = pathToFile, Title = showToUpload.Title, Description = showToUpload.Comments, LicenseURL = (archiveURL != null && String.IsNullOrWhiteSpace(archiveURL.Value) == false) ? archiveURL.Value : m_DefaultArchiveLicenseUrl, ArchiveBucket = m_ArchiveCollection, IdentityToken = m_ArchivePrefix, ArchiveAccessKey = m_ArchiveKey, ArchiveSecret = m_ArchiveSecret, }; try { uploader.StartUploadSync(); //This is where we should set showrecord. LogHelper.Logger.Debug(String.Format("Saving to Cablecast: {0}", uploader.ItemURL)); var fields = new Dictionary<string, string>(); fields.Add("Archive-URL", uploader.ItemURL); m_CCManager.UpdateShow(showToUpload.ShowID, fields); } catch (Exception ex) { LogHelper.Logger.Error(String.Format("Problem Uploading {0}", pathToFile), ex); } } else { LogHelper.Logger.Debug("Could not find any files on disk for uploading"); } } catch (Exception ex) { LogHelper.Logger.Error("General exception in run loop", ex); } } }