Example #1
0
        /// <summary>
        /// Inicializar COMOS para usar banco de dados definido pela conectionstring.
        /// !!! Este methodo se comporta static
        /// </summary>
        /// <param name="connectionstring"></param>
        /// <returns>True é o sucesso, false caso contrário.</returns>
        public bool Open(string connectionstring)
        {
            try
            {
                Console.WriteLine("COMOS.IO Opening : " + connectionstring);
                Log.WriteLog("COMOS.IO Opening : " + connectionstring, System.Diagnostics.EventLogEntryType.Information);

                if (m_ComosSession != null)
                {
                    return(false);
                }
                m_ComosSession = new ComosSession();
                Log.WriteLog("Session Created. Will Call Open in Comos IO", System.Diagnostics.EventLogEntryType.Information);

                if (!m_ComosSession.Open(connectionstring))
                {
                    Console.WriteLine("Invalid <connection string> or <no license> argument: " + connectionstring);
                    Log.WriteLog("Invalid <connection string> or <no license> argument: " + connectionstring, System.Diagnostics.EventLogEntryType.Error);
                    return(false);
                }
                else
                {
                    Log.WriteLog("Success opening COMOS DB:" + connectionstring, System.Diagnostics.EventLogEntryType.Information);
                    m_ComosSession.ReleaseCOMOSObjects();
                }
            }
            catch (Exception ex)
            {
                Log.WriteLog("Exception opening COMOS DB:" + ex.Message, System.Diagnostics.EventLogEntryType.Error);
                //ComosBRWeb.LogHandler.WriteLog(ex.Message + ":Open");
                System.Diagnostics.Debug.Assert(false);
            }
            return(true);
        }