예제 #1
0
 public static XCollection <RegularExpressionItem> GetRegExpressions()
 {
     if (_list == null)
     {
         IMCfgMgt mgt = new IMCfgMgt();
         mgt.FileName = Application.StartupPath + "\\..\\..\\" + mgt.FileName;
         if (mgt.Load())
         {
             _list = mgt.Config.RegularExpressions;
             Program.Log.Write("Load IM configuration (for regular expressions) succeeded.");
         }
         else
         {
             Program.Log.Write(LogType.Warning, "Load IM configuration (for regular expressions) failed.");
         }
     }
     return(_list);
 }
예제 #2
0
        static bool PreLoading(string[] args)
        {
            // initialize logging
            Log = new Logging(Application.StartupPath + "\\InterfaceManager.log");
            LoggingHelper.EnableApplicationLogging(Log);
            //LoggingHelper.EnableDatabaseLogging(Log);
            LoggingHelper.EnableXmlLogging(Log);
            Log.WriteAppStart(AppName, args);

            // check multi instance
            if (CheckMultiInstance(args))
            {
                Log.WriteAppExit(AppName);
                return(false);
            }

            // initialize config
            ConfigMgt          = new IMCfgMgt();
            ConfigMgt.FileName = Application.StartupPath + "\\" + ConfigMgt.FileName;
            if (ConfigMgt.Load())
            {
                Log.Write("Load config succeeded. " + ConfigMgt.FileName);
            }
            else
            {
                Log.Write(LogType.Error, "Load config failed. " + ConfigMgt.FileName);
                Log.Write(ConfigMgt.LastErrorInfor);

                if (MessageBox.Show("Cannot load " + AppName + " config file. \r\n" +
                                    ConfigMgt.FileName + "\r\n\r\nDo you want to create a config file with default setting?",
                                    AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (ConfigMgt.Save())
                    {
                        Log.Write("Create config file succeeded. " + ConfigMgt.FileName);
                    }
                    else
                    {
                        Log.Write(LogType.Error, "Create config file failed. " + ConfigMgt.FileName);
                        Log.Write(ConfigMgt.LastErrorInfor);
                    }
                }

                Log.WriteAppExit(AppName);
                return(false);
            }

            // log config parameters
            string osqlFileName    = ConfigMgt.Config.OSqlFileName;
            string osqlParameter   = ConfigMgt.Config.OSqlParameter;
            string deviceFolder    = Application.StartupPath + "\\" + ConfigMgt.Config.DeviceFolder;
            string interfaceFolder = Application.StartupPath + "\\" + ConfigMgt.Config.InterfaceFolder;

            Log.Write("Device folder: " + deviceFolder, false);
            Log.Write("Interface folder: " + interfaceFolder, false);
            Log.Write("OSql.exe file name: " + osqlFileName, false);
            //Log.Write("OSql.exe paramter: " + osqlParameter, false);      //contains db pwd

            // apply config paramters
            DataBase.OSQLFileName = osqlFileName;
            DataBase.OSQLArgument = osqlParameter;

            ConfigDB = new DataBase(ConfigMgt.Config.ConfigDBConnection);
            LoggingHelper.EnableDatabaseLogging(ConfigDB, Log);

            DataDB = new DataBase(ConfigMgt.Config.DataDBConnection);
            LoggingHelper.EnableDatabaseLogging(DataDB, Log);

            return(true);
        }