Ejemplo n.º 1
0
        /// <summary>
        /// 更新布局
        /// </summary>
        /// <param name="layout">布局</param>
        public void UpdateLayouts(IndicatorLayout layout)
        {
            String sql = String.Format("UPDATE INDICATORLAYOUT SET NAME = '{0}', TEXT = '{1}', TYPE = {2}, ORDERNUM = {3} WHERE USERID = {4} AND LAYOUTID = '{5}'",
                                       CStrA.GetDBString(layout.m_name), CStrA.GetDBString(layout.m_text), layout.m_type, layout.m_orderNum, layout.m_userID, CStrA.GetDBString(layout.m_layoutID));
            SQLiteConnection conn = new SQLiteConnection(m_connectStr);
            SQLiteCommand    cmd  = conn.CreateCommand();

            cmd.CommandText = sql;
            conn.Open();
            cmd.ExecuteNonQuery();
            conn.Close();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 添加布局
        /// </summary>
        /// <param name="message">消息</param>
        /// <returns>状态</returns>
        public int AddJiras(CMessage message)
        {
            List <Jira> layouts = new List <Jira>();

            GetLayouts(layouts, message.m_body, message.m_bodyLength);
            int layoutsSize = layouts.Count;
            List <IndicatorLayout> addLayouts = new List <IndicatorLayout>();

            for (int i = 0; i < layoutsSize; i++)
            {
                IndicatorLayout receive = layouts[i];
                receive.m_layoutID = Guid.NewGuid().ToString();
                String sql = String.Format("INSERT INTO INDICATORLAYOUT(LAYOUTID, USERID, NAME, TEXT, TYPE, ORDERNUM, CREATETIME, MODIFYTIME) values ('{0}', {1}, '{2}', '{3}', {4}, {5}, '1970-1-1', '1970-1-1')",
                                           CStrA.GetDBString(receive.m_layoutID), receive.m_userID, CStrA.GetDBString(receive.m_name), CStrA.GetDBString(receive.m_text), receive.m_type, receive.m_orderNum);
                SQLiteConnection conn = new SQLiteConnection(m_connectStr);
                conn.Open();
                SQLiteCommand cmd = conn.CreateCommand();
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();
                conn.Close();
                addLayouts.Add(receive);
            }
            int ret = Send(message, addLayouts, true);

            layouts.Clear();
            addLayouts.Clear();
            return(ret);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取布局信息
        /// </summary>
        /// <param name="layouts">布局信息</param>
        /// <param name="userID">用户ID</param>
        /// <param name="layoutID">布局ID</param>
        public int GetLayouts(List <IndicatorLayout> layouts, int userID, String layoutID)
        {
            String sql = "";

            if (layoutID != null && layoutID.Length > 0)
            {
                sql = String.Format("SELECT * FROM INDICATORLAYOUT WHERE USERID = {0} AND LAYOUTID = '{1}'", userID, CStrA.GetDBString(layoutID));
            }
            else
            {
                if (userID > 0)
                {
                    sql = String.Format("SELECT * FROM INDICATORLAYOUT WHERE USERID = {0} ORDER BY ORDERNUM", userID);
                }
                else
                {
                    sql = "SELECT * FROM INDICATORLAYOUT ORDER BY ORDERNUM";
                }
            }
            SQLiteConnection conn = new SQLiteConnection(m_connectStr);
            SQLiteCommand    cmd  = conn.CreateCommand();

            cmd.CommandText = sql;
            conn.Open();
            SQLiteDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                IndicatorLayout layout = new IndicatorLayout();
                layout.m_layoutID = reader.GetString(0);
                layout.m_userID   = reader.GetInt32(1);
                layout.m_name     = reader.GetString(2);
                layout.m_text     = reader.GetString(3);
                layout.m_type     = reader.GetInt32(4);
                layout.m_orderNum = reader.GetInt32(5);
                layouts.Add(layout);
            }
            reader.Close();
            conn.Close();
            return(1);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 删除布局
        /// </summary>
        /// <param name="message">消息</param>
        /// <returns>状态</returns>
        public int DeleteLayouts(CMessage message)
        {
            List <IndicatorLayout> layouts = new List <IndicatorLayout>();

            GetLayouts(layouts, message.m_body, message.m_bodyLength);
            int layoutsSize = layouts.Count;
            List <IndicatorLayout> deleteLayouts = new List <IndicatorLayout>();

            for (int i = 0; i < layoutsSize; i++)
            {
                IndicatorLayout  receive = layouts[i];
                String           sql     = String.Format("DELETE FROM INDICATORLAYOUT WHERE USERID = {0} AND LAYOUTID = '{1}'", receive.m_userID, CStrA.GetDBString(receive.m_layoutID));
                SQLiteConnection conn    = new SQLiteConnection(m_connectStr);
                SQLiteCommand    cmd     = conn.CreateCommand();
                cmd.CommandText = sql;
                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
                deleteLayouts.Add(receive);
            }
            int ret = Send(message, deleteLayouts, true);

            layouts.Clear();
            deleteLayouts.Clear();
            return(ret);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 获取用户Cookie
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="cookie">会话</param>
        /// <returns>状态</returns>
        public int GetCookie(String key, ref UserCookie cookie)
        {
            int              state = 0;
            String           sql   = String.Format("SELECT * FROM USERCOOKIE WHERE USERID = {0} AND KEY = '{1}'", m_userID, CStrA.GetDBString(key));
            SQLiteConnection conn  = new SQLiteConnection(m_connectStr);
            SQLiteCommand    cmd   = conn.CreateCommand();

            cmd.CommandText = sql;
            conn.Open();
            SQLiteDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                cookie.m_userID = reader.GetInt32(0);
                cookie.m_key    = reader.GetString(1);
                cookie.m_value  = reader.GetString(2);
                state           = 1;
            }
            reader.Close();
            conn.Close();
            return(state);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 删除用户Cookie
        /// </summary>
        /// <param name="key">键</param>
        /// <returns>状态</returns>
        public int DeleteCookie(String key)
        {
            String           sql  = String.Format("DELETE FROM USERCOOKIE WHERE USERID = {0} AND KEY = '{1}'", m_userID, CStrA.GetDBString(key));
            SQLiteConnection conn = new SQLiteConnection(m_connectStr);
            SQLiteCommand    cmd  = conn.CreateCommand();

            cmd.CommandText = sql;
            conn.Open();
            cmd.ExecuteNonQuery();
            conn.Close();
            return(1);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 添加用户Cookie
        /// </summary>
        /// <param name="cookie">消息</param>
        /// <returns>状态</returns>
        public int AddCookie(UserCookie cookie)
        {
            UserCookie oldCookie = new UserCookie();

            if (GetCookie(cookie.m_key, ref oldCookie) > 0)
            {
                UpdateCookie(cookie);
            }
            else
            {
                String sql = String.Format("INSERT INTO USERCOOKIE(USERID, KEY, VALUE, MODIFYTIME, CREATETIME) values ({0}, '{1}', '{2}','1970-1-1','1970-1-1')",
                                           m_userID, CStrA.GetDBString(cookie.m_key), CStrA.GetDBString(cookie.m_value));
                SQLiteConnection conn = new SQLiteConnection(m_connectStr);
                conn.Open();
                SQLiteCommand cmd = conn.CreateCommand();
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();
                conn.Close();
            }
            return(1);
        }