Example #1
0
        private ISearchPath LoadSearchPath()
        {
            ISearchPath searchPath = PathContainerFor(Db4oClient.OMNConnection).SearchPath;

            Db4oClient.CloseRecentConnectionFile();
            return(searchPath);
        }
 internal void AddQueryToList(OMQuery query)
 {
     try
     {
         long id = ChkIfRecentConnIsInDb();
         if (id > 0)
         {
             ConnectionDetails temprc = Db4oClient.OMNConnection.Ext().GetByID(id) as ConnectionDetails;
             Db4oClient.OMNConnection.Ext().Activate(temprc, 5);
             MaintainCountofTwentyforQueries(temprc);
             MaintainCountofFiveForQueries(query, temprc);
             if (temprc != null)
             {
                 temprc.Timestamp = DateTime.Now;
                 temprc.QueryList.Add(query);
             }
             Db4oClient.OMNConnection.Ext().Store(temprc, 5);
             Db4oClient.OMNConnection.Commit();
         }
     }
     catch (Exception oEx)
     {
         LoggingHelper.HandleException(oEx);
     }
     finally
     {
         Db4oClient.CloseRecentConnectionFile();
     }
 }
 internal void DeleteRecentQueriesForAConnection()
 {
     try
     {
         IQuery query = Db4oClient.OMNConnection.Query();
         query.Constrain(typeof(ConnectionDetails));
         query.Descend("m_connParam").Descend("m_connection").Constrain(currConnParams.Connection);
         IObjectSet objSet = query.Execute();
         if (objSet != null)
         {
             ConnectionDetails connectionDetails = (ConnectionDetails)objSet.Next();
             foreach (OMQuery q in connectionDetails.QueryList.Where(q => q != null))
             {
                 Db4oClient.OMNConnection.Delete(q);
             }
             connectionDetails.QueryList.Clear();
             connectionDetails.TimeOfCreation = Sharpen.Runtime.CurrentTimeMillis();
             Db4oClient.OMNConnection.Store(connectionDetails);
             Db4oClient.OMNConnection.Commit();
         }
     }
     catch (Exception oEx)
     {
         LoggingHelper.HandleException(oEx);
     }
     finally
     {
         Db4oClient.CloseRecentConnectionFile();
     }
 }
 internal void RemoveCustomConfigPath(string path)
 {
     try
     {
         IObjectContainer container = Db4oClient.OMNConnection;
         IQuery           query     = container.Query();
         query.Constrain(typeof(ConnectionDetails));
         query.Descend("m_connParam").Descend("m_connection").Constrain(currConnParams.Connection);
         query.Descend("m_customConfigAssemblyPath").Constrain(path);
         IObjectSet objSet = query.Execute();
         if (objSet.Count > 0)
         {
             ConnectionDetails q = objSet[0] as ConnectionDetails;
             q.CustomConfigAssemblyPath = string.Empty;
             container.Ext().Store(q, 2);
             container.Commit();
         }
     }
     catch (Exception oEx)
     {
         LoggingHelper.HandleException(oEx);
     }
     finally
     {
         Db4oClient.CloseRecentConnectionFile();
     }
 }
        internal long ReturnTimeWhenRecentQueriesCreated()
        {
            try
            {
                long id = ChkIfRecentConnIsInDb();
                if (id > 0)
                {
                    ConnectionDetails connectionDetails = Db4oClient.OMNConnection.Ext().GetByID(id) as ConnectionDetails;

                    if (connectionDetails != null)
                    {
                        Db4oClient.OMNConnection.Ext().Activate(connectionDetails, 3);
                        return(connectionDetails.TimeOfCreation > 0 ? connectionDetails.TimeOfCreation : 0);
                    }
                }
            }
            catch (Exception oEx)
            {
                LoggingHelper.HandleException(oEx);
            }
            finally
            {
                Db4oClient.CloseRecentConnectionFile();
            }
            return(0);
        }
        private void CreateOMNDirectory()
        {
            string omnConfigFolderPath = Path.GetDirectoryName(Db4oClient.GetOMNConfigdbPath());

            if (!Directory.Exists(omnConfigFolderPath))
            {
                Directory.CreateDirectory(omnConfigFolderPath);
            }
        }
Example #7
0
        public void SaveAssemblySearchPath(string path)
        {
            _path = path;
            PathContainer pathContainer = PathContainerFor(Db4oClient.OMNConnection);

            if (pathContainer.SearchPath != null)
            {
                Db4oClient.OMNConnection.Delete(pathContainer.SearchPath);
            }
            pathContainer.SearchPath     = AssemblySearchPath;
            pathContainer.ConnectionPath = path;
            Db4oClient.OMNConnection.Store(pathContainer);
            Db4oClient.CloseRecentConnectionFile();
        }
        public List <ConnectionDetails> GetAllConnections(bool remote)
        {
            List <ConnectionDetails> recConnections = null;

            try
            {
#if DEBUG
                CreateOMNDirectory();
#endif
                IObjectContainer dbrecentConn = Db4oClient.OMNConnection;
                IQuery           query        = dbrecentConn.Query();
                query.Constrain(typeof(ConnectionDetails));
                if (remote)
                {
                    query.Descend("m_connParam").Descend("m_host").Constrain(null).Not();
                    query.Descend("m_connParam").Descend("m_port").Constrain(0).Not();
                }
                else
                {
                    query.Descend("m_connParam").Descend("m_host").Constrain(null);
                    query.Descend("m_connParam").Descend("m_port").Constrain(0);
                }
                IObjectSet os = query.Execute();

                if (os.Count > 0)
                {
                    recConnections = new List <ConnectionDetails>();
                    while (os.HasNext())
                    {
                        recConnections.Add((ConnectionDetails)os.Next());
                    }
                    CompareTimestamps comparator = new CompareTimestamps();
                    recConnections.Sort(comparator);
                }
            }
            catch (Exception oEx)
            {
                LoggingHelper.HandleException(oEx);

                return(null);
            }
            finally
            {
                Db4oClient.CloseRecentConnectionFile();
            }
            return(recConnections);
        }
 public ProxyAuthenticator ReturnProxyAuthenticationInfo()
 {
     try
     {
         IObjectSet ObjSet = Db4oClient.OMNConnection.QueryByExample(typeof(ProxyAuthenticator));
         return(ObjSet.Count > 0 ? (ProxyAuthenticator)ObjSet.Next() : null);
     }
     catch (Exception e)
     {
         LoggingHelper.HandleException(e);
         return(null);
     }
     finally
     {
         Db4oClient.CloseRecentConnectionFile();
     }
 }
        public void AddProxyInfoToDb(ProxyAuthentication proxyAuthObj)
        {
            ProxyAuthenticator proxyobj = ReturnProxyAuthenticationInfo();

            if (proxyobj == null)
            {
                Db4oClient.OMNConnection.Store(this);
            }
            else
            {
                proxyobj._proxyAuthObj = proxyAuthObj;
                Db4oClient.OMNConnection.Store(proxyobj);
            }
            Db4oClient.OMNConnection.Commit();
            Db4oClient.OMNConnection.Ext().Refresh(proxyobj, 1);
            Db4oClient.CloseRecentConnectionFile();
        }
        public bool SaveConnectionDetails(ConnectionDetails connectionDetails)
        {
            try
            {
                ManageConnectionDetails manageConnectionDetails = new ManageConnectionDetails(connectionDetails.ConnParam);
                long              id           = manageConnectionDetails.ChkIfRecentConnIsInDb();
                IObjectContainer  dbrecentConn = Db4oClient.OMNConnection;
                ConnectionDetails temprc       = null;
                if (id > 0)
                {
                    temprc = dbrecentConn.Ext().GetByID(id) as ConnectionDetails;
                    dbrecentConn.Ext().Activate(temprc, 3);
                    if (temprc != null)
                    {
                        temprc.Timestamp = DateTime.Now;
                        temprc.ConnParam.ConnectionReadOnly = connectionDetails.ConnParam.ConnectionReadOnly;
                    }
                }
                else
                {
                    temprc                = connectionDetails;
                    temprc.Timestamp      = DateTime.Now;
                    temprc.TimeOfCreation = Sharpen.Runtime.CurrentTimeMillis();
                }
                dbrecentConn.Store(temprc);
                dbrecentConn.Commit();
            }

            catch (Exception oEx)
            {
                LoggingHelper.HandleException(oEx);
                return(false);
            }
            finally
            {
                Db4oClient.CloseRecentConnectionFile();
            }
            return(true);
        }
        internal long ChkIfRecentConnIsInDb()
        {
            long id = 0;

            try
            {
                IObjectContainer container = Db4oClient.OMNConnection;
                IQuery           qry       = container.Query();
                qry.Constrain(typeof(ConnectionDetails));
                IObjectSet objSet;
                if (currConnParams.Host == null)
                {
                    qry.Descend("m_connParam").Descend("m_connection").Constrain(currConnParams.Connection);
                    objSet = qry.Execute();
                }
                else
                {
                    qry.Descend("m_connParam").Descend("m_host").Constrain(currConnParams.Host);
                    qry.Descend("m_connParam").Descend("m_port").Constrain(currConnParams.Port);
                    qry.Descend("m_connParam").Descend("m_userName").Constrain(currConnParams.UserName);
                    qry.Descend("m_connParam").Descend("m_passWord").Constrain(currConnParams.PassWord);
                    objSet = qry.Execute();
                }
                if (objSet.Count > 0)
                {
                    ConnectionDetails connectionDetails = (ConnectionDetails)objSet.Next();
                    id = Db4oClient.OMNConnection.Ext().GetID(connectionDetails);
                }
            }
            catch (Exception oEx)
            {
                LoggingHelper.HandleException(oEx);
            }
            finally
            {
                Db4oClient.CloseRecentConnectionFile();
            }
            return(id);
        }