DeadLetterMessageHandler(WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper, int receiveTimeoutInSeconds) { this.writeToLog = writeToLog; this.serviceBusHelper = serviceBusHelper; this.receiveTimeoutInSeconds = receiveTimeoutInSeconds; }
public static void UpdateServiceBusNamespace(ConfigFileUse configFileUse, string key, string newKey, string newValue, WriteToLogDelegate writeToLog) { var configuration = TwoFilesConfiguration.Create(configFileUse, writeToLog); configuration.UpdateEntryInDictionarySection(SERVICEBUS_SECTION_NAME, key, newKey, newValue, writeToLog); }
public MessageForm(IEnumerable <BrokeredMessage> brokeredMessages, ServiceBusHelper serviceBusHelper, WriteToLogDelegate writeToLog) { this.brokeredMessages = brokeredMessages; this.serviceBusHelper = serviceBusHelper; this.writeToLog = writeToLog; InitializeComponent(); messagesSplitContainer.Visible = false; btnSave.Visible = false; btnSubmit.Location = btnSave.Location; cboSenderInspector.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; Size = new Size(Size.Width - 104, 80); cboSenderInspector.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; cboBodyType.SelectedIndex = 0; // Get Brokered Message Inspector classes cboSenderInspector.Items.Add(SelectBrokeredMessageInspector); cboSenderInspector.SelectedIndex = 0; if (serviceBusHelper.BrokeredMessageInspectors == null) { return; } foreach (var key in serviceBusHelper.BrokeredMessageInspectors.Keys) { cboSenderInspector.Items.Add(key); } }
public MetricValueControl(WriteToLogDelegate writeToLog, Action closeAction, IEnumerable <MetricValue> metricValues, MetricDataPoint metricDataPoint, MetricInfo metricInfo) { this.writeToLog = writeToLog; this.closeAction = closeAction; this.metricDataPoint = metricDataPoint; this.metricInfo = metricInfo; InitializeComponent(); metricList = metricValues as IList <MetricValue> ?? metricValues.ToList(); bindingList = metricValues != null ? new BindingList <MetricValue>(metricList) { AllowNew = true, AllowEdit = true, AllowRemove = true } : new BindingList <MetricValue> { AllowNew = true, AllowEdit = true, AllowRemove = true }; InitializeControls(); }
public void RemoveSection(string sectionName, WriteToLogDelegate writeToLog) { // First remove the section if (UseUserConfig()) { var userSection = userConfiguration?.Sections[sectionName]; if (userSection != null) { userConfiguration.Sections.Remove(sectionName); userConfiguration.Save(ConfigurationSaveMode.Modified); } } if (UseApplicationConfig()) { var appSection = applicationConfiguration?.Sections[sectionName]; if (appSection != null) { applicationConfiguration.Sections.Remove(sectionName); applicationConfiguration.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection(sectionName); } } // The remove it from the configSections section RemoveEntryFromDictionarySection("configSections", sectionName, writeToLog); }
static void WriteParsingFailure(WriteToLogDelegate writeToLogDelegate, string configFile, string appSettingsKey, string value, Type type) { writeToLogDelegate?.Invoke($"The configuration file {configFile} has a setting, {appSettingsKey}" + $" having the value {value}, which cannot be parsed to a(n) {type}. " + "The setting is therefore ignored."); }
// This is the normal way to create it public static TwoFilesConfiguration Create(ConfigFileUse configFileUse, WriteToLogDelegate writeToLog = null) { var userConfigFilePath = GetUserSettingsFilePath(); return(Create(userConfigFilePath, configFileUse, writeToLog)); }
public static MainSettings GetMainProperties(ConfigFileUse configFileUse, MainSettings currentSettings, WriteToLogDelegate writeToLog) { var configuration = TwoFilesConfiguration.Create(configFileUse, writeToLog); return(GetMainSettingsUsingConfiguration(configuration, currentSettings, writeToLog)); }
public MetricValueControl(WriteToLogDelegate writeToLog, Action closeAction, IEnumerable<MetricValue> metricValues, MetricDataPoint metricDataPoint, MetricInfo metricInfo) { this.writeToLog = writeToLog; this.closeAction = closeAction; this.metricDataPoint = metricDataPoint; this.metricInfo = metricInfo; InitializeComponent(); metricList = metricValues as IList<MetricValue> ?? metricValues.ToList(); bindingList = metricValues != null ? new BindingList<MetricValue>(metricList) { AllowNew = true, AllowEdit = true, AllowRemove = true } : new BindingList<MetricValue> { AllowNew = true, AllowEdit = true, AllowRemove = true }; InitializeControls(); }
public static ServiceBusNamespace GetServiceBusNamespace(string key, string connectionString, WriteToLogDelegate staticWriteToLog) { if (string.IsNullOrWhiteSpace(connectionString)) { staticWriteToLog(string.Format(CultureInfo.CurrentCulture, ServiceBusNamespaceIsNullOrEmpty, key)); return(null); } var isUserCreated = !(key == "CustomConnectionString" || key == "SASConnectionString"); var toLower = connectionString.ToLower(); var parameters = connectionString.Split(';').ToDictionary(s => s.Substring(0, s.IndexOf('=')).ToLower(), s => s.Substring(s.IndexOf('=') + 1)); if (toLower.Contains(ConnectionStringEndpoint) && toLower.Contains(ConnectionStringSharedAccessKeyName) && toLower.Contains(ConnectionStringSharedAccessKey)) { return(GetServiceBusNamespaceUsingSAS(key, connectionString, staticWriteToLog, isUserCreated, parameters)); } if (toLower.Contains(ConnectionStringRuntimePort) || toLower.Contains(ConnectionStringManagementPort) || toLower.Contains(ConnectionStringWindowsUsername) || toLower.Contains(ConnectionStringWindowsDomain) || toLower.Contains(ConnectionStringWindowsPassword)) { return(GetServiceBusNamespaceUsingWindows(key, connectionString, staticWriteToLog, isUserCreated, toLower, parameters)); } return(null); }
public HandlePartitionControl(WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper, PartitionDescription partitionDescription) { this.writeToLog = writeToLog; this.serviceBusHelper = serviceBusHelper; this.partitionDescription = partitionDescription; InitializeComponent(); InitializeData(); }
public HandlePartitionControl(WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper, PartitionDescription partitionDescription) { this.writeToLog = writeToLog; this.serviceBusHelper = serviceBusHelper; this.partitionDescription = partitionDescription; InitializeComponent(); InitializeData(); }
public HandleEventHubControl(WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper, EventHubDescription eventHubDescription) { this.writeToLog = writeToLog; this.serviceBusHelper = serviceBusHelper; this.eventHubDescription = eventHubDescription; InitializeComponent(); InitializeControls(); }
public HandleSubscriptionControl(WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper, SubscriptionWrapper wrapper) { this.writeToLog = writeToLog; this.serviceBusHelper = serviceBusHelper; this.wrapper = wrapper; InitializeComponent(); InitializeData(); }
public HandleRuleControl(WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper, RuleWrapper ruleWrapper, bool?isFirstRule) { this.writeToLog = writeToLog; this.serviceBusHelper = serviceBusHelper; this.ruleWrapper = ruleWrapper; this.isFirstRule = isFirstRule; InitializeComponent(); InitializeData(); }
/// <summary> /// This method is meant to only be called for unit testing, to avoid polluting /// neither the application config file for the executable running the unit /// tests nor the user config file. /// </summary> public static TwoFilesConfiguration Create(string userConfigFilePath, ConfigFileUse configFileUse, WriteToLogDelegate writeToLog = null) { var applicationConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); return(CreateConfiguration(applicationConfiguration, userConfigFilePath, configFileUse, writeToLog)); }
public HandleConsumerGroupControl(WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper, ConsumerGroupDescription consumerGroupDescription, string eventHubName) { this.writeToLog = writeToLog; this.serviceBusHelper = serviceBusHelper; this.consumerGroupDescription = consumerGroupDescription; this.eventHubName = eventHubName; InitializeComponent(); InitializeControls(); }
public HandleConsumerGroupControl(WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper, ConsumerGroupDescription consumerGroupDescription, string eventHubName) { this.writeToLog = writeToLog; this.serviceBusHelper = serviceBusHelper; this.consumerGroupDescription = consumerGroupDescription; this.eventHubName = eventHubName; InitializeComponent(); InitializeControls(); }
public HandleTopicControl(WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper, TopicDescription topicDescription, string path) { this.writeToLog = writeToLog; this.serviceBusHelper = serviceBusHelper; this.topicDescription = topicDescription; this.path = path; InitializeComponent(); InitializeData(); }
public HandleQueueControl(WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper, QueueDescription queueDescription, string path) { this.writeToLog = writeToLog; this.serviceBusHelper = serviceBusHelper; this.path = path; this.queueDescription = queueDescription; InitializeComponent(); InitializeData(); }
public HandleRuleControl(WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper, RuleWrapper ruleWrapper, bool? isFirstRule) { this.writeToLog = writeToLog; this.serviceBusHelper = serviceBusHelper; this.ruleWrapper = ruleWrapper; this.isFirstRule = isFirstRule; InitializeComponent(); InitializeData(); }
public static bool IsLatestVersion(out ReleaseInfo nextReleaseInfo, WriteToLogDelegate writeToLog = null) { nextReleaseInfo = GitHubReleaseProvider.GetServiceBusClientLatestVersion(writeToLog).GetAwaiter().GetResult(); var currentVersionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); var currentVersion = new Version(currentVersionInfo.FileMajorPart, currentVersionInfo.FileMinorPart, currentVersionInfo.FileBuildPart); return(currentVersion.CompareTo(nextReleaseInfo.Version) >= 0); }
public HandleRelayControl(WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper, RelayDescription relayDescription, string path) { this.writeToLog = writeToLog; this.serviceBusHelper = serviceBusHelper; this.relayDescription = relayDescription; this.path = path; InitializeComponent(); InitializeControls(); }
public static async Task <ReleaseInfo> GetServiceBusClientLatestVersion(WriteToLogDelegate writeToLog = null) { var nextReleaseInfo = ReleaseInfo.Null; using (var client = new HttpClient()) { var responseBody = string.Empty; try { client.DefaultRequestHeaders.Add("User-Agent", "ASBE"); responseBody = await client.GetStringAsync("https://api.github.com/repos/paolosalvatori/ServiceBusExplorer/releases/latest") .ConfigureAwait(false); } catch (HttpRequestException e) { if (writeToLog != null) { writeToLog($"GitHubReleaseProvider::{e.Message} " + e?.InnerException); } else { Console.WriteLine(e.Message); } } if (!string.IsNullOrWhiteSpace(responseBody)) { try { var latestReleaseInfo = JsonConvert.DeserializeObject <Release>(responseBody); if (latestReleaseInfo != null && !string.IsNullOrWhiteSpace(latestReleaseInfo.Name)) { var version = new Version(latestReleaseInfo.Name); var uri = latestReleaseInfo.HtmlUrl; var zipUrl = latestReleaseInfo.Assets.FirstOrDefault(x => x.Name.EndsWith(".zip"))?.BrowserDownloadUrl; nextReleaseInfo = new ReleaseInfo(uri, version, latestReleaseInfo.Body, zipUrl); } } catch (Exception e) { if (writeToLog != null) { writeToLog($"GitHubReleaseProvider::{e.Message} " + e?.InnerException); } else { Console.WriteLine(e.Message); } } } } return(nextReleaseInfo); }
public void WriteLogDelegateCanPointToMethod() { WriteToLogDelegate log = ReturnMessage; log += ReturnMessage; log += ReturnMessage; log += ReturnMessageToLower; log -= ReturnMessage; log("xxx"); Assert.Equal(3, counter); }
public TestSubscriptionControl(MainForm mainForm, WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper, SubscriptionWrapper subscriptionWrapper) { this.mainForm = mainForm; this.writeToLog = writeToLog; this.serviceBusHelper = serviceBusHelper; this.subscriptionWrapper = subscriptionWrapper; InitializeComponent(); InitializeControls(); }
public TestControlBase(MainForm mainForm, WriteToLogDelegate writeToLog, Func <Task> stopLog, Action startLog, ServiceBusHelper serviceBusHelper) { this.mainForm = mainForm; this.writeToLog = writeToLog; this.stopLog = stopLog; this.startLog = startLog; this.serviceBusHelper = serviceBusHelper; }
public TestSubscriptionControl(MainForm mainForm, WriteToLogDelegate writeToLog, Func <Task> stopLog, Action startLog, ServiceBusHelper serviceBusHelper, SubscriptionWrapper subscriptionWrapper) : base(mainForm, writeToLog, stopLog, startLog, serviceBusHelper) { this.subscriptionWrapper = subscriptionWrapper; InitializeComponent(); InitializeControls(); }
public void TestDelegateCallPoint() { WriteToLogDelegate logDelegate; logDelegate = new WriteToLogDelegate(ReturnMessageForDeletegate); //OR logDelegate = ReturnMessageForDelegate; logDelegate += ReturnMessageForDeletegate; //add new method to call using the delegate logDelegate += IncrementCount; //add another method to be called to add delegate var result = logDelegate("Hello!"); //this would call all the methods which are mentioned above (it only calls those method whose return type and method signature matches the delegate) //Assert.Equal("Hello!", result);// FOR single delegate(calling one method using delegate) Assert.Equal(3, count); //FOR counting the number of methods called by delegate (multicasting delegate) }
public EventData AfterReceiveMessage(EventData eventData, WriteToLogDelegate writeToLog = null) { var stream = eventData?.Clone().GetBodyStream(); if (stream == null) { return(null); } if (stream.CanSeek) { stream.Seek(0, SeekOrigin.Begin); } return(eventData.Clone(Decompress(stream))); }
public static Dictionary <string, ServiceBusNamespace> GetMessagingNamespaces (TwoFilesConfiguration configuration, WriteToLogDelegate writeToLog) { var hashtable = configuration.GetHashtableFromSection(ServiceBusNamespaces); if (hashtable == null || hashtable.Count == 0) { writeToLog(ServiceBusNamespacesNotConfigured); } var serviceBusNamespaces = new Dictionary <string, ServiceBusNamespace>(); if (hashtable == null) { return(serviceBusNamespaces); } var e = hashtable.GetEnumerator(); while (e.MoveNext()) { if (!(e.Key is string) || !(e.Value is string)) { continue; } var serviceBusNamespace = ServiceBusNamespace.GetServiceBusNamespace((string)e.Key, (string)e.Value, writeToLog); if (serviceBusNamespace != null) { serviceBusNamespaces.Add((string)e.Key, serviceBusNamespace); } } var microsoftServiceBusConnectionString = configuration.GetStringValue(ConfigurationParameters.MicrosoftServiceBusConnectionString); if (!string.IsNullOrWhiteSpace(microsoftServiceBusConnectionString)) { var serviceBusNamespace = ServiceBusNamespace.GetServiceBusNamespace(ConfigurationParameters.MicrosoftServiceBusConnectionString, microsoftServiceBusConnectionString, writeToLog); if (serviceBusNamespace != null) { serviceBusNamespaces. Add(ConfigurationParameters.MicrosoftServiceBusConnectionString, serviceBusNamespace); } } return(serviceBusNamespaces); }
public BrokeredMessage AfterReceiveMessage(BrokeredMessage message, WriteToLogDelegate writeToLog = null) { var stream = message?.Clone().GetBody <Stream>(); if (stream == null) { return(null); } if (stream.CanSeek) { stream.Seek(0, SeekOrigin.Begin); } message.SetBodyStream(Decompress(stream)); return(message); }
/// <summary> /// Writes a message to the Log. /// </summary> /// <param name="message"></param> /// <returns></returns> //protected abstract bool writeToLog(string message); /// <summary> /// Writes to the configured Log. /// </summary> /// <param name="userID"></param> /// <param name="severityID"></param> /// <param name="className"></param> /// <param name="functionName"></param> /// <param name="message"></param> /// <param name="level"></param> /// <returns></returns> public bool WriteToLog(string userID, Severity severityID, string className, string functionName, string message, Level level) { //[2] -- ADD -- START Getting the class name and function name StackTrace stackTrace = new StackTrace(); StackFrame stackFrame = stackTrace.GetFrame(1); MethodBase methodBase = stackFrame.GetMethod(); className = Convert.ToString(methodBase.DeclaringType); functionName = methodBase.Name; WriteToLogDelegate logDelegate = new WriteToLogDelegate(WriteToLogInternal); IAsyncResult ar = logDelegate.BeginInvoke(userID, severityID, className, functionName, message, level, null, null); return(true); }
public HandleConsumerGroupControl(WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper, ConsumerGroupDescription consumerGroupDescription, string eventHubName) { this.writeToLog = writeToLog; this.serviceBusHelper = serviceBusHelper; this.consumerGroupDescription = consumerGroupDescription; this.eventHubName = eventHubName; dataPointBindingList = new BindingList <MetricDataPoint> { AllowNew = true, AllowEdit = true, AllowRemove = true }; InitializeComponent(); InitializeControls(); }
public MetricGraphControl(WriteToLogDelegate writeToLog, Action closeAction, IList<IEnumerable<MetricValue>> metricValueList, IList<MetricDataPoint> metricDataPointList) { this.writeToLog = writeToLog; this.closeAction = closeAction; this.metricDataPointList = metricDataPointList; this.metricValueList = metricValueList; InitializeComponent(); foreach (var item in Enum.GetValues(typeof (SeriesChartType))) { cboChartType.Items.Add(item); cboChartType.SelectedItem = SeriesChartType.FastLine; } }
public EventData AfterReceiveMessage(EventData eventData, WriteToLogDelegate writeToLog = null) { if (eventData == null) { return null; } var stream = eventData.Clone().GetBody<Stream>(); if (stream == null) { return null; } if (stream.CanSeek) { stream.Seek(0, SeekOrigin.Begin); } return eventData.Clone(Decompress(stream)); }
public EventData BeforeSendMessage(EventData eventData, WriteToLogDelegate writeToLog = null) { if (eventData == null) { return null; } var stream = eventData.Clone().GetBodyStream(); if (stream == null) { return null; } if (stream.CanSeek) { stream.Seek(0, SeekOrigin.Begin); } return eventData.Clone(Compress(stream)); }
public BrokeredMessage AfterReceiveMessage(BrokeredMessage message, WriteToLogDelegate writeToLog = null) { if (message == null) { return null; } var stream = message.Clone().GetBody<Stream>(); if (stream == null) { return null; } if (stream.CanSeek) { stream.Seek(0, SeekOrigin.Begin); } message.SetBodyStream(Decompress(stream)); return message; }
public ListenerControl(WriteToLogDelegate writeToLog, Func<Task> stopLog, Action startLog, ServiceBusHelper serviceBusHelper, EntityDescription entityDescription) { this.logStopped = false; Task.Factory.StartNew(AsyncTrackMessage).ContinueWith(t => { if (t.IsFaulted && t.Exception != null) { writeToLog(t.Exception.Message); } }); this.writeToLog = writeToLog; this.stopLog = stopLog; this.startLog = startLog; this.serviceBusHelper = serviceBusHelper; this.entityDescription = entityDescription; var element = new BinaryMessageEncodingBindingElement(); var encoderFactory = element.CreateMessageEncoderFactory(); encoder = encoderFactory.Encoder; InitializeComponent(); InitializeControls(); Disposed += ListenerControl_Disposed; if (entityDescription is SubscriptionDescription) { grouperEntityInformation.GroupTitle = "Subscription Information"; } }
public IEnumerable<EventData> GenerateEventDataCollection(int eventDataCount, WriteToLogDelegate writeToLog) { if (eventDataCount < 0) { return null; } var random = new Random(); var list = new List<EventData>(); for (var i = 0; i < eventDataCount; i++) { try { var payload = new ThresholdDeviceEvent { EventId = EventId++, DeviceId = random.Next(MinDeviceId, MaxDeviceId + 1), Value = random.Next(MinDeviceId, MaxDeviceId + 1), Timestamp = DateTime.UtcNow }; var eventData = new EventData((MessageFormat == MessageFormat.Json ? JsonSerializerHelper.Serialize(payload) : XmlSerializerHelper.Serialize(payload)).ToMemoryStream()) { PartitionKey = payload.DeviceId.ToString(CultureInfo.InvariantCulture), }; eventData.Properties.Add("eventId", payload.EventId); eventData.Properties.Add("deviceId", payload.DeviceId); eventData.Properties.Add("value", payload.Value); eventData.Properties.Add("time", DateTime.UtcNow.Ticks); eventData.Properties.Add("city", City); eventData.Properties.Add("country", Country); list.Add(eventData); } catch (Exception ex) { if (!string.IsNullOrWhiteSpace(ex.Message)) { writeToLog(string.Format(CultureInfo.CurrentCulture, ExceptionFormat, ex.Message)); } if (ex.InnerException != null && !string.IsNullOrWhiteSpace(ex.InnerException.Message)) { writeToLog(string.Format(CultureInfo.CurrentCulture, InnerExceptionFormat, ex.InnerException.Message)); } } } if (writeToLog != null) { writeToLog(string.Format(EventDataCreatedFormat, list.Count)); } return list; }
/// <summary> /// Initializes a new instance of the ServiceBusHelper class. /// </summary> /// <param name="writeToLog">WriteToLog method.</param> /// <param name="serviceBusHelper">Base ServiceBusHelper.</param> public ServiceBusHelper(WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper) { this.writeToLog = writeToLog; traceEnabled = serviceBusHelper.TraceEnabled; AtomFeedUri = serviceBusHelper.AtomFeedUri; IssuerName = serviceBusHelper.IssuerName; IssuerSecret = serviceBusHelper.IssuerSecret; MessageDeferProviderType = serviceBusHelper.MessageDeferProviderType; MessagingFactory = serviceBusHelper.MessagingFactory; Namespace = serviceBusHelper.Namespace; NamespaceUri = serviceBusHelper.NamespaceUri; IssuerSecret = serviceBusHelper.IssuerSecret; MessageDeferProviderType = serviceBusHelper.MessageDeferProviderType; MessagingFactory = serviceBusHelper.MessagingFactory; Namespace = serviceBusHelper.Namespace; Scheme = serviceBusHelper.Scheme; ServiceBusNamespaces = serviceBusHelper.ServiceBusNamespaces; ServicePath = serviceBusHelper.ServicePath; TokenProvider = serviceBusHelper.TokenProvider; TraceEnabled = serviceBusHelper.TraceEnabled; }
public HandleTopicControl(WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper, TopicDescription topicDescription, string path) { this.writeToLog = writeToLog; this.serviceBusHelper = serviceBusHelper; this.topicDescription = topicDescription; this.path = path; dataPointBindingList = new BindingList<MetricDataPoint> { AllowNew = true, AllowEdit = true, AllowRemove = true }; InitializeComponent(); InitializeControls(); }
public PartitionListenerControl(WriteToLogDelegate writeToLog, Func<Task> stopLog, Action startLog, ServiceBusHelper serviceBusHelper, ConsumerGroupDescription consumerGroupDescription, IEnumerable<PartitionDescription> partitionDescriptions) { Task.Factory.StartNew(AsyncTrackEventData).ContinueWith(t => { if (t.IsFaulted && t.Exception != null) { writeToLog(t.Exception.Message); } }); this.writeToLog = writeToLog; this.stopLog = stopLog; this.startLog = startLog; this.serviceBusHelper = serviceBusHelper; eventHubDescription = serviceBusHelper.NamespaceManager.GetEventHub(consumerGroupDescription.EventHubPath); eventHubClient = EventHubClient.CreateFromConnectionString(GetAmqpConnectionString(serviceBusHelper.ConnectionString), consumerGroupDescription.EventHubPath); consumerGroup = string.Compare(consumerGroupDescription.Name, DefaultConsumerGroupName, StringComparison.InvariantCultureIgnoreCase) == 0 ? eventHubClient.GetDefaultConsumerGroup() : eventHubClient.GetConsumerGroup(consumerGroupDescription.Name); IList<string> partitionIdList = partitionDescriptions.Select(pd => pd.PartitionId).ToList(); foreach (var id in partitionIdList) { partitionRuntumeInformationList.Add(eventHubClient.GetPartitionRuntimeInformation(id)); } partitionCount = partitionRuntumeInformationList.Count; InitializeComponent(); InitializeControls(); Disposed += ListenerControl_Disposed; }
/// <summary> /// Initializes a new instance of the ServiceBusHelper class. /// </summary> /// <param name="writeToLog">WriteToLog method.</param> public ServiceBusHelper(WriteToLogDelegate writeToLog) { this.writeToLog = writeToLog; traceEnabled = true; }
/// <summary> /// Initializes a new instance of the ServiceBusHelper class. /// </summary> /// <param name="writeToLog">WriteToLog method.</param> /// <param name="serviceBusHelper">Base ServiceBusHelper.</param> public ServiceBusHelper(WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper) { this.writeToLog = writeToLog; traceEnabled = serviceBusHelper.TraceEnabled; AtomFeedUri = serviceBusHelper.AtomFeedUri; IssuerName = serviceBusHelper.IssuerName; IssuerSecret = serviceBusHelper.IssuerSecret; MessageDeferProviderType = serviceBusHelper.MessageDeferProviderType; connectionString = serviceBusHelper.ConnectionString; namespaceManager = serviceBusHelper.NamespaceManager; MessagingFactory = serviceBusHelper.MessagingFactory; Namespace = serviceBusHelper.Namespace; NamespaceUri = serviceBusHelper.NamespaceUri; IssuerSecret = serviceBusHelper.IssuerSecret; MessageDeferProviderType = serviceBusHelper.MessageDeferProviderType; MessagingFactory = serviceBusHelper.MessagingFactory; Namespace = serviceBusHelper.Namespace; Scheme = serviceBusHelper.Scheme; ServiceBusNamespaces = serviceBusHelper.ServiceBusNamespaces; BrokeredMessageInspectors = serviceBusHelper.BrokeredMessageInspectors; EventDataInspectors = serviceBusHelper.EventDataInspectors; BrokeredMessageGenerators = serviceBusHelper.BrokeredMessageGenerators; EventDataGenerators = serviceBusHelper.EventDataGenerators; ServicePath = serviceBusHelper.ServicePath; TokenProvider = serviceBusHelper.TokenProvider; TraceEnabled = serviceBusHelper.TraceEnabled; }
/// <summary> /// Initializes a new instance of the LogTraceListener class. /// </summary> public LogTraceListener(WriteToLogDelegate writeToLog) : base() { this.writeToLog = writeToLog; }
/// <summary> /// Initializes a new instance of the LogTraceListener class. /// </summary> /// <param name="name">The name of the LogTraceListener.</param> public LogTraceListener(WriteToLogDelegate writeToLog, string name) : base(name) { this.writeToLog = writeToLog; }
/// <summary> /// Initializes a new instance of the LogTraceListener class. /// </summary> public LogTraceListener() : base() { this.writeToLog = MainForm.StaticWriteToLog; }
public MessageForm(BrokeredMessage brokeredMessage, ServiceBusHelper serviceBusHelper, WriteToLogDelegate writeToLog) { this.brokeredMessage = brokeredMessage; this.serviceBusHelper = serviceBusHelper; this.writeToLog = writeToLog; InitializeComponent(); cboBodyType.SelectedIndex = 0; messagePropertyGrid.SelectedObject = brokeredMessage; BodyType bodyType; txtMessageText.Text = XmlHelper.Indent(serviceBusHelper.GetMessageText(brokeredMessage, out bodyType)); // Initialize the DataGridView. bindingSource.DataSource = new BindingList<MessagePropertyInfo>(brokeredMessage.Properties.Select(p => new MessagePropertyInfo(p.Key, p.Value.GetType().ToString().Substring(7), p.Value)).ToList()); propertiesDataGridView.AutoGenerateColumns = false; propertiesDataGridView.AutoSize = true; propertiesDataGridView.DataSource = bindingSource; propertiesDataGridView.ForeColor = SystemColors.WindowText; // Create the Name column var textBoxColumn = new DataGridViewTextBoxColumn { DataPropertyName = PropertyKey, Name = PropertyKey, Width = 138 }; propertiesDataGridView.Columns.Add(textBoxColumn); // Create the Type column var comboBoxColumn = new DataGridViewComboBoxColumn { DataSource = types, DataPropertyName = PropertyType, Name = PropertyType, Width = 90, FlatStyle = FlatStyle.Flat }; propertiesDataGridView.Columns.Add(comboBoxColumn); // Create the Value column textBoxColumn = new DataGridViewTextBoxColumn { DataPropertyName = PropertyValue, Name = PropertyValue, Width = 138 }; propertiesDataGridView.Columns.Add(textBoxColumn); // Set Grid style propertiesDataGridView.EnableHeadersVisualStyles = false; // Set the selection background color for all the cells. propertiesDataGridView.DefaultCellStyle.SelectionBackColor = Color.FromArgb(92, 125, 150); propertiesDataGridView.DefaultCellStyle.SelectionForeColor = SystemColors.Window; // Set RowHeadersDefaultCellStyle.SelectionBackColor so that its default // value won't override DataGridView.DefaultCellStyle.SelectionBackColor. propertiesDataGridView.RowHeadersDefaultCellStyle.SelectionBackColor = Color.FromArgb(153, 180, 209); // Set the background color for all rows and for alternating rows. // The value for alternating rows overrides the value for all rows. propertiesDataGridView.RowsDefaultCellStyle.BackColor = SystemColors.Window; propertiesDataGridView.RowsDefaultCellStyle.ForeColor = SystemColors.ControlText; //propertiesDataGridView.AlternatingRowsDefaultCellStyle.BackColor = Color.White; //propertiesDataGridView.AlternatingRowsDefaultCellStyle.ForeColor = SystemColors.ControlText; // Set the row and column header styles. propertiesDataGridView.RowHeadersDefaultCellStyle.BackColor = Color.FromArgb(215, 228, 242); propertiesDataGridView.RowHeadersDefaultCellStyle.ForeColor = SystemColors.ControlText; propertiesDataGridView.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(215, 228, 242); propertiesDataGridView.ColumnHeadersDefaultCellStyle.ForeColor = SystemColors.ControlText; // Get Brokered Message Inspector classes cboSenderInspector.Items.Add(SelectBrokeredMessageInspector); cboSenderInspector.SelectedIndex = 0; if (serviceBusHelper.BrokeredMessageInspectors == null) { return; } foreach (var key in serviceBusHelper.BrokeredMessageInspectors.Keys) { cboSenderInspector.Items.Add(key); } }
public TestTopicControl(MainForm mainForm, WriteToLogDelegate writeToLog, Action stopAndRestartLog, ServiceBusHelper serviceBusHelper, TopicDescription topic, List<SubscriptionDescription> subscriptionList) { this.mainForm = mainForm; this.writeToLog = writeToLog; this.stopAndRestartLog = stopAndRestartLog; this.serviceBusHelper = serviceBusHelper; this.topic = topic; this.subscriptionList = subscriptionList; InitializeComponent(); InitializeControls(); }
public TestQueueControl(MainForm mainForm, WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper, QueueDescription queueDescription) { this.mainForm = mainForm; this.writeToLog = writeToLog; this.serviceBusHelper = serviceBusHelper; this.queueDescription = queueDescription; InitializeComponent(); InitializeControls(); }
public HandleSubscriptionControl(MainForm mainForm, WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper, SubscriptionWrapper wrapper) { this.mainForm = mainForm; this.writeToLog = writeToLog; this.serviceBusHelper = serviceBusHelper; this.wrapper = wrapper; InitializeComponent(); InitializeData(); }
/// <summary> /// Initializes a new instance of the ServiceBusHelper class. /// </summary> /// <param name="writeToLog">WriteToLog method.</param> /// <param name="traceEnabled">A boolean value indicating whether tracing is enabled.</param> public ServiceBusHelper(WriteToLogDelegate writeToLog, bool traceEnabled) { this.writeToLog = writeToLog; this.traceEnabled = traceEnabled; }
public HandleEventHubControl(WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper, EventHubDescription eventHubDescription) { this.writeToLog = writeToLog; this.serviceBusHelper = serviceBusHelper; this.eventHubDescription = eventHubDescription; InitializeComponent(); InitializeControls(); }
public MetricMonitorControl(WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper, IList<MetricDataPoint> dataPoints, string entityName, string entityType) { monitorRuleBindingList = new BindingList<MonitorRule>(); dataPointBindingList = dataPoints != null ? new BindingList<MetricDataPoint>(dataPoints) { AllowNew = true, AllowEdit = true, AllowRemove = true } : new BindingList<MetricDataPoint> { AllowNew = true, AllowEdit = true, AllowRemove = true }; this.writeToLog = writeToLog; this.serviceBusHelper = serviceBusHelper; this.entityName = entityName; this.entityType = entityType; var regex = new Regex(RegularExpression); existingEntity = !string.IsNullOrWhiteSpace(entityName) && !string.IsNullOrWhiteSpace(entityType) && regex.IsMatch(entityType); InitializeComponent(); InitializeControls(); }
public HandleEventHubControl(WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper, EventHubDescription eventHubDescription) { this.writeToLog = writeToLog; this.serviceBusHelper = serviceBusHelper; this.eventHubDescription = eventHubDescription; dataPointBindingList = new BindingList<MetricDataPoint> { AllowNew = true, AllowEdit = true, AllowRemove = true }; InitializeComponent(); InitializeControls(); }
public IEnumerable<BrokeredMessage> GenerateBrokeredMessageCollection(int brokeredMessageCount, WriteToLogDelegate writeToLog) { if (brokeredMessageCount < 0) { return null; } var random = new Random(); var messageList = new List<BrokeredMessage>(); for (var i = 0; i < brokeredMessageCount; i++) { try { var normalState = AlertState == (int)OnOff.Off ? OnOff.On : OnOff.Off; var alertState = AlertState == (int)OnOff.Off ? OnOff.Off : OnOff.On; var payload = new OnOffDeviceEvent { DeviceId = random.Next(MinDeviceId, MaxDeviceId + 1), Value = random.Next(1, 101) <= AlertPercentage ? alertState : normalState }; var text = MessageFormat == MessageFormat.Json ? JsonSerializerHelper.Serialize(payload) : XmlSerializerHelper.Serialize(payload); var brokeredMessage = new BrokeredMessage(text.ToMemoryStream()) { MessageId = payload.DeviceId.ToString(CultureInfo.InvariantCulture), }; brokeredMessage.Properties.Add("deviceId", payload.DeviceId); brokeredMessage.Properties.Add("value", (int)payload.Value); brokeredMessage.Properties.Add("time", DateTime.UtcNow.Ticks); brokeredMessage.Properties.Add("city", City); brokeredMessage.Properties.Add("country", Country); brokeredMessage.Label = Label; messageList.Add(brokeredMessage); } catch (Exception ex) { if (!string.IsNullOrWhiteSpace(ex.Message)) { writeToLog(string.Format(CultureInfo.CurrentCulture, ExceptionFormat, ex.Message)); } if (ex.InnerException != null && !string.IsNullOrWhiteSpace(ex.InnerException.Message)) { writeToLog(string.Format(CultureInfo.CurrentCulture, InnerExceptionFormat, ex.InnerException.Message)); } } } if (writeToLog != null) { writeToLog(string.Format(BrokeredMessageCreatedFormat, messageList.Count)); } return messageList; }
public HandleSubscriptionControl(WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper, SubscriptionWrapper subscriptionWrapper) { this.writeToLog = writeToLog; this.serviceBusHelper = serviceBusHelper; this.subscriptionWrapper = subscriptionWrapper; dataPointBindingList = new BindingList<MetricDataPoint> { AllowNew = true, AllowEdit = true, AllowRemove = true }; InitializeComponent(); InitializeControls(); }
public PartitionListenerControl(WriteToLogDelegate writeToLog, Func<Task> stopLog, Action startLog, string iotHubConnectionString, string consumerGroupName) { Task.Factory.StartNew(AsyncTrackEventData).ContinueWith(t => { if (t.IsFaulted && t.Exception != null) { writeToLog(t.Exception.Message); } }); this.iotHubConnectionString = iotHubConnectionString; this.writeToLog = writeToLog; this.stopLog = stopLog; this.startLog = startLog; serviceBusHelper = new ServiceBusHelper(writeToLog); eventHubClient = EventHubClient.CreateFromConnectionString(iotHubConnectionString, "messages/events"); consumerGroup = string.Compare(consumerGroupName, DefaultConsumerGroupName, StringComparison.InvariantCultureIgnoreCase) == 0 ? eventHubClient.GetDefaultConsumerGroup() : eventHubClient.GetConsumerGroup(consumerGroupName); IList<string> partitionIdList = new List<string>(eventHubClient.GetRuntimeInformation().PartitionIds); foreach (var id in partitionIdList) { partitionRuntumeInformationList.Add(eventHubClient.GetPartitionRuntimeInformation(id)); } partitionCount = partitionRuntumeInformationList.Count; InitializeComponent(); InitializeControls(); Disposed += ListenerControl_Disposed; }
public HandleConsumerGroupControl(WriteToLogDelegate writeToLog, ServiceBusHelper serviceBusHelper, ConsumerGroupDescription consumerGroupDescription, string eventHubName) { this.writeToLog = writeToLog; this.serviceBusHelper = serviceBusHelper; this.consumerGroupDescription = consumerGroupDescription; this.eventHubName = eventHubName; dataPointBindingList = new BindingList<MetricDataPoint> { AllowNew = true, AllowEdit = true, AllowRemove = true }; InitializeComponent(); InitializeControls(); }