Exemplo n.º 1
0
        void referTables(object id)
        {
            if (m_sysTable == null || m_sysTable.refer == null)
            {
                return;
            }

            var key        = m_table + "_" + ID;
            var sqlSetDict = new Dictionary <string, string>();

            sqlSetDict.Add(key, null);

            var tableList = YoConvert.ToList(m_sysTable.refer);

            foreach (var table in tableList)
            {
                var refer = new YoCacheRefer(table, m_act);

                if (!refer.CheckDisplayChange(sqlSetDict))
                {
                    continue;
                }
                refer.referRows(key, id);
            }
        }
Exemplo n.º 2
0
        public bool Update(JObject uiDict)
        {
            var result = false;

            while (true)
            {
                m_uiDict = uiDict;
                if (m_uiDict == null)
                {
                    break;
                }

                if (!m_uiDict.ContainsKey(ID))
                {
                    break;
                }

                if (!Find(m_uiDict[ID]))
                {
                    break;
                }

                if (!checkUptime())
                {
                    m_errorDict[DB] = "dirty data";
                    break;
                }

                if (!parseSqlSet())
                {
                    break;
                }

                var sql = string.Format("UPDATE `{0}` SET {1} WHERE `id`='{2}';", m_table, string.Join(",", m_sqlSetDict.Values), m_uiDict[ID]);
                if (!runSql(sql))
                {
                    break;
                }

                // remove cache
                var yoRefer = new YoCacheRefer(m_table, (table, id) => {
                    // create cache
                    var selectone = new YoSelectOne(table, m_trans);
                    selectone.GetRowTitleDisplay(id);
                });
                if (yoRefer.CheckDisplayChange(m_sqlSetDict))
                {
                    yoRefer.ReferRow(m_uiDict[ID]);
                }

                result = true;
                break;
            }

            return(result);
        }