Пример #1
0
        public void EditSession(mst_session mst)
        {
            try
            {
                using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    string query = @"UPDATE mst_session 
                                    SET
                                        session_active = @session_active,
                                        session_finalize = @session_finalize
                                    WHERE
                                        session = @session";

                    con.Execute(query, mst);

                    if (mst.session_finalize == "Y")
                    {
                        query = @"UPDATE mst_session 
                                    SET
                                        session_finalize = 'C'
                                    WHERE
                                        session != @session";

                        con.Execute(query, mst);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        public void AddSession(mst_session mst)
        {
            try
            {
                using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    string query = @"INSERT INTO mst_session
                               (session
                               ,session_start_date
                                ,session_end_date
                                ,session_active
                                ,session_finalize)
                                VALUES
                               (@session,
                               @session_start_date,
                                @session_end_date,
                                @session_active,
                                'N')";


                    con.Execute(query, new
                    {
                        mst.session,
                        mst.session_start_date,
                        mst.session_end_date,
                        mst.session_active
                    });
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #3
0
        public bool checkSessionNotExpired()
        {
            using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                string Query = @"SELECT 
                                    session_start_date, session_end_date
                                FROM
                                    mst_session
                                WHERE
                                    session_finalize = 'Y'";

                mst_session mst = con.Query <mst_session>(Query).SingleOrDefault();

                if (System.DateTime.Now.AddMinutes(dateTimeOffSet).Date >= mst.session_start_date && System.DateTime.Now.AddMinutes(dateTimeOffSet).Date <= mst.session_end_date.Date)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }