Esempio n. 1
0
 private void IterateDoc1Group(SecurityCenterDocument2 doc2, NoteGroup clearGroup)
 {
     foreach (Note note in clearGroup.GetNotes())
     {
         Note2 note2 = new Note2();
         note2.Name  = note.Name;
         note2.Notes = note.Text;
         note2.Tags  = clearGroup.Name == "<default>" ? "" : clearGroup.Name;
         doc2.AddNote(note2);
     }
     foreach (NoteGroup subGroup in clearGroup.GetGroups())
     {
         IterateDoc1Group(doc2, subGroup);
     }
 }
Esempio n. 2
0
        public static NoteGroup ConvertNoteGroup(NoteGroup srcGroup, string password, bool decrypt)
        {
            ICryptoService _crypto     = CryptoFactory.Instance.GetMainService();
            NoteGroup      targetGroup = new NoteGroup();

            if (decrypt)
            {
                targetGroup.Name = _crypto.Decrypt(password, srcGroup.Name);
            }
            else
            {
                targetGroup.Name = _crypto.Encrypt(password, srcGroup.Name);
            }
            foreach (Note srcNote in srcGroup.GetNotes())
            {
                Note targetNote = new Note();
                if (decrypt)
                {
                    targetNote.Name = _crypto.Decrypt(password, srcNote.Name);
                    targetNote.Text = _crypto.Decrypt(password, srcNote.Text);
                }
                else
                {
                    targetNote.Name = _crypto.Encrypt(password, srcNote.Name);
                    targetNote.Text = _crypto.Encrypt(password, srcNote.Text);
                }
                targetGroup.Elements.Add(targetNote);
                targetNote.SetParent(targetGroup);
            }

            foreach (NoteGroup subSrcGroup in srcGroup.GetGroups())
            {
                NoteGroup subTargetGroup = ConvertNoteGroup(subSrcGroup, password, decrypt);
                targetGroup.Elements.Add(subTargetGroup);
                subTargetGroup.SetParent(targetGroup);
            }

            return(targetGroup);
        }