Esempio n. 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);
        }
Esempio n. 2
0
        /// <summary>
        /// Checkin or delete the object.
        /// </summary>
        /// <remarks>
        /// This function uploads all modified versions, attachments, previews, signatures
        /// and resets the lockId.
        /// </remarks>
        public override void Checkin()
        {
            if (sordVal.deleted)
            {
                InvalidateFiles();
                Conn.Ix.deleteSord(null, sordVal.guid, LockC.YES, null);
                sordVal.lockId = -1;
            }
            else
            {
                // Upload all modified versions.
                // This makes the files read-only and the DownloadManager will
                // delete them.
                Document doc = uploadAllModifiedVersions();

                // Write all changed members.
                SordZ sordZ = new SordZ(sordVal.changedMembers);
                doc            = Conn.Ix.checkinDocEnd(sordVal, sordZ, doc, LockC.YES);
                sordVal.lockId = -1;
                sordVal.id     = Convert.ToInt32(doc.objId);
                // try to refresh internal data
                // fails if user lacks read rights
                try
                {
                    Refresh();
                }
                catch (Exception ex)
                {
                    if (Conn != null && Conn.Valid)
                    {
                        IXExceptionData exceptionData = Conn.Ix.parseException(ex.Message);

                        if (exceptionData == null ||
                            exceptionData.exceptionType != IXExceptionC.ACCESS_DENIED)
                        {
                            throw;
                        }
                    }

                    else
                    {
                        throw;
                    }
                }

                InvalidateFiles();
            }
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        /// <summary>
        /// Check exception.
        /// </summary>
        /// <param name="e">Exception object</param>
        /// <param name="exceptionType">Exception type constant.</param>
        /// <returns>True, if the given exception is of the given exceptionType.</returns>
        /// <seealso cref="EloixClient.IndexServer.IXExceptionC"/>
        public bool IsException(Exception e, int exceptionType)
        {
            IXExceptionData exd = Ix.parseException(e.ToString());

            return(exd.exceptionType == exceptionType);
        }