示例#1
0
        private static Notification CreateNotification(ScientificProduction sp, Profile researcher)
        {
            Notification n = new Notification();

            n.username = researcher.Username;
            n.type     = sp.Type;
            n.title    = sp.Title;
            return(n);
        }
示例#2
0
        private static Microsoft.Data.Sqlite.SqliteCommand ConstructInsertCommand(ScientificProduction sp, int researcherId)
        {
            var command = Program.SqlConn.CreateCommand();

            command.CommandText = @"
                insert into scientific_productions (ResearcherId, Type, Title, Content)
                values ($researcherId, $type, $title, $content)
            ";
            command.Parameters.AddWithValue("$researcherId", researcherId);
            command.Parameters.AddWithValue("$type", sp.Type);
            command.Parameters.AddWithValue("$title", sp.Title);
            command.Parameters.AddWithValue("$content", sp.Content);
            return(command);
        }
示例#3
0
        private List <ScientificProduction> ReadProductions(SqliteCommand command)
        {
            List <ScientificProduction> productions = new List <ScientificProduction>();
            ScientificProduction        sc;

            using (var reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    sc = new ScientificProduction(
                        reader.GetString(2),
                        reader.GetString(3),
                        reader.GetString(4)
                        );
                    productions.Add(sc);
                }
            }
            return(productions);
        }
示例#4
0
        public string PublishScientificProductionAndNotify(ScientificProduction sp, Profile researcher)
        {
            try
            {
                InsertScientificProductionQuery(sp, researcher.Id);

                List <int>   Ids          = GetIDsOfResearchersInField(researcher.Id, researcher.Field);
                Notification notification = CreateNotification(sp, researcher);
                foreach (int id in Ids)
                {
                    Notify(notification, id);
                }

                return("done");
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
示例#5
0
        private static void InsertScientificProductionQuery(ScientificProduction sp, int researcherId)
        {
            Microsoft.Data.Sqlite.SqliteCommand command = ConstructInsertCommand(sp, researcherId);

            command.ExecuteNonQuery();
        }