/// <summary>
        /// Transfers the data containing on the dataset (related to MSGS table) to the database
        /// </summary>
        /// <param name="data">DataSet with updated MSGS info</param>
        public void UpdateMessages(DataSet data)
        {
            Database       d  = DatabaseFactory.GetDatabase();
            IDbDataAdapter da = d.GetDataAdapter();

            da.UpdateCommand = d.PrepareCommand("UPDATE MSGS SET MSG_STATUS = @MSGS.MSG_STATUS@, MSG_NUMRETRIES = @MSGS.MSG_NUMRETRIES@, MSG_LASTRETRY = @MSGS.MSG_LASTRETRY@");
            d.UpdateDataSet(da, data.Tables[0]);
        }
Esempio n. 2
0
        /// <summary>
        /// Saves subviews' permissions for a role (ROL_PERMISSIONS table)
        /// </summary>
        /// <param name="dt">DataTable containint the users to save</param>
        public void SaveViewsAssignedToRoles(DataTable dt)
        {
            Database       d   = DatabaseFactory.GetDatabase();
            IDbDataAdapter da  = d.GetDataAdapter();
            IDbCommand     cmd = d.PrepareCommand("UPDATE ROL_PERMISSIONS SET RPER_INSALLOWED = @ROL_PERMISSIONS.RPER_INSALLOWED@, RPER_UPDALLOWED = @ROL_PERMISSIONS.RPER_UPDALLOWED@, RPER_DELALLOWED= @ROL_PERMISSIONS.RPER_DELALLOWED@, RPER_EXEALLOWED=@ROL_PERMISSIONS.RPER_EXEALLOWED@ WHERE RPER_ROL_ID  = @ROL_PERMISSIONS.RPER_ROL_ID@ AND  RPER_VELE_VIE_ID = @ROL_PERMISSIONS.RPER_VELE_VIE_ID@ AND  RPER_VELE_ELEMENTNUMBER = @ROL_PERMISSIONS.RPER_VELE_ELEMENTNUMBER@", false);
            IDbConnection  con = d.GetNewConnection();

            con.Open();
            cmd.Connection   = con;
            da.UpdateCommand = cmd;
            d.UpdateDataSet(da, dt);
            con.Close();
            dt.AcceptChanges();
        }
Esempio n. 3
0
        /// <summary>
        /// Updates the USR_PERMISSIONS table
        /// </summary>
        /// <param name="dt">DataTable to udpate</param>
        public void SaveViewsAssignedToUsers(DataTable dt)
        {
            Database       d  = DatabaseFactory.GetDatabase();
            IDbDataAdapter da = d.GetDataAdapter();

            da.UpdateCommand = d.PrepareCommand("UPDATE USR_PERMISSIONS SET UPER_INSALLOWED = @USR_PERMISSIONS.UPER_INSALLOWED@, UPER_UPDALLOWED = @USR_PERMISSIONS.UPER_UPDALLOWED@, UPER_DELALLOWED= @USR_PERMISSIONS.UPER_DELALLOWED@, UPER_EXEALLOWED=@USR_PERMISSIONS.UPER_EXEALLOWED@ WHERE UPER_USR_ID  = @USR_PERMISSIONS.UPER_USR_ID@ AND UPER_VELE_VIE_ID = @USR_PERMISSIONS.UPER_VELE_VIE_ID@ AND  UPER_VELE_ELEMENTNUMBER = @USR_PERMISSIONS.UPER_VELE_ELEMENTNUMBER@", false);
            da.InsertCommand = d.PrepareCommand("INSERT INTO USR_PERMISSIONS (UPER_USR_ID, UPER_VELE_VIE_ID, UPER_VELE_ELEMENTNUMBER, UPER_INSALLOWED,UPER_UPDALLOWED, UPER_DELALLOWED, UPER_EXEALLOWED) VALUES (@USR_PERMISSIONS.UPER_USR_ID@, @USR_PERMISSIONS.UPER_VELE_VIE_ID@, @USR_PERMISSIONS.UPER_VELE_ELEMENTNUMBER@, @USR_PERMISSIONS.UPER_INSALLOWED@,@USR_PERMISSIONS.UPER_UPDALLOWED@, @USR_PERMISSIONS.UPER_DELALLOWED@, @USR_PERMISSIONS.UPER_EXEALLOWED@)", false);
            da.DeleteCommand = d.PrepareCommand("DELETE FROM USR_PERMISSIONS WHERE UPER_USR_ID = @USR_PERMISSIONS.UPER_USR_ID@  AND UPER_VELE_VIE_ID = @USR_PERMISSIONS.UPER_VELE_VIE_ID@ AND UPER_VELE_ELEMENTNUMBER = @USR_PERMISSIONS.UPER_VELE_ELEMENTNUMBER@", false);
            IDbConnection con = d.GetNewConnection();

            con.Open();
            da.UpdateCommand.Connection = con;
            da.InsertCommand.Connection = con;
            da.DeleteCommand.Connection = con;
            d.UpdateDataSet(da, dt);
            con.Close();
            dt.AcceptChanges();
        }
        /// <summary>
        /// Delete ALL alarms contained in arraylist alarms (for the UNIT specified)
        /// </summary>
        /// <param name="alarms">ArrayList of ints (alarms ==> ALA_DALA_ID)</param>
        /// <param name="uniid">UNI_ID of the unit</param>
        /// <param name="con">Connection to use</param>
        /// <param name="tran">Transaction context to use</param>
        /// <returns>true if succesful, false if error</returns>
        protected void DeleteAlarms(ArrayList alarms, int uniid, IDbConnection con, DateTime date)
        {
            Database       d  = DatabaseFactory.GetDatabase();
            IDbDataAdapter da = d.GetDataAdapter();

            try
            {
                //m.WaitOne();
                // Get all the current alarms
                DataTable dtAlarms = d.FillDataTable(
                    "SELECT ALA_ID, ALA_DALA_ID, ALA_UNI_ID, ALA_INIDATE "
                    + "FROM ALARMS WHERE ALA_UNI_ID = @ALARMS.ALA_UNI_ID@",
                    "ALARMS", uniid);

                // Foreach alarm check if we have to delete it  (==> set ALA_ENDDATE to Now)
                foreach (DataRow dr in  dtAlarms.Rows)
                {
                    // cfe -- evito que el error en el procesamiento de una alarma afecte al resto
                    try
                    {
                        int ialarm = Convert.ToInt32(dr["ALA_DALA_ID"]);
                        if (alarms.Contains(ialarm))
                        {
                            // Insert the alarm into alarm_his...
                            InsertAlarmHistory(dr, con, date);
                            // ... and delete it from DataTable
                            dr.Delete();
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
                // Update the database
                da.DeleteCommand            = d.PrepareCommand("DELETE FROM ALARMS WHERE ALA_ID = @ALARMS.ALA_ID@", false);
                da.DeleteCommand.Connection = con;
                d.UpdateDataSet(da, dtAlarms);
                dtAlarms.AcceptChanges();
            }
            finally
            {
                //m.ReleaseMutex();
            }
        }
Esempio n. 5
0
        public override void SaveData(DataTable dt)
        {
            // Loads XML Schema from database
            LoadSchema();

            Database      d   = DatabaseFactory.GetDatabase();
            IDbConnection con = d.GetNewConnection();

            con.Open();

            IDbDataAdapter da = d.GetDataAdapter();

            da.InsertCommand            = d.PrepareCommand(CreateInsertCommand(), false);
            da.UpdateCommand            = d.PrepareCommand(CreateUpdateCommand(), false);
            da.DeleteCommand            = d.PrepareCommand(CreateDeleteCommand(), false);
            da.InsertCommand.Connection = con;
            da.UpdateCommand.Connection = con;
            da.DeleteCommand.Connection = con;

            d.UpdateDataSet(da, dt);
            dt.AcceptChanges();
            con.Close();
        }