/// <summary>
        /// Logs process start
        /// </summary>
        /// <param name="configrec">Configuration record having the information about the process to be started</param>
        /// <param name="pd">Process data</param>
        public void StartProcess(
            ConfigurationRecord configRec,
            ProcessData pd)
        {
            lock (this)
            {
                CheckDamaged();

                XmlSerializer serializer = new XmlSerializer(typeof(StartProcess));
                StartProcess  sp         = new StartProcess();
                sp.ApplicationName      = configRec.m_applicationName;
                sp.StartUpData          = configRec.m_cmdLineArgs;
                sp.SQLServer            = configRec.m_sqlServer;
                sp.Database             = configRec.m_database;
                sp.Schema               = configRec.m_schema;
                sp.Queue                = configRec.m_queue;
                sp.ProcessId            = pd.Pid;
                sp.CreationHighDateTime = pd.CreationHighDateTime;
                sp.CreationLowDateTime  = pd.CreationLowDateTime;

                StringBuilder sb      = new StringBuilder();
                TextWriter    writer  = new StringWriter(sb);
                XmlTextWriter xwriter = new XmlTextWriter(writer);
                xwriter.Formatting = Formatting.None;
                serializer.Serialize(xwriter, sp);
                string xmlStartProcessString = sb.ToString();

                WriteToLog(String.Format("{0}{1}\n{2}", ms_processStart, xmlStartProcessString.Length, xmlStartProcessString));
            }
        }
Exemple #2
0
        /// <summary>
        /// Adds a configuration record to the Configuration Record Table
        /// </summary>
        /// <param name="cfr"></param>
        private void AddTo(
            ConfigurationRecord cfr) // I		Adds the configuration record to the Configuration
        //		Record Table
        {
            string RecordKey = GetKey(cfr);

            Debug.Assert(!m_configRT.ContainsKey(RecordKey));
            lock (this)
            {
                m_configRT.Add(RecordKey, cfr);
            }
        }
Exemple #3
0
        /// <summary>
        /// Removes the configuration from the Configuration Record Table
        /// </summary>
        /// <param name="cfr"></param>
        private void RemoveFrom(
            ConfigurationRecord cfr) // I		Remove the configuration record from the Configuration
        //			Record Table
        {
            string recordKey = GetKey(cfr);

            lock (this)
            {
                Debug.Assert(m_configRT.ContainsKey(recordKey));
                Debug.Assert(m_configRT[recordKey] == cfr);
                m_configRT.Remove(recordKey);
            }
        }
Exemple #4
0
 /// <summary>
 /// Report the status of the configuration manager
 /// </summary>
 public override string  ToString()
 {
     lock (this)
     {
         string me = "Configuration status for notification service '" + m_instance.m_notificationService +
                     "' on SQL Server '" + m_instance.m_notificationSQLServer + "' and Database '" + m_instance.m_notificationDatabase + "'.";
         foreach (DictionaryEntry d in m_configRT)
         {
             ConfigurationRecord cfr = ((ConfigurationRecord)(d.Value));
             me += "\n    " + cfr.ToString();
         }
         return(me);
     }
 }
Exemple #5
0
        /// <summary>
        ///		For the new Configuration Record Table, compare it to the Global Configuration Record Table (this)
        ///		add, delete or replace configuration records and update the application monitor referencing the records.
        ///
        ///     NOTE: If this function throws an exception we have to kill the application because we will have an
        ///     inconsistent configuration.
        /// </summary>
        /// <param name="ActivateProcessList"></param>
        private void Update(
            Hashtable configNew)
        {
            // First iteration adds / changes configuration records to the Global Configuration Record Table
            foreach (DictionaryEntry d in configNew)
            {
                ConfigurationRecord newcfr = ((ConfigurationRecord)(d.Value));
                // If there is old configuration record then remove it because it will be replaced with new one
                ConfigurationRecord oldcfr = GetConfigRec(newcfr.m_sqlServer, newcfr.m_database, newcfr.m_schema, newcfr.m_queue);
                if (oldcfr != null)
                {
                    RemoveFrom(oldcfr);
                }

                AddTo(newcfr);

                Global.AppMonitorMgr.InsertOrUpdate(newcfr);
            }

            // Second iteration deletes configuration records
            ArrayList listToDelete = new ArrayList();

            foreach (DictionaryEntry d in m_configRT)
            {
                ConfigurationRecord oldcfr = ((ConfigurationRecord)(d.Value));

                // New Configuration Record Table does NOT contain the entry
                string key = GetKey(oldcfr);

                if (!configNew.Contains(key))
                {
                    listToDelete.Add(oldcfr);
                }
            }

            foreach (ConfigurationRecord oldcfr in listToDelete)
            {
                // Add to the list to remove from the Global Configuration Record Table
                RemoveFrom(oldcfr);

                ApplicationMonitor am = Global.AppMonitorMgr.GetApplicationMonitor(oldcfr.m_sqlServer, oldcfr.m_database, oldcfr.m_schema, oldcfr.m_queue);

                if (am != null)
                {
                    am.ResetConfig();
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Retrieves a configuratoin record by given key
        /// </summary>
        /// <param name="SQLServer"></param>
        /// <param name="Database"></param>
        /// <param name="Queue"></param>
        /// <returns></returns>
        private ConfigurationRecord GetConfigRec(
            string sqlServer,
            string database,
            string schema,
            string queue)
        {
            string key = GetKey(sqlServer, database, schema, queue);

            lock (this)
            {
                if (m_configRT.ContainsKey(key))
                {
                    ConfigurationRecord value = (ConfigurationRecord)m_configRT[key];
                    return(value);
                }
            }
            return(null);
        }
Exemple #7
0
 /// <summary>
 /// Generates the configuration record key of the provided
 /// configuration record
 /// </summary>
 /// <param name="cfr"></param>
 /// <returns>The generated key</returns>
 private static string GetKey(
     ConfigurationRecord cfr)
 {
     return(GetKey(cfr.m_sqlServer, cfr.m_database, cfr.m_schema, cfr.m_queue));
 }