Example #1
0
        /// <summary>
        /// Will use the License.DAT file for ConnectionString
        /// Use this function for Desktop Applications
        /// </summary>
        public Oyster()
        {
            try
            {
            //				string ConnectionString = GetEncryptedConnectionString();
                string ConnectionString;
                if (System.Web.HttpContext.Current == null)
                {
                    RegistryKey rk = CarverLab.Utility.Registry.DefaultProductKey;
                    if (rk == null)
                    {
                        Logger.WriteLog("Could not find the registry key {0} in the registry.", CarverLab.Utility.Registry.DefaultProductKeyString);
                        throw new ApplicationException("The registry key " + CarverLab.Utility.Registry.DefaultProductKeyString + " could not be found. This application may not be setup properly.");
                    }
                    object obj = rk.GetValue("ConnectionString");
                    if (obj == null)
                    {
                        Logger.WriteLog("Could not find the connection string at {0} in the registry.", rk.ToString());
                        throw new ApplicationException("The server connection info could not be found. Please contact your system administrator.");
                    }
                    ConnectionString = obj.ToString();
                    Logger.WriteLog("Got a ConnectionString from the registry");
                }
                else
                {
                    ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
                    if (ConnectionString == null || ConnectionString.Trim().Length == 0)
                    {
                        throw new ApplicationException("The web.config Connection String for " + CarverLab.Utility.AppInfo.Title + " could not be found. Is this application setup properly?");
                    }
                    Logger.WriteLog("Got a ConnectionString from app settings");
                }
                if(ConnectionString == "")
                    throw new Exception("Unable to acquire connection data to Database!!");

                SCO = new StaticConnectionObject();
                SCO.StaticConnectionString = ConnectionString;
                SCO.IsConnectionStatic = true;

                OysterTimer = new System.Timers.Timer(5000);
                OysterTimer.Elapsed += new System.Timers.ElapsedEventHandler(this.OysterTimer_Tick);
                OysterTimer.AutoReset = true;
                OysterTimer.Enabled = false;
                IsLoggedOn = false;
                Logger.WriteLog("created Oyster object");
            }
            catch(Exception Err)
            {
                throw new Exception(Err.Message,Err.InnerException);
            }
        }
Example #2
0
        /// <summary>
        /// Will use the License.DAT file for ConnectionString
        /// If Set to True it will look for the License.DAT file in
        /// "//LocalHost/License.dat" Otherwise in the application directory.		
        /// </summary>
        public Oyster(bool IsWebApplication)
        {
            try
            {
                mvarIsRunningInWebApp = IsWebApplication;
                string ConnectionString = GetEncryptedConnectionString();
                if(ConnectionString == "")
                    throw new Exception("Unable to aquire connection data to Database!!");

                SCO = new StaticConnectionObject();
                SCO.StaticConnectionString = ConnectionString;
                SCO.IsConnectionStatic = true;

                OysterTimer = new System.Timers.Timer(5000);
                OysterTimer.Elapsed += new System.Timers.ElapsedEventHandler(this.OysterTimer_Tick);
                OysterTimer.AutoReset = true;
                OysterTimer.Enabled = false;
                IsLoggedOn = false;
                Logger.WriteLog("Created an Oyster object for a web application");
            }
            catch(Exception Err)
            {
                throw new Exception(Err.Message,Err.InnerException);
            }
        }
Example #3
0
        public Oyster(string ServerAddress, string sPassword)
        {
            try
            {
                if (ServerAddress != "")
                {
                    SCO = new StaticConnectionObject();
                    SCO.StaticConnectionString = "data source=" + ServerAddress + ";initial catalog=Oyster;persist security info=False;user id=sa;password="******";packet size=4096";
                    SCO.IsConnectionStatic = true;
                    try
                    {
                        EncryptConnectionString(SCO.StaticConnectionString);
                    }
                    catch
                    {
                    }
                }

                OysterTimer = new System.Timers.Timer(5000);
                OysterTimer.Elapsed += new System.Timers.ElapsedEventHandler(this.OysterTimer_Tick);
                OysterTimer.AutoReset = true;
                OysterTimer.Enabled = false;
                IsLoggedOn = false;
                Logger.WriteLog("created Oyster object with passed in ServerAddress and Password");
            }
            catch(Exception Err)
            {
                throw new Exception(Err.Message,Err.InnerException);
            }
        }
Example #4
0
        public Oyster(string ConnectionString)
        {
            try
            {

                if(ConnectionString != "")
                {
                    SCO = new StaticConnectionObject();
                    SCO.StaticConnectionString = ConnectionString;
                    SCO.IsConnectionStatic = true;
                    EncryptConnectionString(ConnectionString);
                }

                OysterTimer = new System.Timers.Timer(5000);
                OysterTimer.Elapsed += new System.Timers.ElapsedEventHandler(this.OysterTimer_Tick);
                OysterTimer.AutoReset = true;
                OysterTimer.Enabled = false;
                IsLoggedOn = false;
                Logger.WriteLog("created Oyster object with passed in ConnectionString");
            }
            catch(Exception Err)
            {
                throw new Exception(Err.Message,Err.InnerException);
            }
        }
Example #5
0
 //        internal void ShareOpenConnection(ref SqlConnection R)
 //        {
 //            R = MC;
 //        }
 //        internal SqlConnection GetConnection()
 //        {
 //            return MC;
 //        }
 internal string GetConnectionString()
 {
     StaticConnectionObject OCL = new StaticConnectionObject();
     return OCL.StaticConnectionString;
 }
Example #6
0
        //internal string ConnectionString;
        /// <summary>
        /// Opens and manages its own connection to the Oyster Database
        /// ALL Instances of the Functions Class use the same Connection
        /// Always returns True
        /// </summary>
        /// 
        public Functions()
        {
            //
            // TODO: Add constructor logic here
            //
            try
            {
            //				if(MC == null)
            //				{
            //					MC = new SqlConnection();
            //				}
            //
            //				if((MC.State == ConnectionState.Closed)||(MC.State == ConnectionState.Broken))
            //				{
                if(!IsInitialized)
                {
                    IsInitialized = true;
                    StaticConnectionObject OCL = new StaticConnectionObject();
                    if(!OCL.IsConnectionStatic)
                    {

                        RegistryKey RK;
                        //RK = Registry.LocalMachine.OpenSubKey("Software\\VSC\\CardVideo");
                        //UseExternalDatabase = 0;
                        RK = Registry.LocalMachine.OpenSubKey("Software\\Carver Lab\\Oyster V2.0\\Data");
                        if(RK != null)
                        {
                            ConnectionString = Convert.ToString((object)RK.GetValue("ConnectionString",""));
                            //UseExternalDatabase = Convert.ToInt32((object)RK.GetValue("UseExternalDatabase",0));
                        }

                        //ConnectionString = "data source=mssql2.michiganwebtech.com;initial catalog=carverl_oyster;persist security info=False;user id=carverl_admin;password = oyster;packet size=4096";

                        //ConnectionString = "data source=localhost;initial catalog=Oyster;persist security info=False;user id=sa;workstation id=LIGHTBRINGER;packet size=4096";
                    }
                    else
                        ConnectionString = OCL.StaticConnectionString;

                    m_Connections = new Functions.RFConnection[5];

                    for (int i = 0; i < m_Connections.GetLength(0); i++)
                    {
                        m_Connections[i] = new Functions.RFConnection(new System.Data.SqlClient.SqlConnection(ConnectionString));
                    }
                }
            //					MC = new SqlConnection(ConnectionString);
            //					numconnections++;
            //					MC.Open();

            //				}
            //				else
            //				{
            //					//Do Nothing but share the already existing connection
            //					numconnections++;
            //				}
            }
            catch(Exception Err)
            {
                throw new Exception(Err.Message,Err.InnerException);
            }
        }
Example #7
0
        public void BeginUsingNewConnectionString(string sConnectionString)
        {
            StaticConnectionObject SCO = new StaticConnectionObject();
            SCO.IsConnectionStatic = true;
            SCO.StaticConnectionString = sConnectionString;
            ConnectionString = sConnectionString;
            foreach(Functions.RFConnection mConn in m_Connections)
            {
                try
                {
                    if((mConn.Connection.State == ConnectionState.Closed)||(mConn.Connection.State == ConnectionState.Broken))
                    {

                        mConn.Connection.ConnectionString = sConnectionString;
                        //mConn.Connection.Open();
                    }
                    else
                    {
                        mConn.Connection.Close();
                        mConn.Connection.ConnectionString = sConnectionString;
                        //mConn.Connection.Open();
                    }
                }
                catch(Exception Err)
                {
                    throw new Exception(Err.Message,Err.InnerException);
                }
            }
        }