Пример #1
0
        /// <summary>
        /// Initializes the log.
        /// </summary>
        private static void InitializeLog()
        {
            _logger = Logger.Instance;

             		_fileLogger = new FileLogger(Global.LogFilePath);
              	_fileLogger.Init();

              	_logger.RegisterObserver(_fileLogger);

            _logger.AddLogMessage("Begin Scraping...");
        }
        public static void DBConnect()
        {
            if (BaseTableAdapter.conn == null)
            {
                Logger filelogger = new FileLogger("DB");
                LogManager.GetInstance().AddLogger(filelogger, "DB", false);
                string connstring = ConfigurationManager.ConnectionStrings["SM_Remote_DB_Conn"].ConnectionString.Trim();
                if (connstring == null)
                {
                    System.Windows.Forms.MessageBox.Show(MissDBParam);
                    throw(new Exception(MissDBParam));
                }

                try
                {
                    BaseTableAdapter.conn = new SAConnection(ConfigurationManager.ConnectionStrings["SM_Remote_DB_Conn"].ConnectionString.Trim());
                    BaseTableAdapter.conn.Open();
                }
                catch (Exception e)
                {
                    string errstr = String.Format("{0} ConnectionString={1}", WrongDBParam, connstring);
                    System.Windows.Forms.MessageBox.Show(errstr);
                    throw (e);
                }
            }
        }