コード例 #1
0
        }//Reconciler_RequestCompleted()

        //
        //
        //
        private void Reconciler_Stopping(object sender, EventArgs eventArg)
        {
            if (sender is Reconciler.ReconcilerTaskHub)
            {
                ReconcilerTaskHub hub = (ReconcilerTaskHub)sender;
                if (m_ReconcilerTaskHubs.Contains(hub))
                {
                    m_ReconcilerTaskHubs.Remove(hub);
                }
            }
            // Check for closing condition
            if (m_ReconcilerTaskHubs.Count == 0)
            {
                RequestShutDown(this, eventArg);
            }
        }// Reconciler_Stopping()
コード例 #2
0
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        public ReconcilerForm(string[] cmdLineArgs)
        {
            InitializeComponent();
            AppInfo m_AppInfo = AppInfo.GetInstance("Breconcile", true);

            m_AppInfo.RequestShutdownAddHandler(new EventHandler(RequestShutDown));     // register my handler as the shutdown request handler.


            string filePath = string.Empty;

            if (cmdLineArgs != null && cmdLineArgs.Length > 0)
            {
                filePath = string.Format("{0}{1}", m_AppInfo.UserConfigPath, cmdLineArgs[0].Trim());
            }
            else
            {
                filePath = string.Format("{0}ReconcilerConfig.txt", m_AppInfo.UserConfigPath);
            }

            // here is temp hard code config file address
            // filePath = "\\\\fileserver\\Users\\DV_Ambre\\AmbreUsers\\dvbre\\Config\\ReconcilerConfig.txt";

            // Create the services defined in the config file.
            using (StringifiableReader reader = new StringifiableReader(filePath))
            {
                List <IStringifiable> objectList = reader.ReadToEnd();
                foreach (IStringifiable obj in objectList)
                {
                    if (obj is ReconcilerTaskHub)
                    {
                        ReconcilerTaskHub newHub = (ReconcilerTaskHub)obj;
                        m_ReconcilerTaskHubs.Add(newHub);
                        if (Log == null)
                        {
                            Log = newHub.Log;              // accept first Log as the form's log.
                        }
                        newHub.TaskCompleted += new EventHandler(Reconciler_RequestCompleted);
                        newHub.Stopping      += new EventHandler(Reconciler_Stopping);
                    }
                }
            }

            // Log start up.
            if (Log != null)
            {
                Log.NewEntry(LogLevel.Minor, "ReconcilerForm: Running config file {0}", filePath);
                if (Log.BeginEntry(LogLevel.Minor, "ReconcilerForm: {0} TaskHubs: ", m_ReconcilerTaskHubs.Count))
                {
                    foreach (ReconcilerTaskHub hub in m_ReconcilerTaskHubs)
                    {
                        Log.AppendEntry("<{0}>", hub.GetAttributes());
                    }
                }
            }

            // Start hubs
            foreach (ReconcilerTaskHub hub in m_ReconcilerTaskHubs)
            {
                hub.Start();
            }
        }