FCExporter.outputExportObject C# (CSharp) Method

outputExportObject() private method

Checks whether the export action is download or save. If action is 'download', send export parameters to 'setupDownload' function. If action is not-'download', send export parameters to 'setupServer' function. In either case it gets exportSettings and passes the settings along with processed export binary (image/PDF) to the output handler function if the export settings return a 'ready' flag set to 'true' or 'download'. The export process would stop here if the action is 'download'. In the other case, it gets back success status from output handler function and returns it.
private outputExportObject ( MemoryStream exportObj, Hashtable exportParams ) : object
exportObj MemoryStream Export binary/object in memery stream
exportParams Hashtable Hashtable of export parameters
return object
    private object outputExportObject(MemoryStream exportObj, Hashtable exportParams)
    {
        //pass export paramters and get back export settings as per export action
        Hashtable exportActionSettings = (isDownload ? setupDownload(exportParams) : setupServer(exportParams));

        // set default export status to true
        bool status = true;

        // filepath returned by server setup would be a string containing the file path
        // where the export file is to be saved.
        // If filepath is a boolean (i.e. false) the server setup must have failed. Hence, terminate process.
        if (exportActionSettings["filepath"] is bool)
        {
            status = false;
            raise_error(" Failed to export.", true);
        }
        else
        {
            // When 'filepath' is a sting write the binary to output stream
            try
            {
                // Write export binary stream to output stream
                Stream outStream = (Stream)exportActionSettings["outStream"];
                exportObj.WriteTo(outStream);
                outStream.Flush();
                outStream.Close();
                exportObj.Close();
            }
            catch (ArgumentNullException e)
            {
                raise_error(" Failed to export. Error:" + e.Message);
                status = false;
            }
            catch (ObjectDisposedException e)
            {
                raise_error(" Failed to export. Error:" + e.Message);
                status = false;
            }

            
            if (isDownload)
            {
                // If 'download'- terminate imediately
                // As nothing is to be written to response now.
                Response.End();
            }

        }

        // This is the response after save action
        // If status remains true return the 'filepath'. Otherwise return false to denote failure.
        return (status ? exportActionSettings["filepath"] : false);


    }
    /// <summary>