コード例 #1
0
        private Document SubmissionToFile(dtoExportSubmission settings)
        {
            Document doc = null;

            System.IO.FileStream stream       = null;
            Impersonate          oImpersonate = new Impersonate();
            Boolean wasImpersonated           = Impersonate.isImpersonated();

            try
            {
                if (!wasImpersonated && oImpersonate.ImpersonateValidUser() == FileMessage.ImpersonationFailed)
                {
                    return(null);
                }
                else
                {
                    stream = new System.IO.FileStream(settings.Filename, System.IO.FileMode.Create);
                    if (stream != null)
                    {
                        doc = FileExport(stream);
                    }
                }
            }
            catch (Exception ex)
            {
                if (stream != null)
                {
                    stream.Close();
                }
                if (lm.Comol.Core.File.Exists.File(settings.Filename))
                {
                    lm.Comol.Core.File.Delete.File(settings.Filename);
                }

                if (!wasImpersonated)
                {
                    oImpersonate.UndoImpersonation();
                }
                doc = null;
            }
            finally
            {
                if (!wasImpersonated)
                {
                    oImpersonate.UndoImpersonation();
                }
            }
            return(doc);
        }
コード例 #2
0
        //Se Setting == null, viene preso quello di default!
        private iTextSharp5.text.Document SavePDFtoFile(String storeFileName, lm.Comol.Core.DomainModel.DocTemplateVers.Domain.DTO.ServiceExport.DTO_Settings settings,
                                                        IList <lm.Comol.Core.DomainModel.DocTemplateVers.Domain.DTO.ServiceExport.DTO_Signature> signatures)
        {
            iTS.Document         doc          = null;
            System.IO.FileStream stream       = null;
            Impersonate          oImpersonate = new Impersonate();
            Boolean wasImpersonated           = Impersonate.isImpersonated();

            try
            {
                if (!wasImpersonated && oImpersonate.ImpersonateValidUser() == FileMessage.ImpersonationFailed)
                {
                    return(null);
                }
                else
                {
                    stream = new System.IO.FileStream(storeFileName, System.IO.FileMode.Create);
                    if (stream != null)
                    {
                        doc = FileExport(settings, stream, signatures);
                    }
                }
            }
            catch (Exception ex)
            {
                if (stream != null)
                {
                    stream.Close();
                }
                if (lm.Comol.Core.File.Exists.File(storeFileName))
                {
                    lm.Comol.Core.File.Delete.File(storeFileName);
                }
                if (!wasImpersonated)
                {
                    oImpersonate.UndoImpersonation();
                }
                doc = null;
            }
            finally
            {
                if (!wasImpersonated)
                {
                    oImpersonate.UndoImpersonation();
                }
            }
            return(doc);
        }