/// <include file='doc\MessageQueueInstaller.uex' path='docs/doc[@for="MessageQueueInstaller.Install"]/*' /> /// <devdoc> /// <para>Writes message queue information to the registry. This method is meant to be /// used by installation tools, which process the appropriate methods /// automatically</para> /// </devdoc> public override void Install(IDictionary stateSaver) { base.Install(stateSaver); Context.LogMessage(Res.GetString(Res.CreatingQueue, Path)); bool exists = MessageQueue.Exists(path); stateSaver["Exists"] = exists; MessageQueue queue = null; if (!exists) { queue = MessageQueue.Create(Path, Transactional); } else { // it exists. If it's got the right transactional property, we're OK. // Otherwise we have to recreate. queue = new MessageQueue(Path); // save off the properties for rollback stateSaver["Authenticate"] = queue.Authenticate; stateSaver["BasePriority"] = queue.BasePriority; stateSaver["Category"] = queue.Category; stateSaver["EncryptionRequired"] = queue.EncryptionRequired; stateSaver["Label"] = queue.Label; stateSaver["MaximumJournalSize"] = queue.MaximumJournalSize; stateSaver["MaximumQueueSize"] = queue.MaximumQueueSize; stateSaver["Path"] = queue.Path; stateSaver["Transactional"] = queue.Transactional; stateSaver["UseJournalQueue"] = queue.UseJournalQueue; if (queue.Transactional != Transactional) { // Messages won't be kept. MessageQueue.Delete(Path); queue = MessageQueue.Create(Path, Transactional); } } // now change all the properties to how we want them. queue.Authenticate = Authenticate; queue.BasePriority = BasePriority; queue.Category = Category; queue.EncryptionRequired = EncryptionRequired; queue.Label = Label; queue.MaximumJournalSize = MaximumJournalSize; queue.MaximumQueueSize = MaximumQueueSize; queue.UseJournalQueue = UseJournalQueue; if (permissions != null) { queue.SetPermissions(permissions); } }
public override void Install(IDictionary stateSaver) { base.Install(stateSaver); base.Context.LogMessage(System.Messaging.Res.GetString("CreatingQueue", new object[] { this.Path })); bool flag = MessageQueue.Exists(this.path); stateSaver["Exists"] = flag; MessageQueue queue = null; if (!flag) { queue = MessageQueue.Create(this.Path, this.Transactional); } else { queue = new MessageQueue(this.Path); stateSaver["Authenticate"] = queue.Authenticate; stateSaver["BasePriority"] = queue.BasePriority; stateSaver["Category"] = queue.Category; stateSaver["EncryptionRequired"] = queue.EncryptionRequired; stateSaver["Label"] = queue.Label; stateSaver["MaximumJournalSize"] = queue.MaximumJournalSize; stateSaver["MaximumQueueSize"] = queue.MaximumQueueSize; stateSaver["Path"] = queue.Path; stateSaver["Transactional"] = queue.Transactional; stateSaver["UseJournalQueue"] = queue.UseJournalQueue; if (MessageQueue.Msmq3OrNewer) { stateSaver["MulticastAddress"] = queue.MulticastAddress; } if (queue.Transactional != this.Transactional) { MessageQueue.Delete(this.Path); queue = MessageQueue.Create(this.Path, this.Transactional); } } queue.Authenticate = this.Authenticate; queue.BasePriority = this.BasePriority; queue.Category = this.Category; queue.EncryptionRequired = this.EncryptionRequired; queue.Label = this.Label; queue.MaximumJournalSize = this.MaximumJournalSize; queue.MaximumQueueSize = this.MaximumQueueSize; queue.UseJournalQueue = this.UseJournalQueue; if (MessageQueue.Msmq3OrNewer) { queue.MulticastAddress = this.MulticastAddress; } if (this.permissions != null) { queue.SetPermissions(this.permissions); } }
public override void Uninstall(IDictionary savedState) { base.Uninstall(savedState); if (this.UninstallAction == System.Configuration.Install.UninstallAction.Remove) { base.Context.LogMessage(System.Messaging.Res.GetString("DeletingQueue", new object[] { this.Path })); if (MessageQueue.Exists(this.Path)) { MessageQueue.Delete(this.Path); } } }
private void RestoreQueue(IDictionary state) { bool flag = false; if ((state != null) && (state["Exists"] != null)) { flag = (bool)state["Exists"]; } else { return; } if (flag) { base.Context.LogMessage(System.Messaging.Res.GetString("RestoringQueue", new object[] { this.Path })); MessageQueue queue = null; if (!MessageQueue.Exists(this.Path)) { queue = MessageQueue.Create(this.Path, (bool)state["Transactional"]); } else { queue = new MessageQueue(this.Path); if (queue.Transactional != ((bool)state["Transactional"])) { MessageQueue.Delete(this.Path); queue = MessageQueue.Create(this.Path, (bool)state["Transactional"]); } } queue.Authenticate = (bool)state["Authenticate"]; queue.BasePriority = (short)state["BasePriority"]; queue.Category = (Guid)state["Category"]; queue.EncryptionRequired = (System.Messaging.EncryptionRequired)state["EncryptionRequired"]; queue.Label = (string)state["Label"]; queue.MaximumJournalSize = (long)state["MaximumJournalSize"]; queue.MaximumQueueSize = (long)state["MaximumQueueSize"]; if (MessageQueue.Msmq3OrNewer) { queue.MulticastAddress = (string)state["MulticastAddress"]; } queue.UseJournalQueue = (bool)state["UseJournalQueue"]; queue.ResetPermissions(); } else { base.Context.LogMessage(System.Messaging.Res.GetString("RemovingQueue", new object[] { this.Path })); if (MessageQueue.Exists(this.path)) { MessageQueue.Delete(this.path); } } }
/// <include file='doc\MessageQueueInstaller.uex' path='docs/doc[@for="MessageQueueInstaller.Uninstall"]/*' /> /// <devdoc> /// <para>Uninstalls the queue by removing information concerning it from the registry. /// If the <see cref='System.Messaging.MessageQueueInstaller.UninstallAction'/> is <see langword='Remove'/>, /// Uninstall also deletes the queue associated with the <see cref='System.Messaging.MessageQueue'/>. </para> /// </devdoc> public override void Uninstall(IDictionary savedState) { base.Uninstall(savedState); if (UninstallAction == UninstallAction.Remove) { Context.LogMessage(Res.GetString(Res.DeletingQueue, Path)); if (MessageQueue.Exists(Path)) { MessageQueue.Delete(Path); } } }
/// <include file='doc\MessageQueueInstaller.uex' path='docs/doc[@for="MessageQueueInstaller.RestoreQueue"]/*' /> /// <devdoc> /// Called by Rollback and Uninstall to restore a queue to its state prior to Install /// </devdoc> private void RestoreQueue(IDictionary state) { bool exists = false; if (state != null && state["Exists"] != null) { exists = (bool)state["Exists"]; } else { // this can only happen at uninstall - the user might have deleted the .InstallState // file since Install ran. It's probably best to leave things the way they are. return; } if (exists) { Context.LogMessage(Res.GetString(Res.RestoringQueue, Path)); // the queue existed before install. Restore the properties MessageQueue queue = null; // first, restore the queue with the right Transactional property if (!MessageQueue.Exists(Path)) { // weird, but possible: the queue used to exist, but it doesn't now. // put it back queue = MessageQueue.Create(Path, (bool)state["Transactional"]); } else { queue = new MessageQueue(Path); if (queue.Transactional != (bool)state["Transactional"]) { // the transactional property doesn't match. Recreate so it does MessageQueue.Delete(Path); queue = MessageQueue.Create(Path, (bool)state["Transactional"]); } } // now change all the other properties to how they were. queue.Authenticate = (bool)state["Authenticate"]; queue.BasePriority = (short)state["BasePriority"]; queue.Category = (Guid)state["Category"]; queue.EncryptionRequired = (EncryptionRequired)state["EncryptionRequired"]; queue.Label = (string)state["Label"]; queue.MaximumJournalSize = (long)state["MaximumJournalSize"]; queue.MaximumQueueSize = (long)state["MaximumQueueSize"]; if (MessageQueue.Msmq3OrNewer) //this feature is unavailable on win2k { queue.MulticastAddress = (string)state["MulticastAddress"]; } queue.UseJournalQueue = (bool)state["UseJournalQueue"]; queue.ResetPermissions(); } else { Context.LogMessage(Res.GetString(Res.RemovingQueue, Path)); // it wasn't there before install, so let's make sure it still isn't if (MessageQueue.Exists(path)) { MessageQueue.Delete(path); } } }