Example #1
0
        /// <summary>
        /// 保存脚本到数据库和内存,如果内存中没有tab页,则只进数据库.此函数目前只被脚本调用
        /// </summary>
        /// <param name="fieldid"></param>
        /// <param name="tabid"></param>
        /// <param name="strCode"></param>
        /// <returns></returns>
        public string SaveScriptIntoDatabase(string fieldid, string tabid, string strCode)
        {
            DBCustomClass    dbclass = FindDbClassByTabid(tabid);
            DBCustomProperty prop    = FindPropByID(fieldid, tabid);

            if (fieldid == "0")
            {
                //是Tab页脚本
                //DBCustomClass dbclass = FindDbClassByTabid(tabid);
                if (dbclass != null)
                {
                    dbclass.SetScriptCode(null, strCode);
                    dbclass.SaveScript(null);
                    string logcomment = string.Format("PropertyName={0}, FieldID={1}", "#", fieldid);
                    //logscript.Log(TimeLog.enumLogType.ltend, null, null, logcomment + " 脚本被更改!");
                    dbclass.DoScript(null);
                    return("OK");
                }
            }
            else
            {
                //是属性脚本
                //DBCustomClass dbclass = FindDbClassByTabid(tabid);
                //DBCustomProperty prop = FindPropByID(fieldid, tabid);
                if (prop != null && dbclass != null)
                {
                    //内存中有脚本
                    dbclass.SetScriptCode(prop, strCode);
                    dbclass.SaveScript(prop);
                    string logcomment = string.Format("PropertyName={0}, FieldID={1}", prop.Name, prop.Key);
                    //logscript.Log(TimeLog.enumLogType.ltend, null, null, logcomment + " 脚本被更改!");
                    dbclass.DoScript(prop);
                    return("OK");
                }
            }

            //内存中没有脚本,直接进数据库
            string strMainTable = prop == null ? "" : (prop.Parent as DBCustomClass).MainTable;

            return(DBProcess.SaveScriptByID(strMainTable, fieldid, tabid, strCode) ? "OK" : "NG");
        }
Example #2
0
 static public void InitConn()
 {
     if (Program.EnableRemoting)
     {
         if (!DataTableServerProxy.IsInit)
         {
             DataTableServerProxy.InitServerProxy(Application.ExecutablePath + ".config", Program.Database);
         }
         m_strconn = DataTableServerProxy.GetDBSourceString();
         Program.ConnetionString = m_strconn;
         conn = new SqlConnection(m_strconn);
         DataTableServerProxy.GetDataTableProxy().InitRemoting(conn);
     }
     else
     {
         m_strconn = Program.ConnetionString;
         conn      = new SqlConnection(m_strconn);
     }
     CustomClassCache.Conn = conn;
     CustomClassCache.DelAllCaches();
     //add by cuiwei 07.10.16
     DBProcess.SetConnection(conn);
     //add end
 }