Esempio n. 1
0
        private void StartupPeriode()
        {
            working.Visible = true;
            try
            {
                status.Text = eyeSync.langs.eyeSync.connecting_with_server;
                Update();
                eye = new eyeOS();

                status.Text = eyeSync.langs.eyeSync.loading_data;
                Update();
                eye.setCurrentUserDir();

                status.Text = eyeSync.langs.eyeSync.building_local_tree;
                Update();
                tree_local.Nodes.Clear();
                TreeNode node = new TreeNode(langs.eyeSync.desktop);
                node.ImageIndex         = 5;
                node.SelectedImageIndex = 5;
                node.Tag = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                tree_local.Nodes.Add(node);
                node.Expand();
                tree_local.Nodes[0].Nodes.Add(langs.eyeSync.my_documents);
                tree_local.Nodes[0].Nodes[0].Tag = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                tree_local.Nodes[0].Nodes[0].Nodes.Add(eyeSync.langs.eyeSync.loading);
                node                    = new TreeNode(langs.eyeSync.my_computer);
                node.ImageIndex         = 6;
                node.SelectedImageIndex = 6;
                tree_local.Nodes[0].Nodes.Add(node);
                node.Expand();
                build_local_tree("", tree_local.Nodes[0].Nodes[1].Nodes);
                build_local_tree(tree_local.Nodes[0].Tag.ToString(), tree_local.Nodes[0].Nodes);
                tree_local.Nodes[0].Expand();
                tree_local.Nodes[0].Nodes[1].Expand();

                status.Text = eyeSync.langs.eyeSync.building_remote_tree;
                Update();
                tree_remote.Nodes.Clear();
                node                    = new TreeNode(Config.User + "@" + Config.Server);
                node.ImageIndex         = 4;
                node.SelectedImageIndex = 4;
                tree_remote.Nodes.Add(node);
                build_remote_tree("", tree_remote.Nodes[0].Nodes);
                tree_remote.Nodes[0].Expand();
            }
            catch (XmlRpc.XmlRpcFaultException)
            {
                MessageBox.Show(langs.eyeSync.error_not_a_user, langs.eyeSync.error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                userPasswordToolStripMenuItem_Click(null, null);
            }
            catch (Exception)
            {
                MessageBox.Show(langs.eyeSync.error_not_eyeOS, langs.eyeSync.error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                serverURLToolStripMenuItem_Click(null, null);
            }
            status.Text     = eyeSync.langs.eyeSync.ready;
            working.Visible = false;
        }
Esempio n. 2
0
        void RunJob_RealJob(object sender, DoWorkEventArgs e)
        {
            ((BackgroundWorker)sender).ReportProgress(0, e.Argument);
            eyeOS eye = new eyeOS();

            eye.setCurrentUserDir();
            if (Direction == 1)
            {
                string[] files = System.IO.Directory.GetFiles(Local + "\\", "*", System.IO.SearchOption.AllDirectories);
                int      num   = 0;
                foreach (string localfile in files)
                {
                    ((BackgroundWorker)sender).ReportProgress(files.Length - num, e.Argument);
                    string remotefile = remote + localfile.Replace(Local, "").Replace('\\', '/');
                    eye.uploadFile(localfile, remotefile);
                    num++;
                }
            }
            else if (Direction == -1)
            {
                string[] files = eye.getDirContent(remote);
                int      num   = 0;
                foreach (string remotefile in files)
                {
                    ((BackgroundWorker)sender).ReportProgress(files.Length - num, e.Argument);
                    string localfile = local + "\\" + remotefile;
                    eye.downloadFile(remote + "/" + remotefile, localfile);
                    num++;
                }
            }
            else if (Direction == 0)
            {
                string[] files = System.IO.Directory.GetFiles(Local + "\\", "*", System.IO.SearchOption.AllDirectories);
                int      num   = 0;
                foreach (string localfile in files)
                {
                    num++;
                    ((BackgroundWorker)sender).ReportProgress(files.Length - (num - 1), e.Argument);
                    if (new System.IO.FileInfo(localfile).Name.StartsWith(".eyeSyncInfo__"))
                    {
                        continue;
                    }
                    string remotefile = remote + localfile.Replace(Local, "").Replace('\\', '/');
                    eye.updateFile(remotefile, localfile);
                }
            }
            ((BackgroundWorker)sender).ReportProgress(-1, e.Argument);
            isActive = false;
        }