Ejemplo n.º 1
0
        private static bool UnregisterEventHandlers(DialogMgr_srv i_dmSrv)
        {
            bool bRet = true;

            ISMessaging.Delivery.ISMDistributer.ISMDistributerEventHandler dmh = new ISMessaging.Delivery.ISMDistributer.ISMDistributerEventHandler(i_dmSrv.NewMsg);
            DMEvHook.MsgDistr.ISMMsg -= dmh;

            return(bRet);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            bool bRes;

            DialogMgr_srv.eDMResult eRes  = DialogMgr_srv.eDMResult.eUnknown;
            DialogMgr_srv           dmSrv = null;
            string        sPath;
            string        sDisableKeyboard = "", sVer = "";
            AssemblyName  asmName = null;
            ILegacyLogger logger  = null;

            // Name the main thread
            Thread.CurrentThread.Name = "DialogMgrMainT";

            // Set up the logger(s)
            sPath  = ConfigurationManager.AppSettings["LogFilePath"];
            logger = new LegacyLogger();
            logger.Init("", "", Thread.CurrentThread.Name, "", "", sPath);
            bRes = logger.Open();
            if (!bRes)
            {
                Console.Error.WriteLine("DialogMgr failed to open the logger!");
            }
            else
            {
                asmName = Assembly.GetAssembly(typeof(DialogMgr_Console.DialogMgr)).GetName();
                sVer    = asmName.Version.ToString();
                logger.Log(Level.Info, "DialogMgr v" + sVer);

                bRes = LoadCustomAssemblies(logger);

                bRes = RemotingConfig(logger);

                dmSrv = new DialogMgr_srv(logger);
                bRes  = RegisterEventHandlers(dmSrv);

                if (bRes)
                {
                    bRes = dmSrv.CreateWorkerThreads("");

                    //Console.WriteLine("DialogMgr_Console startup successful.");
                    logger.Log(Level.Info, "DialogMgr_Console startup successful.");

                    sDisableKeyboard = ConfigurationManager.AppSettings["DisableKeyboard"];
                    sDisableKeyboard = (sDisableKeyboard == null) ? "" : sDisableKeyboard;
                    if (sDisableKeyboard == "false")
                    {
                        // Start processing messages
                        eRes = dmSrv.ProcessKbMsgLoop();
                    }

                    // Join worker threads before exiting
                    dmSrv.JoinWorkerThreads();

                    // Clean up
                    UnregisterEventHandlers(dmSrv);
                }
                else
                {
                    //Console.WriteLine("DialogMgr_Console startup unsuccessful!!!");
                    logger.Log(Level.Exception, "DialogMgr_Console startup unsuccessful!!!");
                }

                logger.Log(Level.Info, "DialogMgr_Console shutdown.");
                logger.Close();
            }
        }