Ejemplo n.º 1
0
        public static string SelectAnnotationScheme(AnnoList annoList)
        {
            string        annotype          = null;
            List <string> AnnotationSchemes = new List <string>();

            MongoClient    mongo    = Client;
            IMongoDatabase database = Database;
            IMongoCollection <BsonDocument> collection = database.GetCollection <BsonDocument>(DatabaseDefinitionCollections.Schemes);

            var sessions = collection.Find(_ => true).ToList();

            foreach (var document in sessions)
            {
                if (document["isValid"].AsBoolean == true)
                {
                    if ((annoList.Scheme.Type == AnnoScheme.TYPE.DISCRETE && document["type"].ToString() == "DISCRETE"))
                    {
                        AnnotationSchemes.Add(document["name"].ToString());
                    }
                    else if (annoList.Scheme.Type == AnnoScheme.TYPE.FREE && (document["type"].ToString() == "FREE"))
                    {
                        AnnotationSchemes.Add(document["name"].ToString());
                    }
                    else if (annoList.Scheme.Type == AnnoScheme.TYPE.CONTINUOUS && document["type"].ToString() == "CONTINUOUS")
                    {
                        AnnotationSchemes.Add(document["name"].ToString());
                    }
                }
            }

            int  auth    = DatabaseHandler.CheckAuthentication(Properties.Settings.Default.MongoDBUser, Properties.Settings.Default.DatabaseName);
            bool hasauth = false;

            if (auth > 2)
            {
                hasauth = true;
            }

            string name = annoList.Scheme.Name;

            DatabaseSelectionWindow dbw = new DatabaseSelectionWindow(AnnotationSchemes, hasauth, "Tier: " + name + ". What is annotated? ", DatabaseDefinitionCollections.Schemes, true, annoList);

            dbw.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            dbw.ShowDialog();

            if (dbw.DialogResult == true)
            {
                annotype = dbw.Result().ToString();
            }
            return(annotype);
        }
Ejemplo n.º 2
0
        //public void sendmail(string adressto, string subject, string body)
        //{
        //    //dummy code, need some logic but hey, automated notifications
        //    MailMessage objeto_mail = new MailMessage();
        //    SmtpClient client = new SmtpClient();
        //    client.Port = 25;
        //    client.Host = "smtp.internal.mycompany.com";
        //    client.Timeout = 10000;
        //    client.DeliveryMethod = SmtpDeliveryMethod.Network;
        //    client.UseDefaultCredentials = false;
        //    client.Credentials = new System.Net.NetworkCredential("user", "Password");
        //    objeto_mail.From = new MailAddress("*****@*****.**");
        //    objeto_mail.To.Add(new MailAddress(adressto));
        //    objeto_mail.Subject = subject;
        //    objeto_mail.Body = body;
        //    client.Send(objeto_mail);
        //}


        public static string LoadRoles(AnnoList annoList)
        {
            string        role  = null;
            List <string> roles = new List <string>();

            MongoClient    mongo    = Client;
            IMongoDatabase database = Database;
            IMongoCollection <BsonDocument> collection = database.GetCollection <BsonDocument>(DatabaseDefinitionCollections.Roles);

            var sessions = collection.Find(_ => true).ToList();

            foreach (var document in sessions)
            {
                if (document["isValid"].AsBoolean == true)
                {
                    roles.Add(document["name"].ToString());
                }
            }


            int  auth    = DatabaseHandler.CheckAuthentication(Properties.Settings.Default.MongoDBUser, Properties.Settings.Default.DatabaseName);
            bool hasauth = false;

            if (auth > 3)
            {
                hasauth = true;
            }

            string name = annoList.Scheme.Name;

            DatabaseSelectionWindow dbw = new DatabaseSelectionWindow(roles, hasauth, "Tier: " + name + ". Who is annotated? ", DatabaseDefinitionCollections.Roles);

            dbw.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            dbw.ShowDialog();

            if (dbw.DialogResult == true)
            {
                role = dbw.Result().ToString();
            }

            return(role);
        }
Ejemplo n.º 3
0
        private void CopyAnnotation_Click(object sender, RoutedEventArgs e)
        {
            if (AnnotationResultBox.SelectedItem != null)
            {
                var sessions          = database.GetCollection <BsonDocument>(DatabaseDefinitionCollections.Sessions);
                var roles             = database.GetCollection <BsonDocument>(DatabaseDefinitionCollections.Roles);
                var annotationschemes = database.GetCollection <BsonDocument>(DatabaseDefinitionCollections.Schemes);
                var annotations       = database.GetCollection <BsonDocument>(DatabaseDefinitionCollections.Annotations);
                var annotators        = database.GetCollection <BsonDocument>(DatabaseDefinitionCollections.Annotators);


                List <string> annotator_names = new List <string>();
                foreach (var document in annotators.Find(_ => true).ToList())
                {
                    annotator_names.Add(document["fullname"].ToString());
                }

                DatabaseSelectionWindow dbw = new DatabaseSelectionWindow(annotator_names, false, "Select Annotator", "Annotator");
                dbw.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
                dbw.ShowDialog();

                if (dbw.DialogResult == true)
                {
                    string   annotator_name = dbw.Result().ToString();
                    ObjectId annotid_new    = GetObjectID(mongo.GetDatabase(Properties.Settings.Default.DatabaseName), DatabaseDefinitionCollections.Annotators, "fullname", annotator_name);


                    foreach (var item in AnnotationResultBox.SelectedItems)
                    {
                        ObjectId roleid    = GetIdFromName(roles, ((DatabaseAnno)(item)).Role);
                        ObjectId annotid   = GetIdFromName(annotationschemes, ((DatabaseAnno)(item)).AnnoScheme);
                        ObjectId annotatid = GetIdFromName(annotators, ((DatabaseAnno)(item)).Annotator);
                        ObjectId sessionid = GetIdFromName(sessions, Properties.Settings.Default.LastSessionId);

                        var builder = Builders <BsonDocument> .Filter;
                        var filter  = builder.Eq("role_id", roleid) & builder.Eq("scheme_id", annotid) & builder.Eq("annotator_id", annotatid) & builder.Eq("session_id", sessionid);
                        var anno    = annotations.Find(filter).Single();

                        anno.Remove("_id");
                        anno["annotator_id"] = annotid_new;
                        try
                        {
                            anno["isFinished"] = false;
                        }
                        catch (Exception ex)
                        { }

                        try
                        {
                            anno["isLocked"] = false;
                        }
                        catch (Exception ex)
                        { }

                        UpdateOptions uo = new UpdateOptions();
                        uo.IsUpsert = true;

                        filter = builder.Eq("role_id", roleid) & builder.Eq("scheme_id", annotid) & builder.Eq("annotator_id", annotid_new) & builder.Eq("session_id", sessionid);
                        var result = annotations.ReplaceOne(filter, anno, uo);
                    }
                    AnnoItems.Clear();
                    GetAnnotations(showonlymine.IsChecked == true, showonlyunfinished.IsChecked == true);
                }
            }
        }