Beispiel #1
0
        /// <summary>
        /// Add new notification
        /// </summary>
        /// <param name="workerId">Worker, that should see this notification</param>
        /// <param name="module">Module, for wich notification is added</param>
        /// <param name="originalId">Id of the new row</param>
        public static void AddNotification(int workerId, AdministrationClass.Modules module, int originalId)
        {
            //if(workerId == AdministrationClass.CurrentWorkerId) return;

            const string sqlCommandText = "INSERT INTO FAIIAdministration.Notifications " +
                                          "(WorkerID, ModuleID, OriginalID, ShowCount, ShowNotification) " +
                                          "VALUES (@WorkerID, @ModuleID, @OriginalID, @ShowCount, @ShowNotification)";

            using (var sqlConn = new MySqlConnection(App.ConnectionInfo.ConnectionString))
            {
                var sqlCommand = new MySqlCommand(sqlCommandText, sqlConn);
                sqlCommand.Parameters.Add("@WorkerID", MySqlDbType.Int64).Value       = workerId;
                sqlCommand.Parameters.Add("@ModuleID", MySqlDbType.Int64).Value       = (int)module;
                sqlCommand.Parameters.Add("@OriginalID", MySqlDbType.Int64).Value     = originalId;
                sqlCommand.Parameters.Add("@ShowCount", MySqlDbType.Bit).Value        = true;
                sqlCommand.Parameters.Add("@ShowNotification", MySqlDbType.Bit).Value = true;

                try
                {
                    sqlConn.Open();
                    sqlCommand.ExecuteScalar();
                }
                catch (MySqlException)
                {
                }
                finally
                {
                    sqlConn.Close();
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Returns notifications count for module
        /// </summary>
        /// <param name="module">Id of selected module</param>
        /// <returns>Notifications count</returns>
        public static int GetNotificationsCount(AdministrationClass.Modules module)
        {
            var notificationCount =
                NotificationsTable.AsEnumerable().Count(r => r.Field <Int64>("ModuleID") == (long)module);

            return(notificationCount);
        }
Beispiel #3
0
        /// <summary>
        /// Clear ShowNotification value for every notification in module
        /// </summary>
        /// <param name="module">Id of selected module</param>
        private static void ClearShowNotifications(AdministrationClass.Modules module)
        {
            if (_notificationsAdapter == null)
            {
                return;
            }

            foreach (var dataRow in NotificationsTable.AsEnumerable().
                     Where(r => r.Field <Int64>("ModuleID") == (long)module))
            {
                dataRow["ShowNotification"] = false;
            }

            try
            {
                _notificationsAdapter.Update(NotificationsTable);
            }
            catch (MySqlException)
            {
            }
        }