コード例 #1
0
        private void btn_private_Click(object sender, System.EventArgs e)
        {
            var fbdPriv = new FolderBrowserDialog {
                Description = "Privates Repository"
            };

            if (fbdPriv.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            DiscoverDirectory(fbdPriv.SelectedPath, fbdPriv.SelectedPath, tree_private);
            SecureCopy.LoadCryptoStatus(fbdPriv.SelectedPath);

            var fbdPub = new FolderBrowserDialog {
                Description = "Öffentliches Repository"
            };

            if (fbdPub.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            DiscoverDirectory(fbdPub.SelectedPath, fbdPub.SelectedPath, tree_public);

            privatePath = fbdPriv.SelectedPath;
            publicPath  = fbdPub.SelectedPath;

            SelectAllExsistingItems();

            btn_secure.Visibility = Telerik.WinControls.ElementVisibility.Visible;
            btn_sync.Visibility   = Telerik.WinControls.ElementVisibility.Visible;
        }
コード例 #2
0
        private void RecursiveSync(RadTreeNodeCollection nodes)
        {
            foreach (var node in nodes)
            {
                try
                {
                    if (!node.Checked)
                    {
                        continue;
                    }

                    if (node.Nodes != null && node.Nodes.Count > 0)
                    {
                        var destination = publicPath + (string)node.Tag;
                        if (!Directory.Exists(destination))
                        {
                            Directory.CreateDirectory(destination);
                        }

                        var source      = privatePath + (string)node.Tag;
                        var sourceFiles = new HashSet <string>(Directory.GetFiles(source).Select(x => x.Replace(source, "")));
                        foreach (var file in Directory.GetFiles(destination).Select(x => x.Replace(destination, "").Replace(".aes", "")))
                        {
                            if (!sourceFiles.Contains(file))
                            {
                                File.Delete(destination + file);
                            }
                        }

                        RecursiveSync(node.Nodes);
                    }
                    else
                    {
                        try
                        {
                            SecureCopy.Copy(privatePath + (string)node.Tag, publicPath + (string)node.Tag);
                        }
                        catch (IOException)
                        {
                            // ignore
                        }
                    }
                }
                catch (UnauthorizedAccessException)
                {
                    // ignore
                }
                catch (Exception)
                {
                    // ignore
                }
            }
        }
コード例 #3
0
 private static bool SendFile(string user, string password, string localFile, string remoteFile)
 {
     try
     {
         Logger.WriteLine("copying " + localFile + " to " + remoteFile, "ui");
         SecureCopy.CopyTo(user, HydrometHostAddress, password, localFile, remoteFile);
         return(true);
     }
     catch (Exception ex)
     {
         Logger.WriteLine(ex.Message, "ui");
         System.Windows.Forms.MessageBox.Show(ex.Message);
         return(false);
     }
 }
コード例 #4
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;

            var mode = CryptoMode.None;

            switch (radDropDownList1.SelectedIndex)
            {
            case 0:
                mode = CryptoMode.None; break;

            case 1:
                mode = CryptoMode.Encrypt; break;

            case 2:
                mode = CryptoMode.Decrypt; break;
            }

            SecureCopy.SaveCryptoStatus(_directory, mode, radTextBox1.Text);

            Close();
        }