Exemple #1
0
 private static com.sybase.afx.db.DataSourceInfo GetDSI()
 {
     if (DSI != null)
     {
         return DSI;
     }
     com.sybase.afx.db.DataSourceInfo _dsi = new com.sybase.afx.db.DataSourceInfo();
     _dsi.SetConnectionUltraLiteClass();       
     string _tmpConnStr = "DBF=" + GetDbPath() + ";DBN=cRMMobile1_0";
     if(GetConnectionProfile().GetProperty("encryptionKey") != null)
     {
         _tmpConnStr = _tmpConnStr + ";dbkey=" + GetConnectionProfile().GetProperty("encryptionKey");
     }    
     _tmpConnStr = _tmpConnStr + ";CACHE_SIZE=" + GetConnectionProfile().CacheSize;
     _dsi.SetConnectionString(_tmpConnStr);
     _dsi.SetThreadLocal(true);
     _dsi.SetConnectionProfile(GetConnectionProfile());
     DSI = _dsi;
     return _dsi;
 }
Exemple #2
0
 /// <summary>
 /// Create local database
 /// </summary>
 public static void CreateDatabase()
 {
     if (YPF.Comercial.RRCC.SUP.CRMMobileDesaDB._created)
     {
         return;
     }
     lock(typeof(YPF.Comercial.RRCC.SUP.CRMMobileDesaDB))
     {
         if (!System.IO.File.Exists(GetDbPath()))
         {
             Sybase.Persistence.ConnectionWrapper _connWrapper = null;
             try
             {
                 string encryptionKey = null;
                 if(GetConnectionProfile().GetProperty("encryptionKey") != null)
                 {
                     encryptionKey = GetConnectionProfile().GetProperty("encryptionKey");
                 }
                 string collation = null;
                 if(GetConnectionProfile().GetProperty("collation") != null)
                 {
                     collation = GetConnectionProfile().GetProperty("collation");
                 }
                 com.sybase.afx.db.DBUtil.CreateDatabase(GetDbPath(), encryptionKey, GetConnectionProfile().PageSize, collation);
                 DSI = null;
                 _connWrapper = (Sybase.Persistence.ConnectionWrapper)GetLockManager().AcquireWriteLock();
                 com.sybase.afx.DatabaseBase.ExecuteBatchSQLs(_connWrapper, GetCreateDatabaseSQLs());
                 InitClientPropsTable(_connWrapper);          
             
                 YPF.Comercial.RRCC.SUP.CRMMobileDesaDB._created = true;
             }
             finally
             {
                 if (_connWrapper != null)
                 {
                     YPF.Comercial.RRCC.SUP.CRMMobileDesaDB.ReleaseDBConnection();
                 }
             }
         }
         else
         {
             YPF.Comercial.RRCC.SUP.CRMMobileDesaDB._created = true;
         }
     }
 }