/// <summary> /// Parse the arguments for the programme and start either the reporting or deleting process /// </summary> /// <param name="args">The args.</param> static void Main(string[] args) { try { // Is the delete action specified as a parameter? bool delete = false; var len = args.Length; for (var i = 0; i < len; i++) { if (args[i].ToUpperInvariant() == "/DELETE" || args[i].ToUpperInvariant() == "-DELETE") { delete = true; args[i] = String.Empty; } } // Is a specific gallery specified as a parameter? ResourceGallery startGallery = null; using (var cmsContext = new CmsApplicationContext()) { cmsContext.AuthenticateAsCurrentUser(delete ? PublishingMode.Update : PublishingMode.Published); for (var i = 0; i < len; i++) { if (!String.IsNullOrEmpty(args[i])) { startGallery = CmsUtilities.ParseResourceGalleryUrl(args[i], cmsContext); // If gallery was specified but not found, tell the user and finish if (startGallery == null) { Console.WriteLine(String.Format(CultureInfo.CurrentCulture, Properties.Resources.ErrorGalleryNotFound, args[i])); return; } } } // If method hasn't returned and there's no gallery yet, none was specified, so default to root if (startGallery == null) { startGallery = cmsContext.RootResourceGallery; } // Based on arguments, either delete resources from the gallery or just report what would be deleted if (delete) { DeleteResources(cmsContext, startGallery); } else { ReportResources(startGallery); } } } catch (Exception ex) { ExceptionManager.Publish(ex); log.Error(ex.Message); } }