コード例 #1
0
        public bool Login()
        {
            bool result = false;

            if (_State == enConnectionState.InstanceCreated)
            {
                try
                {
                    var args = new Object[3];
                    args[0] = _v7Type.InvokeMember(@"RMTrade", BindingFlags.Public | BindingFlags.InvokeMethod, null,
                                                   _v7,
                                                   null);
                    args[1] = string.Format(@"/d""{0}"" /n{1} /p{2}", _pathDB, _userName, _password); //D:\\1S_Data
                    args[2] = "NO_SPLASH_SHOW";
                    result  =
                        (Boolean)
                        _v7Type.InvokeMember(@"Initialize",
                                             BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Static, null,
                                             _v7, args);
                    if (result)
                    {
                        _State = enConnectionState.Connected;
                    }
                }
                catch (Exception e)
                {
                    Logger.logger.Error(string.Format("Can't login to DB: '{0}' Error: '{1}'", _pathDB, e.Message));
                    throw;
                }
            }
            return(result);
        }
コード例 #2
0
        private void Initialize()
        {
            try
            {
                string fullFileName = Path.Combine(_pathDB, "1Cv7.DD");
                if (File.Exists(fullFileName))
                {
                    string[] fileDescribe = File.ReadAllLines(_pathDB + "1Cv7.DD", Encoding.GetEncoding("windows-1251"));
                    LoadDescribeDB(fileDescribe);

                    _connection =
                        new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + _pathDB +
                                            @";Extended Properties=""dBASE IV;Exclusive=No;""");
                    _connection.Open();
                    _State = enConnectionState.Connected;
                }
                else
                {
                    throw new Exception(string.Format("Can't initialize dbf1Cv77Adaptor {0} not found", fullFileName));
                }
            }
            catch (Exception e)
            {
                Logger.logger.Error("Can't initialize dbf1Cv77Adaptor" + e.Message);
                throw;
            }
            Logger.logger.Debug("Initialize dbf1Cv77Adaptor");
        }
コード例 #3
0
 public void Dispose()
 {
     if (_v7 != null)
     {
         Marshal.Release(Marshal.GetIDispatchForObject(_v7));
         Marshal.ReleaseComObject(_v7);
         _v7     = null;
         _v7Type = null;
     }
     _State = enConnectionState.Closed;
     GC.Collect();
     GC.WaitForPendingFinalizers();
 }
コード例 #4
0
 public void Dispose()
 {
     if (_connection != null)
     {
         if (_connection.State == ConnectionState.Open)
         {
             _connection.Close();
         }
         _connection.Dispose();
     }
     _connection = null;
     _State      = enConnectionState.Closed;
 }
コード例 #5
0
 private void Initialize()
 {
     try
     {
         _v7     = Activator.CreateInstance(Type.GetTypeFromProgID("V77.Application", true));
         _v7Type = _v7.GetType();
         _State  = enConnectionState.InstanceCreated;
     }
     catch (Exception e)
     {
         Logger.logger.Error("Can't initialize V77.Application" + e.Message);
         throw;
     }
     Logger.logger.Debug("Initialize V77.Application");
 }