private void AddDB_Click(object sender, RoutedEventArgs e)
        {
            DatabaseDBMeta meta = new DatabaseDBMeta();

            DatabaseAdminDBMeta dialog = new DatabaseAdminDBMeta(ref meta);

            dialog.ShowDialog();

            if (dialog.DialogResult == true)
            {
                if (DatabaseHandler.AddDB(meta))
                {
                    GetDatabases(meta.Name);
                    Refresh();
                }
            }
        }
Ejemplo n.º 2
0
        public DatabaseAdminDBMeta(ref DatabaseDBMeta db)
        {
            InitializeComponent();

            this.db = db;

            NameField.Text                = db.Name;
            DescriptionField.Text         = db.Description;
            ServerField.Text              = db.Server;
            AuthentificationBox.IsChecked = db.ServerAuth;
            if (db.UrlFormat == UrlFormat.NEXTCLOUD)
            {
                UrlFormatNextCloud.IsChecked = true;
            }

            else
            {
                UrlFormatGeneral.IsChecked = true;
            }
        }
Ejemplo n.º 3
0
        private void DatabaseResultsBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (DatabaseBox.SelectedItem != null)
            {
                DatabaseHandler.ChangeDatabase(DatabaseBox.SelectedItem.ToString());
                DatabaseDBMeta meta = new DatabaseDBMeta {
                    Name = DatabaseBox.SelectedItem.ToString()
                };
                if (DatabaseHandler.GetDBMeta(ref meta))
                {
                    ServerLoginPanel.Visibility = meta.ServerAuth? Visibility.Visible : Visibility.Collapsed;
                }

                GetSessions();
                GetStreams();

                AnnotationsBox.ItemsSource = null;

                DatabaseSession session = (DatabaseSession)SessionsBox.SelectedItem;
                GetAnnotations(session);
            }
        }
        private void EditDB_Click(object sender, RoutedEventArgs e)
        {
            if (DatabaseBox.SelectedItem != null)
            {
                string name = (string)DatabaseBox.SelectedItem;

                DatabaseDBMeta meta = new DatabaseDBMeta {
                    Name = name
                };
                if (DatabaseHandler.GetDBMeta(ref meta))
                {
                    DatabaseAdminDBMeta dialog = new DatabaseAdminDBMeta(ref meta);
                    dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                    dialog.ShowDialog();

                    if (dialog.DialogResult == true)
                    {
                        DatabaseHandler.UpdateDBMeta(meta.Name, meta);
                        GetAnnotators();
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void databaseLoadSession()
        {
            DatabaseAnnoMainWindow dialog = new DatabaseAnnoMainWindow();



            if (showDialogClearWorkspace(dialog) && (dialog.DialogResult == true))
            {
                Action EmptyDelegate = delegate() { };
                control.ShadowBox.Visibility = Visibility.Visible;
                control.UpdateLayout();
                control.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);

                System.Collections.IList annotations = dialog.Annotations();
                if (annotations != null && annotations.Count > 0)
                {
                    List <AnnoList> annoLists = DatabaseHandler.LoadSession(annotations);
                    if (annoLists != null)
                    {
                        foreach (AnnoList annoList in annoLists)
                        {
                            addAnnoTierFromList(annoList);
                        }
                    }
                }

                control.ShadowBox.Visibility = Visibility.Collapsed;

                List <StreamItem> streams = dialog.SelectedStreams();
                databaseSessionStreams = new List <string>();

                foreach (StreamItem stream in streams)
                {
                    databaseSessionStreams.Add(stream.Name);
                }



                if (streams != null && streams.Count > 0)
                {
                    List <string> streamsAll = new List <string>();
                    foreach (StreamItem stream in streams)
                    {
                        if (stream.Extension == "stream")
                        {
                            streamsAll.Add(stream.Name + "~");
                        }
                        streamsAll.Add(stream.Name);
                    }

                    try
                    {
                        if (filesToDownload != null)
                        {
                            filesToDownload.Clear();
                        }

                        MainHandler.NumberOfAllCurrentDownloads = streamsAll.Count;


                        tokenSource = new CancellationTokenSource();

                        string url          = "";
                        bool   requiresAuth = false;

                        DatabaseDBMeta meta = new DatabaseDBMeta()
                        {
                            Name = DatabaseHandler.DatabaseName
                        };
                        if (!DatabaseHandler.GetDBMeta(ref meta))
                        {
                            return;
                        }

                        string localPath = Properties.Settings.Default.DatabaseDirectory + "\\" + DatabaseHandler.DatabaseName + "\\" + DatabaseHandler.SessionName + "\\";

                        if (meta.UrlFormat == UrlFormat.NEXTCLOUD)
                        {
                            url = meta.Server + "/download?path=%2F" + DatabaseHandler.DatabaseName + "%2F" + DatabaseHandler.SessionName + "&files=";
                        }
                        else
                        {
                            url          = meta.Server + '/' + DatabaseHandler.SessionName + '/';
                            requiresAuth = meta.ServerAuth;
                        }

                        string connection = "";

                        if (meta.Server == "")
                        {
                            connection = "";
                        }

                        else
                        {
                            string[] split = url.Split(':');
                            connection = split[0];
                        }


                        Directory.CreateDirectory(Path.GetDirectoryName(localPath));

                        List <string> streamstoDownload = new List <string>();
                        foreach (string stream in streamsAll)
                        {
                            string llocal = localPath + stream;
                            string lurl   = url + stream;
                            if (File.Exists(llocal))
                            {
                                loadFile(llocal);
                                continue;
                            }

                            streamstoDownload.Add(stream);

                            Thread.Sleep(100);


                            //TODO add more servers...


                            if (connection == "sftp")
                            {
                                SFTP(lurl, llocal);
                            }
                            else if (connection == "http" || connection == "https" && requiresAuth == false)

                            {
                                int result = httpGetSync(lurl, llocal);
                                if (result == -1)
                                {
                                    streamstoDownload.RemoveAt(streamstoDownload.Count - 1);
                                }
                            }
                            else if (connection == "http" || connection == "https" && requiresAuth == true)
                            {
                                httpPost(lurl, llocal);
                            }

                            else
                            {
                                loadFile(localPath);
                            }
                        }


                        control.ShadowBoxText.UpdateLayout();
                        control.ShadowBoxText.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
                        control.ShadowBoxText.Text               = "Loading Data";
                        control.ShadowBox.Visibility             = Visibility.Collapsed;
                        control.shadowBoxCancelButton.Visibility = Visibility.Collapsed;
                        control.ShadowBox.UpdateLayout();


                        foreach (string stream in streamstoDownload)
                        {
                            string llocal = localPath + stream;

                            try
                            {
                                long length = new System.IO.FileInfo(llocal).Length;
                                if (length == 0)
                                {
                                    Thread.Sleep(100);
                                    if (File.Exists(llocal))
                                    {
                                        File.Delete(llocal);
                                    }
                                    continue;
                                }
                            }
                            catch
                            {
                            }


                            loadFile(llocal);
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("Error: " + e, "Connection to database not possible");
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private void downloadSelectedFiles()
        {
            labelDownloaded.Visibility = Visibility.Visible;
            labelPerc.Visibility       = Visibility.Visible;
            labelSpeed.Visibility      = Visibility.Visible;
            progressBar.Visibility     = Visibility.Visible;
            string localPath = Properties.Settings.Default.DatabaseDirectory + "\\" + DatabaseBox.SelectedItem.ToString() + "\\" + ((DatabaseSession)SessionsBox.SelectedItem).Name + "\\";

            Directory.CreateDirectory(Path.GetDirectoryName(localPath));
            List <string> streamstoDownload = new List <string>();

            foreach (StreamItem stream in SelectedStreams())
            {
                string localfile = localPath + stream.Name;

                if (!File.Exists(localfile))
                {
                    streamstoDownload.Add(stream.Name);
                }
            }

            if (streamstoDownload.Count == 0 && closeAfterDownload)
            {
                DialogResult = true;
                Close();
                return;
            }

            string url          = "";
            bool   requiresAuth = false;

            DatabaseDBMeta meta = new DatabaseDBMeta()
            {
                Name = DatabaseHandler.DatabaseName
            };

            if (!DatabaseHandler.GetDBMeta(ref meta))
            {
                return;
            }

            if (meta.Server == "" || meta.Server == null)
            {
                return;
            }


            if (meta.UrlFormat == UrlFormat.NEXTCLOUD)
            {
                url = meta.Server + "/download?path=%2F" + DatabaseBox.SelectedItem.ToString() + "%2F" + ((DatabaseSession)SessionsBox.SelectedItem).Name + "&files=";
            }
            else
            {
                url          = meta.Server + '/' + DatabaseHandler.SessionName + '/';
                requiresAuth = meta.ServerAuth;
            }



            List <string> urls = new List <string>();

            foreach (string file in streamstoDownload)
            {
                urls.Add(url + file);
                if (file.EndsWith(".stream"))
                {
                    urls.Add(url + file + "~");
                }
            }


            remainingfiles = urls.Count;
            downloadFile(urls);
        }