Exemplo n.º 1
0
        public void Initialize(string dataDBConnectionString, Logging log)
        {
            _dbConnection = new DataBase(dataDBConnectionString);
            LoggingHelper.EnableDatabaseLogging(_dbConnection, log);

            string[] tableList = GWDataDB.GetTableNames();
            foreach (string table in tableList)
            {
                _comboTable.Items.Add(table);
            }
            if (_comboTable.Items.Count > 0)
            {
                _comboTable.SelectedIndex = 0;
            }
        }
Exemplo n.º 2
0
        static void Main()
        {
            Preloading();

            // for stand alone runtime only
            LoggingHelper.EnableXmlLogging(Log);
            LoggingHelper.EnableDatabaseLogging(db, Log);
            LoggingHelper.EnableApplicationLogging(Log);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new FormMain());

            BeforeExit();
        }
Exemplo n.º 3
0
        private bool UpdateConfigDBEventType()
        {
            if (!Program.InIM)
            {
                return(true);
            }

            string   interfaceName = Program.DeviceMgt.DeviceDirInfor.Header.Name;
            string   eventType     = Program.DeviceMgt.DeviceDirInfor.Header.EventType;
            DataBase db            = new DataBase(Program.ConfigMgt.Config.ConfigDBConnection);

            LoggingHelper.EnableDatabaseLogging(db, Program.Log);
            Program.Log.Write("Updating event type in GWConfigDB.");

            string sqlString = "UPDATE Interface SET EVENT_TYPE = N'" + eventType + "' WHERE INTERFACE_NAME = '" + interfaceName + "'";

            return(db.ExecuteQuery(sqlString) != null);
        }
Exemplo n.º 4
0
        internal static void PreLoading()
        {
            Log = new Logging(Application.StartupPath + "\\MWLServer.log");
            LoggingHelper.EnableApplicationLogging(Log);
            LoggingHelper.EnableXmlLogging(Log);
            Log.WriteAppStart(AppName);

            ConfigMgt          = new MWLServerConfigMgt();
            ConfigMgt.FileName = Application.StartupPath + "\\" + ConfigMgt.FileName;
            if (ConfigMgt.Load())
            {
                Log.Write("Load config succeeded. " + ConfigMgt.FileName);
                DHelper.CharacterSetName        = ConfigMgt.Config.CharacterSetName;
                DHelper.PersonNameEncodingRule  = ConfigMgt.Config.PersonNameEncodingRule;
                PrivateTagHelper.PrivateTagList = ConfigMgt.Config.PrivateTagList;
                Log.Write("Character Set: " + DHelper.CharacterSetName);
            }
            else
            {
                Log.Write(LogType.Error, "Load config failed. " + ConfigMgt.FileName);
            }

            DeviceMgt          = new DeviceDirManager();
            DeviceMgt.FileName = Application.StartupPath + "\\" + DeviceDirManager.IndexFileName;
            if (DeviceMgt.LoadDeviceDir())
            {
                Log.Write("Load DeviceDir succeeded. " + DeviceMgt.FileName);
            }
            else
            {
                Log.Write(LogType.Error, "Load DeviceDir failed. " + DeviceMgt.FileName);
            }

            Database = new DataBase(Program.ConfigMgt.Config.GWDataDBConnection);
            LoggingHelper.EnableDatabaseLogging(Database, Program.Log);
        }
Exemplo n.º 5
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);
        }