Exemplo n.º 1
0
        private static bool UnzipPackage(UpdateStatusExecutor executor, Filing f, string zipPath, out string[] zipFiles)
        {
            zipFiles = new string[0];

            string errorMsg;

            if (!ZipUtilities.TryUnzipAndUncompressFiles(f.InstancePath, zipPath, out zipFiles, out errorMsg))
            {
                executor.Invoke("Error: The ZIP file cannot be opened.");
                executor.Invoke("\tSkipping filing: " + f.InstancePath);
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        private static bool UnzipPackage(Filing f, string zipPath, out string[] zipFiles)
        {
            zipFiles = new string[0];

            string errorMsg;

            if (!ZipUtilities.TryUnzipAndUncompressFiles(f.InstancePath, zipPath, out zipFiles, out errorMsg))
            {
                Console.WriteLine("Error: The ZIP file cannot be opened.");
                Console.WriteLine("\tSkipping filing: " + f.InstancePath);
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        private bool CleanOrOverwriteFile(string filePath, Filing f)
        {
            if (!File.Exists(filePath))
            {
                return(true);
            }

            if (this.Quiet)
            {
                Console.WriteLine("Information: The destination reports zip already exists.  Prompt suppressed.");
                Console.WriteLine("\tSkipping filing: " + f.InstancePath);
                return(false);
            }

            bool validSelection = false;

            while (!validSelection)
            {
                Console.WriteLine();
                Console.Write("The destination zip already exists.  Overwrite this file? [Y/N] ");

                ConsoleKeyInfo keyInfo = Console.ReadKey(false);
                switch (keyInfo.Key)
                {
                case ConsoleKey.Y:
                    validSelection = true;
                    File.Delete(filePath);
                    Console.WriteLine();
                    break;

                case ConsoleKey.N:
                    Console.WriteLine();
                    Console.Write("Information:  The user selected not to overwrite destination zip.");
                    Console.WriteLine("\tSkipping filing: " + f.InstancePath);
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 4
0
        private bool CleanOrOverwriteFile(string filePath, Filing f)
        {
            if (!File.Exists(filePath))
            {
                return(true);
            }

            //if( this.Quiet )
            //{
            //    executor.Invoke( "Information: The destination reports zip already exists.  Prompt suppressed." );
            //    executor.Invoke( "\tSkipping filing: " + f.InstancePath );
            //    return false;
            //}

            //bool validSelection = false;
            //while( !validSelection )
            //{
            //    Console.WriteLine();
            //    Console.Write( "The destination zip already exists.  Overwrite this file? [Y/N] " );

            //    ConsoleKeyInfo keyInfo = Console.ReadKey( false );
            //    switch( keyInfo.Key )
            //    {
            //        case ConsoleKey.Y:
            //            validSelection = true;
            //            File.Delete( filePath );
            //            Console.WriteLine();
            //            break;
            //        case ConsoleKey.N:
            //            Console.WriteLine();
            //            Console.Write( "Information:  The user selected not to overwrite destination zip." );
            //            Console.WriteLine( "\tSkipping filing: " + f.InstancePath );
            //            return false;
            //    }
            //}

            File.Delete(filePath);
            return(true);
        }
Exemplo n.º 5
0
        private bool GetOutputPath(string basePath, Filing.SaveAs saveAs, bool isMultiple, Filing f, out string outputPath)
        {
            outputPath = null;

            if (Path.IsPathRooted(this.ReportsFolder))
            {
                if (!Directory.Exists(this.ReportsFolder))
                {
                    executor.Invoke("Error: The ReportsFolder does not exist at " + this.ReportsFolder + ".");
                    executor.Invoke("\tSkipping filing: " + f.InstancePath);
                    return(false);
                }

                string tmpPath = this.ReportsFolder.TrimEnd('\\');
                if (string.Equals(basePath, tmpPath, StringComparison.CurrentCultureIgnoreCase))
                {
                    executor.Invoke("Error: The ReportsFolder matches the Filing folder:");
                    executor.Invoke("\tReportsFolder: " + this.ReportsFolder);
                    executor.Invoke("\tFiling folder: " + basePath);
                    executor.Invoke("\tSkipping filing: " + f.InstancePath);
                    return(false);
                }

                if (saveAs == Filing.SaveAs.Xml)
                {
                    string xmlPath = Path.Combine(this.ReportsFolder, Path.GetFileNameWithoutExtension(f.InstancePath));
                    if (!this.CleanOrCreateReportsPath(xmlPath, f))
                    {
                        return(false);
                    }

                    outputPath = xmlPath;
                    return(true);
                }
                else
                {
                    string zipPath = Path.Combine(this.ReportsFolder, Path.GetFileNameWithoutExtension(f.InstancePath) + ".zip");
                    if (!this.CleanOrOverwriteFile(zipPath, f))
                    {
                        return(false);
                    }

                    outputPath = zipPath;
                    return(true);
                }
            }
            else
            {
                if (saveAs == Filing.SaveAs.Xml)
                {
                    string xmlPath = Path.Combine(basePath, this.ReportsFolder);
                    if (!Directory.Exists(xmlPath))
                    {
                        Directory.CreateDirectory(xmlPath);
                    }

                    if (isMultiple)
                    {
                        xmlPath = Path.Combine(xmlPath, Path.GetFileNameWithoutExtension(f.InstancePath));
                    }

                    if (!this.CleanOrCreateReportsPath(xmlPath, f))
                    {
                        return(false);
                    }

                    outputPath = xmlPath;
                    return(true);
                }
                else
                {
                    string zipPath = Path.Combine(basePath, this.ReportsFolder);
                    if (!Directory.Exists(zipPath))
                    {
                        Directory.CreateDirectory(zipPath);
                    }

                    zipPath = Path.Combine(zipPath, Path.GetFileNameWithoutExtension(f.InstancePath) + ".zip");
                    if (!this.CleanOrOverwriteFile(zipPath, f))
                    {
                        return(false);
                    }

                    outputPath = zipPath;
                    return(true);
                }
            }
        }
Exemplo n.º 6
0
        // plamen
        private bool CleanOrCreateReportsPath(string reportsPath, Filing f)
        {
            bool deleted = true;

            if (Directory.Exists(reportsPath))
            {
                string[] files = Directory.GetFiles(reportsPath);
                if (files.Length == 0)
                {
                    return(true);
                }

                //if( this.Quiet )
                //{
                //    Console.WriteLine( "Information: The destination reports folder contains other files.  Prompt suppressed." );
                //    Console.WriteLine( "\tSkipping filing: " + f.InstancePath );
                //    return false;
                //}

                deleted = false;
                bool canDeleteOrReplace = true;                 // plamen
                //if( !canDeleteOrReplace )
                //{
                //    bool validSelection = false;
                //    while( !validSelection )
                //    {
                //        Console.WriteLine();
                //        Console.Write( "The destination reports folder contains other files.  Overwrite these files? [Y/N] " );
                //        ConsoleKeyInfo keyInfo = Console.ReadKey( false );

                //        switch( keyInfo.Key )
                //        {
                //            case ConsoleKey.Y:
                //                canDeleteOrReplace = true;
                //                goto case ConsoleKey.N;
                //            case ConsoleKey.N:
                //                validSelection = true;
                //                break;
                //        }
                //    }
                //    Console.WriteLine();
                //}

                if (!canDeleteOrReplace)
                {
                    return(false);
                }

                deleted = CleanPath(reportsPath);
            }

            if (!deleted)
            {
                executor.Invoke("Error: Reports folder already exists and cannot delete or replace files.");
                executor.Invoke("\tReports folder: " + reportsPath);
                executor.Invoke("\tSkipping filing: " + f.InstancePath);
                return(false);
            }

            if (!Directory.Exists(reportsPath))
            {
                try
                {
                    Directory.CreateDirectory(reportsPath);
                }
                catch
                {
                    executor.Invoke("Error: Reports folder does not exist and cannot be created.");
                    executor.Invoke("\tReports folder: " + reportsPath);
                    executor.Invoke("\tSkipping filing: " + f.InstancePath);
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 7
0
        public void ProcessFiling(Filing f, bool isMultipleFilings)
        {
            executor.Invoke("Information: Preparing " + f.InstancePath);

            if (!File.Exists(f.InstancePath))
            {
                executor.Invoke("Error: Instance document not found at " + f.InstancePath + ".");
                executor.Invoke("\tSkipping filing: " + f.InstancePath);
                return;
            }

            Filing.SaveAs saveAs = Filing.SaveAs.Auto;
            bool          isZip  = string.Equals(Path.GetExtension(f.InstancePath), ".zip", StringComparison.CurrentCultureIgnoreCase);

            if (isZip)
            {
                saveAs = Filing.SaveAs.Zip;
                if (this.SaveAs == Filing.SaveAs.Xml)
                {
                    saveAs = Filing.SaveAs.Xml;
                }
            }
            else
            {
                saveAs = Filing.SaveAs.Xml;
                if (this.SaveAs == Filing.SaveAs.Zip)
                {
                    saveAs = Filing.SaveAs.Zip;
                }
            }

            string outputPath;
            string basePath = Path.GetDirectoryName(f.InstancePath);

            if (!this.GetOutputPath(basePath, saveAs, isMultipleFilings, f, out outputPath))
            {
                return;
            }

            string tmpPath = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(f.InstancePath));

            if (!Directory.Exists(tmpPath))
            {
                Directory.CreateDirectory(tmpPath);
            }
            else
            {
                CleanPath(tmpPath);
            }

            try
            {
                if (isZip)
                {
                    string[] packageFiles;
                    if (!UnzipPackage(executor, f, tmpPath, out packageFiles))
                    {
                        return;
                    }

                    string taxonomy;
                    bool   instanceFound = false;
                    foreach (string file in packageFiles)
                    {
                        if (IsInstance(file, out taxonomy))
                        {
                            instanceFound  = true;
                            f.InstancePath = file;
                            f.TaxonomyPath = taxonomy;
                            break;
                        }
                    }

                    if (!instanceFound)
                    {
                        executor.Invoke("Error: The ZIP file does not contain an instance document.");
                        executor.Invoke("\tSkipping filing: " + f.InstancePath);
                        return;
                    }
                }
                else
                {
                    string taxonomyPath;
                    if (!this.IsInstance(f.InstancePath, out taxonomyPath))
                    {
                        executor.Invoke("Error: Instance document not found at " + f.InstancePath + ".");
                        executor.Invoke("\tSkipping filing: " + f.InstancePath);
                        return;
                    }

                    f.TaxonomyPath = taxonomyPath;
                }
                string        error;
                FilingSummary fs;
                string        reportsPath = isZip ? Path.Combine(tmpPath, "Reports") : tmpPath;
                string        fsPath      = Path.Combine(reportsPath, FilingSummary.FilingSummaryXmlName);

                XRB.ReportBuilder rb = new XRB.ReportBuilder(executor, RulesEngineUtils.DefaultRulesFile, this.ReportFormat, this.HtmlReportFormat);
                rb.CurrencyMappingFile   = this.CurrencyMappingFile;
                rb.RemoteFileCachePolicy = this.RemoteFileCachePolicy;
                rb.XsltStylesheetPath    = this.XsltStylesheetPath;

                if (!rb.BuildReports(f.InstancePath, f.TaxonomyPath, fsPath, reportsPath, out fs, out error))
                {
                    executor.Invoke("Unexpected error: " + error);
                    executor.Invoke("\tFailed filing: " + f.InstancePath);
                }

                if (saveAs == Filing.SaveAs.Xml)
                {
                    foreach (string copyFrom in Directory.GetFiles(reportsPath))
                    {
                        string copyTo = Path.Combine(outputPath, Path.GetFileName(copyFrom));
                        File.Copy(copyFrom, copyTo);
                    }
                }
                else
                {
                    string[] reports = Directory.GetFiles(reportsPath);
                    this.ZipReports(outputPath, reports);
                }

                executor.Invoke("Information: Reports successfully created.");
                executor.Invoke("\t" + (fs.MyReports.Count - 1) + " reports created at " + outputPath + ".");
                if (string.IsNullOrEmpty(error))
                {
                    executor.Invoke("reload");
                }
            }
            catch (Exception ex)
            {
                executor.Invoke("Unexpected error: " + ex.Message);
            }
            finally
            {
                CleanPath(tmpPath);
            }
        }
Exemplo n.º 8
0
        public static FilingProcessor Load(UpdateStatusExecutor executor, params string[] args)
        {
            FilingProcessor fp = new FilingProcessor(executor);

            //return fp;

            foreach (string arg in args)
            {
                if (!arg.StartsWith("/"))
                {
                    executor.Invoke("Ignoring parameter.  Reason: incorrect format." + separator +
                                    "\t" + arg + "");
                    continue;
                }

                int    commandEnd    = arg.IndexOf('=');
                bool   isCommandOnly = commandEnd == -1;
                string command       = isCommandOnly ? arg.Substring(1) : arg.Substring(1, commandEnd - 1);
                if (isCommandOnly && !string.Equals(command, QUIET_COMMAND))
                {
                    executor.Invoke("Ignoring parameter.  Reason: incorrect format." + separator + "\t" + arg + "");
                    continue;
                }

                string value = arg.Substring(commandEnd + 1);
                switch (command)
                {
                case INSTANCE_COMMAND:
                    Filing filing = new Filing(executor, value);
                    fp.Filings.Add(filing);
                    break;

                case REPORTS_FOLDER_COMMAND:
                    fp.SetReportsFolder(value, "Arguments");
                    break;

                case REPORT_FORMAT_COMMAND:
                    fp.SetReportFormat(value, "Arguments");
                    break;

                case HTML_REPORT_FORMAT_COMMAND:
                    fp.SetHtmlReportFormat(value, "Arguments");
                    break;

                case REMOTE_CACHE_POLICY_COMMAND:
                    fp.SetRemoteFileCachePolicy(value, "Arguments");
                    break;

                case QUIET_COMMAND:
                    fp.Quiet = true;
                    break;

                case SAVEAS_COMMAND:
                    fp.SetSaveAs(value, "Arguments");
                    break;

                case XSLT_STYLESHEET_COMMAND:
                    fp.SetXsltStylesheetPath(value, "Arguments");
                    break;

                default:
                    executor.Invoke("Arguments: Ignoring parameter " + command + ".  Reason: unrecognized command " + command + "" + separator +
                                    "\t" + arg + "");
                    break;
                }
            }

            return(fp);
        }
Exemplo n.º 9
0
        private bool GetOutputPath( string basePath, Filing.SaveAs saveAs, bool isMultiple, Filing f, out string outputPath )
        {
            outputPath = null;

            if( Path.IsPathRooted( this.ReportsFolder ) )
            {
                if( !Directory.Exists( this.ReportsFolder ) )
                {
                    executor.Invoke( "Error: The ReportsFolder does not exist at " + this.ReportsFolder + "." );
                    executor.Invoke( "\tSkipping filing: " + f.InstancePath );
                    return false;
                }

                string tmpPath = this.ReportsFolder.TrimEnd( '\\' );
                if( string.Equals( basePath, tmpPath, StringComparison.CurrentCultureIgnoreCase ) )
                {
                    executor.Invoke( "Error: The ReportsFolder matches the Filing folder:" );
                    executor.Invoke( "\tReportsFolder: " + this.ReportsFolder );
                    executor.Invoke( "\tFiling folder: " + basePath );
                    executor.Invoke( "\tSkipping filing: " + f.InstancePath );
                    return false;
                }

                if( saveAs == Filing.SaveAs.Xml )
                {
                    string xmlPath = Path.Combine( this.ReportsFolder, Path.GetFileNameWithoutExtension( f.InstancePath ) );
                    if( !this.CleanOrCreateReportsPath( xmlPath, f ) )
                        return false;

                    outputPath = xmlPath;
                    return true;
                }
                else
                {
                    string zipPath = Path.Combine( this.ReportsFolder, Path.GetFileNameWithoutExtension( f.InstancePath ) + ".zip" );
                    if( !this.CleanOrOverwriteFile( zipPath, f ) )
                        return false;

                    outputPath = zipPath;
                    return true;
                }
            }
            else
            {
                if( saveAs == Filing.SaveAs.Xml )
                {
                    string xmlPath = Path.Combine( basePath, this.ReportsFolder );
                    if( !Directory.Exists( xmlPath ) )
                        Directory.CreateDirectory( xmlPath );

                    if( isMultiple )
                        xmlPath = Path.Combine( xmlPath, Path.GetFileNameWithoutExtension( f.InstancePath ) );

                    if( !this.CleanOrCreateReportsPath( xmlPath, f ) )
                        return false;

                    outputPath = xmlPath;
                    return true;
                }
                else
                {
                    string zipPath = Path.Combine( basePath, this.ReportsFolder );
                    if( !Directory.Exists( zipPath ) )
                        Directory.CreateDirectory( zipPath );

                    zipPath = Path.Combine( zipPath, Path.GetFileNameWithoutExtension( f.InstancePath ) + ".zip" );
                    if( !this.CleanOrOverwriteFile( zipPath, f ) )
                        return false;

                    outputPath = zipPath;
                    return true;
                }
            }
        }
Exemplo n.º 10
0
        private bool CleanOrOverwriteFile( string filePath, Filing f )
        {
            if( !File.Exists( filePath ) )
                return true;

            //if( this.Quiet )
            //{
            //    executor.Invoke( "Information: The destination reports zip already exists.  Prompt suppressed." );
            //    executor.Invoke( "\tSkipping filing: " + f.InstancePath );
            //    return false;
            //}

            //bool validSelection = false;
            //while( !validSelection )
            //{
            //    Console.WriteLine();
            //    Console.Write( "The destination zip already exists.  Overwrite this file? [Y/N] " );

            //    ConsoleKeyInfo keyInfo = Console.ReadKey( false );
            //    switch( keyInfo.Key )
            //    {
            //        case ConsoleKey.Y:
            //            validSelection = true;
            //            File.Delete( filePath );
            //            Console.WriteLine();
            //            break;
            //        case ConsoleKey.N:
            //            Console.WriteLine();
            //            Console.Write( "Information:  The user selected not to overwrite destination zip." );
            //            Console.WriteLine( "\tSkipping filing: " + f.InstancePath );
            //            return false;
            //    }
            //}

            File.Delete(filePath);
            return true;
        }
Exemplo n.º 11
0
        // plamen
        private bool CleanOrCreateReportsPath( string reportsPath, Filing f )
        {
            bool deleted = true;
            if( Directory.Exists( reportsPath ) )
            {
                string[] files = Directory.GetFiles( reportsPath );
                if( files.Length == 0 )
                    return true;

                //if( this.Quiet )
                //{
                //    Console.WriteLine( "Information: The destination reports folder contains other files.  Prompt suppressed." );
                //    Console.WriteLine( "\tSkipping filing: " + f.InstancePath );
                //    return false;
                //}

                deleted = false;
                bool canDeleteOrReplace = true; // plamen
                //if( !canDeleteOrReplace )
                //{
                //    bool validSelection = false;
                //    while( !validSelection )
                //    {
                //        Console.WriteLine();
                //        Console.Write( "The destination reports folder contains other files.  Overwrite these files? [Y/N] " );
                //        ConsoleKeyInfo keyInfo = Console.ReadKey( false );

                //        switch( keyInfo.Key )
                //        {
                //            case ConsoleKey.Y:
                //                canDeleteOrReplace = true;
                //                goto case ConsoleKey.N;
                //            case ConsoleKey.N:
                //                validSelection = true;
                //                break;
                //        }
                //    }
                //    Console.WriteLine();
                //}

                if( !canDeleteOrReplace )
                    return false;

                deleted = CleanPath( reportsPath );
            }

            if( !deleted )
            {
                executor.Invoke( "Error: Reports folder already exists and cannot delete or replace files." );
                executor.Invoke( "\tReports folder: " + reportsPath );
                executor.Invoke( "\tSkipping filing: " + f.InstancePath );
                return false;
            }

            if( !Directory.Exists( reportsPath ) )
            {
                try
                {
                    Directory.CreateDirectory( reportsPath );
                }
                catch
                {
                    executor.Invoke( "Error: Reports folder does not exist and cannot be created." );
                    executor.Invoke( "\tReports folder: " + reportsPath );
                    executor.Invoke( "\tSkipping filing: " + f.InstancePath );
                    return false;
                }
            }

            return true;
        }
Exemplo n.º 12
0
        private static bool UnzipPackage(UpdateStatusExecutor executor, Filing f, string zipPath, out string[] zipFiles )
        {
            zipFiles = new string[ 0 ];

            string errorMsg;
            if( !ZipUtilities.TryUnzipAndUncompressFiles( f.InstancePath, zipPath, out zipFiles, out errorMsg ) )
            {
                executor.Invoke( "Error: The ZIP file cannot be opened." );
                executor.Invoke( "\tSkipping filing: " + f.InstancePath );
                return false;
            }

            return true;
        }
Exemplo n.º 13
0
        public void ProcessFiling( Filing f, bool isMultipleFilings )
        {
            executor.Invoke( "Information: Preparing " + f.InstancePath );

            if( !File.Exists( f.InstancePath ) )
            {
                executor.Invoke( "Error: Instance document not found at " + f.InstancePath + "." );
                executor.Invoke( "\tSkipping filing: " + f.InstancePath );
                return;
            }

            Filing.SaveAs saveAs = Filing.SaveAs.Auto;
            bool isZip = string.Equals( Path.GetExtension( f.InstancePath ), ".zip", StringComparison.CurrentCultureIgnoreCase );
            if( isZip )
            {
                saveAs = Filing.SaveAs.Zip;
                if( this.SaveAs == Filing.SaveAs.Xml )
                    saveAs = Filing.SaveAs.Xml;
            }
            else
            {
                saveAs = Filing.SaveAs.Xml;
                if( this.SaveAs == Filing.SaveAs.Zip )
                    saveAs = Filing.SaveAs.Zip;
            }

            string outputPath;
            string basePath = Path.GetDirectoryName( f.InstancePath );
            if( !this.GetOutputPath( basePath, saveAs, isMultipleFilings, f, out outputPath ) )
                return;

            string tmpPath = Path.Combine( Path.GetTempPath(), Path.GetFileNameWithoutExtension( f.InstancePath ) );
            if( !Directory.Exists( tmpPath ) )
                Directory.CreateDirectory( tmpPath );
            else
                CleanPath( tmpPath );

            try
            {
                if( isZip )
                {
                    string[] packageFiles;
                    if( !UnzipPackage(executor, f, tmpPath, out packageFiles ) )
                        return;

                    string taxonomy;
                    bool instanceFound = false;
                    foreach( string file in packageFiles )
                    {
                        if( IsInstance( file, out taxonomy ) )
                        {
                            instanceFound = true;
                            f.InstancePath = file;
                            f.TaxonomyPath = taxonomy;
                            break;
                        }
                    }

                    if( !instanceFound )
                    {
                        executor.Invoke( "Error: The ZIP file does not contain an instance document." );
                        executor.Invoke( "\tSkipping filing: " + f.InstancePath );
                        return;
                    }
                }
                else
                {
                    string taxonomyPath;
                    if( !this.IsInstance( f.InstancePath, out taxonomyPath ) )
                    {
                        executor.Invoke( "Error: Instance document not found at " + f.InstancePath + "." );
                        executor.Invoke( "\tSkipping filing: " + f.InstancePath );
                        return;
                    }

                    f.TaxonomyPath = taxonomyPath;
                }
                string error;
                FilingSummary fs;
                string reportsPath = isZip ? Path.Combine( tmpPath, "Reports" ) : tmpPath;
                string fsPath = Path.Combine( reportsPath, FilingSummary.FilingSummaryXmlName );

                XRB.ReportBuilder rb = new XRB.ReportBuilder(executor, RulesEngineUtils.DefaultRulesFile, this.ReportFormat, this.HtmlReportFormat );
                rb.CurrencyMappingFile = this.CurrencyMappingFile;
                rb.RemoteFileCachePolicy = this.RemoteFileCachePolicy;
                rb.XsltStylesheetPath = this.XsltStylesheetPath;

                if( !rb.BuildReports( f.InstancePath, f.TaxonomyPath, fsPath, reportsPath, out fs, out error ) )
                {
                    executor.Invoke( "Unexpected error: " + error );
                    executor.Invoke( "\tFailed filing: " + f.InstancePath );
                }

                if( saveAs == Filing.SaveAs.Xml )
                {
                    foreach( string copyFrom in Directory.GetFiles( reportsPath ) )
                    {
                        string copyTo = Path.Combine( outputPath, Path.GetFileName( copyFrom ) );
                        File.Copy( copyFrom, copyTo );
                    }
                }
                else
                {
                    string[] reports = Directory.GetFiles( reportsPath );
                    this.ZipReports( outputPath, reports );
                }

                executor.Invoke( "Information: Reports successfully created." );
                executor.Invoke( "\t" + ( fs.MyReports.Count - 1 ) + " reports created at " + outputPath + "." );
                if (string.IsNullOrEmpty(error))
                {
                    executor.Invoke("reload");
                }
            }
            catch( Exception ex )
            {
                executor.Invoke( "Unexpected error: " + ex.Message );
            }
            finally
            {
                CleanPath( tmpPath );
            }
        }
Exemplo n.º 14
0
        public static FilingProcessor Load(UpdateStatusExecutor executor, params string[] args)
        {
            FilingProcessor fp = new FilingProcessor(executor);
            //return fp;

            foreach( string arg in args )
            {
                if( !arg.StartsWith( "/" ) )
                {
                    executor.Invoke( "Ignoring parameter.  Reason: incorrect format." + separator +
                        "\t" + arg +"" );
                    continue;
                }

                int commandEnd = arg.IndexOf( '=' );
                bool isCommandOnly = commandEnd == -1;
                string command = isCommandOnly ? arg.Substring( 1 ) : arg.Substring( 1, commandEnd - 1 );
                if( isCommandOnly && !string.Equals( command, QUIET_COMMAND ) )
                {
                    executor.Invoke( "Ignoring parameter.  Reason: incorrect format." + separator + "\t" + arg + "" );
                    continue;
                }

                string value = arg.Substring( commandEnd + 1 );
                switch( command )
                {
                    case INSTANCE_COMMAND:
                        Filing filing = new Filing(executor, value );
                        fp.Filings.Add( filing );
                        break;
                    case REPORTS_FOLDER_COMMAND:
                        fp.SetReportsFolder( value, "Arguments" );
                        break;
                    case REPORT_FORMAT_COMMAND:
                        fp.SetReportFormat( value, "Arguments" );
                        break;
                    case HTML_REPORT_FORMAT_COMMAND:
                        fp.SetHtmlReportFormat( value, "Arguments" );
                        break;
                    case REMOTE_CACHE_POLICY_COMMAND:
                        fp.SetRemoteFileCachePolicy( value, "Arguments" );
                        break;
                    case QUIET_COMMAND:
                        fp.Quiet = true;
                        break;
                    case SAVEAS_COMMAND:
                        fp.SetSaveAs( value, "Arguments" );
                        break;
                    case XSLT_STYLESHEET_COMMAND:
                        fp.SetXsltStylesheetPath( value, "Arguments" );
                        break;
                    default:
                        executor.Invoke( "Arguments: Ignoring parameter " + command + ".  Reason: unrecognized command " + command + "" + separator +
                            "\t" + arg + "" );
                        break;
                }
            }

            return fp;
        }