コード例 #1
0
ファイル: DbManager.cs プロジェクト: misiaxis/LabEye
        /// <summary>
        /// Adding alert to AllertsHistory collection for current workstation
        /// </summary>
        /// <param name="alert">Allert to history.</param>
        /// <param name="previousStudentName">First and last name of previous student</param>
        /// <param name="previousUserName">Previous user name</param>
        public void AlertHistoryMakeNew(Alerts alert)
        {
            AlertsHistory newDocument = new AlertsHistory
            {
                WorkstationName         = StationInformation.WorkstationName,
                StudentFirstAndLastName = alert.StudentFirstAndLastName,
                AddDate   = alert.AddDate,
                AlertName = alert.AlertName,
                Link1     = alert.Link1,
                Link2     = alert.Link2,
                Link3     = alert.Link3
            };

            try
            {
                RefreshAlertsHistory();
                alertHistoryCollection.InsertOne(newDocument);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Wystąpił błąd podczas dodawania dokumentu <AlertsHistory> do bazy danych. Treść błędu: /n /n" + ex);
            }
        }
コード例 #2
0
 /// <summary>
 /// Sending alert list (update) in database.
 /// </summary>
 /// <param name="messages">List of strings, contains alert names.</param>
 /// <param name="listName">Name of parameter in documents (Workstations, DBEntity) where to update. </param>
 static public void SendMessanges(List <Tuple <string, ObjectId, ObjectId, ObjectId> > messages, string listName)
 {
     try
     {
         DbManager manager    = new DbManager();
         var       collection = manager.ShowWorkstationsCollection();
         if (manager.CheckIfExsists(StationInformation.WorkstationName))
         {
             List <Alerts> messagesToInsert = new List <Alerts>();
             foreach (var l in collection)
             {
                 if (l.WorkstationName == StationInformation.WorkstationName)
                 {
                     messagesToInsert.AddRange(l.Alerts);
                 }
             }
             foreach (var msg in messages)
             {
                 Alerts alert = new Alerts()
                 {
                     AddDate = DateTime.Now.ToString(),
                     StudentFirstAndLastName = StationInformation.StudentFirstAndLastName,
                     AlertName = msg.Item1,
                     Link1     = msg.Item2,
                     Link2     = msg.Item3,
                     Link3     = msg.Item4
                 };
                 messagesToInsert.Add(alert);
             }
             manager.UpdateOneList(listName, messagesToInsert, StationInformation.WorkstationName);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Wystąpił błąd z połączaniem z bazą danych. Treść błedu: /n /n" + ex);
     }
 }