Пример #1
0
        public static string GetDocumentFile(FWSord sord)
        {
            string documentFile = null;

            if (sord is FWDocument)
            {
                FWDocument doc           = sord as FWDocument;
                int        encryptionSet = doc.Core.details.encryptionSet;
                if (encryptionSet > 0)
                {
                    if (doc.Conn.Session.EncrPasswords[encryptionSet.ToString()] != null)
                    {
                        return(doc.File);
                    }

                    // Anzeige eines Dialogs zur Eingabe des Verschlüsselungspassworts
                    if (doc.Conn != null && doc.Conn.Ix != null)
                    {
                        EncryptionPasswordDialog dlg = new EncryptionPasswordDialog(encryptionSet);
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            try
                            {
                                string key = Convert.ToString(encryptionSet);
                                doc.Conn.Session.EncrPasswords[key] = dlg.Password;
                                doc.Conn.Session.EncrPasswords.Checkin();
                                doc          = doc.Conn.Content.GetDocument(doc.Id);
                                documentFile = doc.File;
                            }
                            catch (Exception exc)
                            {
                                if (sord.Conn.IsException(exc, IXExceptionC.INVALID_CRYPT_KEY))
                                {
                                    string key = Convert.ToString(encryptionSet);
                                    doc.Conn.Session.EncrPasswords[key] = null;
                                    IXExceptionData exceptionData = sord.Conn.Ix.parseException(exc.ToString());
                                    MessageBox.Show(exceptionData.message, "ELO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                        }
                    }
                }
                else
                {
                    documentFile = doc.File;
                }
            }

            return(documentFile);
        }
Пример #2
0
        public static string DocumentFile(FWDocVersion docVersion, FWDocument document)
        {
            string documentFile = null;

            int encryptionSet = docVersion.Core.encryptionSet;

            if (encryptionSet > 0)
            {
                bool keyExists = false;

                if (docVersion.Conn.Session.EncrPasswords[encryptionSet.ToString()] != null)
                {
                    //return docVersion.File;
                    keyExists = true;
                }

                // Anzeige eines Dialogs zur Eingabe des Verschlüsselungspassworts
                if (docVersion.Conn != null && docVersion.Conn.Ix != null)
                {
                    EncryptionPasswordDialog dlg = new EncryptionPasswordDialog(encryptionSet);
                    if (keyExists || dlg.ShowDialog() == DialogResult.OK)
                    {
                        try
                        {
                            if (!keyExists)
                            {
                                string key = Convert.ToString(encryptionSet);
                                docVersion.Conn.Session.EncrPasswords[key] = dlg.Password;
                                docVersion.Conn.Session.EncrPasswords.Checkin();
                                document.Checkin();
                            }
                            document = document.Conn.Content.GetSord(document.Id) as FWDocument;
                            foreach (FWDocVersion version in document.Versions)
                            {
                                if (version.Id == docVersion.Id)
                                {
                                    docVersion = version;
                                    break;
                                }
                            }

                            documentFile = docVersion.File;
                        }
                        catch (Exception exc)
                        {
                            if (document.Conn.IsException(exc, IXExceptionC.INVALID_CRYPT_KEY))
                            {
                                string key = Convert.ToString(encryptionSet);
                                docVersion.Conn.Session.EncrPasswords[key] = null;
                                IXExceptionData exceptionData = document.Conn.Ix.parseException(exc.ToString());
                                MessageBox.Show(exceptionData.message, "ELO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                }
            }
            else
            {
                documentFile = docVersion.File;
            }

            return(documentFile);
        }