private static List <Tuple <string, Exception> > ProcessContentResume(string sContentUniqueId, string sContentHashCode) { string sIP = ""; List <Tuple <string, Exception> > listFailedSeed = new List <Tuple <string, Exception> >(); try { // Check the specified torrent in the offical seeds IManagementTask oCheckTask = (IManagementTask) new GetTorrentFileListTask(sContentHashCode); // Resume the specified torrent in the offical seeds IManagementTask oTask = (IManagementTask) new ResumeTorrentTask(sContentHashCode); // Enumerate each seed web for sending the command AppConfig.ContentDeployJob.OfficalSeedWebList.ForEach(oSeedWeb => { try { sIP = oSeedWeb.IP; QbtAdapter oAdapter = new QbtAdapter( false, sIP, oSeedWeb.Port, oSeedWeb.AdminName, oSeedWeb.AdminPassword); oAdapter.ExecuteTask(oCheckTask); if (((ArrayList)oCheckTask.Result).Count > 0) { oAdapter.ExecuteTask(oTask); } } catch (Exception oEx) { listFailedSeed.Add(new Tuple <string, Exception>(sIP, oEx)); } }); } catch (Exception oEx) { throw oEx; } return(listFailedSeed); }
private static string ProcessSeedMonitor(AppConfig.ContentDeployJob.OfficalSeedWeb oSeedWeb) { try { // Retrieve all the torrent details in the offical seed IManagementTask oTask = (IManagementTask) new RetrieveTorrentDetailsTask(); QbtAdapter oAdapter = new QbtAdapter( false, oSeedWeb.IP, oSeedWeb.Port, oSeedWeb.AdminName, oSeedWeb.AdminPassword); oAdapter.ExecuteTask(oTask); // Serialize the torrent details to JSON and return return(JsonConvert.SerializeObject(oTask.Result)); } catch (Exception oEx) { // Generate the exception in more detail throw new ApplicationException(string.Format(AppResource.OfficalSeedCmdFailed, oSeedWeb.IP, typeof(RetrieveTorrentDetailsTask).Name), oEx); } }
private static List <Tuple <string, Exception> > ProcessContentOffline(string sContentUniqueId, string sContentHashCode) { // Send the torrent remove command to the offical seeds first // then deleted the reployed torrent files afterward to make // the availability of the content files more consistent. string sIP = ""; List <Tuple <string, Exception> > listFailedSeed = new List <Tuple <string, Exception> >(); try { // Remove the deployed torrent files from the offical seeds IManagementTask oTask = (IManagementTask) new RemoveTorrentTask(sContentHashCode); // Enumerate each seed web for sending the command AppConfig.ContentDeployJob.OfficalSeedWebList.ForEach(oSeedWeb => { try { sIP = oSeedWeb.IP; QbtAdapter oAdapter = new QbtAdapter( false, sIP, oSeedWeb.Port, oSeedWeb.AdminName, oSeedWeb.AdminPassword); oAdapter.ExecuteTask(oTask); } catch (Exception oEx) { listFailedSeed.Add(new Tuple <string, Exception>(sIP, oEx)); } }); } catch (Exception oEx) { throw oEx; } try { // Delete the deployed torrent files if any if (File.Exists( AppConfig.ContentDeployJob.TorrentDeployTarget + "\\" + sContentHashCode + ContentGenJob.TorrentExtension)) { File.Delete( AppConfig.ContentDeployJob.TorrentDeployTarget + "\\" + sContentHashCode + ContentGenJob.TorrentExtension); } if (File.Exists( AppConfig.ContentDeployJob.VipTorrentDeployTarget + "\\" + sContentHashCode + ContentGenJob.TorrentVipExtension)) { File.Delete( AppConfig.ContentDeployJob.VipTorrentDeployTarget + "\\" + sContentHashCode + ContentGenJob.TorrentVipExtension); } if (File.Exists( AppConfig.ContentDeployJob.FqdnTorrentDeployTarget + "\\" + sContentHashCode + ContentGenJob.TorrentFqdnExtension)) { File.Delete( AppConfig.ContentDeployJob.FqdnTorrentDeployTarget + "\\" + sContentHashCode + ContentGenJob.TorrentFqdnExtension); } // Delete the deployed downloader (for portal users download) if any if (File.Exists( AppConfig.ContentDeployJob.DownloaderDeployTarget + "\\" + sContentUniqueId + "\\" + sContentHashCode + ContentGenJob.DownloaderExtension)) { File.Delete( AppConfig.ContentDeployJob.DownloaderDeployTarget + "\\" + sContentUniqueId + "\\" + sContentHashCode + ContentGenJob.DownloaderExtension); } // Delete the deployed torrent file (for portal users download) if any if (File.Exists( AppConfig.ContentDeployJob.DownloaderDeployTarget + "\\" + sContentUniqueId + "\\" + sContentHashCode + ContentGenJob.TorrentExtension)) { File.Delete( AppConfig.ContentDeployJob.DownloaderDeployTarget + "\\" + sContentUniqueId + "\\" + sContentHashCode + ContentGenJob.TorrentExtension); } } catch (Exception oEx) { throw oEx; } return(listFailedSeed); }
public static void Rollback(string sContentHashCode) { lock (ContentGenJob.sigLock) { if (sContentHashCode != "") { // Delete the deployed torrent files if any if (File.Exists( AppConfig.ContentDeployJob.TorrentDeployTarget + "\\" + sContentHashCode + ContentGenJob.TorrentExtension)) { File.Delete( AppConfig.ContentDeployJob.TorrentDeployTarget + "\\" + sContentHashCode + ContentGenJob.TorrentExtension); } if (File.Exists( AppConfig.ContentDeployJob.VipTorrentDeployTarget + "\\" + sContentHashCode + ContentGenJob.TorrentVipExtension)) { File.Delete( AppConfig.ContentDeployJob.VipTorrentDeployTarget + "\\" + sContentHashCode + ContentGenJob.TorrentVipExtension); } if (File.Exists( AppConfig.ContentDeployJob.FqdnTorrentDeployTarget + "\\" + sContentHashCode + ContentGenJob.TorrentFqdnExtension)) { File.Delete( AppConfig.ContentDeployJob.FqdnTorrentDeployTarget + "\\" + sContentHashCode + ContentGenJob.TorrentFqdnExtension); } if (File.Exists( AppConfig.ContentDeployJob.DownloaderDeployTarget + "\\" + sContentHashCode + ContentGenJob.DownloaderExtension)) { File.Delete( AppConfig.ContentDeployJob.DownloaderDeployTarget + "\\" + sContentHashCode + ContentGenJob.DownloaderExtension); } if (File.Exists( AppConfig.ContentDeployJob.DownloaderDeployTarget + "\\" + sContentHashCode + ContentGenJob.TorrentExtension)) { File.Delete( AppConfig.ContentDeployJob.DownloaderDeployTarget + "\\" + sContentHashCode + ContentGenJob.TorrentExtension); } // Remove the deployed torrent files from the offical seeds by sending the remove command anyway IManagementTask oTask = (IManagementTask) new RemoveTorrentTask(sContentHashCode); // Enumerate each seed web for sending the command AppConfig.ContentDeployJob.OfficalSeedWebList.ForEach(oSeedWeb => { QbtAdapter oAdapter = new QbtAdapter( false, oSeedWeb.IP, oSeedWeb.Port, oSeedWeb.AdminName, oSeedWeb.AdminPassword); // Supress the exception if occurs to keep on trying the next seed try { oAdapter.ExecuteTask(oTask); } catch { } }); } } }
public static List <Tuple <string, Exception> > ProcessContentDeploy(string sContentUniqueId, string sContentHashCode) { try { // Deploy Torrent File to the target folder CopyFile( AppConfig.ContentDeployJob.TorrentDeployTarget, sContentUniqueId, sContentHashCode, ContentGenJob.TorrentExtension); // Deploy Vip Torrent File to the target folder CopyFile( AppConfig.ContentDeployJob.VipTorrentDeployTarget, sContentUniqueId, sContentHashCode, ContentGenJob.TorrentVipExtension); // Deploy FQDN Torrent File to the target folder CopyFile( AppConfig.ContentDeployJob.FqdnTorrentDeployTarget, sContentUniqueId, sContentHashCode, ContentGenJob.TorrentFqdnExtension); // Deploy Content Downloader (for portal users download) to the target folder CopyFile( AppConfig.ContentDeployJob.DownloaderDeployTarget, sContentUniqueId, sContentHashCode, ContentGenJob.DownloaderExtension, true); // Deploy Torrent File (for portal users download) to the target folder CopyFile( AppConfig.ContentDeployJob.DownloaderDeployTarget, sContentUniqueId, sContentHashCode, ContentGenJob.TorrentExtension); } catch (Exception oEx) { Rollback(sContentHashCode); throw oEx; } string sIP = ""; List <Tuple <string, Exception> > listFailedSeed = new List <Tuple <string, Exception> >(); try { string sFqdnTorrentPublishUrl = AppConfig.ContentDeployJob.FqdnTorrentPublishUrl + "//" + sContentHashCode + ContentGenJob.TorrentFqdnExtension; IManagementTask oTask = (IManagementTask) new AddTorrentByUrlTask(sFqdnTorrentPublishUrl); // Enumerate each seed web for sending the command AppConfig.ContentDeployJob.OfficalSeedWebList.ForEach(oSeedWeb => { try { sIP = oSeedWeb.IP; QbtAdapter oAdapter = new QbtAdapter( false, sIP, oSeedWeb.Port, oSeedWeb.AdminName, oSeedWeb.AdminPassword); oAdapter.ExecuteTask(oTask); } catch (Exception oEx) { listFailedSeed.Add(new Tuple <string, Exception>(sIP, oEx)); } }); } catch (Exception oEx) { Rollback(sContentHashCode); throw oEx; } return(listFailedSeed); }