Пример #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
        private void BackupWizard_OnNextBtnClick(object sender, EventArgs e)
        {
            switch (BackupWizard.SelectedTabIndex)
            {
            case (int)WizzardProcess.Introduction:
                BackupWizard.SelectedTabIndex = (int)WizzardProcess.OptionChoose;

                break;

            case (int)WizzardProcess.OptionChoose:
                if (!BackupWizard.UseWords)
                {
                    BackupWizard.FileLabel = "Step 2. Select the destination for your backup file.";
                    if (string.IsNullOrEmpty(BackupWizard.FolderPath))
                    {
                        BackupWizard.NextButtonEnabled = false;
                    }
                    else
                    {
                        BackupWizard.NextButtonText    = "Backup";
                        BackupWizard.NextButtonEnabled = true;
                    }
                    BackupWizard.SelectedTabIndex = (int)WizzardProcess.File;
                }
                else
                {
                    F12Words = "";
                    BackupWizard.CopiLabelVisibility = false;
                    FWordList = new WordList();
                    BackupWizard.TwelveWordsLabel = "Step 2. Store your 12 words display here";
                    BackupWizard.TwelveWordsControl.ReadOnlyTextBoxes = true;
                    if (!EncryptionPasswordDialog.Execute())
                    {
                        return;
                    }

                    string[] Words = FWordList.GetWords(FWallet.Get12NumbersOf11Bits());

                    for (int i = 0; i < 12; i++)
                    {
                        string lLookingFor = "Word" + (i + 1).ToString();

                        PropertyInfo prop = BackupWizard.TwelveWordsControl.GetType().GetProperty(lLookingFor, BindingFlags.Public | BindingFlags.Instance);
                        prop.SetValue(BackupWizard.TwelveWordsControl, Words[i]);

                        if (string.IsNullOrEmpty(F12Words))
                        {
                            F12Words = Words[i];
                        }
                        else
                        {
                            if (i % 4 == 0)
                            {
                                F12Words = string.Format("{0}{1}{2}", F12Words, Environment.NewLine, Words[i]);
                            }
                            else
                            {
                                F12Words = string.Format("{0}, {1}", F12Words, Words[i]);
                            }
                        }
                    }

                    BackupWizard.SelectedTabIndex = (int)WizzardProcess.TwelveWords;
                }
                break;

            case (int)WizzardProcess.File:
                string lBackupFile = Path.ChangeExtension(BackupWizard.FolderPath, ".bkp");
                try
                {
                    FWallet.CreateBackup(BackupWizard.FolderPath);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                BackupWizard.FinalLabel = "You backup your personal configurations and addressess successfully";
                SetupFinishTab(BackupWizard);
                BackupWizard.OnNextBtnClick  += BackupWizard_OnCancelBtnClick;
                BackupWizard.SelectedTabIndex = (int)WizzardProcess.Finish;
                break;

            case (int)WizzardProcess.TwelveWords:
                BackupWizard.FinalLabel = "You backup your addresses succesfully";
                SetupFinishTab(BackupWizard);
                BackupWizard.OnNextBtnClick  += BackupWizard_OnCancelBtnClick;
                BackupWizard.SelectedTabIndex = (int)WizzardProcess.Finish;
                break;
            }
        }
Пример #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);
        }